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

Finished feature interface-addresses.

parents 197390ed b541c94d
No related branches found
No related tags found
No related merge requests found
......@@ -173,9 +173,17 @@ Any non-empty responses are JSON formatted messages.
"type": "object",
"properties": {
"name": {"type": "string"},
"description": {"type": "string"}
"description": {"type": "string"},
"ipv4": {
"type": "array",
"items": {"type": "string"}
},
"ipv6": {
"type": "array",
"items": {"type": "string"}
}
},
"required": ["name", "description"],
"required": ["name", "description", "ipv4", "ipv6"],
"additionalProperties": False
}
}
......
......@@ -148,11 +148,18 @@ def list_interfaces(netconf_config):
def _ifc_info(e):
name = e.find('name')
assert name is not None, "expected interface 'name' child element"
description = e.find('description')
return {
ifc = {
'name': name.text,
'description': description.text if description is not None else ''
'description': ''
}
description = e.find('description')
if description is not None:
ifc['description'] = description.text
ifc['ipv4'] = e.xpath('./family/inet/address/name/text()')
ifc['ipv6'] = e.xpath('./family/inet6/address/name/text()')
return ifc
for i in netconf_config.xpath('//configuration/interfaces/interface'):
info = _ifc_info(i)
......
......@@ -66,9 +66,17 @@ def test_router_interfaces(router, client_with_mocked_data):
"type": "object",
"properties": {
"name": {"type": "string"},
"description": {"type": "string"}
"description": {"type": "string"},
"ipv4": {
"type": "array",
"items": {"type": "string"}
},
"ipv6": {
"type": "array",
"items": {"type": "string"}
}
},
"required": ["name", "description"],
"required": ["name", "description", "ipv4", "ipv6"],
"additionalProperties": False
}
}
......
......@@ -42,25 +42,33 @@ def netconf_doc(mocker, router, data_config):
return juniper.load_config(router, data_config['ssh'])
# def test_interface_list(netconf_doc):
#
# schema = {
# "$schema": "http://json-schema.org/draft-07/schema#",
# "type": "array",
# "items": {
# "type": "object",
# "properties": {
# "name": {"type": "string"},
# "description": {"type": "string"}
# },
# "required": ["name", "description"],
# "additionalProperties": False
# }
# }
#
# interfaces = list(netconf.list_interfaces(netconf_doc))
# jsonschema.validate(interfaces, schema)
# assert interfaces # at least shouldn't be empty
def test_interface_list(netconf_doc):
schema = {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {"type": "string"},
"description": {"type": "string"},
"ipv4": {
"type": "array",
"items": {"type": "string"}
},
"ipv6": {
"type": "array",
"items": {"type": "string"}
}
},
"required": ["name", "description", "ipv4", "ipv6"],
"additionalProperties": False
}
}
interfaces = list(juniper.list_interfaces(netconf_doc))
jsonschema.validate(interfaces, schema)
assert interfaces # at least shouldn't be empty
def test_bgp_list(netconf_doc):
......
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