Added hashed username and password to the state
This commit is contained in:
parent
b81a8db0bc
commit
36a2619bc1
@ -161,7 +161,9 @@ def init_state(config):
|
||||
'vir_connection': vir_connection,
|
||||
'db': init_db(config['sql_connection']),
|
||||
'physical_cpu_mhz_total': physical_cpu_mhz_total,
|
||||
'hostname': vir_connection.getHostname()}
|
||||
'hostname': vir_connection.getHostname(),
|
||||
'hashed_username': sha1(config['os_admin_user']).hexdigest(),
|
||||
'hashed_password': sha1(config['os_admin_password']).hexdigest()}
|
||||
|
||||
|
||||
@contract
|
||||
@ -266,15 +268,10 @@ def execute(config, state):
|
||||
|
||||
if underload:
|
||||
log.info('Underload detected')
|
||||
host = 'http://' + config['global_manager_host'] + \
|
||||
':' + config['global_manager_port']
|
||||
username = sha1(config['os_admin_user']).hexdigest()
|
||||
password = sha1(config['os_admin_password']).hexdigest()
|
||||
log.info('Request: host %s, username %s, password %s',
|
||||
host, username, password)
|
||||
requests.put(host,
|
||||
{'username': username,
|
||||
'password': password,
|
||||
requests.put('http://' + config['global_manager_host'] + \
|
||||
':' + config['global_manager_port'],
|
||||
{'username': state['hashed_username'],
|
||||
'password': state['hashed_password'],
|
||||
'reason': 0,
|
||||
'host': state['hostname']})
|
||||
# Send a request to the global manager with the host name
|
||||
|
@ -17,6 +17,7 @@ from pyqcy import *
|
||||
|
||||
import shutil
|
||||
import libvirt
|
||||
from hashlib import sha1
|
||||
|
||||
import neat.locals.manager as manager
|
||||
import neat.common as common
|
||||
@ -63,13 +64,17 @@ class LocalManager(TestCase):
|
||||
expect(common).physical_cpu_mhz_total(vir_connection). \
|
||||
and_return(mhz)
|
||||
expect(vir_connection).getHostname().and_return('host').once()
|
||||
config = {'sql_connection': 'db'}
|
||||
config = {'sql_connection': 'db',
|
||||
'os_admin_user': 'user',
|
||||
'os_admin_password': 'password'}
|
||||
state = manager.init_state(config)
|
||||
assert state['previous_time'] == 0
|
||||
assert state['vir_connection'] == vir_connection
|
||||
assert state['db'] == db
|
||||
assert state['physical_cpu_mhz_total'] == mhz
|
||||
assert state['hostname'] == 'host'
|
||||
assert state['hashed_username'] == sha1('user').hexdigest()
|
||||
assert state['hashed_password'] == sha1('password').hexdigest()
|
||||
|
||||
@qc(1)
|
||||
def get_local_data(
|
||||
|
Loading…
x
Reference in New Issue
Block a user