aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/common/openstack_utils.py
diff options
context:
space:
mode:
authorShobhi Jain <shobhi.jain@intel.com>2018-03-27 14:28:08 +0100
committerShobhi Jain <shobhi.jain@intel.com>2018-04-23 13:09:54 +0000
commitc1ab98526209a761a0565afa7ccd552ba9ac7ade (patch)
tree7aec3b0543b31e994dd719c442b132b8dd209b5f /yardstick/common/openstack_utils.py
parent2ca15a8c87e171cbd82b1e748dfc60903662b73b (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>
Diffstat (limited to 'yardstick/common/openstack_utils.py')
-rw-r--r--yardstick/common/openstack_utils.py19
1 files changed, 12 insertions, 7 deletions
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,