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 <yang.li@easystack.cn>
This commit is contained in:
Yang Li
2018-12-20 10:16:23 +08:00
committed by Ivan Anfimov
parent 791d789ec2
commit 9420df764b
2 changed files with 22 additions and 0 deletions

View File

@@ -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:

View File

@@ -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": [
{