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:
@@ -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:
|
||||
|
||||
@@ -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": [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user