aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/benchmark/scenarios/lib
diff options
context:
space:
mode:
Diffstat (limited to 'yardstick/benchmark/scenarios/lib')
-rw-r--r--yardstick/benchmark/scenarios/lib/attach_volume.py53
-rw-r--r--yardstick/benchmark/scenarios/lib/create_floating_ip.py60
-rw-r--r--yardstick/benchmark/scenarios/lib/create_keypair.py71
-rw-r--r--yardstick/benchmark/scenarios/lib/create_network.py64
-rw-r--r--yardstick/benchmark/scenarios/lib/create_port.py66
-rw-r--r--yardstick/benchmark/scenarios/lib/create_router.py66
-rw-r--r--yardstick/benchmark/scenarios/lib/create_sec_group.py65
-rw-r--r--yardstick/benchmark/scenarios/lib/create_server.py2
-rw-r--r--yardstick/benchmark/scenarios/lib/create_subnet.py66
-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
13 files changed, 732 insertions, 0 deletions
diff --git a/yardstick/benchmark/scenarios/lib/attach_volume.py b/yardstick/benchmark/scenarios/lib/attach_volume.py
new file mode 100644
index 000000000..88124964b
--- /dev/null
+++ b/yardstick/benchmark/scenarios/lib/attach_volume.py
@@ -0,0 +1,53 @@
+##############################################################################
+# 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 AttachVolume(base.Scenario):
+ """Attach a volmeu to an instance"""
+
+ __scenario_type__ = "AttachVolume"
+
+ 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.attach_server_volume(self.server_id,
+ self.volume_id)
+
+ if status:
+ LOG.info("Attach volume to server successful!")
+ else:
+ LOG.info("Attach volume to server failed!")
diff --git a/yardstick/benchmark/scenarios/lib/create_floating_ip.py b/yardstick/benchmark/scenarios/lib/create_floating_ip.py
new file mode 100644
index 000000000..328566d48
--- /dev/null
+++ b/yardstick/benchmark/scenarios/lib/create_floating_ip.py
@@ -0,0 +1,60 @@
+##############################################################################
+# 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
+import os
+
+from yardstick.benchmark.scenarios import base
+import yardstick.common.openstack_utils as op_utils
+
+LOG = logging.getLogger(__name__)
+
+
+class CreateFloatingIp(base.Scenario):
+ """Create an OpenStack floating ip"""
+
+ __scenario_type__ = "CreateFloatingIp"
+
+ def __init__(self, scenario_cfg, context_cfg):
+ self.scenario_cfg = scenario_cfg
+ self.context_cfg = context_cfg
+ self.ext_net_id = os.getenv("EXTERNAL_NETWORK", "external")
+
+ self.neutron_client = op_utils.get_neutron_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()
+
+ net_id = op_utils.get_network_id(self.neutron_client, self.ext_net_id)
+ floating_info = op_utils.create_floating_ip(self.neutron_client,
+ extnet_id=net_id)
+ if floating_info:
+ LOG.info("Creating floating ip successful!")
+ else:
+ LOG.error("Creating floating ip failed!")
+
+ try:
+ keys = self.scenario_cfg.get('output', '').split()
+ except KeyError:
+ pass
+ else:
+ values = [floating_info["fip_id"], floating_info["fip_addr"]]
+ return self._push_to_outputs(keys, values)
diff --git a/yardstick/benchmark/scenarios/lib/create_keypair.py b/yardstick/benchmark/scenarios/lib/create_keypair.py
new file mode 100644
index 000000000..2185bfa5d
--- /dev/null
+++ b/yardstick/benchmark/scenarios/lib/create_keypair.py
@@ -0,0 +1,71 @@
+##############################################################################
+# 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
+import paramiko
+
+from yardstick.benchmark.scenarios import base
+import yardstick.common.openstack_utils as op_utils
+
+LOG = logging.getLogger(__name__)
+
+
+class CreateKeypair(base.Scenario):
+ """Create an OpenStack keypair"""
+
+ __scenario_type__ = "CreateKeypair"
+
+ 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.key_filename = self.options.get("key_path", "/tmp/yardstick_key")
+
+ 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()
+
+ rsa_key = paramiko.RSAKey.generate(bits=2048, progress_func=None)
+ rsa_key.write_private_key_file(self.key_filename)
+ print("Writing %s ..." % self.key_filename)
+ with open(self.key_filename + ".pub", "w") as pubkey_file:
+ pubkey_file.write(
+ "%s %s\n" % (rsa_key.get_name(), rsa_key.get_base64()))
+ del rsa_key
+
+ keypair = op_utils.create_keypair(self.key_name,
+ self.key_filename + ".pub")
+
+ if keypair:
+ result.update({"keypair_create": 1})
+ LOG.info("Create keypair successful!")
+ else:
+ result.update({"keypair_create": 0})
+ LOG.info("Create keypair failed!")
+ try:
+ keys = self.scenario_cfg.get('output', '').split()
+ except KeyError:
+ pass
+ else:
+ values = [keypair.id]
+ return self._push_to_outputs(keys, values)
diff --git a/yardstick/benchmark/scenarios/lib/create_network.py b/yardstick/benchmark/scenarios/lib/create_network.py
new file mode 100644
index 000000000..cffff132a
--- /dev/null
+++ b/yardstick/benchmark/scenarios/lib/create_network.py
@@ -0,0 +1,64 @@
+##############################################################################
+# 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 CreateNetwork(base.Scenario):
+ """Create an OpenStack network"""
+
+ __scenario_type__ = "CreateNetwork"
+
+ def __init__(self, scenario_cfg, context_cfg):
+ self.scenario_cfg = scenario_cfg
+ self.context_cfg = context_cfg
+ self.options = self.scenario_cfg['options']
+
+ self.openstack = self.options.get("openstack_paras", None)
+
+ self.neutron_client = op_utils.get_neutron_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()
+
+ openstack_paras = {'network': self.openstack}
+ network_id = op_utils.create_neutron_net(self.neutron_client,
+ openstack_paras)
+ if network_id:
+ result.update({"network_create": 1})
+ LOG.info("Create network successful!")
+ else:
+ result.update({"network_create": 0})
+ LOG.error("Create network failed!")
+
+ try:
+ keys = self.scenario_cfg.get('output', '').split()
+ except KeyError:
+ pass
+ else:
+ values = [network_id]
+ return self._push_to_outputs(keys, values)
diff --git a/yardstick/benchmark/scenarios/lib/create_port.py b/yardstick/benchmark/scenarios/lib/create_port.py
new file mode 100644
index 000000000..6a3a23a10
--- /dev/null
+++ b/yardstick/benchmark/scenarios/lib/create_port.py
@@ -0,0 +1,66 @@
+##############################################################################
+# 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 CreatePort(base.Scenario):
+ """Create an OpenStack flavor"""
+
+ __scenario_type__ = "CreatePort"
+
+ def __init__(self, scenario_cfg, context_cfg):
+ self.scenario_cfg = scenario_cfg
+ self.context_cfg = context_cfg
+ self.options = self.scenario_cfg['options']
+
+ self.openstack = self.options.get("openstack_paras", None)
+
+ self.neutron_client = op_utils.get_neutron_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()
+
+ openstack_paras = {'port': self.openstack}
+ port = self.neutron_client.create_port(openstack_paras)
+
+ if port:
+ result.update({"Port_Create": 1})
+ LOG.info("Create Port successful!")
+ else:
+ result.update({"Port_Create": 0})
+ LOG.error("Create Port failed!")
+
+ check_result = port['port']['id']
+
+ try:
+ keys = self.scenario_cfg.get('output', '').split()
+ except KeyError:
+ pass
+ else:
+ values = [check_result]
+ return self._push_to_outputs(keys, values)
diff --git a/yardstick/benchmark/scenarios/lib/create_router.py b/yardstick/benchmark/scenarios/lib/create_router.py
new file mode 100644
index 000000000..9aa57ebb2
--- /dev/null
+++ b/yardstick/benchmark/scenarios/lib/create_router.py
@@ -0,0 +1,66 @@
+##############################################################################
+# 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 CreateRouter(base.Scenario):
+ """Create an OpenStack router"""
+
+ __scenario_type__ = "CreateRouter"
+
+ def __init__(self, scenario_cfg, context_cfg):
+ self.scenario_cfg = scenario_cfg
+ self.context_cfg = context_cfg
+ self.options = self.scenario_cfg['options']
+
+ self.openstack = self.options.get("openstack_paras", None)
+
+ self.neutron_client = op_utils.get_neutron_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()
+
+ openstack_paras = {'router': self.openstack}
+ router_id = op_utils.create_neutron_router(self.neutron_client,
+ openstack_paras)
+ if router_id:
+ result.update({"network_create": 1})
+ LOG.info("Create router successful!")
+ else:
+ result.update({"network_create": 0})
+ LOG.error("Create router failed!")
+
+ check_result = router_id
+
+ try:
+ keys = self.scenario_cfg.get('output', '').split()
+ except KeyError:
+ pass
+ else:
+ values = [check_result]
+ return self._push_to_outputs(keys, values)
diff --git a/yardstick/benchmark/scenarios/lib/create_sec_group.py b/yardstick/benchmark/scenarios/lib/create_sec_group.py
new file mode 100644
index 000000000..3d1aec9e8
--- /dev/null
+++ b/yardstick/benchmark/scenarios/lib/create_sec_group.py
@@ -0,0 +1,65 @@
+##############################################################################
+# 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 CreateSecgroup(base.Scenario):
+ """Create an OpenStack security group"""
+
+ __scenario_type__ = "CreateSecgroup"
+
+ def __init__(self, scenario_cfg, context_cfg):
+ self.scenario_cfg = scenario_cfg
+ self.context_cfg = context_cfg
+ self.options = self.scenario_cfg['options']
+
+ self.sg_name = self.options.get("sg_name", "yardstick_sec_group")
+ self.description = self.options.get("description", None)
+ self.neutron_client = op_utils.get_neutron_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()
+
+ sg_id = op_utils.create_security_group_full(self.neutron_client,
+ sg_name=self.sg_name,
+ sg_description=self.description)
+
+ if sg_id:
+ result.update({"sg_create": 1})
+ LOG.info("Create security group successful!")
+ else:
+ result.update({"sg_create": 0})
+ LOG.error("Create security group failed!")
+
+ try:
+ keys = self.scenario_cfg.get('output', '').split()
+ except KeyError:
+ pass
+ else:
+ values = [sg_id]
+ return self._push_to_outputs(keys, values)
diff --git a/yardstick/benchmark/scenarios/lib/create_server.py b/yardstick/benchmark/scenarios/lib/create_server.py
index 45c0bfde9..273b0045a 100644
--- a/yardstick/benchmark/scenarios/lib/create_server.py
+++ b/yardstick/benchmark/scenarios/lib/create_server.py
@@ -59,8 +59,10 @@ class CreateServer(base.Scenario):
vm = op_utils.create_instance_and_wait_for_active(self.openstack)
if vm:
+ result.update({"instance_create": 1})
LOG.info("Create server successful!")
else:
+ result.update({"instance_create": 0})
LOG.error("Create server failed!")
try:
diff --git a/yardstick/benchmark/scenarios/lib/create_subnet.py b/yardstick/benchmark/scenarios/lib/create_subnet.py
new file mode 100644
index 000000000..c34af8a9e
--- /dev/null
+++ b/yardstick/benchmark/scenarios/lib/create_subnet.py
@@ -0,0 +1,66 @@
+##############################################################################
+# 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 CreateSubnet(base.Scenario):
+ """Create an OpenStack flavor"""
+
+ __scenario_type__ = "CreateSubnet"
+
+ def __init__(self, scenario_cfg, context_cfg):
+ self.scenario_cfg = scenario_cfg
+ self.context_cfg = context_cfg
+ self.options = self.scenario_cfg['options']
+
+ self.openstack = self.options.get("openstack_paras", None)
+
+ self.neutron_client = op_utils.get_neutron_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()
+
+ openstack_paras = {'subnets': [self.openstack]}
+ subnet_id = op_utils.create_neutron_subnet(self.neutron_client,
+ openstack_paras)
+ if subnet_id:
+ result.update({"subnet_create": 1})
+ LOG.info("Create subnet successful!")
+ else:
+ result.update({"subnet_create": 0})
+ LOG.error("Create subnet failed!")
+
+ check_result = subnet_id
+
+ try:
+ keys = self.scenario_cfg.get('output', '').split()
+ except KeyError:
+ pass
+ else:
+ values = [check_result]
+ return self._push_to_outputs(keys, values)
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!")