write vmpass and email
This commit is contained in:
parent
db5225b11d
commit
d1cd131250
3 changed files with 10 additions and 9 deletions
|
@ -11,7 +11,7 @@ import bcrypt
|
||||||
import ioconfig
|
import ioconfig
|
||||||
import utils
|
import utils
|
||||||
|
|
||||||
def addclient(vmid, vmname, clientid, clientname, srvpass):
|
def addclient(vmid, vmname, clientid, clientname, clientemail, srvpass):
|
||||||
""" add new client to the clientsdb.json """
|
""" add new client to the clientsdb.json """
|
||||||
clientsdb = readclientsdb()
|
clientsdb = readclientsdb()
|
||||||
|
|
||||||
|
@ -19,10 +19,11 @@ def addclient(vmid, vmname, clientid, clientname, srvpass):
|
||||||
ioconfig.logger.info('clients> client ' + clientid + ' already exists. merging.')
|
ioconfig.logger.info('clients> client ' + clientid + ' already exists. merging.')
|
||||||
else:
|
else:
|
||||||
ioconfig.logger.info('clients> client ' + clientid + ' does not exist. creating.')
|
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 }
|
newclient = { str(clientid):vcard }
|
||||||
clientsdb.update(newclient)
|
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) }
|
vmdata = { 'hostname':str(vmname), 'vmid':str(vmid), 'ownerid':str(clientid), 'username':str(srvuser), 'password': str(srvpass) }
|
||||||
clientsdb[str(clientid)][str(vmid)] = vmdata
|
clientsdb[str(clientid)][str(vmid)] = vmdata
|
||||||
|
|
||||||
|
|
|
@ -16,13 +16,13 @@ ipv4_min = 192.168.0.4
|
||||||
ipv4_max = 192.168.0.254
|
ipv4_max = 192.168.0.254
|
||||||
|
|
||||||
[slave_0]
|
[slave_0]
|
||||||
name = host.0CHANGEME
|
name = CHANGEME0.fqdn.com
|
||||||
masterip = 192.168.0.2
|
masterip = 192.168.0.2
|
||||||
password = CHANGEME
|
password = CHANGEME
|
||||||
regionid = 0
|
regionid = 0
|
||||||
|
|
||||||
[slave_1]
|
[slave_1]
|
||||||
name = host1.CHANGEME
|
name = CHANGEME1.fqdn.com
|
||||||
masterip = 192.168.0.3
|
masterip = 192.168.0.3
|
||||||
password = CHANGEME
|
password = CHANGEME
|
||||||
regionid = 0
|
regionid = 0
|
||||||
|
|
|
@ -65,7 +65,7 @@ def vmcreate(req):
|
||||||
vm_id = str(grid.generate_vmid())
|
vm_id = str(grid.generate_vmid())
|
||||||
vm_ipv4 = grid.generate_ipv4(region_id, req['vps_ipv4'])
|
vm_ipv4 = grid.generate_ipv4(region_id, req['vps_ipv4'])
|
||||||
vm_name = req['hostname']
|
vm_name = req['hostname']
|
||||||
vm_pass = req['password']
|
vm_pass = req['vmpass']
|
||||||
client_id = req['clientid']
|
client_id = req['clientid']
|
||||||
client_name = req['clientname']
|
client_name = req['clientname']
|
||||||
|
|
||||||
|
@ -78,6 +78,7 @@ def vmcreate(req):
|
||||||
for ip in vm_ipv4:
|
for ip in vm_ipv4:
|
||||||
ipv4_dict[str(ipidx)] = str(ip)
|
ipv4_dict[str(ipidx)] = str(ip)
|
||||||
ipidx += 1
|
ipidx += 1
|
||||||
|
|
||||||
response = { 'status':'CREATE', 'vmid':vm_id, 'name':vm_name, 'password':vm_pass, 'ipv4_0':vm_ipv4[0] }
|
response = { 'status':'CREATE', 'vmid':vm_id, 'name':vm_name, 'password':vm_pass, 'ipv4_0':vm_ipv4[0] }
|
||||||
|
|
||||||
disk_filename = 'vm-' + vm_id + '-disk-1'
|
disk_filename = 'vm-' + vm_id + '-disk-1'
|
||||||
|
@ -118,8 +119,8 @@ def vmcreate(req):
|
||||||
#populate the client db
|
#populate the client db
|
||||||
client_id = req['clientid']
|
client_id = req['clientid']
|
||||||
client_name = req['clientname']
|
client_name = req['clientname']
|
||||||
srv_pass = req['password']
|
client_email = req['clientemail']
|
||||||
clientsdb.addclient(vm_id, vm_name, client_id, client_name, srv_pass)
|
clientsdb.addclient(vm_id, vm_name, client_id, client_name, client_email, vm_pass)
|
||||||
|
|
||||||
#start the machihe
|
#start the machihe
|
||||||
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
|
||||||
|
@ -141,7 +142,6 @@ def vmstatus(vm_id):
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def vmstart(vm_id):
|
def vmstart(vm_id):
|
||||||
""" starts a machine """
|
""" starts a machine """
|
||||||
slave_id, vm_type = grid.query_vm(vm_id)
|
slave_id, vm_type = grid.query_vm(vm_id)
|
||||||
|
|
Loading…
Reference in a new issue