From 531578fd28c45f62962d03d21f61b3b8130ebcf8 Mon Sep 17 00:00:00 2001 From: Joshua Boniface Date: Wed, 23 Oct 2019 23:53:25 -0400 Subject: [PATCH] Use consistent tense for VM states Replace "failed" with "fail" and "disabled" with "disable" for consistency with the remaining states. --- client-common/cluster.py | 6 +++--- client-common/vm.py | 12 ++++++------ node-daemon/pvcd/VMInstance.py | 8 ++++---- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/client-common/cluster.py b/client-common/cluster.py index e8fdf74e..e7ad1503 100644 --- a/client-common/cluster.py +++ b/client-common/cluster.py @@ -73,7 +73,7 @@ def getClusterInformation(zk_conn): vm_report_status = list(range(0, vm_count)) for index, vm in enumerate(vm_list): 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 else: vm_healthy_status[index] = True @@ -114,7 +114,7 @@ def getClusterInformation(zk_conn): 'stop,ready', 'stop,flush', 'stop,flushed', 'stop,unflush' ] vm_state_combinations = [ - 'start', 'restart', 'shutdown', 'stop', 'disabled', 'failed', 'migrate', 'unmigrate' + 'start', 'restart', 'shutdown', 'stop', 'disable', 'fail', 'migrate', 'unmigrate' ] ceph_osd_state_combinations = [ 'up,in', 'up,out', 'down,in', 'down,out' @@ -219,7 +219,7 @@ def format_info(cluster_information, oformat): if state == 'total' or state == 'start': continue - if state == 'disabled': + if state == 'disable': colour = ansiprint.blue() else: colour = ansiprint.yellow() diff --git a/client-common/vm.py b/client-common/vm.py index 49e4ce3b..79372821 100644 --- a/client-common/vm.py +++ b/client-common/vm.py @@ -400,9 +400,9 @@ def disable_vm(zk_conn, domain): return False, 'ERROR: VM "{}" must be stopped before disabling!'.format(domain) # 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): # 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) 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: 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(), 'shutdown': ansiprint.yellow(), 'stop': ansiprint.red(), - 'disabled': ansiprint.blue(), - 'failed': ansiprint.red(), + 'disable': ansiprint.blue(), + 'fail': ansiprint.red(), 'migrate': ansiprint.blue(), 'unmigrate': ansiprint.blue() } @@ -868,7 +868,7 @@ def format_list(zk_conn, vm_list, raw): vm_state_colour = ansiprint.yellow() elif domain_information['state'] == 'stop': vm_state_colour = ansiprint.red() - elif domain_information['state'] == 'failed': + elif domain_information['state'] == 'fail': vm_state_colour = ansiprint.red() else: vm_state_colour = ansiprint.blue() diff --git a/node-daemon/pvcd/VMInstance.py b/node-daemon/pvcd/VMInstance.py index 1a68a0fb..7e786d93 100644 --- a/node-daemon/pvcd/VMInstance.py +++ b/node-daemon/pvcd/VMInstance.py @@ -221,7 +221,7 @@ class VMInstance(object): zkhandler.writedata(self.zk_conn, { '/domains/{}/failedreason'.format(self.domuuid): '' }) except libvirt.libvirtError as e: 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) }) 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 if tick > 90: # 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)) break @@ -447,9 +447,9 @@ class VMInstance(object): # If we've already been waiting 120s for a shutdown # HARDCODE: The remote timeout is 90s, so an extra 30s of buffer 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, { - '/domains/{}/state'.format(self.domuuid): 'failed', + '/domains/{}/state'.format(self.domuuid): 'fail', '/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))