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

use juniper logging

parent 719fb747
No related branches found
No related tags found
No related merge requests found
...@@ -3,6 +3,8 @@ import logging ...@@ -3,6 +3,8 @@ import logging
from jnpr.junos import Device from jnpr.junos import Device
from lxml import etree from lxml import etree
from inventory_provider.constants import JUNIPER_LOGGER_NAME
CONFIG_SCHEMA = """<?xml version="1.1" encoding="UTF-8" ?> CONFIG_SCHEMA = """<?xml version="1.1" encoding="UTF-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
...@@ -108,13 +110,16 @@ def load_config(hostname, ssh_params): ...@@ -108,13 +110,16 @@ def load_config(hostname, ssh_params):
:param ssh_params: 'ssh' config element(cf. config.py:CONFIG_SCHEMA) :param ssh_params: 'ssh' config element(cf. config.py:CONFIG_SCHEMA)
:return: :return:
""" """
juniper_logger = logging.getLogger(JUNIPER_LOGGER_NAME)
config = _rpc(hostname, ssh_params).get_config() config = _rpc(hostname, ssh_params).get_config()
juniper_logger.info("capturing netconf data for '%s'" % hostname)
def _validate(schema, doc): def _validate(schema, doc):
if schema.validate(doc): if schema.validate(doc):
return return
for e in schema.error_log: 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 assert False
schema_doc = etree.XML(CONFIG_SCHEMA.encode('utf-8')) schema_doc = etree.XML(CONFIG_SCHEMA.encode('utf-8'))
...@@ -178,3 +183,18 @@ def list_bgp_routes(netconf_config): ...@@ -178,3 +183,18 @@ def list_bgp_routes(netconf_config):
'peer': int(peer_as.text) '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 {}
#
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