Updated the local manager to call the overload detection algorithm at every iteration: since the algorithm may require to update its state, as for example MHOD

This commit is contained in:
Anton Beloglazov 2012-12-18 14:36:08 +11:00
parent 52c581b783
commit 1d67c8c312

View File

@ -278,17 +278,26 @@ def execute(config, state):
overload_detection = state['overload_detection'] overload_detection = state['overload_detection']
vm_selection = state['vm_selection'] vm_selection = state['vm_selection']
log.info('Started underload detection') if log.isEnabledFor(logging.INFO):
log.info('Started underload detection')
underload, state['underload_detection_state'] = underload_detection( underload, state['underload_detection_state'] = underload_detection(
host_cpu_utilization, state['underload_detection_state']) host_cpu_utilization, state['underload_detection_state'])
log.info('Completed underload detection') if log.isEnabledFor(logging.INFO):
log.info('Completed underload detection')
if log.isEnabledFor(logging.INFO):
log.info('Started overload detection')
overload, state['overload_detection_state'] = overload_detection(
host_cpu_utilization, state['overload_detection_state'])
if log.isEnabledFor(logging.INFO):
log.info('Completed overload detection')
if underload: if underload:
if log.isEnabledFor(logging.INFO): if log.isEnabledFor(logging.INFO):
log.info('Underload detected') log.info('Underload detected')
try: try:
r = requests.put('http://' + config['global_manager_host'] + \ r = requests.put('http://' + config['global_manager_host'] +
':' + config['global_manager_port'], ':' + config['global_manager_port'],
{'username': state['hashed_username'], {'username': state['hashed_username'],
'password': state['hashed_password'], 'password': state['hashed_password'],
'time': time.time(), 'time': time.time(),
@ -301,11 +310,6 @@ def execute(config, state):
log.exception('Exception at underload request:') log.exception('Exception at underload request:')
else: else:
log.info('Started overload detection')
overload, state['overload_detection_state'] = overload_detection(
host_cpu_utilization, state['overload_detection_state'])
log.info('Completed overload detection')
if overload: if overload:
if log.isEnabledFor(logging.INFO): if log.isEnabledFor(logging.INFO):
log.info('Overload detected') log.info('Overload detected')
@ -318,8 +322,8 @@ def execute(config, state):
if log.isEnabledFor(logging.INFO): if log.isEnabledFor(logging.INFO):
log.info('Selected VMs to migrate: %s', str(vm_uuids)) log.info('Selected VMs to migrate: %s', str(vm_uuids))
try: try:
r = requests.put('http://' + config['global_manager_host'] + \ r = requests.put('http://' + config['global_manager_host'] +
':' + config['global_manager_port'], ':' + config['global_manager_port'],
{'username': state['hashed_username'], {'username': state['hashed_username'],
'password': state['hashed_password'], 'password': state['hashed_password'],
'time': time.time(), 'time': time.time(),
@ -335,7 +339,9 @@ def execute(config, state):
if log.isEnabledFor(logging.INFO): if log.isEnabledFor(logging.INFO):
log.info('No underload or overload detected') log.info('No underload or overload detected')
log.info('Completed an iteration') if log.isEnabledFor(logging.INFO):
log.info('Completed an iteration')
return state return state