aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/benchmark/contexts
diff options
context:
space:
mode:
authorJingLu5 <lvjing5@huawei.com>2017-01-09 11:35:47 +0000
committerJingLu5 <lvjing5@huawei.com>2017-01-10 10:06:32 +0000
commit5386de98f7d9e44ab507904d82530fff3a3ae5e4 (patch)
tree5629791c65ee13f553a830344726a666b291edb3 /yardstick/benchmark/contexts
parent57011bd0769f54a98b90d489df0f38751ca76c0e (diff)
associate an uuid to yardstick_key and yardstick_key.pub
JIRA: YARDSTICK-527 This work is to support yardstick parallel tasks in the future. Currently, the RSA key we generated and used to access the VM is named 'yardstick_key'. If more than two tasks are running paralleled, the later 'yardstick_key' will cover the former. We want associate an uuid to identify differnets for each tasks. So the key files won't conflict. The first 8 digits will be used, as there is no need to used a full-length uuid. Change-Id: If8eaf47ae527cf9b3bd50f37ab3051fbdccf5f03 Signed-off-by: JingLu5 <lvjing5@huawei.com>
Diffstat (limited to 'yardstick/benchmark/contexts')
-rw-r--r--yardstick/benchmark/contexts/heat.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/yardstick/benchmark/contexts/heat.py b/yardstick/benchmark/contexts/heat.py
index fcbe825d6..166ca40c8 100644
--- a/yardstick/benchmark/contexts/heat.py
+++ b/yardstick/benchmark/contexts/heat.py
@@ -9,6 +9,7 @@
import os
import sys
+import uuid
import pkg_resources
import paramiko
@@ -40,8 +41,11 @@ class HeatContext(Context):
self._user = None
self.template_file = None
self.heat_parameters = None
+ # generate an uuid to identify yardstick_key
+ # the first 8 digits of the uuid will be used
+ self.key_uuid = uuid.uuid4()
self.key_filename = YARDSTICK_ROOT_PATH + \
- 'yardstick/resources/files/yardstick_key'
+ 'yardstick/resources/files/yardstick_key-' + str(self.key_uuid)[:8]
super(self.__class__, self).__init__()
def init(self, attrs):
@@ -79,16 +83,12 @@ class HeatContext(Context):
self.servers.append(server)
self._server_map[server.dn] = server
- print "Generating RSA host key ..."
rsa_key = paramiko.RSAKey.generate(bits=2048, progress_func=None)
- print "Writing yardstick_key ..."
rsa_key.write_private_key_file(self.key_filename)
- print "Writing yardstick_key.pub ..."
open(self.key_filename + ".pub", "w").write("%s %s\n" %
(rsa_key.get_name(),
rsa_key.get_base64()))
del rsa_key
- print "... done!"
@property
def image(self):
@@ -107,7 +107,7 @@ class HeatContext(Context):
def _add_resources_to_template(self, template):
'''add to the template the resources represented by this context'''
- template.add_keypair(self.keypair_name)
+ template.add_keypair(self.keypair_name, self.key_uuid)
template.add_security_group(self.secgroup_name)
for network in self.networks:
@@ -243,7 +243,8 @@ class HeatContext(Context):
with attribute name mapping when using external heat templates
'''
key_filename = pkg_resources.resource_filename(
- 'yardstick.resources', 'files/yardstick_key')
+ 'yardstick.resources', 'files/yardstick_key-{:.{width}}'.format(
+ self.key_uuid, width=8))
if type(attr_name) is dict:
cname = attr_name["name"].split(".")[1]