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

fixed & debugged snmp redis data format schema

parent fcc18cf9
Branches
Tags
No related merge requests found
...@@ -458,20 +458,20 @@ Any non-empty responses are JSON formatted messages. ...@@ -458,20 +458,20 @@ Any non-empty responses are JSON formatted messages.
"properties": { "properties": {
"v4Address": { "v4Address": {
"type": "string", "type": "string",
"pattern": "^(\d+\.){3}\d+$" "pattern": r'^(\d+\.){3}\d+$'
}, },
"v4Mask": { "v4Mask": {
"type": "string", "type": "string",
"pattern": "^(\d+\.){3}\d+$" "pattern": r'^(\d+\.){3}\d+$'
}, },
"v4InterfaceName": {:"type", "string"}, "v4InterfaceName": {"type": "string"},
"index": {` "index": {
"type": "string", "type": "string",
"pattern": "^\d+$" "pattern": r'^\d+$'
} }
}, },
"required": [ "required": [
"v4Address", "v4Mask", "v4InterfaceName", "index], "v4Address", "v4Mask", "v4InterfaceName", "index"],
"additionalProperties": False "additionalProperties": False
}, },
"v6ifc": { "v6ifc": {
...@@ -479,30 +479,30 @@ Any non-empty responses are JSON formatted messages. ...@@ -479,30 +479,30 @@ Any non-empty responses are JSON formatted messages.
"properties": { "properties": {
"v6Address": { "v6Address": {
"type": "string", "type": "string",
"pattern": "^[\d:]+$" "pattern": r'^[a-f\d:]+$'
}, },
"v6Mask": { "v6Mask": {
"type": "string", "type": "string",
"pattern": "^\d+$" "pattern": r'^\d+$'
}, },
"v6InterfaceName": {:"type", "string"}, "v6InterfaceName": {"type": "string"},
"index": {` "index": {
"type": "string", "type": "string",
"pattern": "^\d+$" "pattern": r'^\d+$'
} }
}, },
"required": [ "required": [
"v6Address", "v6Mask", "v6InterfaceName", "index], "v6Address", "v6Mask", "v6InterfaceName", "index"],
"additionalProperties": False "additionalProperties": False
} }
}, },
"type": "array", "type": "array",
"items": { "items": {
"anyOf": { "anyOf": [
"$ref": "#/definitions/v4Ifc", {"$ref": "#/definitions/v4ifc"},
"$ref": "#/definitions/v6Ifc" {"$ref": "#/definitions/v6ifc"}
} ]
} }
} }
``` ```
...@@ -744,33 +744,3 @@ Any non-empty responses are JSON formatted messages. ...@@ -744,33 +744,3 @@ Any non-empty responses are JSON formatted messages.
"additionalProperties": False "additionalProperties": False
} }
``` ```
* `vpn_rr_peers/<address>`
* key examples
* `ix_public_peer:193.203.0.203`
* valid values:
```json
{
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"ip-address": {
"type": "string",
"oneOf": [
{"pattern": r'^(\d+\.){3}\d+$'},
{"pattern": r'^([a-f\d]{4}:){7}[a-f\d]{4}$'}
]
}
},
"type": "object",
"properties": {
"name": {"$ref": "#/definitions/ip-address"},
"description": {"type": "string"},
"peer-as": {"type": "integer"}
},
"required": ["name", "description"],
"additionalProperties": False
}
```
...@@ -26,20 +26,58 @@ def test_snmp_interfaces(mocker, data_config, snmp_walk_responses): ...@@ -26,20 +26,58 @@ def test_snmp_interfaces(mocker, data_config, snmp_walk_responses):
expected_result_schema = { expected_result_schema = {
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft-07/schema#",
"type": "array",
"items": { "definitions": {
"type": "object", "v4ifc": {
"properties": { "type": "object",
"v4Address": {"type": "string"}, "properties": {
"v4Mask": {"type": "string"}, "v4Address": {
"v4InterfaceName": {"type": "string"}, "type": "string",
"v6Address": {"type": "string"}, "pattern": r'^(\d+\.){3}\d+$'
"v6Mask": {"type": "string"}, },
"v6InterfaceName": {"type": "string"}, "v4Mask": {
"index": {"type": "string"} "type": "string",
"pattern": r'^(\d+\.){3}\d+$'
},
"v4InterfaceName": {"type": "string"},
"index": {
"type": "string",
"pattern": r'^\d+$'
}
},
"required": [
"v4Address", "v4Mask", "v4InterfaceName", "index"],
"additionalProperties": False
}, },
"required": ["index"], "v6ifc": {
"additionalProperties": False "type": "object",
"properties": {
"v6Address": {
"type": "string",
"pattern": r'^[a-f\d:]+$'
},
"v6Mask": {
"type": "string",
"pattern": r'^\d+$'
},
"v6InterfaceName": {"type": "string"},
"index": {
"type": "string",
"pattern": r'^\d+$'
}
},
"required": [
"v6Address", "v6Mask", "v6InterfaceName", "index"],
"additionalProperties": False
}
},
"type": "array",
"items": {
"anyOf": [
{"$ref": "#/definitions/v4ifc"},
{"$ref": "#/definitions/v6ifc"}
]
} }
} }
...@@ -57,13 +95,3 @@ def test_snmp_interfaces(mocker, data_config, snmp_walk_responses): ...@@ -57,13 +95,3 @@ def test_snmp_interfaces(mocker, data_config, snmp_walk_responses):
jsonschema.validate(interfaces, expected_result_schema) jsonschema.validate(interfaces, expected_result_schema)
assert interfaces, "interface list isn't empty" assert interfaces, "interface list isn't empty"
for ifc in interfaces:
if 'v4Address' in ifc \
and 'v4Mask' in ifc \
and 'v4InterfaceName' in ifc:
continue
if 'v6Address' in ifc \
and 'v6Mask' in ifc \
and 'v6InterfaceName' in ifc:
continue
assert False, "address details not found in interface dict"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment