Use consistent tense for VM states

Replace "failed" with "fail" and "disabled" with "disable" for
consistency with the remaining states.
This commit is contained in:
Joshua Boniface 2019-10-23 23:53:25 -04:00
parent 6a4c75deb8
commit 531578fd28
3 changed files with 13 additions and 13 deletions

View File

@ -73,7 +73,7 @@ def getClusterInformation(zk_conn):
vm_report_status = list(range(0, vm_count)) vm_report_status = list(range(0, vm_count))
for index, vm in enumerate(vm_list): for index, vm in enumerate(vm_list):
vm_state = vm['state'] vm_state = vm['state']
if vm_state != 'start' and vm_state != 'disabled': if vm_state != 'start' and vm_state != 'disable':
vm_healthy_status[index] = False vm_healthy_status[index] = False
else: else:
vm_healthy_status[index] = True vm_healthy_status[index] = True
@ -114,7 +114,7 @@ def getClusterInformation(zk_conn):
'stop,ready', 'stop,flush', 'stop,flushed', 'stop,unflush' 'stop,ready', 'stop,flush', 'stop,flushed', 'stop,unflush'
] ]
vm_state_combinations = [ vm_state_combinations = [
'start', 'restart', 'shutdown', 'stop', 'disabled', 'failed', 'migrate', 'unmigrate' 'start', 'restart', 'shutdown', 'stop', 'disable', 'fail', 'migrate', 'unmigrate'
] ]
ceph_osd_state_combinations = [ ceph_osd_state_combinations = [
'up,in', 'up,out', 'down,in', 'down,out' 'up,in', 'up,out', 'down,in', 'down,out'
@ -219,7 +219,7 @@ def format_info(cluster_information, oformat):
if state == 'total' or state == 'start': if state == 'total' or state == 'start':
continue continue
if state == 'disabled': if state == 'disable':
colour = ansiprint.blue() colour = ansiprint.blue()
else: else:
colour = ansiprint.yellow() colour = ansiprint.yellow()

View File

@ -400,9 +400,9 @@ def disable_vm(zk_conn, domain):
return False, 'ERROR: VM "{}" must be stopped before disabling!'.format(domain) return False, 'ERROR: VM "{}" must be stopped before disabling!'.format(domain)
# Set the VM to start # Set the VM to start
zkhandler.writedata(zk_conn, {'/domains/{}/state'.format(dom_uuid): 'disabled'}) zkhandler.writedata(zk_conn, {'/domains/{}/state'.format(dom_uuid): 'disable'})
return True, 'Marked VM "{}" as disabled.'.format(domain) return True, 'Marked VM "{}" as disable.'.format(domain)
def move_vm(zk_conn, domain, target_node): def move_vm(zk_conn, domain, target_node):
# Validate that VM exists in cluster # Validate that VM exists in cluster
@ -622,7 +622,7 @@ def get_list(zk_conn, node, state, limit, is_fuzzy=True):
return False, 'Specified node "{}" is invalid.'.format(node) return False, 'Specified node "{}" is invalid.'.format(node)
if state: if state:
valid_states = [ 'start', 'restart', 'shutdown', 'stop', 'disabled', 'failed', 'migrate', 'unmigrate' ] valid_states = [ 'start', 'restart', 'shutdown', 'stop', 'disable', 'fail', 'migrate', 'unmigrate' ]
if not state in valid_states: if not state in valid_states:
return False, 'VM state "{}" is not valid.'.format(state) return False, 'VM state "{}" is not valid.'.format(state)
@ -708,8 +708,8 @@ def format_info(zk_conn, domain_information, long_output):
'restart': ansiprint.yellow(), 'restart': ansiprint.yellow(),
'shutdown': ansiprint.yellow(), 'shutdown': ansiprint.yellow(),
'stop': ansiprint.red(), 'stop': ansiprint.red(),
'disabled': ansiprint.blue(), 'disable': ansiprint.blue(),
'failed': ansiprint.red(), 'fail': ansiprint.red(),
'migrate': ansiprint.blue(), 'migrate': ansiprint.blue(),
'unmigrate': ansiprint.blue() 'unmigrate': ansiprint.blue()
} }
@ -868,7 +868,7 @@ def format_list(zk_conn, vm_list, raw):
vm_state_colour = ansiprint.yellow() vm_state_colour = ansiprint.yellow()
elif domain_information['state'] == 'stop': elif domain_information['state'] == 'stop':
vm_state_colour = ansiprint.red() vm_state_colour = ansiprint.red()
elif domain_information['state'] == 'failed': elif domain_information['state'] == 'fail':
vm_state_colour = ansiprint.red() vm_state_colour = ansiprint.red()
else: else:
vm_state_colour = ansiprint.blue() vm_state_colour = ansiprint.blue()

