diff --git a/inventory_provider/netconf.py b/inventory_provider/netconf.py index 9588dc571ad4747ef0bbb6bfef8ad51f6cf92018..58f9e76b9cdda9abeaf0f17b8b226ca84e2817d8 100644 --- a/inventory_provider/netconf.py +++ b/inventory_provider/netconf.py @@ -3,6 +3,8 @@ import logging from jnpr.junos import Device from lxml import etree +from inventory_provider.constants import JUNIPER_LOGGER_NAME + CONFIG_SCHEMA = """<?xml version="1.1" encoding="UTF-8" ?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> @@ -108,13 +110,16 @@ def load_config(hostname, ssh_params): :param ssh_params: 'ssh' config element(cf. config.py:CONFIG_SCHEMA) :return: """ + juniper_logger = logging.getLogger(JUNIPER_LOGGER_NAME) config = _rpc(hostname, ssh_params).get_config() + juniper_logger.info("capturing netconf data for '%s'" % hostname) + def _validate(schema, doc): if schema.validate(doc): return for e in schema.error_log: - logging.debug("%d.%d: %s" % (e.line, e.column, e.message)) + juniper_logger.error("%d.%d: %s" % (e.line, e.column, e.message)) assert False schema_doc = etree.XML(CONFIG_SCHEMA.encode('utf-8')) @@ -178,3 +183,18 @@ def list_bgp_routes(netconf_config): 'peer': int(peer_as.text) } } + +# note for enabling vrr data parsing ... +# def fetch_vrr_config(hostname, ssh_params): +# +# commands = [ +# _DISABLE_PAGING_COMMAND, +# ('show configuration logical-systems ' +# 'VRR protocols bgp | display json') +# ] +# +# output = list(ssh_exec_commands(hostname, ssh_params, commands)) +# assert len(output) == len(commands) +# +# return _loads(output[1]) if output[1] else {} +#