aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/benchmark/scenarios/lib/create_subnet.py
diff options
context:
space:
mode:
Diffstat (limited to 'yardstick/benchmark/scenarios/lib/create_subnet.py')
-rw-r--r--yardstick/benchmark/scenarios/lib/create_subnet.py60
1 files changed, 37 insertions, 23 deletions
diff --git a/yardstick/benchmark/scenarios/lib/create_subnet.py b/yardstick/benchmark/scenarios/lib/create_subnet.py
index c34af8a9e..e383c99de 100644
--- a/yardstick/benchmark/scenarios/lib/create_subnet.py
+++ b/yardstick/benchmark/scenarios/lib/create_subnet.py
@@ -7,13 +7,12 @@
# 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
+from yardstick.common import openstack_utils
+from yardstick.common import exceptions
+
LOG = logging.getLogger(__name__)
@@ -28,9 +27,23 @@ class CreateSubnet(base.Scenario):
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.network_name_or_id = self.options['network_name_or_id']
+ self.cidr = self.options.get('cidr')
+ self.ip_version = self.options.get('ip_version', 4)
+ self.enable_dhcp = self.options.get('enable_dhcp', False)
+ self.subnet_name = self.options.get('subnet_name')
+ self.tenant_id = self.options.get('tenant_id')
+ self.allocation_pools = self.options.get('allocation_pools')
+ self.gateway_ip = self.options.get('gateway_ip')
+ self.disable_gateway_ip = self.options.get('disable_gateway_ip', False)
+ self.dns_nameservers = self.options.get('dns_nameservers')
+ self.host_routes = self.options.get('host_routes')
+ self.ipv6_ra_mode = self.options.get('ipv6_ra_mode')
+ self.ipv6_address_mode = self.options.get('ipv6_address_mode')
+ self.use_default_subnetpool = self.options.get(
+ 'use_default_subnetpool', False)
+
+ self.shade_client = openstack_utils.get_shade_client()
self.setup_done = False
@@ -45,22 +58,23 @@ class CreateSubnet(base.Scenario):
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:
+ subnet_id = openstack_utils.create_neutron_subnet(
+ self.shade_client, self.network_name_or_id, cidr=self.cidr,
+ ip_version=self.ip_version, enable_dhcp=self.enable_dhcp,
+ subnet_name=self.subnet_name, tenant_id=self.tenant_id,
+ allocation_pools=self.allocation_pools, gateway_ip=self.gateway_ip,
+ disable_gateway_ip=self.disable_gateway_ip,
+ dns_nameservers=self.dns_nameservers, host_routes=self.host_routes,
+ ipv6_ra_mode=self.ipv6_ra_mode,
+ ipv6_address_mode=self.ipv6_address_mode,
+ use_default_subnetpool=self.use_default_subnetpool)
+ if not subnet_id:
result.update({"subnet_create": 0})
LOG.error("Create subnet failed!")
+ raise exceptions.ScenarioCreateSubnetError
- 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)
+ result.update({"subnet_create": 1})
+ LOG.info("Create subnet successful!")
+ keys = self.scenario_cfg.get('output', '').split()
+ values = [subnet_id]
+ return self._push_to_outputs(keys, values)