From 9420df764be2f02b3e8002de23566d4d442530ee Mon Sep 17 00:00:00 2001 From: Yang Li Date: Thu, 20 Dec 2018 10:16:23 +0800 Subject: [PATCH] Set public network which can be access by all tenants The current logic to set public network is get the first public network from neutronclien, but this network could only be seen by only one tenant for rbac policy, this will cause testcase fail. Now modify the logic, get the public network which can be seen by all tenants. Also if there is no rbac policy, we still use the first public network. Closes-Bug: #1809111 Change-Id: I565ec563abc0ffe22643d88e79f64c6980f2ca21 Signed-off-by: Yang Li --- rally_openstack/verification/tempest/config.py | 11 +++++++++++ tests/unit/verification/tempest/test_config.py | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/rally_openstack/verification/tempest/config.py b/rally_openstack/verification/tempest/config.py index 7c9016fc..62f79759 100644 --- a/rally_openstack/verification/tempest/config.py +++ b/rally_openstack/verification/tempest/config.py @@ -152,8 +152,19 @@ class TempestConfigfileManager(object): if net["status"] == "ACTIVE" and net["router:external"] is True ] if public_nets: + rbac_list = neutronclient.list_rbac_policies()["rbac_policies"] + rbac_all_list = [] + for rbac in rbac_list: + if rbac["target_tenant"] == "*" and \ + rbac["object_type"] == "network": + rbac_all_list.append(rbac["object_id"]) net_id = public_nets[0]["id"] net_name = public_nets[0]["name"] + for public_net in public_nets: + if public_net["id"] in rbac_all_list: + net_id = public_net["id"] + net_name = public_net["name"] + break self.conf.set(section_name, "public_network_id", net_id) self.conf.set(section_name, "floating_network_name", net_name) else: diff --git a/tests/unit/verification/tempest/test_config.py b/tests/unit/verification/tempest/test_config.py index 9c0c2dda..bc08e3c8 100644 --- a/tests/unit/verification/tempest/test_config.py +++ b/tests/unit/verification/tempest/test_config.py @@ -158,6 +158,17 @@ class TempestConfigfileManagerTestCase(test.TestCase): def test__configure_network_if_neutron(self): self.tempest.available_services = ["neutron"] client = self.tempest.clients.neutron() + client.list_rbac_policies.return_value = { + "rbac_policies": [ + { + "target_tenant": "*", + "object_type": "network", + "object_id": "test_id", + "action": "access_as_shared", + "id": "test_id" + } + ] + } client.list_networks.return_value = { "networks": [ {