1 ##############################################################################
2 # Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
10 from __future__ import print_function
11 from __future__ import absolute_import
15 from yardstick.benchmark.scenarios import base
16 import yardstick.common.openstack_utils as op_utils
18 LOG = logging.getLogger(__name__)
21 class DeleteKeypair(base.Scenario):
22 """Delete an OpenStack keypair"""
24 __scenario_type__ = "DeleteKeypair"
26 def __init__(self, scenario_cfg, context_cfg):
27 self.scenario_cfg = scenario_cfg
28 self.context_cfg = context_cfg
29 self.options = self.scenario_cfg['options']
31 self.key_name = self.options.get("key_name", "yardstick_key")
33 self.nova_client = op_utils.get_nova_client()
35 self.setup_done = False
40 self.setup_done = True
42 def run(self, result):
43 """execute the test"""
45 if not self.setup_done:
48 status = op_utils.delete_keypair(self.nova_client,
52 result.update({"delete_keypair": 1})
53 LOG.info("Delete keypair successful!")
55 result.update({"delete_keypair": 0})
56 LOG.info("Delete keypair failed!")