dealing with passwords

This commit is contained in:
deflax 2016-03-02 05:01:33 +02:00
parent 9cebb7f7c0
commit e64f9806bb
2 changed files with 7 additions and 4 deletions

View file

@ -9,9 +9,10 @@ import json
import ioconfig import ioconfig
import utils import utils
def addclient(vmid, vmname, clientid, clientname): def addclient(vmid, vmname, clientid, clientname, srvuser, srvpass):
""" add new client to the clientsdb.json """ """ add new client to the clientsdb.json """
clientsdb = readclientsdb() clientsdb = readclientsdb()
if str(clientid) in clientsdb: if str(clientid) in clientsdb:
ioconfig.logger.info('clients> client ' + clientid + ' already exists. merging.') ioconfig.logger.info('clients> client ' + clientid + ' already exists. merging.')
else: else:
@ -19,10 +20,10 @@ def addclient(vmid, vmname, clientid, clientname):
vcard = { 'name':str(clientname) } vcard = { 'name':str(clientname) }
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 ' + vmid + ' will be owned by ' + clientid + ' (' + clientname + ')')
vmdata = { 'name':str(vmname), 'vmid':str(vmid), 'ownerid':str(clientid) } vmdata = { 'name':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
writeclientsdb(clientsdb) writeclientsdb(clientsdb)

View file

@ -119,7 +119,9 @@ def vmcreate(req):
#populate the client db and vm journal #populate the client db and vm journal
client_id = req['clientid'] client_id = req['clientid']
client_name = req['clientname'] client_name = req['clientname']
clientsdb.addclient(vm_id, vm_name, client_id, client_name) srv_user = req['username']
srv_pass = req['password']
clientsdb.addclient(vm_id, vm_name, client_id, client_name, srv_user, srv_pass)
journaldb.createjnode(vm_id, region_id, slave_id) journaldb.createjnode(vm_id, region_id, slave_id)
#start the machihe #start the machihe