aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/common
diff options
context:
space:
mode:
authorRodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>2018-04-26 09:04:38 +0000
committerGerrit Code Review <gerrit@opnfv.org>2018-04-26 09:04:38 +0000
commitd2769a6197b3104d5ebaeb2e022e1d3dc7f353ea (patch)
treeccc3a3b595637be295e1eafafe080b28f776a1f3 /yardstick/common
parent7e17ed6290be0afa09eb4fce19926aaf8e9c47ff (diff)
parentc1ab98526209a761a0565afa7ccd552ba9ac7ade (diff)
Merge "Replace nova client create keypair with shade."
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 694536a37..b68deba1d 100644
--- a/yardstick/common/exceptions.py
+++ b/yardstick/common/exceptions.py
@@ -198,3 +198,7 @@ class ScenarioCreateServerError(YardstickException):
class ScenarioDeleteServerError(YardstickException):
message = 'Delete Server Scenario failed'
+
+
+class ScenarioCreateKeypairError(YardstickException):
+ message = 'Nova Create Keypair Scenario failed'
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,