diff --git a/rally-jobs/rally-neutron.yaml b/rally-jobs/rally-neutron.yaml index 73d8b4c2..63185702 100644 --- a/rally-jobs/rally-neutron.yaml +++ b/rally-jobs/rally-neutron.yaml @@ -657,6 +657,8 @@ dns_nameservers: - "8.8.8.8" - "8.8.4.4" + router: + external: false sla: failure_rate: max: 0 diff --git a/rally/plugins/openstack/context/network/networks.py b/rally/plugins/openstack/context/network/networks.py index 26b572cc..33d81c44 100644 --- a/rally/plugins/openstack/context/network/networks.py +++ b/rally/plugins/openstack/context/network/networks.py @@ -59,6 +59,24 @@ class Network(context.Context): "type": "array", "items": {"type": "string"}, "uniqueItems": True + }, + "router": { + "type": "object", + "properties": { + "external": { + "type": "boolean" + }, + "external_gateway_info": { + "description": "The external gateway information .", + "type": "object", + "properties": { + "network_id": {"type": "string"}, + "enable_snat": {"type": "boolean"} + }, + "additionalProperties": False + } + }, + "additionalProperties": False } }, "additionalProperties": False @@ -69,7 +87,8 @@ class Network(context.Context): "networks_per_tenant": 1, "subnets_per_network": 1, "network_create_args": {}, - "dns_nameservers": None + "dns_nameservers": None, + "router": {"external": True} } def setup(self): @@ -92,9 +111,9 @@ class Network(context.Context): network_create_args = self.config["network_create_args"].copy() network = net_wrapper.create_network( tenant_id, - add_router=True, subnets_num=self.config["subnets_per_network"], network_create_args=network_create_args, + router_create_args=self.config["router"], **kwargs) self.context["tenants"][tenant_id]["networks"].append(network) diff --git a/rally/plugins/openstack/wrappers/network.py b/rally/plugins/openstack/wrappers/network.py index 6301bc28..aa11c2c5 100644 --- a/rally/plugins/openstack/wrappers/network.py +++ b/rally/plugins/openstack/wrappers/network.py @@ -194,12 +194,14 @@ class NeutronWrapper(NetworkWrapper): The following keyword arguments are accepted: - * add_router: Create an external router and add an interface to each + * add_router: Deprecated, please use router_create_args instead. + Create an external router and add an interface to each subnet created. Default: False * subnets_num: Number of subnets to create per network. Default: 0 * dns_nameservers: Nameservers for each subnet. Default: 8.8.8.8, 8.8.4.4 * network_create_args: Additional network creation arguments. + * router_create_args: Additional router creation arguments. :param tenant_id: str, tenant ID :param kwargs: Additional options, left open-ended for compatbilitiy. @@ -213,8 +215,13 @@ class NeutronWrapper(NetworkWrapper): network = self.client.create_network(network_args)["network"] router = None - if kwargs.get("add_router", False): - router = self.create_router(external=True, tenant_id=tenant_id) + router_args = dict(kwargs.get("router_create_args", {})) + add_router = kwargs.get("add_router", False) + if router_args or add_router: + router_args["external"] = ( + router_args.get("external", False) or add_router) + router_args["tenant_id"] = tenant_id + router = self.create_router(**router_args) subnets = [] subnets_num = kwargs.get("subnets_num", 0) diff --git a/samples/tasks/contexts/network.json b/samples/tasks/contexts/network.json index a28e719a..5958b59f 100644 --- a/samples/tasks/contexts/network.json +++ b/samples/tasks/contexts/network.json @@ -36,7 +36,10 @@ "networks_per_tenant": 1, "subnets_per_network": 1, "network_create_args": {}, - "dns_nameservers": ["10.2.0.1"] + "dns_nameservers": ["10.2.0.1"], + "router": { + "external": false + } } } } diff --git a/samples/tasks/contexts/network.yaml b/samples/tasks/contexts/network.yaml index 60c8f67e..53c9de6b 100644 --- a/samples/tasks/contexts/network.yaml +++ b/samples/tasks/contexts/network.yaml @@ -29,4 +29,6 @@ subnets_per_network: 1 network_create_args: {} dns_nameservers: - - "10.2.0.1" \ No newline at end of file + - "10.2.0.1" + router: + external: false \ No newline at end of file diff --git a/tests/unit/plugins/openstack/context/network/test_network.py b/tests/unit/plugins/openstack/context/network/test_network.py index b87fab66..93020939 100644 --- a/tests/unit/plugins/openstack/context/network/test_network.py +++ b/tests/unit/plugins/openstack/context/network/test_network.py @@ -86,8 +86,9 @@ class NetworkTestCase(test.TestCase): dns_kwargs["dns_nameservers"] = tuple( dns_kwargs["dns_nameservers"]) create_calls = [ - mock.call(tenant, add_router=True, + mock.call(tenant, subnets_num=1, network_create_args={"fakearg": "fake"}, + router_create_args={"external": True}, **dns_kwargs) for user, tenant in mock_utils.iterate_per_tenants.return_value] mock_create.assert_has_calls(create_calls)