diff options
author | Emma Foley <emma.l.foley@intel.com> | 2018-02-16 15:22:12 +0000 |
---|---|---|
committer | Emma Foley <emma.l.foley@intel.com> | 2018-03-01 15:02:27 +0000 |
commit | 5c2824d8e184a3ff63a52e7c7cca7b4e6f0c0222 (patch) | |
tree | a731956bfdef110f6a601c35e5001093d0120b4f /yardstick/benchmark/contexts | |
parent | 4a21b4a434d5a60cb57dce576365dc6a9a6825b5 (diff) |
Use context name instead of key_uuid
context.key_uuid is only used as a suffix for the key files.
There is already a unique ID associated with a the context;
the context name includes a task ID, which is a UUID.
This patch sets context.key_uuid to to context.name instead of
generating a separate UUID
As a result, get_short_key_uuid() is not needed.
JIRA: YARDSTICK-1028
Change-Id: Id175061d6cfe23a068bb3d12ce176c1f176e8236
Signed-off-by: Emma Foley <emma.l.foley@intel.com>
Diffstat (limited to 'yardstick/benchmark/contexts')
-rw-r--r-- | yardstick/benchmark/contexts/heat.py | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/yardstick/benchmark/contexts/heat.py b/yardstick/benchmark/contexts/heat.py index 8dd7d85e6..be8815060 100644 --- a/yardstick/benchmark/contexts/heat.py +++ b/yardstick/benchmark/contexts/heat.py @@ -13,7 +13,6 @@ from __future__ import print_function import collections import logging import os -import uuid import errno from collections import OrderedDict @@ -27,7 +26,7 @@ from yardstick.benchmark.contexts.model import Server from yardstick.benchmark.contexts.model import update_scheduler_hints from yardstick.common import exceptions as y_exc from yardstick.common.openstack_utils import get_neutron_client -from yardstick.orchestrator.heat import HeatTemplate, get_short_key_uuid +from yardstick.orchestrator.heat import HeatTemplate from yardstick.common import constants as consts from yardstick.common.utils import source_env from yardstick.ssh import SSH @@ -68,13 +67,8 @@ class HeatContext(Context): self.template_file = None self.heat_parameters = None self.neutron_client = None - # generate an uuid to identify yardstick_key - # the first 8 digits of the uuid will be used - self.key_uuid = uuid.uuid4() self.heat_timeout = None - self.key_filename = ''.join( - [consts.YARDSTICK_ROOT_PATH, 'yardstick/resources/files/yardstick_key-', - get_short_key_uuid(self.key_uuid)]) + self.key_filename = None super(HeatContext, self).__init__() @staticmethod @@ -137,7 +131,16 @@ class HeatContext(Context): self._server_map[server.dn] = server self.attrs = attrs - SSH.gen_keys(self.key_filename) + + self.key_filename = ''.join( + [consts.YARDSTICK_ROOT_PATH, + 'yardstick/resources/files/yardstick_key-', + self.name]) + # Permissions may have changed since creation; this can be fixed. If we + # overwrite the file, we lose future access to VMs using this key. + # As long as the file exists, even if it is unreadable, keep it intact + if not os.path.exists(self.key_filename): + SSH.gen_keys(self.key_filename) def check_environment(self): try: @@ -176,7 +179,7 @@ class HeatContext(Context): template.add_flavor(**self.flavor) self.flavors.add(flavor) - template.add_keypair(self.keypair_name, self.key_uuid) + template.add_keypair(self.keypair_name, self.name) template.add_security_group(self.secgroup_name) for network in self.networks.values(): @@ -438,7 +441,7 @@ class HeatContext(Context): pkey = pkg_resources.resource_string( 'yardstick.resources', - h_join('files/yardstick_key', get_short_key_uuid(self.key_uuid))).decode('utf-8') + h_join('files/yardstick_key', self.name)).decode('utf-8') result = { "user": server.context.user, |