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

relaxed junosspace xml validation

parent 11adfda0
No related branches found
No related tags found
No related merge requests found
......@@ -105,6 +105,11 @@ UNIT_SCHEMA = """<?xml version="1.1" encoding="UTF-8" ?>
</xs:schema>
""" # noqa: E501
# elements 'use-nat' and 'fingerprint' were added between
# junosspace versions 15.x and 17.x ... hopefully new versions
# will also add new elements at the end of the sequence so
# that the final xs:any below will suffice to allow validation
JUNOSSPACE_DEVICES_SCHEMA = """<?xml version="1.1" encoding="UTF-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
......@@ -127,8 +132,7 @@ JUNOSSPACE_DEVICES_SCHEMA = """<?xml version="1.1" encoding="UTF-8" ?>
<xs:element name="domain-id" minOccurs="1" maxOccurs="1" type="xs:string" />
<xs:element name="domain-name" minOccurs="1" maxOccurs="1" type="xs:string" />
<xs:element name="config-status" minOccurs="1" maxOccurs="1" type="xs:string" />
<xs:element name="use-nat" minOccurs="0" maxOccurs="1" type="xs:boolean" />
<xs:element name="fingerprint" minOccurs="0" maxOccurs="1" type="xs:string" />
<xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute name="href" type="xs:string" />
<xs:attribute name="uri" type="xs:string" />
......@@ -148,7 +152,6 @@ JUNOSSPACE_DEVICES_SCHEMA = """<?xml version="1.1" encoding="UTF-8" ?>
</xs:schema>
""" # noqa: E501
def _rpc(hostname, ssh):
dev = Device(
host=hostname,
......@@ -336,7 +339,7 @@ def load_routers_from_junosspace(config):
schema = etree.XMLSchema(schema_doc)
if not schema.validate(devices):
for e in schema.error_log:
juniper_logger.error("%d.%d: %s" % (e.line, e.column, e.message))
juniper_logger.error('%d.%d: %s' % (e.line, e.column, e.message))
assert False
for d in devices.xpath('//devices/device'):
......@@ -346,6 +349,8 @@ def load_routers_from_junosspace(config):
if m:
hostname = m.group(1) + '.geant.net'
else:
juniper_logger.error(
'unrecognized junosspace device name format :%s' % name)
hostname = None
yield {
"OSVersion": d.xpath('./OSVersion/text()')[0],
......
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