Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
inventory-provider
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
geant-swd
dashboardv3
inventory-provider
Commits
fe5831d5
Commit
fe5831d5
authored
6 years ago
by
Erik Reid
Browse files
Options
Downloads
Plain Diff
Finished feature classifier-cache.
parents
7cab35bc
266efe7a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.md
+3
-2
3 additions, 2 deletions
README.md
inventory_provider/routes/classifier.py
+40
-30
40 additions, 30 deletions
inventory_provider/routes/classifier.py
with
43 additions
and
32 deletions
README.md
+
3
−
2
View file @
fe5831d5
...
...
@@ -426,7 +426,7 @@ Any non-empty responses are JSON formatted messages.
}
}
}
```
```
`opsdb:interface_services:<equipment name>:<interface name>`
...
...
@@ -542,7 +542,7 @@ Any non-empty responses are JSON formatted messages.
*
`opsdb:services:children:12363`
*
`opsdb:services:parents:14407`
*
value schema
TODO: this needs to be checked ...
TODO: this needs to be checked ...
```
json
{
"$schema"
:
"http://json-schema.org/draft-07/schema#"
,
...
...
@@ -593,6 +593,7 @@ Any non-empty responses are JSON formatted messages.
*
`alarmsdb:interface_status:Lab node 1:1-1/3`
*
`alarmsdb:interface_status:mx1.ams.nl.geant.net:ae15.1500`
*
valid values:
TODO: verify these values
*
`unknown`
*
`up`
*
`down`
\ No newline at end of file
This diff is collapsed.
Click to expand it.
inventory_provider/routes/classifier.py
+
40
−
30
View file @
fe5831d5
...
...
@@ -39,33 +39,43 @@ def juniper_addresses():
def
get_trap_metadata
(
source_equipment
,
interface
):
r
=
common
.
get_redis
()
# todo - Change this to a call to the yet-to-be-created one source of all
# relevant information
# This could be different calls dependant on vendor, in which case we may
# need to check the trap type, or it could be a case of a key check for
# each possible data source
interface_info
=
r
.
get
(
'
opsdb:interface_services:%s:%s
'
%
(
source_equipment
,
interface
))
if
not
interface_info
:
return
Response
(
response
=
"
no available info for {} {}
"
.
format
(
source_equipment
,
interface
),
status
=
404
,
mimetype
=
"
text/html
"
)
interface_info
=
json
.
loads
(
interface_info
.
decode
(
'
utf-8
'
))
# todo - refactor once structure of new source is decided, currently this
# is just a list of services
vendor
=
interface_info
[
0
][
'
manufacturer
'
]
hostname
=
interface_info
[
0
][
'
equipment
'
]
# TODO: don't copy unecessary data into response (let client do this)
result
=
{
"
vendor
"
:
vendor
,
"
equipment-name
"
:
hostname
,
"
interface-name
"
:
interface
,
"
services
"
:
interface_info
}
return
jsonify
(
result
)
cache_key
=
'
classifier:cache:%s:%s
'
%
(
source_equipment
,
interface
)
result
=
r
.
get
(
cache_key
)
if
result
:
result
=
result
.
decode
(
'
utf-8
'
)
else
:
# todo - Change this to a call to the yet-to-be-created one source of all
# relevant information
# This could be different calls dependant on vendor, in which case we may
# need to check the trap type, or it could be a case of a key check for
# each possible data source
interface_info
=
r
.
get
(
'
opsdb:interface_services:%s:%s
'
%
(
source_equipment
,
interface
))
if
not
interface_info
:
return
Response
(
response
=
"
no available info for {} {}
"
.
format
(
source_equipment
,
interface
),
status
=
404
,
mimetype
=
"
text/html
"
)
interface_info
=
json
.
loads
(
interface_info
.
decode
(
'
utf-8
'
))
# todo - refactor once structure of new source is decided, currently this
# is just a list of services
vendor
=
interface_info
[
0
][
'
manufacturer
'
]
hostname
=
interface_info
[
0
][
'
equipment
'
]
# TODO: don't copy unecessary data into response (let client do this)
result
=
{
"
vendor
"
:
vendor
,
"
equipment-name
"
:
hostname
,
"
interface-name
"
:
interface
,
"
services
"
:
interface_info
}
result
=
json
.
dumps
(
result
)
# cache this data for the next call
r
.
set
(
cache_key
,
result
.
encode
(
'
utf-8
'
))
return
Response
(
result
,
mimetype
=
"
application/json
"
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment