From e64f9806bb5b8d693ae2d4e4660d3c9663ac4785 Mon Sep 17 00:00:00 2001 From: deflax Date: Wed, 2 Mar 2016 05:01:33 +0200 Subject: [PATCH] dealing with passwords --- clientsdb.py | 7 ++++--- plugin.py | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/clientsdb.py b/clientsdb.py index 1d466ec..48afd05 100644 --- a/clientsdb.py +++ b/clientsdb.py @@ -9,9 +9,10 @@ import json import ioconfig import utils -def addclient(vmid, vmname, clientid, clientname): +def addclient(vmid, vmname, clientid, clientname, srvuser, srvpass): """ add new client to the clientsdb.json """ clientsdb = readclientsdb() + if str(clientid) in clientsdb: ioconfig.logger.info('clients> client ' + clientid + ' already exists. merging.') else: @@ -19,10 +20,10 @@ def addclient(vmid, vmname, clientid, clientname): vcard = { 'name':str(clientname) } newclient = { str(clientid):vcard } clientsdb.update(newclient) - 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 + writeclientsdb(clientsdb) diff --git a/plugin.py b/plugin.py index ff8c7a7..7d011d6 100644 --- a/plugin.py +++ b/plugin.py @@ -119,7 +119,9 @@ def vmcreate(req): #populate the client db and vm journal client_id = req['clientid'] 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) #start the machihe