Skip to content
Snippets Groups Projects
Commit 31cd6c13 authored by Release Webservice's avatar Release Webservice
Browse files

Finished release 0.12.

parents 440f901c d291c6ef
Branches
Tags 0.12
No related merge requests found
...@@ -173,9 +173,17 @@ Any non-empty responses are JSON formatted messages. ...@@ -173,9 +173,17 @@ Any non-empty responses are JSON formatted messages.
"type": "object", "type": "object",
"properties": { "properties": {
"name": {"type": "string"}, "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 "additionalProperties": False
} }
} }
......
...@@ -9,5 +9,7 @@ ...@@ -9,5 +9,7 @@
added some route docs to README added some route docs to README
0.7/0.8: added static/* to release 0.7/0.8: added static/* to release
0.9: use pyez/netconf for gathering juniper data 0.9: use pyez/netconf for gathering juniper data
0.10: cache storage formatting bugfix 0.10/0.11: cache storage formatting bugfix
logging levels configured from environment logging levels configured from environment
\ No newline at end of file 0.12: added addresses to interface response
put actual module number in version response
...@@ -148,11 +148,18 @@ def list_interfaces(netconf_config): ...@@ -148,11 +148,18 @@ def list_interfaces(netconf_config):
def _ifc_info(e): def _ifc_info(e):
name = e.find('name') name = e.find('name')
assert name is not None, "expected interface 'name' child element" assert name is not None, "expected interface 'name' child element"
description = e.find('description') ifc = {
return {
'name': name.text, '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'): for i in netconf_config.xpath('//configuration/interfaces/interface'):
info = _ifc_info(i) info = _ifc_info(i)
......
import functools import functools
import json import json
import pkg_resources
from flask import Blueprint, request, Response, current_app from flask import Blueprint, request, Response, current_app
from lxml import etree from lxml import etree
...@@ -9,10 +10,7 @@ from inventory_provider import juniper ...@@ -9,10 +10,7 @@ from inventory_provider import juniper
routes = Blueprint("inventory-data-query-routes", __name__) routes = Blueprint("inventory-data-query-routes", __name__)
VERSION = { API_VERSION = '0.1'
"api": "0.1",
"module": "0.1"
}
def require_accepts_json(f): def require_accepts_json(f):
...@@ -38,7 +36,11 @@ def require_accepts_json(f): ...@@ -38,7 +36,11 @@ def require_accepts_json(f):
@require_accepts_json @require_accepts_json
def version(): def version():
return Response( return Response(
json.dumps(VERSION), json.dumps({
'api': API_VERSION,
'module':
pkg_resources.get_distribution('inventory_provider').version
}),
mimetype="application/json" mimetype="application/json"
) )
......
...@@ -2,7 +2,7 @@ from setuptools import setup, find_packages ...@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
setup( setup(
name='inventory-provider', name='inventory-provider',
version="0.11", version="0.12",
author='GEANT', author='GEANT',
author_email='swd@geant.org', author_email='swd@geant.org',
description='Dashboard inventory provider', description='Dashboard inventory provider',
......
...@@ -66,9 +66,17 @@ def test_router_interfaces(router, client_with_mocked_data): ...@@ -66,9 +66,17 @@ def test_router_interfaces(router, client_with_mocked_data):
"type": "object", "type": "object",
"properties": { "properties": {
"name": {"type": "string"}, "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 "additionalProperties": False
} }
} }
......
...@@ -42,25 +42,33 @@ def netconf_doc(mocker, router, data_config): ...@@ -42,25 +42,33 @@ def netconf_doc(mocker, router, data_config):
return juniper.load_config(router, data_config['ssh']) return juniper.load_config(router, data_config['ssh'])
# def test_interface_list(netconf_doc): def test_interface_list(netconf_doc):
#
# schema = { schema = {
# "$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft-07/schema#",
# "type": "array", "type": "array",
# "items": { "items": {
# "type": "object", "type": "object",
# "properties": { "properties": {
# "name": {"type": "string"}, "name": {"type": "string"},
# "description": {"type": "string"} "description": {"type": "string"},
# }, "ipv4": {
# "required": ["name", "description"], "type": "array",
# "additionalProperties": False "items": {"type": "string"}
# } },
# } "ipv6": {
# "type": "array",
# interfaces = list(netconf.list_interfaces(netconf_doc)) "items": {"type": "string"}
# jsonschema.validate(interfaces, schema) }
# assert interfaces # at least shouldn't be empty },
"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): def test_bgp_list(netconf_doc):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment