fixing vmcreate

This commit is contained in:
deflax 2016-11-03 06:52:37 +02:00
parent 577a654940
commit a4b794361b
2 changed files with 15 additions and 8 deletions

8
humanjson.sh Executable file
View file

@ -0,0 +1,8 @@
#!/bin/bash
#makes jsons human (and machine) readable
for filename in db/*.json ; do
cat $filename | python3 -m json.tool
done;

View file

@ -94,26 +94,25 @@ def vmcreate(req):
proxobject = auth(slave_name) proxobject = auth(slave_name)
#slave_name = proxobject.cluster.status.get()[0]['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, ipv4_list, req)
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) grid.writedb(deploy)
ipv4_dict = {} ipv4_dict = {}
ipidx = 0 ipidx = 0
for ip in vm_ipv4: for ip in ipv4_list:
ipv4_dict[str(ipidx)] = str(ip) ipv4_dict[str(ipidx)] = str(ip)
ipidx += 1 ipidx += 1
response = { 'status':'CREATE', 'cube':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':ipv4_list[0] }
description = vm_name + ' (' + vm_id + ')\n' + 'owned by ' + client_name + ' (' + client_id + ')\n' + 'master ip: ' + vm_ipv4[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-' + vm_id + '-disk-0' image_name = 'vm-' + str(cubeid) + '-disk-0'
local_storage = proxobject.nodes(slave_name).storage('lvm') local_storage = proxobject.nodes(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_disk'] + 'G') size=req['vps_hdd'] + 'G')
if req['vps_type'] == 'KVM': if req['vps_type'] == 'KVM':
create_result = proxobject.nodes(slave_name).qemu.post(vmid=vm_id, create_result = proxobject.nodes(slave_name).qemu.post(vmid=vm_id,
@ -135,7 +134,7 @@ def vmcreate(req):
cores=req['vps_cpu'], cores=req['vps_cpu'],
memory=req['vps_mem'], memory=req['vps_mem'],
virtio0='lvm:' + image_name, virtio0='lvm:' + image_name,
ip_address=vm_ipv4[0], ip_address=ipv4_list[0],
onboot=1, onboot=1,
description=description) description=description)