Skip to content
Snippets Groups Projects

Support ASN dot notation.

Merged Neda Moeini requested to merge feature/DBOARD3-719-support-extended-asn-notation into develop
All threads resolved!
2 files
+ 34
2
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -243,6 +243,23 @@ def list_interfaces(netconf_config):
yield u
def asn_to_int(asn_string: str) -> int:
"""
Convert a possibly dotted ASN to an integer.
Args:
asn_string (str): ASN to be converted, can be in dot notation or not.
Returns:
int: ASN in integer format.
"""
+1
if '.' in asn_string:
high_order, low_order = map(int, asn_string.split('.'))
return (high_order << 16) | low_order
else:
return int(asn_string)
def _system_bgp_peers(system_node):
def _peering_params(neighbor_node):
@@ -251,11 +268,11 @@ def _system_bgp_peers(system_node):
peer_as = neighbor_node.find('peer-as')
if peer_as is not None:
# lxml usage warning: can't just test `if peer_as:`
info['remote-asn'] = int(peer_as.text)
info['remote-asn'] = asn_to_int(peer_as.text)
local_as = neighbor_node.find('local-as')
if local_as is not None:
asn_value_node = local_as.find('as-number')
info['local-asn'] = int(asn_value_node.text)
info['local-asn'] = asn_to_int(asn_value_node.text)
description = neighbor_node.find('description')
if description is not None:
# lxml usage warning: can't just test `if description:`
Loading