aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/benchmark/scenarios
diff options
context:
space:
mode:
authorJing Lu <lvjing5@huawei.com>2017-08-24 01:04:20 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-08-24 01:04:20 +0000
commit5ed1f7ebbe7a9ae6138f56051a15e7774f6e71b9 (patch)
tree3ca6aed6937399682d6f34092097bc87710497ee /yardstick/benchmark/scenarios
parentfaf7ef045dbb08d00e0a19374c6075d85ff5ad60 (diff)
parentb8f0aedae524539e9d0d069c07662e288046bc6f (diff)
Merge "Add common openstack opertation scenarios: volume & floating ip"
Diffstat (limited to 'yardstick/benchmark/scenarios')
-rw-r--r--yardstick/benchmark/scenarios/lib/delete_floating_ip.py54
-rw-r--r--yardstick/benchmark/scenarios/lib/delete_keypair.py56
-rw-r--r--yardstick/benchmark/scenarios/lib/delete_volume.py55
-rw-r--r--yardstick/benchmark/scenarios/lib/detach_volume.py54
4 files changed, 219 insertions, 0 deletions
diff --git a/yardstick/benchmark/scenarios/lib/delete_floating_ip.py b/yardstick/benchmark/scenarios/lib/delete_floating_ip.py
new file mode 100644
index 000000000..4314952fb
--- /dev/null
+++ b/yardstick/benchmark/scenarios/lib/delete_floating_ip.py
@@ -0,0 +1,54 @@
+##############################################################################
+# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+from __future__ import print_function
+from __future__ import absolute_import
+
+import logging
+
+from yardstick.benchmark.scenarios import base
+import yardstick.common.openstack_utils as op_utils
+
+LOG = logging.getLogger(__name__)
+
+
+class DeleteFloatingIp(base.Scenario):
+ """Delete an OpenStack floating ip """
+
+ __scenario_type__ = "DeleteFloatingIp"
+
+ def __init__(self, scenario_cfg, context_cfg):
+ self.scenario_cfg = scenario_cfg
+ self.context_cfg = context_cfg
+ self.options = self.scenario_cfg['options']
+
+ self.floating_ip_id = self.options.get("floating_ip_id", None)
+
+ self.nova_client = op_utils.get_nova_client()
+ self.setup_done = False
+
+ def setup(self):
+ """scenario setup"""
+
+ self.setup_done = True
+
+ def run(self, result):
+ """execute the test"""
+
+ if not self.setup_done:
+ self.setup()
+
+ status = op_utils.delete_floating_ip(nova_client=self.nova_client,
+ floatingip_id=self.floating_ip_id)
+ if status:
+ result.update({"delete_floating_ip": 1})
+ LOG.info("Delete floating ip successful!")
+ else:
+ result.update({"delete_floating_ip": 0})
+ LOG.error("Delete floating ip failed!")
diff --git a/yardstick/benchmark/scenarios/lib/delete_keypair.py b/yardstick/benchmark/scenarios/lib/delete_keypair.py
new file mode 100644
index 000000000..135139959
--- /dev/null
+++ b/yardstick/benchmark/scenarios/lib/delete_keypair.py
@@ -0,0 +1,56 @@
+##############################################################################
+# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+from __future__ import print_function
+from __future__ import absolute_import
+
+import logging
+
+from yardstick.benchmark.scenarios import base
+import yardstick.common.openstack_utils as op_utils
+
+LOG = logging.getLogger(__name__)
+
+
+class DeleteKeypair(base.Scenario):
+ """Delete an OpenStack keypair"""
+
+ __scenario_type__ = "DeleteKeypair"
+
+ def __init__(self, scenario_cfg, context_cfg):
+ self.scenario_cfg = scenario_cfg
+ self.context_cfg = context_cfg
+ self.options = self.scenario_cfg['options']
+
+ self.key_name = self.options.get("key_name", "yardstick_key")
+
+ self.nova_client = op_utils.get_nova_client()
+
+ self.setup_done = False
+
+ def setup(self):
+ """scenario setup"""
+
+ self.setup_done = True
+
+ def run(self, result):
+ """execute the test"""
+
+ if not self.setup_done:
+ self.setup()
+
+ status = op_utils.delete_keypair(self.nova_client,
+ self.key_name)
+
+ if status:
+ result.update({"delete_keypair": 1})
+ LOG.info("Delete keypair successful!")
+ else:
+ result.update({"delete_keypair": 0})
+ LOG.info("Delete keypair failed!")
diff --git a/yardstick/benchmark/scenarios/lib/delete_volume.py b/yardstick/benchmark/scenarios/lib/delete_volume.py
new file mode 100644
index 000000000..ea2b85812
--- /dev/null
+++ b/yardstick/benchmark/scenarios/lib/delete_volume.py
@@ -0,0 +1,55 @@
+##############################################################################
+# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+from __future__ import print_function
+from __future__ import absolute_import
+
+import logging
+
+from yardstick.benchmark.scenarios import base
+import yardstick.common.openstack_utils as op_utils
+
+LOG = logging.getLogger(__name__)
+
+
+class DeleteVolume(base.Scenario):
+ """Delete an OpenStack volume"""
+
+ __scenario_type__ = "DeleteVolume"
+
+ def __init__(self, scenario_cfg, context_cfg):
+ self.scenario_cfg = scenario_cfg
+ self.context_cfg = context_cfg
+ self.options = self.scenario_cfg['options']
+
+ self.volume_id = self.options.get("volume_id", None)
+
+ self.cinder_client = op_utils.get_cinder_client()
+
+ self.setup_done = False
+
+ def setup(self):
+ """scenario setup"""
+
+ self.setup_done = True
+
+ def run(self, result):
+ """execute the test"""
+
+ if not self.setup_done:
+ self.setup()
+
+ status = op_utils.delete_volume(self.cinder_client, self.volume_id)
+
+ if status:
+ result.update({"delete_volume": 1})
+ LOG.info("Delete volume successful!")
+ else:
+ result.update({"delete_volume": 0})
+ LOG.info("Delete volume failed!")
diff --git a/yardstick/benchmark/scenarios/lib/detach_volume.py b/yardstick/benchmark/scenarios/lib/detach_volume.py
new file mode 100644
index 000000000..0b02a3a81
--- /dev/null
+++ b/yardstick/benchmark/scenarios/lib/detach_volume.py
@@ -0,0 +1,54 @@
+##############################################################################
+# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+from __future__ import print_function
+from __future__ import absolute_import
+
+import logging
+
+from yardstick.benchmark.scenarios import base
+import yardstick.common.openstack_utils as op_utils
+
+LOG = logging.getLogger(__name__)
+
+
+class DetachVolume(base.Scenario):
+ """Detach a volume from an instance"""
+
+ __scenario_type__ = "DetachVolume"
+
+ def __init__(self, scenario_cfg, context_cfg):
+ self.scenario_cfg = scenario_cfg
+ self.context_cfg = context_cfg
+ self.options = self.scenario_cfg['options']
+
+ self.server_id = self.options.get("server_id", "TestServer")
+ self.volume_id = self.options.get("volume_id", None)
+
+ self.setup_done = False
+
+ def setup(self):
+ """scenario setup"""
+
+ self.setup_done = True
+
+ def run(self, result):
+ """execute the test"""
+
+ if not self.setup_done:
+ self.setup()
+
+ status = op_utils.detach_volume(self.server_id, self.volume_id)
+
+ if status:
+ result.update({"detach_volume": 1})
+ LOG.info("Detach volume from server successful!")
+ else:
+ result.update({"detach_volume": 0})
+ LOG.info("Detach volume from server failed!")