diff options
author | 2018-02-19 16:06:50 +0000 | |
---|---|---|
committer | 2018-03-02 19:08:37 +0000 | |
commit | 24a8c6d89f150666a37a3f8daba0fce7c17a436a (patch) | |
tree | 888e25fc09d65bda2bdfacbf8c24f4c19143f9ef /yardstick/benchmark/contexts | |
parent | a74ad5a1ec1a73389c5983440b2031b0bc72cea1 (diff) |
Add yardstick.benchmark.contexts.heat.HeatContext._delete_key_file()
* Move logic for removing key file into its own method
* Update the log message to be more useful
JIRA: YARDSTICK-1026
Change-Id: I8c131720ed91c939698c41ad63d586396fcce1fe
Signed-off-by: Emma Foley <emma.l.foley@intel.com>
Diffstat (limited to 'yardstick/benchmark/contexts')
-rw-r--r-- | yardstick/benchmark/contexts/heat.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/yardstick/benchmark/contexts/heat.py b/yardstick/benchmark/contexts/heat.py index 75e26e06f..77ac24899 100644 --- a/yardstick/benchmark/contexts/heat.py +++ b/yardstick/benchmark/contexts/heat.py @@ -29,6 +29,7 @@ from yardstick.common.openstack_utils import get_neutron_client from yardstick.orchestrator.heat import HeatStack from yardstick.orchestrator.heat import HeatTemplate from yardstick.common import constants as consts +from yardstick.common import utils from yardstick.common.utils import source_env from yardstick.ssh import SSH @@ -402,6 +403,14 @@ class HeatContext(Context): "local_ip": private_ip, } + def _delete_key_file(self): + try: + utils.remove_file(self.key_filename) + utils.remove_file(self.key_filename + ".pub") + except OSError: + LOG.exception("There was an error removing the key file %s", + self.key_filename) + def undeploy(self): """undeploys stack from cloud""" if self._flags.no_teardown: @@ -414,12 +423,7 @@ class HeatContext(Context): self.stack = None LOG.info("Undeploying context '%s' DONE", self.name) - if os.path.exists(self.key_filename): - try: - os.remove(self.key_filename) - os.remove(self.key_filename + ".pub") - except OSError: - LOG.exception("Key filename %s", self.key_filename) + self._delete_key_file() super(HeatContext, self).undeploy() |