From d4dc3ac6490c597de6782e7ef30f14b675fe12c1 Mon Sep 17 00:00:00 2001 From: Joshua Boniface Date: Mon, 9 Dec 2019 09:56:59 -0500 Subject: [PATCH] Enforce VM uniqueness when defining Closes #56 --- client-common/vm.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client-common/vm.py b/client-common/vm.py index 79372821..52757d5c 100644 --- a/client-common/vm.py +++ b/client-common/vm.py @@ -166,6 +166,10 @@ def define_vm(zk_conn, config_data, target_node, node_limit, node_selector, node dom_uuid = parsed_xml.uuid.text dom_name = parsed_xml.name.text + # Ensure that the UUID and name are unique + if searchClusterByUUID(dom_uuid) or searchClusterByName(dom_name): + return False, 'ERROR: Specified VM "{}" or UUID "{}" matches an existing VM on the cluster'.format(dom_name, dom_uuid) + if not target_node: target_node = common.findTargetNode(zk_conn, dom_uuid) else: