From f7eaef9bd786853a354db86a02ef1a6ac3f002a8 Mon Sep 17 00:00:00 2001 From: Sebastian Lohff Date: Mon, 14 Oct 2024 16:35:19 +0200 Subject: [PATCH] Remove support for BDI/hyperloop cable Before we had BD-VIF/bridge support on our routes we needed to have a hyperloop cable (traversing two port channels, using up like two thirds of our router ports). Now that all of this is long behind us we can also remove the compatibility code for switching back to BDI. This means we remove the PortChannels LoopbackExternalInterface and LoopbackInternalInterface and also switch-over support by removing the bd_iftype (tied to an asr1k context), the use_bdvif flag (both on a context and in the oslo config part of the driver) and the force_bdi flag (used to fetch BDIs on a router already on BD-VIFs so we can still remove them). VBInterface was renamed to BDInterface, same goes for the related classes VBPrimaryIpAddress, VBSecondaryIpAddress and VBInterfaceStats. For migrating the code I updated all conditionals in a way as if bd_iftype is always BD-VIF and use_bdvif is always True. --- asr1k_neutron_l3/common/config.py | 1 - asr1k_neutron_l3/models/asr1k_pair.py | 20 +---- .../models/netconf_yang/l2_interface.py | 81 +++-------------- .../models/netconf_yang/l3_interface.py | 88 ++++++------------- .../models/netconf_yang/l3_interface_state.py | 14 +-- asr1k_neutron_l3/models/netconf_yang/nat.py | 2 +- asr1k_neutron_l3/models/netconf_yang/vrf.py | 22 ++--- .../models/neutron/l2/bridgedomain.py | 18 +--- .../models/neutron/l3/interface.py | 30 +++---- .../plugins/l3/agents/device_cleaner.py | 9 +- 10 files changed, 77 insertions(+), 208 deletions(-) diff --git a/asr1k_neutron_l3/common/config.py b/asr1k_neutron_l3/common/config.py index 6d727a70..36505909 100644 --- a/asr1k_neutron_l3/common/config.py +++ b/asr1k_neutron_l3/common/config.py @@ -30,7 +30,6 @@ cfg.IntOpt('nc_timeout', default=5, help='Netconf-YANG timeout, default 5s'), cfg.StrOpt('user_name', default='admin', help='Netconf-YANG User'), cfg.StrOpt('password', default='secret', help='Netconf-YANG Password'), - cfg.BoolOpt('use_bdvif', default=True, help='Use BD-VIF when supported by device firmware'), ] ASR1K_OPTS = [ diff --git a/asr1k_neutron_l3/models/asr1k_pair.py b/asr1k_neutron_l3/models/asr1k_pair.py index b10d517e..5eae2651 100644 --- a/asr1k_neutron_l3/models/asr1k_pair.py +++ b/asr1k_neutron_l3/models/asr1k_pair.py @@ -27,13 +27,7 @@ class ASR1KContextBase(object): - @property - def use_bdvif(self): - return True - - @property - def bd_iftype(self): - return "BD-VIF" if self.use_bdvif else "BDI" + pass class FakeASR1KContext(ASR1KContextBase): @@ -60,17 +54,15 @@ class ASR1KContext(ASR1KContextBase): version_min_17_15 = property(lambda self: self._get_version_attr('_version_min_17_15')) has_stateless_nat = property(lambda self: self._get_version_attr('_has_stateless_nat')) - def __init__(self, name, host, yang_port, nc_timeout, username, password, use_bdvif, insecure=True, - force_bdi=False, headers={}): + def __init__(self, name, host, yang_port, nc_timeout, username, password, insecure=True, + headers={}): self.name = name self.host = host self.yang_port = yang_port self.nc_timeout = nc_timeout self.username = username self.password = password - self._use_bdvif = use_bdvif self.insecure = insecure - self.force_bdi = force_bdi self.headers = headers self.headers['content-type'] = headers.get('content-type', "application/yang-data+json") self.headers['accept'] = headers.get('accept', "application/yang-data+json") @@ -129,10 +121,6 @@ def wait_alive(self): time.sleep(1) return False - @property - def use_bdvif(self): - return self._use_bdvif and not self.force_bdi - def mark_alive(self, alive): if not alive: LOG.debug("Device %s marked as dead, resetting version info", self.host) @@ -158,7 +146,7 @@ def __setup(self): for device_name, config in device_config.items(): asr1kctx = ASR1KContext(device_name, config.host, config.yang_port, config.nc_timeout, - config.user_name, config.password, config.use_bdvif, + config.user_name, config.password, insecure=True) self.contexts.append(asr1kctx) diff --git a/asr1k_neutron_l3/models/netconf_yang/l2_interface.py b/asr1k_neutron_l3/models/netconf_yang/l2_interface.py index 05335b3c..2e323f10 100644 --- a/asr1k_neutron_l3/models/netconf_yang/l2_interface.py +++ b/asr1k_neutron_l3/models/netconf_yang/l2_interface.py @@ -18,7 +18,6 @@ from collections import OrderedDict from oslo_log import log as logging -from asr1k_neutron_l3.common import utils from asr1k_neutron_l3.models.netconf_yang.ny_base import NC_OPERATION, NyBase, execute_on_pair from asr1k_neutron_l3.models.netconf_yang import xml_utils from asr1k_neutron_l3.plugins.db import asr1k_db @@ -163,22 +162,20 @@ def to_dict(self, context): bddef = OrderedDict() bddef[xml_utils.NS] = xml_utils.NS_CISCO_BRIDGE_DOMAIN bddef[L2Constants.BRIDGE_DOMAIN_ID] = self.id - - if context.use_bdvif: - bddef[L2Constants.MEMBER] = { - L2Constants.MEMBER_IFACE: [_m.to_dict(context) - for _m in sorted(self.if_members, - key=lambda _x: _x.interface)], - L2Constants.MEMBER_BDVIF: [_m.to_dict(context) - for _m in sorted(self.bdvif_members, key=attrgetter('name'))], - } - if self.has_complete_member_config: - bddef[L2Constants.MEMBER][xml_utils.OPERATION] = NC_OPERATION.PUT + bddef[L2Constants.MEMBER] = { + L2Constants.MEMBER_IFACE: [_m.to_dict(context) + for _m in sorted(self.if_members, + key=lambda _x: _x.interface)], + L2Constants.MEMBER_BDVIF: [_m.to_dict(context) + for _m in sorted(self.bdvif_members, key=attrgetter('name'))], + } + if self.has_complete_member_config: + bddef[L2Constants.MEMBER][xml_utils.OPERATION] = NC_OPERATION.PUT return {L2Constants.BRIDGE_DOMAIN_BRIDGE_ID: bddef} def _diff(self, context, device_config): - if context.use_bdvif and device_config and not self.has_complete_member_config: + if device_config and not self.has_complete_member_config: # we don't know all bd-vif members - the diff should represent if # the bd-vifs we know about are configured neutron_bdvif_names = [_m.name for _m in self.bdvif_members] @@ -394,8 +391,6 @@ def to_dict(self, context): instance[L2Constants.ENCAPSULATION] = OrderedDict() instance[L2Constants.ENCAPSULATION][L2Constants.DOT1Q] = dot1q instance[L2Constants.REWRITE] = rewrite - if not context.use_bdvif: - instance[L2Constants.BRIDGE_DOMAIN] = bridge_domain result = OrderedDict() result[L2Constants.SERVICE_INSTANCE] = instance @@ -430,61 +425,9 @@ def is_orphan(self, all_segmentation_ids, *args, **kwargs): int(self.id) not in all_segmentation_ids -class LoopbackExternalInterface(ServiceInstance): - PORT_CHANNEL = "2" - - def __init__(self, **kwargs): - kwargs['bridge_domain'] = kwargs.get('dot1q') - kwargs['dot1q'] = kwargs.get('dot1q') - super(LoopbackExternalInterface, self).__init__(**kwargs) - - def to_dict(self, context): - if context.use_bdvif: - return {} - else: - return super(LoopbackExternalInterface, self).to_dict(context) - - def is_orphan(self, all_segmentation_ids, all_bd_ids, context, *args, **kwargs): - # KeepBDUpInterface is included here, as they share a port-channel - return not context.use_bdvif and \ - (utils.to_bridge_domain(asr1k_db.MIN_SECOND_DOT1Q) <= int(self.id) <= - utils.to_bridge_domain(asr1k_db.MAX_SECOND_DOT1Q) and - int(self.id) not in all_bd_ids) or \ - context.use_bdvif and \ - (asr1k_db.MIN_DOT1Q <= int(self.id) <= asr1k_db.MAX_DOT1Q and - int(self.id) not in all_segmentation_ids) - - -class LoopbackInternalInterface(ServiceInstance): - PORT_CHANNEL = "3" - - def __init__(self, **kwargs): - super(LoopbackInternalInterface, self).__init__(**kwargs) - - def to_dict(self, context): - if context.use_bdvif: - return {} - else: - return super(LoopbackInternalInterface, self).to_dict(context) - - def is_orphan(self, all_bd_ids, context, *args, **kwargs): - return context.use_bdvif or \ - (utils.to_bridge_domain(asr1k_db.MIN_SECOND_DOT1Q) <= int(self.id) <= - utils.to_bridge_domain(asr1k_db.MAX_SECOND_DOT1Q) and - int(self.id) not in all_bd_ids) - - class KeepBDUpInterface(ServiceInstance): PORT_CHANNEL = "2" - def __init__(self, **kwargs): - super(KeepBDUpInterface, self).__init__(**kwargs) - - def to_dict(self, context): - if context.use_bdvif: - return super(KeepBDUpInterface, self).to_dict(context) - else: - return {} - def is_orphan(self, all_router_ids, all_segmentation_ids, all_bd_ids, context, *args, **kwargs): - raise NotImplementedError("This class' orphan check is handled by LoopbackExternalInterface") + return (asr1k_db.MIN_DOT1Q <= int(self.id) <= asr1k_db.MAX_DOT1Q and + int(self.id) not in all_segmentation_ids) diff --git a/asr1k_neutron_l3/models/netconf_yang/l3_interface.py b/asr1k_neutron_l3/models/netconf_yang/l3_interface.py index a4463b72..f03eae7c 100644 --- a/asr1k_neutron_l3/models/netconf_yang/l3_interface.py +++ b/asr1k_neutron_l3/models/netconf_yang/l3_interface.py @@ -14,7 +14,6 @@ # License for the specific language governing permissions and limitations # under the License. from collections import OrderedDict -import copy from asr1k_neutron_l3.models.netconf_yang.l2_interface import BridgeDomain from asr1k_neutron_l3.models.netconf_yang.ny_base import NyBase, execute_on_pair, YANG_TYPE, NC_OPERATION @@ -71,13 +70,13 @@ class L3Constants(object): TIMEOUT = "timeout" -class VBInterface(NyBase): +class BDInterface(NyBase): ID_FILTER = """ - <{iftype}> + {id} - + """ @@ -85,12 +84,12 @@ class VBInterface(NyBase): GET_ALL_STUB = """ - <{iftype}> + - + """ @@ -98,38 +97,22 @@ class VBInterface(NyBase): VRF_FILTER = """ - <{iftype}> + {vrf} - + """ - VRF_XPATH_FILTER = "/native/interface/{iftype}/vrf[forwarding='{vrf}']" + VRF_XPATH_FILTER = "/native/interface/BD-VIF/vrf[forwarding='{vrf}']" LIST_KEY = L3Constants.INTERFACE + ITEM_KEY = L3Constants.BDVIF_INTERFACE MIN_MTU = 1500 MAX_MTU = 9216 - @classmethod - def get_item_key(cls, context): - return context.bd_iftype - - @classmethod - def get_primary_filter(cls, id, context, **kwargs): - return cls.ID_FILTER.format(id=id, iftype=context.bd_iftype) - - @classmethod - def get_all_stub_filter(cls, context): - return cls.GET_ALL_STUB.format(iftype=context.bd_iftype) - - @classmethod - def get_for_vrf(cls, context, vrf=None): - return cls._get_all(context=context, xpath_filter=cls.VRF_XPATH_FILTER.format(vrf=vrf, - iftype=context.bd_iftype)) - @classmethod def __parameters__(cls): # secondary IPs will be validated in NAT @@ -138,11 +121,11 @@ def __parameters__(cls): {"key": "name", "id": True}, {'key': 'description'}, {'key': 'mac_address'}, - {'key': 'mtu', 'default': VBInterface.MIN_MTU}, + {'key': 'mtu', 'default': BDInterface.MIN_MTU}, {'key': 'vrf', 'yang-path': 'vrf', 'yang-key': "forwarding"}, - {'key': 'ip_address', 'yang-path': 'ip/address', 'yang-key': "primary", 'type': VBIPrimaryIpAddress}, + {'key': 'ip_address', 'yang-path': 'ip/address', 'yang-key': "primary", 'type': BDPrimaryIpAddress}, {'key': 'secondary_ip_addresses', 'yang-path': 'ip/address', 'yang-key': "secondary", - 'type': [VBISecondaryIpAddress], 'default': [], 'validate':False}, + 'type': [BDSecondaryIpAddress], 'default': [], 'validate':False}, {'key': 'nat_inside', 'yang-key': 'inside', 'yang-path': 'ip/nat', 'default': False, 'yang-type': YANG_TYPE.EMPTY}, {'key': 'nat_outside', 'yang-key': 'outside', 'yang-path': 'ip/nat', 'default': False, @@ -163,7 +146,7 @@ def __parameters__(cls): ] def __init__(self, **kwargs): - super(VBInterface, self).__init__(**kwargs) + super().__init__(**kwargs) if int(self.mtu) < self.MIN_MTU: self.mtu = str(self.MIN_MTU) if int(self.mtu) > self.MAX_MTU: @@ -174,21 +157,6 @@ def neutron_router_id(self): if self.vrf: return utils.vrf_id_to_uuid(self.vrf) - def preflight(self, context): - """Remove BDI with same name when BD-VIF is in use (migration code)""" - if not context.use_bdvif: - return - - # XXX: to get the BDI we need to act like this context does - # this should be removed after we're done with the migration - nobdvif_context = copy.copy(context) - nobdvif_context.force_bdi = True - - bdi = self._internal_get(context=nobdvif_context) - if bdi: - LOG.debug("Removing BDI%s from %s before adding new BD-VIF%s", bdi.name, context.host, self.name) - bdi._delete(context=nobdvif_context, postflight=False) # disable postflight checks - def to_dict(self, context): vbi = OrderedDict() vbi[L3Constants.NAME] = self.name @@ -287,7 +255,7 @@ def to_dict(self, context): vbi[L3Constants.ARP] = {L3Constants.TIMEOUT: {xml_utils.OPERATION: NC_OPERATION.REMOVE}} result = OrderedDict() - result[context.bd_iftype] = vbi + result[L3Constants.BDVIF_INTERFACE] = vbi return dict(result) @@ -302,7 +270,7 @@ def to_delete_dict(self, context, existing=None): vbi[L3Constants.IP] = ip result = OrderedDict() - result[context.bd_iftype] = vbi + result[L3Constants.BDVIF_INTERFACE] = vbi return dict(result) @@ -362,14 +330,14 @@ def is_reassigned(self, queried): return self.vrf != queried.vrf -class VBISecondaryIpAddress(NyBase): +class BDSecondaryIpAddress(NyBase): ITEM_KEY = L3Constants.SECONDARY LIST_KEY = L3Constants.ADDRESS ID_FILTER = """ - <{iftype}> + {bridge_domain}
@@ -378,7 +346,7 @@ class VBISecondaryIpAddress(NyBase):
- +
""" @@ -395,11 +363,11 @@ def __parameters__(cls): @classmethod def remove_wrapper(cls, dict, context): - dict = super(VBISecondaryIpAddress, cls)._remove_base_wrapper(dict, context) + dict = cls._remove_base_wrapper(dict, context) if dict is None: return dict = dict.get(L3Constants.INTERFACE, dict) - dict = dict.get(context.bd_iftype, dict) + dict = dict.get(L3Constants.BDVIF_INTERFACE, dict) dict = dict.get(L3Constants.IP, dict) dict = dict.get(cls.LIST_KEY, None) return dict @@ -410,26 +378,22 @@ def _wrapper_preamble(self, dict, context): a = OrderedDict() a[L3Constants.NAME] = self.bridge_domain a[L3Constants.IP] = result - result = OrderedDict({context.bd_iftype: a}) + result = OrderedDict({L3Constants.BDVIF_INTERFACE: a}) result = OrderedDict({L3Constants.INTERFACE: result}) return result - @classmethod - def get_primary_filter(cls, id, bridge_domain, context, **kwargs): - return cls.ID_FILTER.format(id=id, iftype=context.bd_iftype, bridge_domain=bridge_domain) - @classmethod @execute_on_pair(return_raw=True) def get(cls, bridge_domain, id, context): - return super(VBISecondaryIpAddress, cls)._get(id=id, bridge_domain=bridge_domain, context=context) + return cls._get(id=id, bridge_domain=bridge_domain, context=context) @classmethod @execute_on_pair(return_raw=True) def exists(cls, bridge_domain, id, context): - return super(VBISecondaryIpAddress, cls)._exists(id=id, bridge_domain=bridge_domain, context=context) + return cls._exists(id=id, bridge_domain=bridge_domain, context=context) def __init__(self, **kwargs): - super(VBISecondaryIpAddress, self).__init__(**kwargs) + super().__init__(**kwargs) self.bridge_domain = kwargs.get('bridge_domain') def to_dict(self, context): @@ -443,7 +407,7 @@ def to_dict(self, context): return ip -class VBIPrimaryIpAddress(NyBase): +class BDPrimaryIpAddress(NyBase): ITEM_KEY = L3Constants.PRIMARY LIST_KEY = L3Constants.ADDRESS @@ -455,7 +419,7 @@ def __parameters__(cls): ] def __init__(self, **kwargs): - super(VBIPrimaryIpAddress, self).__init__(**kwargs) + super().__init__(**kwargs) self.bridge_domain = kwargs.get('bridge_domain') def to_dict(self, context): diff --git a/asr1k_neutron_l3/models/netconf_yang/l3_interface_state.py b/asr1k_neutron_l3/models/netconf_yang/l3_interface_state.py index 5cd0d539..a80f4f0e 100644 --- a/asr1k_neutron_l3/models/netconf_yang/l3_interface_state.py +++ b/asr1k_neutron_l3/models/netconf_yang/l3_interface_state.py @@ -1,12 +1,12 @@ -from asr1k_neutron_l3.models.netconf_yang.ny_base import NyBase, execute_on_pair +from asr1k_neutron_l3.models.netconf_yang.ny_base import NyBase from asr1k_neutron_l3.models.netconf_yang import xml_utils -class VBInterfaceState(NyBase): +class BDInterfaceState(NyBase): ID_FILTER = """ - {iftype}{id} + BD-VIF{id} """ @@ -39,14 +39,6 @@ def __parameters__(cls): {'key': 'out_errors', 'yang-key': 'out-errors', 'yang-path': 'statistics'}, ] - def __init__(self, **kwargs): - super(VBInterfaceState, self).__init__(**kwargs) - - @classmethod - @execute_on_pair() - def get(cls, id=None, port_channel=None, context=None): - return cls._get(id=id, iftype=context.bd_iftype, context=context) - @classmethod def _remove_base_wrapper(cls, dict, context): dict = dict.get(xml_utils.RPC_REPLY, dict) diff --git a/asr1k_neutron_l3/models/netconf_yang/nat.py b/asr1k_neutron_l3/models/netconf_yang/nat.py index 6ca8149d..b7cfeab3 100644 --- a/asr1k_neutron_l3/models/netconf_yang/nat.py +++ b/asr1k_neutron_l3/models/netconf_yang/nat.py @@ -314,7 +314,7 @@ def __init__(self, **kwargs): self.redundancy = None def to_dict(self, context): - ifname = "{}{}".format(context.bd_iftype, self.bd) + ifname = f"BD-VIF{self.bd}" vrf = { NATConstants.NAME: self.vrf, } diff --git a/asr1k_neutron_l3/models/netconf_yang/vrf.py b/asr1k_neutron_l3/models/netconf_yang/vrf.py index 6f2d5a9b..d22829d5 100644 --- a/asr1k_neutron_l3/models/netconf_yang/vrf.py +++ b/asr1k_neutron_l3/models/netconf_yang/vrf.py @@ -23,7 +23,7 @@ from asr1k_neutron_l3.common import cli_snippets from asr1k_neutron_l3.common import utils from asr1k_neutron_l3.models.connection import ConnectionManager -from asr1k_neutron_l3.models.netconf_yang.l3_interface import VBInterface +from asr1k_neutron_l3.models.netconf_yang.l3_interface import BDInterface from asr1k_neutron_l3.models.netconf_yang.nat import InterfaceDynamicNat from asr1k_neutron_l3.models.netconf_yang.ny_base import NyBase, Requeable, NC_OPERATION, execute_on_pair, \ retry_on_failure @@ -245,20 +245,20 @@ def postflight(self, context, method): LOG.error("Failed to delete {} routes in VRF {} postlight : {}".format(len(routes), self.id, e)) LOG.debug("Processing Interfaces") - vbis = [] + bdifs = [] try: - vbis = VBInterface.get_for_vrf(context=context, vrf=self.id) - if len(vbis) == 0: + bdifs = BDInterface.get_for_vrf(context=context, vrf=self.id) + if len(bdifs) == 0: LOG.info("No interfaces to clean") - for vbi in vbis: - LOG.info("Deleting hanging interface {}{} in vrf {} postflight." - .format(context.bd_iftype, vbi.name, self.name)) - vbi._delete(context=context) - LOG.info("Deleted hanging interface {}{} in vrf {} postflight." - .format(context.bd_iftype, vbi.name, self.name)) + for bdif in bdifs: + LOG.info("Deleting hanging interface BD-VIF%s in vrf %s postflight.", + bdif.name, self.name) + bdif._delete(context=context) + LOG.info("Deleted hanging interface BD-VIF%s in vrf %s postflight.", + bdif.name, self.name) except BaseException as e: - LOG.error("Failed to delete {} intefaces in VRF {} postlight : {}".format(len(vbis), self.id, e)) + LOG.error("Failed to delete {} intefaces in VRF {} postlight : {}".format(len(bdifs), self.id, e)) LOG.debug("Processing Address Families") afs = [] diff --git a/asr1k_neutron_l3/models/neutron/l2/bridgedomain.py b/asr1k_neutron_l3/models/neutron/l2/bridgedomain.py index d3227b4d..1b4591eb 100644 --- a/asr1k_neutron_l3/models/neutron/l2/bridgedomain.py +++ b/asr1k_neutron_l3/models/neutron/l2/bridgedomain.py @@ -105,7 +105,7 @@ def __init__(self, bd_id, network_id, ports, has_complete_portset=True): .format(self.network_id) if self.network_id else None) - # process ports (16.9: build hyperloop, 17.3: build bdvif members) + # process ports (17.3+: build bdvif members) self.lb_ext_ifaces = [] self.lb_int_ifaces = [] self.if_members = [ @@ -121,22 +121,6 @@ def __init__(self, bd_id, network_id, ports, has_complete_portset=True): second_dot1q = port['second_dot1q'] int_service_instance = utils.to_bridge_domain(second_dot1q) - # only used for 16.9 - lb_ext_iface = l2_interface.LoopbackExternalInterface(id=int_service_instance, - description="Port : {}".format(port['port_id']), - dot1q=self.bd_id, - second_dot1q=second_dot1q, - way=2, mode="symmetric") - self.lb_ext_ifaces.append(lb_ext_iface) - lb_int_iface = l2_interface.LoopbackInternalInterface(id=int_service_instance, - description="Port : {}".format(port['port_id']), - bridge_domain=int_service_instance, - dot1q=self.bd_id, - second_dot1q=second_dot1q, - way=2, mode="symmetric") - self.lb_int_ifaces.append(lb_int_iface) - - # only used for 17.3 bdvif_member = l2_interface.BDVIFMember(name=int_service_instance) self.bdvif_members.append(bdvif_member) diff --git a/asr1k_neutron_l3/models/neutron/l3/interface.py b/asr1k_neutron_l3/models/neutron/l3/interface.py index 1e086e61..8c79f92c 100644 --- a/asr1k_neutron_l3/models/neutron/l3/interface.py +++ b/asr1k_neutron_l3/models/neutron/l3/interface.py @@ -20,8 +20,8 @@ from asr1k_neutron_l3.common import utils from asr1k_neutron_l3.models.neutron.l3 import base from asr1k_neutron_l3.models.neutron.l3.firewall import Zone -from asr1k_neutron_l3.models.netconf_yang.l3_interface import VBInterface, VBIPrimaryIpAddress, VBISecondaryIpAddress -from asr1k_neutron_l3.models.netconf_yang.l3_interface_state import VBInterfaceState +from asr1k_neutron_l3.models.netconf_yang.l3_interface import BDInterface, BDPrimaryIpAddress, BDSecondaryIpAddress +from asr1k_neutron_l3.models.netconf_yang.l3_interface_state import BDInterfaceState LOG = logging.getLogger(__name__) @@ -77,7 +77,7 @@ def __init__(self, router_id, router_port, extra_atts): self.address_scope = router_port.get('address_scopes', {}).get('4') def add_secondary_ip_address(self, ip_address, netmask): - self.secondary_ip_addresses.append(VBISecondaryIpAddress(address=ip_address, + self.secondary_ip_addresses.append(BDSecondaryIpAddress(address=ip_address, mask=utils.to_netmask(netmask))) def _ip_address(self): @@ -86,8 +86,8 @@ def _ip_address(self): self._primary_subnet_id = n_fixed_ip.get('subnet_id') - return VBIPrimaryIpAddress(address=n_fixed_ip.get('ip_address'), - mask=utils.to_netmask(n_fixed_ip.get('prefixlen'))) + return BDPrimaryIpAddress(address=n_fixed_ip.get('ip_address'), + mask=utils.to_netmask(n_fixed_ip.get('prefixlen'))) def _primary_subnet(self): for subnet in self.router_port.get('subnets', []): @@ -100,7 +100,7 @@ def subnets(self): return self.router_port.get('subnets', []) def get_state(self): - state = VBInterfaceState.get(id=self.bridge_domain) + state = BDInterfaceState.get(id=self.bridge_domain) result = {} if state is not None: @@ -109,18 +109,18 @@ def get_state(self): return result def get(self): - return VBInterface.get(self.bridge_domain) + return BDInterface.get(self.bridge_domain) def delete(self): - vbi = VBInterface(name=self.bridge_domain, vrf=self.vrf) + vbi = BDInterface(name=self.bridge_domain, vrf=self.vrf) return vbi.delete() def disable_nat(self): - vbi = VBInterface(name=self.bridge_domain) + vbi = BDInterface(name=self.bridge_domain) return vbi.disable_nat() def enable_nat(self): - vbi = VBInterface(name=self.bridge_domain) + vbi = BDInterface(name=self.bridge_domain) return vbi.enable_nat() @@ -152,7 +152,7 @@ def _rest_definition(self): interface_args['rii'] = self.bridge_domain interface_args['zone'] = Zone.get_id_by_vrf(self.vrf) - return VBInterface(**interface_args) + return BDInterface(**interface_args) def _ip_address(self): if self.dynamic_nat_pool is None or not self.router_port.get('fixed_ips'): @@ -172,8 +172,8 @@ def _ip_address(self): self._primary_subnet_id = n_fixed_ip.get('subnet_id') - return VBIPrimaryIpAddress(address=n_fixed_ip['ip_address'], - mask=utils.to_netmask(n_fixed_ip.get('prefixlen'))) + return BDPrimaryIpAddress(address=n_fixed_ip['ip_address'], + mask=utils.to_netmask(n_fixed_ip.get('prefixlen'))) def _nat_address(self): ips = self.router_port.get('fixed_ips') @@ -195,7 +195,7 @@ def __init__(self, router_id, router_port, extra_atts, ingress_acl=None, egress_ def _rest_definition(self): # annotate details about the router to the interface description so this can be picked up by SNMP description = (f'type:internal;project:{self.router_port["project_id"]};router:{self.router_id};' - f'network:{self.router_port["network_id"]};subnet:{self._primary_subnet_id}') + f'network:{self.router_port["network_id"]};subnet:{self._primary_subnet_id}') interface_args = dict(name=self.bridge_domain, description=description, mac_address=self.mac_address, mtu=self.mtu, vrf=self.vrf, @@ -212,7 +212,7 @@ def _rest_definition(self): interface_args['redundancy_group_decrement'] = 1 interface_args['rii'] = self.bridge_domain - return VBInterface(**interface_args) + return BDInterface(**interface_args) class OrphanedInterface(Interface): diff --git a/asr1k_neutron_l3/plugins/l3/agents/device_cleaner.py b/asr1k_neutron_l3/plugins/l3/agents/device_cleaner.py index ecd53065..48477a31 100644 --- a/asr1k_neutron_l3/plugins/l3/agents/device_cleaner.py +++ b/asr1k_neutron_l3/plugins/l3/agents/device_cleaner.py @@ -26,10 +26,9 @@ from asr1k_neutron_l3.models.asr1k_pair import ASR1KPair from asr1k_neutron_l3.models.netconf_yang.access_list import AccessList from asr1k_neutron_l3.models.netconf_yang.arp import VrfArpList -from asr1k_neutron_l3.models.netconf_yang.l2_interface import BridgeDomain, LoopbackInternalInterface, \ - LoopbackExternalInterface, ExternalInterface +from asr1k_neutron_l3.models.netconf_yang.l2_interface import BridgeDomain, ExternalInterface, KeepBDUpInterface from asr1k_neutron_l3.models.netconf_yang.class_map import ClassMap -from asr1k_neutron_l3.models.netconf_yang.l3_interface import VBInterface +from asr1k_neutron_l3.models.netconf_yang.l3_interface import BDInterface from asr1k_neutron_l3.models.netconf_yang.nat import StaticNat, NatPool, InterfaceDynamicNat, PoolDynamicNat from asr1k_neutron_l3.models.netconf_yang.parameter_map import ParameterMapInspectGlobalVrf from asr1k_neutron_l3.models.netconf_yang.prefix import Prefix @@ -57,9 +56,9 @@ def encode(self, obj): class DeviceCleanerMixin(object): ENTITIES = [ - BridgeDomain, LoopbackInternalInterface, LoopbackExternalInterface, ExternalInterface, + BridgeDomain, KeepBDUpInterface, ExternalInterface, StaticNat, PoolDynamicNat, InterfaceDynamicNat, NatPool, - VBInterface, + BDInterface, RouteMap, Prefix, AccessList, VrfArpList, VrfRoute, ZonePair, Zone, ParameterMapInspectGlobalVrf, VrfDefinition