Ensure no ssh key file already exists before launch cloudify deployment
authorboucherv <valentin.boucher@orange.com>
Tue, 5 Jan 2016 10:43:09 +0000 (11:43 +0100)
committerboucherv <valentin.boucher@orange.com>
Tue, 5 Jan 2016 10:43:09 +0000 (11:43 +0100)
JIRA: FUNCTEST-115

Change-Id: Icef3da22f8cd4a528bd466d955037a9f37864f9b
Signed-off-by: boucherv <valentin.boucher@orange.com>
testcases/vIMS/CI/orchestrator.py

index 409b3e0..729e678 100644 (file)
@@ -72,8 +72,17 @@ class orchestrator:
                                f.write(yaml.dump(self.config, default_style='"') )
                        f.close()
 
-                       if self.logger:
+                       # Ensure no ssh key file already exists
+                       key_files = ["/.ssh/cloudify-manager-kp.pem", "/.ssh/cloudify-agent-kp.pem"]
+            home = os.path.expanduser("~")
+
+            for key_file in key_files:
+                if os.path.isfile(home + key_file):
+                    os.remove(home + key_file)
+
+            if self.logger:
                                self.logger.info("Launching the cloudify-manager deployment")
+
                        script = "source " + self.testcase_dir + "venv_cloudify/bin/activate; "
                        script += "cd " + self.testcase_dir + "; "
                        script += "cfy init -r; "
@@ -97,7 +106,7 @@ class orchestrator:
 
                script = "source " + self.testcase_dir + "venv_cloudify/bin/activate; "
                script += "cd " + self.testcase_dir + "; "
-               script += "cfy teardown -f; "
+               script += "cfy teardown -f --ignore-deployments=True; "
                cmd = "/bin/bash -c '" + script + "'"
                execute_command(cmd, self.logger)
 
@@ -144,7 +153,10 @@ class orchestrator:
                script += "cfy deployments delete -d " + dep_name + "; "
 
                cmd = "/bin/bash -c '" + script + "'"
-               execute_command(cmd, self.logger)
+               try:
+                       execute_command(cmd, self.logger)
+               except:
+                       logger.error("Clearwater undeployment failed")
 
 
 def execute_command(cmd, logger):