Skip to content
Snippets Groups Projects
Commit 8f9da6e0 authored by Erik Reid's avatar Erik Reid
Browse files

remove some commented code, updated some docstrings

parent 97831d60
No related branches found
No related tags found
No related merge requests found
......@@ -109,30 +109,6 @@ UNIT_SCHEMA = """<?xml version="1.1" encoding="UTF-8" ?>
</xs:schema>
""" # noqa: E501
# PEERING_LIST_SCHEMA = {
# "$schema": "http://json-schema.org/draft-07/schema#",
# "definitions": {
# "peering": {
# "type": "object",
# "properties": {
# "group": {"type": "string"},
# "description": {"type": "string"},
# "address": {"type": "string"},
# "remote-asn": {"type": "integer"},
# "local-asn": {"type": "integer"},
# "instance": {"type": "string"},
# "logical-system": {"type": "string"},
# "hostname": {"type": "string"}
# },
# # lots of internal peerings - so maybe no explicit asn's
# "required": ["group", "address", "hostname"],
# "additionalProperties": False
# }
# },
# "type": "array",
# "items": {"$ref": "#/definitions/peering"}
# }
class NetconfHandlingError(Exception):
pass
......@@ -294,6 +270,20 @@ def _system_bgp_peers(system_node):
def all_bgp_peers(netconf_config):
"""
Return all active bgp peering sessions defined for this router.
The response will be a generator, which renders a list
formatted according to the following schema:
.. asjson::
inventory_provider.routes.msr.PEERING_LIST_SCHEMA
EXCEPT: the 'hostname' parameter is not present
:param netconf_config:
:return: yields active peering sessions
"""
for base_system in netconf_config.xpath('//configuration'):
# there should only be one
......@@ -309,7 +299,8 @@ def all_bgp_peers(netconf_config):
def interface_addresses(netconf_config):
"""
yields a list of all distinct interface addresses
Yields a list of all distinct interface addresses.
:param netconf_config:
:return:
"""
......@@ -324,7 +315,7 @@ def interface_addresses(netconf_config):
def load_routers_from_netdash(url):
"""
query url for a linefeed-delmitted list of managed router hostnames
Query url for a linefeed-delimitted list of managed router hostnames.
:param url: url of alldevices.txt file
:return: list of router hostnames
......@@ -341,8 +332,10 @@ def local_interfaces(
omit_link_local=True,
omit_loopback=True):
"""
generator yielding IPv4Interface or IPv6Interface objects,
depending on the value of type
Generator yielding IPv4Interface or IPv6Interface objects for
the interfaces present on the local system,
depending on the value of type.
:param type: hopefully AF_INET or AF_INET6
:param omit_link_local: skip v6 fe80* addresses if true
:param omit_loopback: skip lo* interfaces if true
......@@ -378,11 +371,12 @@ def snmp_community_string(netconf_config):
def netconf_changed_timestamp(netconf_config):
'''
return the last change timestamp published by the config document
"""
Return the last change timestamp published by the config document.
:param netconf_config: netconf lxml etree document
:return: an epoch timestamp (integer number of seconds) or None
'''
"""
for ts in netconf_config.xpath('/configuration/@changed-seconds'):
if re.match(r'^\d+$', ts):
return int(ts)
......
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