From cda04dcf2765bfb0fee397b2c46ecef6deb7c579 Mon Sep 17 00:00:00 2001 From: Erik Reid <erik.reid@geant.org> Date: Thu, 17 Oct 2019 17:29:11 +0200 Subject: [PATCH] support extra fields in qfx* netconf docs --- inventory_provider/juniper.py | 4 +++ test/test_netconf_validation.py | 50 +++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 test/test_netconf_validation.py diff --git a/inventory_provider/juniper.py b/inventory_provider/juniper.py index ef0b5ee0..3e4405e4 100644 --- a/inventory_provider/juniper.py +++ b/inventory_provider/juniper.py @@ -56,6 +56,7 @@ CONFIG_SCHEMA = """<?xml version="1.1" encoding="UTF-8" ?> <xs:sequence> <xs:choice minOccurs="1" maxOccurs="unbounded"> <xs:element name="apply-groups" minOccurs="0" type="xs:string" /> + <xs:element name="interface-range" minOccurs="0" type="generic-sequence" /> <xs:element name="interface" minOccurs="1" maxOccurs="unbounded" type="juniper-interface" /> </xs:choice> </xs:sequence> @@ -70,6 +71,9 @@ CONFIG_SCHEMA = """<?xml version="1.1" encoding="UTF-8" ?> <xs:element name="firewall" minOccurs="0" type="generic-sequence" /> <xs:element name="routing-instances" minOccurs="0" type="generic-sequence" /> <xs:element name="bridge-domains" minOccurs="0" type="generic-sequence" /> + <xs:element name="virtual-chassis" minOccurs="0" type="generic-sequence" /> + <xs:element name="vlans" minOccurs="0" type="generic-sequence" /> + <xs:element name="comment" minOccurs="0" type="xs:string" /> </xs:choice> </xs:sequence> <xs:attribute name="changed-seconds" type="xs:string" /> diff --git a/test/test_netconf_validation.py b/test/test_netconf_validation.py new file mode 100644 index 00000000..3eca33cf --- /dev/null +++ b/test/test_netconf_validation.py @@ -0,0 +1,50 @@ +import os +import pytest +from lxml import etree +from inventory_provider.juniper import validate_netconf_config + + +@pytest.mark.parametrize('hostname', [ + 'mx1.ams.nl.geant.net', + 'mx1.ath2.gr.geant.net', + 'mx1.buc.ro.geant.net', + 'mx1.bud.hu.geant.net', + 'mx1.dub.ie.geant.net', + 'mx1.dub2.ie.geant.net', + 'mx1.fra.de.geant.net', + 'mx1.gen.ch.geant.net', + 'mx1.ham.de.geant.net', + 'mx1.kau.lt.geant.net', + 'mx1.lis.pt.geant.net', + 'mx1.lon.uk.geant.net', + 'mx1.lon2.uk.geant.net', + 'mx1.mad.es.geant.net', + 'mx1.mar.fr.geant.net', + 'mx1.mil2.it.geant.net', + 'mx1.par.fr.geant.net', + 'mx1.poz.pl.geant.net', + 'mx1.pra.cz.geant.net', + 'mx1.sof.bg.geant.net', + 'mx1.tal.ee.geant.net', + 'mx1.vie.at.geant.net', + 'mx2.ath.gr.geant.net', + 'mx2.bra.sk.geant.net', + 'mx2.bru.be.geant.net', + 'mx2.kau.lt.geant.net', + 'mx2.lis.pt.geant.net', + 'mx2.lju.si.geant.net', + 'mx2.rig.lv.geant.net', + 'mx2.tal.ee.geant.net', + 'mx2.zag.hr.geant.net', + 'qfx.fra.de.geant.net', + 'qfx.lon2.uk.geant.net', + 'qfx.par.fr.geant.net' +]) +def test_netconf_docs(hostname): + filename = os.path.join( + os.path.dirname(__file__), + 'data', + hostname + '-netconf.xml') + + doc = etree.parse(filename) + validate_netconf_config(doc) -- GitLab