diff --git a/humanjson.sh b/humanjson.sh new file mode 100755 index 0000000..c07ca61 --- /dev/null +++ b/humanjson.sh @@ -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; + diff --git a/plugin.py b/plugin.py index 3581420..796534e 100644 --- a/plugin.py +++ b/plugin.py @@ -94,26 +94,25 @@ 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) + #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) grid.writedb(deploy) ipv4_dict = {} ipidx = 0 - for ip in vm_ipv4: + for ip in ipv4_list: ipv4_dict[str(ipidx)] = str(ip) ipidx += 1 - 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] + response = { 'status':'CREATE', 'cube':vm_id, '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] #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.content.post(vmid=vm_id, filename=image_name, - size=req['vps_disk'] + 'G') + size=req['vps_hdd'] + 'G') if req['vps_type'] == 'KVM': create_result = proxobject.nodes(slave_name).qemu.post(vmid=vm_id, @@ -135,7 +134,7 @@ def vmcreate(req): cores=req['vps_cpu'], memory=req['vps_mem'], virtio0='lvm:' + image_name, - ip_address=vm_ipv4[0], + ip_address=ipv4_list[0], onboot=1, description=description)