Skip to content

Commit

Permalink
Remove support for BDI/hyperloop cable
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sebageek committed Oct 29, 2024
1 parent 318c98a commit dad545e
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 208 deletions.
1 change: 0 additions & 1 deletion asr1k_neutron_l3/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
20 changes: 4 additions & 16 deletions asr1k_neutron_l3/models/asr1k_pair.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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")
Expand Down Expand Up @@ -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)
Expand All @@ -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)
81 changes: 12 additions & 69 deletions asr1k_neutron_l3/models/netconf_yang/l2_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Loading

0 comments on commit dad545e

Please sign in to comment.