Skip to content
Snippets Groups Projects
Commit 5dabe1ef authored by Robert Latta's avatar Robert Latta
Browse files

excluded pxc ports and related lags. RE DBOARD3-997

parent 8802988a
No related branches found
Tags 0.130
No related merge requests found
import ipaddress
import logging
import re
from functools import lru_cache
from lxml import etree
from ncclient import manager, xml_
......@@ -173,6 +174,19 @@ def get_interfaces_state(state_doc):
yield details
@lru_cache
def get_pxc_ports(netconf_config):
# these ports will be ignored for the purposes of the update
pxc_ports = set()
for port in netconf_config.findall('./configure/port-xc/pxc'):
pxc_ports.add(port.find('port-id').text)
for port in netconf_config.findall('./configure/port'):
port_id = port.find('port-id').text
if port_id.startswith('pxc'):
pxc_ports.add(port_id)
return pxc_ports
def get_ports_config(netconf_config):
def _port_info(e):
pi = {
......@@ -193,10 +207,14 @@ def get_ports_config(netconf_config):
breakout_match.group('unit'), 'Unknown')
return pi
pxc_ports = get_pxc_ports(netconf_config)
# making the assumption that the breakout ports are listed directly before their
current_parent_port = None
# child ports
for port in netconf_config.findall('./configure/port'):
port_id = port.find('port-id').text
if port_id in pxc_ports:
continue
port_info = _port_info(port)
if 'breakout' in port_info:
current_parent_port = port_info
......@@ -212,6 +230,7 @@ def get_lags_config(netconf_config):
enabled_ports = {
p['port-id'] for p in get_ports_config(netconf_config) if p['admin-state'] == 'enable'
}
pxc_ports = get_pxc_ports(netconf_config)
def _lag_info(e):
_name = e.find('./lag-name').text
......@@ -228,6 +247,9 @@ def get_lags_config(netconf_config):
return ifc
for lag in netconf_config.findall('./configure/lag'):
ports = {p.find('./port-id').text for p in lag.findall('./port')}
if pxc_ports > ports:
continue
yield _lag_info(lag)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment