Parameter name 'ssh-public-keys' causes trouble
when written as ssh-public-keys. Because it can read as
arthmetic expression ssh minus public minus keys.

So an alias to the rescue.
Parameter name is 'ssh_public_keys'.

Signed-off-by: Geert Stappers <stapp...@stappers.it>
---
 src/PVE/API2/LXC.pm |   12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
index 733826e..ae3cbd8 100644
--- a/src/PVE/API2/LXC.pm
+++ b/src/PVE/API2/LXC.pm
@@ -161,6 +161,11 @@ __PACKAGE__->register_method({
                description => "Setup public SSH keys (one key per line, " .
                                "OpenSSH format).",
            },
+           'ssh_public_keys' => {
+               optional => 1,
+               type => 'string',
+               description => "Alias for ssh-public-keys",
+           },
        }),
     },
     returns => {
@@ -204,7 +209,12 @@ __PACKAGE__->register_method({
 
        my $password = extract_param($param, 'password');
 
-       my $ssh_keys = extract_param($param, 'ssh-public-keys');
+       my $ssh_keys;
+       my $ssh_keys_orig = extract_param($param, 'ssh-public-keys');
+       my $ssh_keys_alias = extract_param($param, 'ssh_public_keys');
+       $ssh_keys = $ssh_keys_alias if defined($ssh_keys_alias);
+       # Allow the original 'ssh-public-keys' parameter to win
+       $ssh_keys = $ssh_keys_orig if defined($ssh_keys_orig);
        PVE::Tools::validate_ssh_public_keys($ssh_keys) if defined($ssh_keys);
 
        my $pool = extract_param($param, 'pool');
-- 
1.7.10.4

_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to