Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Descriptions for ACCESS_DOWNLINK type ports #189

Merged
merged 2 commits into from
Aug 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/cnaas_nms/confpush/init_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,14 +318,15 @@ def init_access_device_step1(device_id: int, new_hostname: str,
logger = get_logger()
with sqla_session() as session:
dev = pre_init_checks(session, device_id)
new_linknets = []

# update linknets using LLDP data
update_linknets(session, dev.hostname, DeviceType.ACCESS)
new_linknets += update_linknets(session, dev.hostname, DeviceType.ACCESS)

# If this is the first device in an MLAG pair
if mlag_peer_id and mlag_peer_new_hostname:
mlag_peer_dev = pre_init_checks(session, mlag_peer_id)
update_linknets(session, mlag_peer_dev.hostname, DeviceType.ACCESS)
new_linknets += update_linknets(session, mlag_peer_dev.hostname, DeviceType.ACCESS)
update_interfacedb_worker(session, dev, replace=True, delete_all=False,
mlag_peer_hostname=mlag_peer_dev.hostname)
update_interfacedb_worker(session, mlag_peer_dev, replace=True, delete_all=False,
Expand Down Expand Up @@ -397,6 +398,12 @@ def init_access_device_step1(device_id: int, new_hostname: str,
reserved_ip = session.query(ReservedIP).filter(ReservedIP.device == dev).one_or_none()
if reserved_ip:
session.delete(reserved_ip)
# Mark remote peers as unsynchronized so they can update interface descriptions
for linknet in new_linknets:
peer_hostname = linknet['device_b_hostname']
peer_dev: Device = session.query(Device).filter(Device.hostname == peer_hostname).one_or_none()
if peer_dev:
peer_dev.synchronized = False

# Plugin hook, allocated IP
try:
Expand Down
6 changes: 6 additions & 0 deletions src/cnaas_nms/confpush/sync_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ def populate_device_vars(session, dev: Device,
'interfaces': []
}

# Check peer names for populating description on ACCESS_DOWNLINK ports
ifname_peer_map = dev.get_linknet_localif_mapping(session)

intfs = session.query(Interface).filter(Interface.device == dev).all()
intf: Interface
for intf in intfs:
Expand All @@ -178,6 +181,9 @@ def populate_device_vars(session, dev: Device,
tagged_vlan_list = resolve_vlanid_list(intf.data['tagged_vlan_list'],
settings['vxlans'])
intfdata = dict(intf.data)
elif intf.name in ifname_peer_map:
intfdata = {'description': ifname_peer_map[intf.name]}

access_device_variables['interfaces'].append({
'name': intf.name,
'ifclass': intf.configtype.name,
Expand Down