aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/common
diff options
context:
space:
mode:
authorShobhi Jain <shobhi.jain@intel.com>2018-03-27 14:28:08 +0100
committerEmma Foley <emma.l.foley@intel.com>2018-06-27 17:08:57 +0100
commit79ee87f223e2f466c099dcd47d56a3b1094491d6 (patch)
tree56a77aba5e14314adf6d779d75322ef55aa3a669 /yardstick/common
parent672c7213503e0cb041f14b5384205ae183cd0f1d (diff)
Replace nova client create keypair with shade.
Function create_keypair now uses shade client instead of nova client. JIRA: YARDSTICK-1088 Change-Id: I060580504d6969c5ba859ed4494082feb998d37d Signed-off-by: Shobhi Jain <shobhi.jain@intel.com> (cherry pick from commit c1ab98526209a761a0565afa7ccd552ba9ac7ade)
Diffstat (limited to 'yardstick/common')
-rw-r--r--yardstick/common/exceptions.py4
-rw-r--r--yardstick/common/openstack_utils.py19
2 files changed, 16 insertions, 7 deletions
diff --git a/yardstick/common/exceptions.py b/yardstick/common/exceptions.py
index fa9217921..aa718456d 100644
--- a/yardstick/common/exceptions.py
+++ b/yardstick/common/exceptions.py
@@ -226,6 +226,10 @@ class ScenarioDeleteServerError(YardstickException):
message = 'Delete Server Scenario failed'
+class ScenarioCreateKeypairError(YardstickException):
+ message = 'Nova Create Keypair Scenario failed'
+
+
class ApiServerError(YardstickException):
message = 'An unkown exception happened to Api Server!'
diff --git a/yardstick/common/openstack_utils.py b/yardstick/common/openstack_utils.py
index d469929e3..e79c98872 100644
--- a/yardstick/common/openstack_utils.py
+++ b/yardstick/common/openstack_utils.py
@@ -162,14 +162,19 @@ def get_shade_client():
# *********************************************
# NOVA
# *********************************************
-def create_keypair(name, key_path=None): # pragma: no cover
+def create_keypair(shade_client, name, public_key=None):
+ """Create a new keypair.
+
+ :param name: Name of the keypair being created.
+ :param public_key: Public key for the new keypair.
+
+ :return: Created keypair.
+ """
try:
- with open(key_path) as fpubkey:
- keypair = get_nova_client().keypairs.create(
- name=name, public_key=fpubkey.read())
- return keypair
- except Exception: # pylint: disable=broad-except
- log.exception("Error [create_keypair(nova_client)]")
+ return shade_client.create_keypair(name, public_key=public_key)
+ except exc.OpenStackCloudException as o_exc:
+ log.error("Error [create_keypair(shade_client)]. "
+ "Exception message, '%s'", o_exc.orig_message)
def create_instance_and_wait_for_active(shade_client, name, image,