From ae576870aaab6007e52cd1a9c3c7a0fa78c4b3a4 Mon Sep 17 00:00:00 2001 From: sripathi Date: Tue, 28 Apr 2015 14:58:37 +0530 Subject: [PATCH 1/2] written code to execute labspec.yml --- src/VMManager/VMManager.py | 59 ++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 24 deletions(-) diff --git a/src/VMManager/VMManager.py b/src/VMManager/VMManager.py index b15123f..ddaa3c4 100644 --- a/src/VMManager/VMManager.py +++ b/src/VMManager/VMManager.py @@ -88,32 +88,43 @@ def get_runtime_actions_steps(lab_spec): return lab_spec['lab']['runtime_requirements']['platform']['lab_actions'] logger.info("Starting test_lab") - + repo_name = construct_repo_name(lab_src_url) + lab_spec = get_lab_spec(repo_name) + spec_path = get_spec_path(repo_name) + yml_file = "labspec.yml" try: - fill_aptconf() - repo_name = construct_repo_name(lab_src_url) - lab_spec = get_lab_spec(repo_name) - spec_path = get_spec_path(repo_name) - logger.debug("spec_path: %s" % spec_path) - os.chdir(spec_path) - logger.debug("Changed to Diretory: %s" % spec_path) - logger.debug("CWD: %s" % str(os.getcwd())) - - lar = LabActionRunner(get_build_installer_steps_spec(lab_spec)) - lar.run_install_source() - - lar = LabActionRunner(get_build_steps_spec(lab_spec)) - lar.run_build_steps() - - lar = LabActionRunner(get_runtime_installer_steps(lab_spec)) - lar.run_install_source() - - lar = LabActionRunner(get_runtime_actions_steps(lab_spec)) - lar.run_init_lab() - lar.run_start_lab() - logger.info("Finishing test_lab: Success") - return "Success" + if os.path.isfile(spec_path+yml_file): + try: + command = "ansible-playbook "+ spec_path + yml_file + logger.info("Command executed: " + command) + (ret_code, output) = execute_command(command) + return "Success" + except Exception, e: + logger.error("Execution failed: " + str(e)) + return "Error executing the command: " + str(e) + + else: + fill_aptconf() + logger.debug("spec_path: %s" % spec_path) + os.chdir(spec_path) + logger.debug("Changed to Diretory: %s" % spec_path) + logger.debug("CWD: %s" % str(os.getcwd())) + + lar = LabActionRunner(get_build_installer_steps_spec(lab_spec)) + lar.run_install_source() + + lar = LabActionRunner(get_build_steps_spec(lab_spec)) + lar.run_build_steps() + + lar = LabActionRunner(get_runtime_installer_steps(lab_spec)) + lar.run_install_source() + + lar = LabActionRunner(get_runtime_actions_steps(lab_spec)) + lar.run_init_lab() + lar.run_start_lab() + logger.info("Finishing test_lab: Success") + return "Success" except Exception, e: logger.error("VMManager.test_lab failed: " + str(e)) return "Test lab failed" From 5476b722132176b603126cb2362a72d851ab09f1 Mon Sep 17 00:00:00 2001 From: sripathi Date: Tue, 28 Apr 2015 15:20:31 +0530 Subject: [PATCH 2/2] corrected spell mistakes --- src/VMManager/VMManager.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/VMManager/VMManager.py b/src/VMManager/VMManager.py index ddaa3c4..88e080c 100644 --- a/src/VMManager/VMManager.py +++ b/src/VMManager/VMManager.py @@ -92,10 +92,12 @@ def get_runtime_actions_steps(lab_spec): lab_spec = get_lab_spec(repo_name) spec_path = get_spec_path(repo_name) yml_file = "labspec.yml" - + fill_aptconf() try: if os.path.isfile(spec_path+yml_file): try: + logger.debug("spec_path: %s" % spec_path) + logger.debug("===== Installing pre-requisites for lab =====") command = "ansible-playbook "+ spec_path + yml_file logger.info("Command executed: " + command) (ret_code, output) = execute_command(command) @@ -104,8 +106,7 @@ def get_runtime_actions_steps(lab_spec): logger.error("Execution failed: " + str(e)) return "Error executing the command: " + str(e) - else: - fill_aptconf() + else: logger.debug("spec_path: %s" % spec_path) os.chdir(spec_path) logger.debug("Changed to Diretory: %s" % spec_path)