diff options
author | JingLu5 <lvjing5@huawei.com> | 2016-10-24 15:22:52 +0800 |
---|---|---|
committer | JingLu5 <lvjing5@huawei.com> | 2016-10-25 14:50:05 +0800 |
commit | 9471f3f85d9ef0ac3d9b85d24b39cfa431bf5674 (patch) | |
tree | 511b87cab98f032e8d9462ec3e3d6f6323810fa6 /yardstick/benchmark/contexts | |
parent | 31226362a10c1e90d4bf0cd10fb81e50606becaf (diff) |
remove yardstick_key from the repo
JIRA: YARDSTICK-370
private key should not be in the repo. yardstick image now use
yardstick_key in the repo to log in the vm, so it should be
change to automatic generate it.
also the userguide should be updated to generate yardstick_key
before the test.
Change-Id: I61775bb429a8fddb9b8d312203f10ec369a1f801
Signed-off-by: JingLu5 <lvjing5@huawei.com>
Diffstat (limited to 'yardstick/benchmark/contexts')
-rw-r--r-- | yardstick/benchmark/contexts/heat.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/yardstick/benchmark/contexts/heat.py b/yardstick/benchmark/contexts/heat.py index 8c514d250..b504cd4df 100644 --- a/yardstick/benchmark/contexts/heat.py +++ b/yardstick/benchmark/contexts/heat.py @@ -7,8 +7,10 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +import os import sys import pkg_resources +import paramiko from yardstick.benchmark.contexts.base import Context from yardstick.benchmark.contexts.model import Server @@ -37,6 +39,7 @@ class HeatContext(Context): self._user = None self.template_file = None self.heat_parameters = None + self.key_filename = 'yardstick/resources/files/yardstick_key' super(self.__class__, self).__init__() def init(self, attrs): @@ -74,6 +77,17 @@ 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): '''returns application's default image name''' @@ -214,6 +228,13 @@ class HeatContext(Context): self.stack = None print "Context '%s' undeployed" % self.name + if os.path.exists(self.key_filename): + try: + os.remove(self.key_filename) + os.remove(self.key_filename + ".pub") + except OSError, e: + print ("Error: %s - %s." % (e.key_filename, e.strerror)) + def _get_server(self, attr_name): '''lookup server info by name from context attr_name: either a name for a server created by yardstick or a dict |