Skip to content
Snippets Groups Projects

Add port_type parsing from description for BRIAN

Merged Bjarke Madsen requested to merge feature/POL1-643-poller-port-type into develop
1 unresolved thread
2 files
+ 38
10
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -120,10 +120,16 @@ class BRIAN_DASHBOARDS(Enum):
# NREN customer
NREN = auto()
class PORT_TYPES(Enum):
ACCESS = auto()
SERVICE = auto()
UNKNOWN = auto()
# only used in INTERFACE_LIST_SCHEMA and sphinx docs
_DASHBOARD_IDS = [d.name for d in list(BRIAN_DASHBOARDS)]
_PORT_TYPES = [t.name for t in list(PORT_TYPES)]
_INTERFACE_TYPES = [i.name for i in list(INTERFACE_TYPES)]
INTERFACE_LIST_SCHEMA = {
@@ -182,12 +188,13 @@ INTERFACE_LIST_SCHEMA = {
'dashboards_info': {
'type': 'array',
'items': {'$ref': '#/definitions/db_info'}
}
},
'port_type': {'enum': _PORT_TYPES}
},
'required': [
'router', 'name', 'description',
'snmp-index', 'bundle', 'bundle-parents',
'circuits', 'dashboards'],
'circuits', 'dashboards', 'port_type'],
'additionalProperties': False
},
},
@@ -498,13 +505,6 @@ def _get_dashboard_data(ifc, customers):
if len(dashboards) == 0:
return ifc
def _get_l2_customer_names(description):
info = description.upper().split('#')[0].split('|')[0].split()[1:]
yield info[1]
if info[0] in ['CUSTOMER', 'RE_INTERCONNECT'] \
and len(info) > 2 and info[2]:
yield info[2]
def _get_customer_name(description):
name = description.split(' ')
if len(name) >= 3:
@@ -720,6 +720,17 @@ def _add_bundle_parents(interfaces, hostname=None):
yield ifc
def _get_port_type(description):
rex = re.search(r'\$([a-zA-Z]+\-\d+)', description)
if rex:
sid = rex.group(1)
if 'GA' in sid:
return PORT_TYPES.ACCESS.name
elif 'GS' in sid:
return PORT_TYPES.SERVICE.name
return PORT_TYPES.UNKNOWN.name
def load_interfaces_to_poll(
config, hostname=None, no_lab=False, use_next_redis=False):
basic_interfaces = \
@@ -757,8 +768,12 @@ def load_interfaces_to_poll(
dashboards = _get_dashboards(ifc)
ifc['dashboards'] = sorted([d.name for d in dashboards])
yield _get_dashboard_data(
ifc = _get_dashboard_data(
ifc, ifc_services_and_customers.get('customers', []))
port_type = _get_port_type(ifc['description'])
ifc['port_type'] = port_type
yield ifc
else:
continue
return _get_populated_interfaces(basic_interfaces)
Loading