View File

@ -221,7 +221,7 @@ class VMInstance(object):
zkhandler.writedata(self.zk_conn, { '/domains/{}/failedreason'.format(self.domuuid): '' }) zkhandler.writedata(self.zk_conn, { '/domains/{}/failedreason'.format(self.domuuid): '' })
except libvirt.libvirtError as e: except libvirt.libvirtError as e:
self.logger.out('Failed to create VM', state='e', prefix='Domain {}:'.format(self.domuuid)) self.logger.out('Failed to create VM', state='e', prefix='Domain {}:'.format(self.domuuid))
zkhandler.writedata(self.zk_conn, { '/domains/{}/state'.format(self.domuuid): 'failed' }) zkhandler.writedata(self.zk_conn, { '/domains/{}/state'.format(self.domuuid): 'fail' })
zkhandler.writedata(self.zk_conn, { '/domains/{}/failedreason'.format(self.domuuid): str(e) }) zkhandler.writedata(self.zk_conn, { '/domains/{}/failedreason'.format(self.domuuid): str(e) })
self.dom = None self.dom = None
@ -420,7 +420,7 @@ class VMInstance(object):
# HARDCODE: 90s should be plenty of time for even extremely large VMs on reasonable networks # HARDCODE: 90s should be plenty of time for even extremely large VMs on reasonable networks
if tick > 90: if tick > 90:
# The receive timed out # The receive timed out
zkhandler.writedata(self.zk_conn, { '/domains/{}/state'.format(self.domuuid): 'failed' }) zkhandler.writedata(self.zk_conn, { '/domains/{}/state'.format(self.domuuid): 'fail' })
self.logger.out('Receive timed out without state change', state='e', prefix='Domain {}:'.format(self.domuuid)) self.logger.out('Receive timed out without state change', state='e', prefix='Domain {}:'.format(self.domuuid))
break break
@ -447,9 +447,9 @@ class VMInstance(object):
# If we've already been waiting 120s for a shutdown # If we've already been waiting 120s for a shutdown
# HARDCODE: The remote timeout is 90s, so an extra 30s of buffer # HARDCODE: The remote timeout is 90s, so an extra 30s of buffer
if tick > 120: if tick > 120:
# The shutdown timed out; something is very amiss, so switch state to failed and abort # The shutdown timed out; something is very amiss, so switch state to fail and abort
zkhandler.writedata(self.zk_conn, { zkhandler.writedata(self.zk_conn, {
'/domains/{}/state'.format(self.domuuid): 'failed', '/domains/{}/state'.format(self.domuuid): 'fail',
'/domains/{}/failedreason'.format(self.domuuid): 'Timeout waiting for migrate or shutdown' '/domains/{}/failedreason'.format(self.domuuid): 'Timeout waiting for migrate or shutdown'
}) })
self.logger.out('Shutdown timed out without state change', state='e', prefix='Domain {}:'.format(self.domuuid)) self.logger.out('Shutdown timed out without state change', state='e', prefix='Domain {}:'.format(self.domuuid))