diff --git a/clientsdb.py b/clientsdb.py index ef8704f..7be0ea2 100644 --- a/clientsdb.py +++ b/clientsdb.py @@ -11,7 +11,7 @@ import bcrypt import ioconfig import utils -def addclient(vmid, vmname, clientid, clientname, srvpass): +def addclient(vmid, vmname, clientid, clientname, clientemail, srvpass): """ add new client to the clientsdb.json """ clientsdb = readclientsdb() @@ -19,10 +19,11 @@ def addclient(vmid, vmname, clientid, clientname, srvpass): ioconfig.logger.info('clients> client ' + clientid + ' already exists. merging.') else: ioconfig.logger.info('clients> client ' + clientid + ' does not exist. creating.') - vcard = { 'name':str(clientname) } + vcard = { 'name':str(clientname), 'email':str(clientemail) } newclient = { str(clientid):vcard } clientsdb.update(newclient) - ioconfig.logger.info('clients> vmid ' + vmid + ' will be owned by ' + clientid + ' (' + clientname + ')') + ioconfig.logger.info('clients> vmid {} owner set to {} (id: {}, email: {})'.format(vmid, clientname, clientid, clientemail)) + vmdata = { 'hostname':str(vmname), 'vmid':str(vmid), 'ownerid':str(clientid), 'username':str(srvuser), 'password': str(srvpass) } clientsdb[str(clientid)][str(vmid)] = vmdata diff --git a/config.ini.dist b/config.ini.dist index e93e308..eca19bf 100644 --- a/config.ini.dist +++ b/config.ini.dist @@ -16,13 +16,13 @@ ipv4_min = 192.168.0.4 ipv4_max = 192.168.0.254 [slave_0] -name = host.0CHANGEME +name = CHANGEME0.fqdn.com masterip = 192.168.0.2 password = CHANGEME regionid = 0 [slave_1] -name = host1.CHANGEME +name = CHANGEME1.fqdn.com masterip = 192.168.0.3 password = CHANGEME regionid = 0 diff --git a/plugin.py b/plugin.py index 7fa4186..d789ac6 100644 --- a/plugin.py +++ b/plugin.py @@ -65,7 +65,7 @@ def vmcreate(req): vm_id = str(grid.generate_vmid()) vm_ipv4 = grid.generate_ipv4(region_id, req['vps_ipv4']) vm_name = req['hostname'] - vm_pass = req['password'] + vm_pass = req['vmpass'] client_id = req['clientid'] client_name = req['clientname'] @@ -78,6 +78,7 @@ def vmcreate(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] } disk_filename = 'vm-' + vm_id + '-disk-1' @@ -118,8 +119,8 @@ def vmcreate(req): #populate the client db client_id = req['clientid'] client_name = req['clientname'] - srv_pass = req['password'] - clientsdb.addclient(vm_id, vm_name, client_id, client_name, srv_pass) + client_email = req['clientemail'] + clientsdb.addclient(vm_id, vm_name, client_id, client_name, client_email, vm_pass) #start the machihe time.sleep(7) #wait few seconds for the slave to prepare the machine for initial run @@ -141,7 +142,6 @@ def vmstatus(vm_id): return result - def vmstart(vm_id): """ starts a machine """ slave_id, vm_type = grid.query_vm(vm_id)