[pve-devel] PVE/API2/LXC.pm ssh-public-keys alias

Geert Stappers stappers at stappers.it
Sun Feb 4 21:42:46 CET 2018


On Wed, Jan 31, 2018 at 09:23:47AM +0100, Wolfgang Bumiller wrote:
> On Wed, Jan 31, 2018 at 12:14:43AM +0100, Geert Stappers wrote:
> > 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.
> 
> Just put quotes around it (and/or encode it properly depending on what
> you're actually doing).

Using proxmoxer, a python API for proxmox API2, different was the solution.

Code change at my client side, for what its worth: 


--- a/create/trw
+++ b/create/trw
@@ -23,6 +23,25 @@ net1 += 'ip=dhcp,'
 net1 += 'ip6=dhcp,'
 net1 += 'hwaddr=02:90:ED:74:72:77'
 
+
+newcontainer = { 'vmid': vmid
+        #, 'ostemplate': 'local:vztmpl/debian-9.0-standard_9.0-2_amd64.tar.gz'
+        , 'ostemplate': 'local:vztmpl/debian-builder-sid.tar.xz'
+        , 'hostname': vmname
+        # 'rootfs': rootfs
+        , 'arch': 'amd64'
+        , 'memory': 512
+        , 'swap': 512
+        , 'storage': 'local-lvm'
+        , 'cores': 1
+        , 'password': 'secret'
+        , 'onboot': 1
+        , 'ostype': 'debian'
+        , 'ssh-public-keys': ssh_public_keys
+        , 'net0': net0
+        , 'net1': net1
+}
+
 import sys
 import time
 from proxmoxer import ProxmoxAPI
@@ -67,23 +86,7 @@ if vmfound:
         print("{k}: {v}".format(k=k, v=v))
 else:
     print("Creating")
-    upid = pn.lxc.post(vmid=vmid
-        #, ostemplate='local:vztmpl/debian-9.0-standard_9.0-2_amd64.tar.gz'
-        , ostemplate='local:vztmpl/debian-builder-sid.tar.xz'
-        , hostname=vmname
-        # rootfs=rootfs
-        , arch='amd64'
-        , memory=512
-        , swap=512
-        , storage='local-lvm'
-        , cores=1
-        , password='secret'
-        , onboot='1'
-        , ostype='debian'
-        , ssh_public_keys=ssh_public_keys
-        , net0=net0
-        , net1=net1
-        )
+    upid = pn.lxc.post(**newcontainer)
     (rv,extra) = patience(pn,upid,18,1)
     print('Return value: {}'.format(rv))
     for entry in extra:



Cheers
Geert Stappers
-- 
Leven en laten leven



More information about the pve-devel mailing list