diff --git a/test/data/update_netconf_data.py b/test/data/update_netconf_data.py index 72850761f0da5b4f5aa086d9ade40a6bd05638ec..354176d30ab2facd8e752772cd4ca42314ebb1c3 100644 --- a/test/data/update_netconf_data.py +++ b/test/data/update_netconf_data.py @@ -1,3 +1,4 @@ +import logging import os from jnpr.junos import Device @@ -35,16 +36,28 @@ def _load_netconf(hostname, ssh_params): # -SCHEMA = """<?xml version="1.0" encoding="UTF-8" ?> +SCHEMA = """<?xml version="1.1" encoding="UTF-8" ?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:complexType name="generic-sequence"> <xs:sequence> - <xs:any processContents="skip" minOccurs="0" maxOccurs="unbounded"/> + <xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence> <xs:anyAttribute processContents="skip" /> </xs:complexType> + <!-- NOTE: 'unit' content isn't validated --> + <xs:complexType name="juniper-interface"> + <xs:sequence> + <xs:choice minOccurs="1" maxOccurs="unbounded"> + <xs:element name="name" minOccurs="1" maxOccurs="1" type="xs:string" /> + <xs:element name="description" minOccurs="0" maxOccurs="1" type="xs:string" /> + <xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded" /> + </xs:choice> + </xs:sequence> + <xs:attribute name="inactive" type="xs:string" /> + </xs:complexType> + <xs:element name="configuration"> <xs:complexType> <xs:sequence> @@ -61,7 +74,7 @@ SCHEMA = """<?xml version="1.0" 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" minOccurs="1" type="generic-sequence" /> + <xs:element name="interface" minOccurs="1" maxOccurs="unbounded" type="juniper-interface" /> </xs:choice> </xs:sequence> </xs:complexType> @@ -86,6 +99,8 @@ SCHEMA = """<?xml version="1.0" encoding="UTF-8" ?> """ if __name__ == "__main__": + logging.basicConfig(level=logging.DEBUG) + TEST_DATA_DIR = os.path.dirname(__file__) CONFIG_FILENAME = "config.json" SCHEMA_FILENAME = os.path.join(TEST_DATA_DIR, "juniper-netconf.xsd") @@ -109,5 +124,12 @@ if __name__ == "__main__": schema = etree.XMLSchema(schema_doc) parser = etree.XMLParser(schema=schema) - print(filename) - etree.parse(filename, parser) + logging.debug("FILENAME: %s" % filename) + try: + etree.parse(filename, parser) + except etree.XMLSyntaxError as ex: + logging.debug(ex) + for e in parser.error_log: + logging.debug("%d.%d: %s" % ( + e.line, e.column, e.message)) + exit(-1)