From 88924497c2c5adce5dbbba1f30abd6753b7df282 Mon Sep 17 00:00:00 2001 From: Joshua Boniface Date: Wed, 11 Dec 2019 17:05:05 -0500 Subject: [PATCH] Define with profile and allow options --- .../provisioner_lib/provisioner.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/client-provisioner/provisioner_lib/provisioner.py b/client-provisioner/provisioner_lib/provisioner.py index 05f73ca6..7cb40541 100755 --- a/client-provisioner/provisioner_lib/provisioner.py +++ b/client-provisioner/provisioner_lib/provisioner.py @@ -669,7 +669,7 @@ def clone_vm(self, vm_name, vm_profile): # # Main VM provisioning function - executed by the Celery worker # -def create_vm(self, vm_name, vm_profile): +def create_vm(self, vm_name, vm_profile, define_vm=True, start_vm=True): # Runtime imports import time import importlib @@ -1108,12 +1108,19 @@ def create_vm(self, vm_name, vm_profile): self.update_state(state='RUNNING', meta={'current': 9, 'total': 10, 'status': 'Defining and starting VM on the cluster'}) time.sleep(1) - print("Defining and starting VM on cluster") + if start_vm and not define_vm: + start_vm = False - retcode, retmsg = pvc_vm.define_vm(zk_conn, vm_schema, target_node, vm_data['system_details']['node_limit'].split(','), vm_data['system_details']['node_selector'], vm_data['system_details']['start_with_node']) - print(retmsg) - retcode, retmsg = pvc_vm.start_vm(zk_conn, vm_name) - print(retmsg) + if define_vm or start_vm: + print("Defining and starting VM on cluster") + + if define_vm: + retcode, retmsg = pvc_vm.define_vm(zk_conn, vm_schema, target_node, vm_data['system_details']['node_limit'].split(','), vm_data['system_details']['node_selector'], vm_data['system_details']['start_with_node'], vm_profile) + print(retmsg) + + if start_vm: + retcode, retmsg = pvc_vm.start_vm(zk_conn, vm_name) + print(retmsg) pvc_common.stopZKConnection(zk_conn) return {"status": "VM '{}' with profile '{}' has been provisioned and started successfully".format(vm_name, vm_profile), "current": 10, "total": 10}