Use a common method for is a router interface
Tempest currently tries to figure out is port a router interface or not by the device_owner of the port. The logic in some places extended to be able to deal with dvr setups, but in another places it was missing. This change also adds support for L3-Ha support where the interface owner is network:ha_router_replicated_interface. By having common method it allows as to improve the logic just by change it only in one place. Change-Id: Ia83c8ad1bac9e44041b0661e26b7791a83087420
This commit is contained in:
@@ -20,6 +20,7 @@ import six
|
||||
|
||||
from tempest.api.network import base
|
||||
from tempest.common.utils import data_utils
|
||||
from tempest.common.utils import net_info
|
||||
from tempest import config
|
||||
from tempest.lib import exceptions as lib_exc
|
||||
from tempest import test
|
||||
@@ -66,7 +67,7 @@ class NetworksTestDHCPv6(base.BaseNetworkTest):
|
||||
body = self.ports_client.list_ports()
|
||||
ports = body['ports']
|
||||
for port in ports:
|
||||
if (port['device_owner'].startswith('network:router_interface') and
|
||||
if (net_info.is_router_interface_port(port) and
|
||||
port['device_id'] in [r['id'] for r in self.routers]):
|
||||
self.routers_client.remove_router_interface(port['device_id'],
|
||||
port_id=port['id'])
|
||||
|
||||
@@ -18,6 +18,7 @@ from oslo_log import log as logging
|
||||
|
||||
from tempest.common import credentials_factory as credentials
|
||||
from tempest.common import identity
|
||||
from tempest.common.utils import net_info
|
||||
from tempest import config
|
||||
from tempest import test
|
||||
|
||||
@@ -463,7 +464,7 @@ class NetworkRouterService(NetworkService):
|
||||
rid = router['id']
|
||||
ports = [port for port
|
||||
in ports_client.list_ports(device_id=rid)['ports']
|
||||
if port["device_owner"] == "network:router_interface"]
|
||||
if net_info.is_router_interface_port(port)]
|
||||
for port in ports:
|
||||
client.remove_router_interface(rid, port_id=port['id'])
|
||||
client.delete_router(rid)
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import re
|
||||
|
||||
RE_OWNER = re.compile('^network:.*router_.*interface.*')
|
||||
|
||||
|
||||
def _is_owner_router_interface(owner):
|
||||
return bool(RE_OWNER.match(owner))
|
||||
|
||||
|
||||
def is_router_interface_port(port):
|
||||
"""Based on the port attributes determines is it a router interface."""
|
||||
return _is_owner_router_interface(port['device_owner'])
|
||||
@@ -17,6 +17,7 @@ import testtools
|
||||
|
||||
from tempest import clients
|
||||
from tempest.common.utils import data_utils
|
||||
from tempest.common.utils import net_info
|
||||
from tempest import config
|
||||
from tempest.scenario import manager
|
||||
from tempest import test
|
||||
@@ -247,16 +248,10 @@ class TestSecurityGroupsBasicOps(manager.NetworkScenarioTest):
|
||||
myport = (tenant.router['id'], tenant.subnet['id'])
|
||||
router_ports = [(i['device_id'], i['fixed_ips'][0]['subnet_id']) for i
|
||||
in self._list_ports()
|
||||
if self._is_router_port(i)]
|
||||
if net_info.is_router_interface_port(i)]
|
||||
|
||||
self.assertIn(myport, router_ports)
|
||||
|
||||
def _is_router_port(self, port):
|
||||
"""Return True if port is a router interface."""
|
||||
# NOTE(armando-migliaccio): match device owner for both centralized
|
||||
# and distributed routers; 'device_owner' is "" by default.
|
||||
return port['device_owner'].startswith('network:router_interface')
|
||||
|
||||
def _create_server(self, name, tenant, security_groups, **kwargs):
|
||||
"""Creates a server and assigns it to security group.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user