From 505c109875b7a5db80c85ee45779ded2a785d9e1 Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Sat, 5 Jun 2021 01:08:13 -0400 Subject: [PATCH] Avoid re-flush or re-ready nodes if unnecessary --- daemon-common/node.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/daemon-common/node.py b/daemon-common/node.py index 7b6167cc..cb8dd2ba 100644 --- a/daemon-common/node.py +++ b/daemon-common/node.py @@ -139,6 +139,9 @@ def flush_node(zkhandler, node, wait=False): if not common.verifyNode(zkhandler, node): return False, 'ERROR: No node named "{}" is present in the cluster.'.format(node) + if zkhandler.read('/nodes/{}/domainstate'.format(node)) == 'flushed': + return True, 'Hypervisor {} is already flushed.'.format(node) + retmsg = 'Flushing hypervisor {} of running VMs.'.format(node) # Add the new domain to Zookeeper @@ -159,6 +162,9 @@ def ready_node(zkhandler, node, wait=False): if not common.verifyNode(zkhandler, node): return False, 'ERROR: No node named "{}" is present in the cluster.'.format(node) + if zkhandler.read('/nodes/{}/domainstate'.format(node)) == 'ready': + return True, 'Hypervisor {} is already ready.'.format(node) + retmsg = 'Restoring hypervisor {} to active service.'.format(node) # Add the new domain to Zookeeper