aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/benchmark
diff options
context:
space:
mode:
authorJing Lu <lvjing5@huawei.com>2017-08-22 07:13:28 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-08-22 07:13:28 +0000
commitb82340a4e3b63b38fe3b797070baacfb70a6df38 (patch)
tree6479fb3e8eb0f8962f974da1c5694540fab24a18 /yardstick/benchmark
parent9da77e9572bc9bd90b3978713b197339480a4a74 (diff)
parent2e3974f99811dda12ca3f7e3a9521a0efc2e8677 (diff)
Merge "Add common openstack opertation scenarios: subnet & port"
Diffstat (limited to 'yardstick/benchmark')
-rw-r--r--yardstick/benchmark/scenarios/lib/create_keypair.py2
-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
7 files changed, 331 insertions, 0 deletions
diff --git a/yardstick/benchmark/scenarios/lib/create_keypair.py b/yardstick/benchmark/scenarios/lib/create_keypair.py
index 5610de651..2185bfa5d 100644
--- a/yardstick/benchmark/scenarios/lib/create_keypair.py
+++ b/yardstick/benchmark/scenarios/lib/create_keypair.py
@@ -57,8 +57,10 @@ class CreateKeypair(base.Scenario):
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()
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)