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

Merge branch 'develop' into feature/DBOARD3-384-flatten-bgp-peer-handling

parents 3cbdad8d 1a61e7ca
Branches
Tags
No related merge requests found
......@@ -2,6 +2,12 @@
All notable changes to this project will be documented in this file.
## [0.58] - 2021-01-23
- DBOARD3-385: use cached netconf data in case of schema validation errors
## [0.57] - 2021-01-23
- DBOARD3-380: added snmp info to peer-info responses
## [0.56] - 2021-01-08
- DBOARD3-372: added snmp indexes to juniper-link-info responses
......
......@@ -108,6 +108,10 @@ UNIT_SCHEMA = """<?xml version="1.1" encoding="UTF-8" ?>
""" # noqa: E501
class NetconfHandlingError(Exception):
pass
def _rpc(hostname, ssh):
dev = Device(
host=hostname,
......@@ -121,14 +125,22 @@ def _rpc(hostname, ssh):
def validate_netconf_config(config_doc):
"""
:param config_doc:
:return:
:raises: NetconfHandlingError in case of validation errors
"""
logger = logging.getLogger(__name__)
def _validate(schema, doc):
if schema.validate(doc):
return
messages = []
for e in schema.error_log:
logger.error("%d.%d: %s" % (e.line, e.column, e.message))
assert False
msg = f'{e.line}.{e.column}: {e.message}'
messages.append(msg)
logger.error(msg)
raise NetconfHandlingError('\n'.join(messages))
schema_doc = etree.XML(CONFIG_SCHEMA.encode('utf-8'))
config_schema = etree.XMLSchema(schema_doc)
......@@ -151,6 +163,7 @@ def load_config(hostname, ssh_params):
:param hostname: router hostname
:param ssh_params: 'ssh' config element(cf. config.py:CONFIG_SCHEMA)
:return:
:raises: NetconfHandlingError from validate_netconf_config
"""
logger = logging.getLogger(__name__)
logger.info("capturing netconf data for '%s'" % hostname)
......
......@@ -157,7 +157,7 @@ def netconf_refresh_config(self, hostname):
netconf_doc = juniper.load_config(
hostname, InventoryTask.config["ssh"])
netconf_str = etree.tostring(netconf_doc, encoding='unicode')
except ConnectionError:
except (ConnectionError, juniper.NetconfHandlingError):
msg = f'error loading netconf data from {hostname}'
logger.exception(msg)
self.log_warning(msg)
......
......@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
setup(
name='inventory-provider',
version="0.57",
version="0.59",
author='GEANT',
author_email='swd@geant.org',
description='Dashboard inventory provider',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment