fixing vmcreate
This commit is contained in:
parent
f030f3fbb5
commit
07e0e4cfaa
1 changed files with 9 additions and 6 deletions
15
plugin.py
15
plugin.py
|
@ -75,16 +75,16 @@ def vmcreate(req):
|
|||
slave_name = 'warrior' #staic route
|
||||
#vmid = str(grid.generate_vmid()) #TODO: this should be between 100 and 65000
|
||||
vmid = random.randint(200, 62000)
|
||||
cube_id = time.time() #TODO: make sure this is unique. time since epoch is not random enough but should do the trick for now
|
||||
cubeid = time.time() #TODO: make sure this is unique. time since epoch is not random enough but should do the trick for now
|
||||
ipv4_list = grid.generate_ipv4(req['region'], req['vps_ipv4'])
|
||||
|
||||
#metadata
|
||||
deploy = { 'cube': int(cube_id),
|
||||
deploy = { 'cube': int(cubeid),
|
||||
'type': req['vps_type'],
|
||||
'host': vm_name,
|
||||
'region': region_fullname,
|
||||
'slave': slave_name,
|
||||
'vmid': vmid,
|
||||
'vmid': vm_id,
|
||||
'cpu_mem_hdd': (req['vps_cpu'], req['vps_mem'], req['vps_hdd']),
|
||||
'clientid': req['clientid'],
|
||||
'clientname': req['clientname'],
|
||||
|
@ -95,14 +95,17 @@ def vmcreate(req):
|
|||
proxobject = auth(slave_name)
|
||||
#slave_name = proxobject.cluster.status.get()[0]['name']
|
||||
|
||||
ioconfig.logger.info('slave[' + slave_name + ']> deploying %s on %s (%s) at %s with %s and %s', cubeid, slave_name, vm_id, region_id, vm_ipv4, req)
|
||||
grid.writedb(deploy)
|
||||
|
||||
ipv4_dict = {}
|
||||
ipidx = 0
|
||||
ioconfig.logger.info('slave[' + slave_name + ']> deploying %s on %s at %s with %s and %s', vm_id, slave_id , region_id, vm_ipv4, req)
|
||||
|
||||
for ip in vm_ipv4:
|
||||
ipv4_dict[str(ipidx)] = str(ip)
|
||||
ipidx += 1
|
||||
|
||||
response = { 'status':'CREATE', 'vmid':vm_id, 'name':vm_name, 'password':vm_pass, 'ipv4_0':vm_ipv4[0] }
|
||||
response = { 'status':'CREATE', 'cube':vm_id, 'name':vm_name, 'password':vm_pass, 'ipv4_0':vm_ipv4[0] }
|
||||
description = vm_name + ' (' + vm_id + ')\n' + 'owned by ' + client_name + ' (' + client_id + ')\n' + 'master ip: ' + vm_ipv4[0]
|
||||
|
||||
#create partition
|
||||
|
@ -141,7 +144,7 @@ def vmcreate(req):
|
|||
|
||||
#start the machihe
|
||||
time.sleep(7) #wait few seconds for the slave to prepare the machine for initial run
|
||||
vmstart(vm_id)
|
||||
vmstart(cubeid)
|
||||
return response
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue