fixing vmcreate
This commit is contained in:
parent
92e91aa631
commit
40dc709d68
1 changed files with 11 additions and 10 deletions
21
plugin.py
21
plugin.py
|
@ -103,39 +103,37 @@ def vmcreate(req):
|
||||||
|
|
||||||
proxobject = auth(slave_name)
|
proxobject = auth(slave_name)
|
||||||
real_slave_name = proxobject.cluster.status.get()[0]['name']
|
real_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, ipv4_list, req)
|
print(real_slave_name)
|
||||||
grid.writedb(deploy)
|
|
||||||
|
|
||||||
response = { 'status':'CREATE', 'cube':cubeid, 'name':vm_name, 'password':vm_pass, 'ipv4_0':ipv4_list[0] }
|
|
||||||
description = vm_name + ' (' + str(cubeid) + '/' + str(vm_id) + ')\n' + 'owned by ' + req['clientname'] + ' (' + req['clientid'] + ')\n' + 'master ip: ' + ipv4_list[0]
|
description = vm_name + ' (' + str(cubeid) + '/' + str(vm_id) + ')\n' + 'owned by ' + req['clientname'] + ' (' + req['clientid'] + ')\n' + 'master ip: ' + ipv4_list[0]
|
||||||
|
|
||||||
#create partition
|
#create partition
|
||||||
image_name = 'vm-' + str(vm_id) + '-disk-0'
|
image_name = 'vm-' + str(vm_id) + '-disk-1'
|
||||||
local_storage = proxobject.nodes(slave_name).storage('lvm')
|
local_storage = proxobject.nodes(real_slave_name).storage('lvm')
|
||||||
local_storage.content.post(vmid=vm_id,
|
local_storage.content.post(vmid=vm_id,
|
||||||
filename=image_name,
|
filename=image_name,
|
||||||
size=req['vps_hdd'] + 'G')
|
size=req['vps_hdd'] + 'G')
|
||||||
|
|
||||||
if req['vps_type'] == 'kvm':
|
if req['vps_type'] == 'kvm':
|
||||||
create_result = proxobject.nodes(real_slave_name).qemu.post(vmid=str(vm_id),
|
create_result = proxobject.nodes(real_slave_name).qemu.post(vmid=int(vm_id),
|
||||||
name=vm_name,
|
name=vm_name,
|
||||||
sockets=1,
|
sockets=1,
|
||||||
cores=req['vps_cpu'],
|
cores=req['vps_cpu'],
|
||||||
memory=req['vps_mem'],
|
memory=req['vps_mem'],
|
||||||
virtio0='vm:' + image_name,
|
virtio0='file=lvm:' + image_name,
|
||||||
ide1='skyblue:iso/' + req['vps_iso9660'] + ',media=cdrom',
|
ide1='skyblue:iso/' + req['vps_iso9660'] + ',media=cdrom',
|
||||||
net0='virtio=' + macaddr + ' ,bridge=vmbr0',
|
net0='virtio,bridge=vmbr0,macaddr=' + macaddr,
|
||||||
onboot=1,
|
onboot=1,
|
||||||
description=description)
|
description=description)
|
||||||
|
|
||||||
if req['vps_type'] == 'lxc':
|
if req['vps_type'] == 'lxc':
|
||||||
create_result = proxobject.nodes(real_slave_name).lxc.post(vmid=str(vm_id),
|
create_result = proxobject.nodes(real_slave_name).lxc.post(vmid=int(vm_id),
|
||||||
hostname=vm_name,
|
hostname=vm_name,
|
||||||
password=vm_pass,
|
password=vm_pass,
|
||||||
sockets=1,
|
sockets=1,
|
||||||
cores=req['vps_cpu'],
|
cores=req['vps_cpu'],
|
||||||
memory=req['vps_mem'],
|
memory=req['vps_mem'],
|
||||||
virtio0='lvm:' + image_name,
|
virtio0='file=lvm:' + image_name,
|
||||||
ip_address=ipv4_list[0],
|
ip_address=ipv4_list[0],
|
||||||
onboot=1,
|
onboot=1,
|
||||||
description=description)
|
description=description)
|
||||||
|
@ -146,6 +144,9 @@ def vmcreate(req):
|
||||||
#time.sleep(7) #wait few seconds for the slave to prepare the machine for initial run
|
#time.sleep(7) #wait few seconds for the slave to prepare the machine for initial run
|
||||||
#vmstart(cubeid)
|
#vmstart(cubeid)
|
||||||
print(str(create_result))
|
print(str(create_result))
|
||||||
|
|
||||||
|
response = { 'status':'CREATE', 'cube':cubeid, 'name':vm_name, 'password':vm_pass, 'ipv4_0':ipv4_list[0] }
|
||||||
|
grid.writedb(deploy)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue