From d0d3933c3e92b33508d6f87fc971647a32beda77 Mon Sep 17 00:00:00 2001 From: deflax Date: Thu, 3 Nov 2016 07:06:46 +0200 Subject: [PATCH] fixing vmcreate --- grid.py | 2 +- plugin.py | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/grid.py b/grid.py index 923062f..3e25130 100644 --- a/grid.py +++ b/grid.py @@ -36,7 +36,7 @@ def querydb(cubeid): except Exception as e: logger.critical('grid> {}'.format(e)) pass - return None + return data def writedb(src_data): diff --git a/plugin.py b/plugin.py index 796534e..c4806a6 100644 --- a/plugin.py +++ b/plugin.py @@ -75,7 +75,8 @@ def vmcreate(req): slave_name = 'warrior' #staic route #vmid = str(grid.generate_vmid()) #TODO: this should be between 100 and 65000 vm_id = random.randint(200, 62000) - cubeid = time.time() #TODO: make sure this is unique. time since epoch is not random enough but should do the trick for now + cubeid = int(time.time() * 10000 * 10000) + ipv4_list = grid.generate_ipv4(req['region'], req['vps_ipv4']) #metadata @@ -99,7 +100,6 @@ def vmcreate(req): ipv4_dict = {} ipidx = 0 - for ip in ipv4_list: ipv4_dict[str(ipidx)] = str(ip) ipidx += 1 @@ -108,7 +108,7 @@ def vmcreate(req): description = vm_name + ' (' + str(cubeid) + '/' + str(vm_id) + ')\n' + 'owned by ' + req['clientname'] + ' (' + req['clientid'] + ')\n' + 'master ip: ' + ipv4_list[0] #create partition - image_name = 'vm-' + str(cubeid) + '-disk-0' + image_name = 'vm-' + str(vm_id) + '-disk-0' local_storage = proxobject.nodes(slave_name).storage('lvm') local_storage.content.post(vmid=vm_id, filename=image_name, @@ -138,9 +138,6 @@ def vmcreate(req): onboot=1, description=description) - print('result:') - print(create_result) - #start the machihe time.sleep(7) #wait few seconds for the slave to prepare the machine for initial run vmstart(cubeid)