From aded0fdb30caf035e0eb94c1216f436ba597c2c7 Mon Sep 17 00:00:00 2001 From: Shobhi Jain Date: Tue, 27 Mar 2018 16:47:04 +0100 Subject: Replace nova delete keypair with shade client. Function delete_keypair now uses shade client. JIRA: YARDSTICK-1088 Change-Id: I46b895748c5c44b0bf7d5b035395676ebff48d7f Signed-off-by: Shobhi Jain --- yardstick/common/exceptions.py | 4 ++++ yardstick/common/openstack_utils.py | 16 +++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) (limited to 'yardstick/common') diff --git a/yardstick/common/exceptions.py b/yardstick/common/exceptions.py index 41333c161..734706191 100644 --- a/yardstick/common/exceptions.py +++ b/yardstick/common/exceptions.py @@ -186,3 +186,7 @@ class ScenarioDeleteServerError(YardstickException): class ScenarioCreateKeypairError(YardstickException): message = 'Nova Create Keypair Scenario failed' + + +class ScenarioDeleteKeypairError(YardstickException): + message = 'Nova Delete Keypair Scenario failed' diff --git a/yardstick/common/openstack_utils.py b/yardstick/common/openstack_utils.py index e79c98872..0902d29e1 100644 --- a/yardstick/common/openstack_utils.py +++ b/yardstick/common/openstack_utils.py @@ -348,12 +348,18 @@ def delete_flavor(flavor_id): # pragma: no cover return True -def delete_keypair(nova_client, key): # pragma: no cover +def delete_keypair(shade_client, name): + """Delete a keypair. + + :param name: Name of the keypair to delete. + + :returns: True if delete succeeded, False otherwise. + """ try: - nova_client.keypairs.delete(key=key) - return True - except Exception: # pylint: disable=broad-except - log.exception("Error [delete_keypair(nova_client)]") + return shade_client.delete_keypair(name) + except exc.OpenStackCloudException as o_exc: + log.error("Error [delete_neutron_router(shade_client, '%s')]. " + "Exception message: %s", name, o_exc.orig_message) return False -- cgit 1.2.3-korg