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
81432d32
Commit
81432d32
authored
6 years ago
by
Robert Latta
Browse files
Options
Downloads
Patches
Plain Diff
Added in routes for circuit hierarchy and tidied up other routes
parent
78ee78c0
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
inventory_provider/routes/opsdb.py
+19
-29
19 additions, 29 deletions
inventory_provider/routes/opsdb.py
with
19 additions
and
29 deletions
inventory_provider/routes/opsdb.py
+
19
−
29
View file @
81432d32
import
functools
import
functools
import
json
import
json
from
flask
import
Blueprint
,
request
,
Response
,
current_app
from
flask
import
Blueprint
,
request
,
Response
from
inventory_provider
import
opsdb
from
inventory_provider
import
db
from
inventory_provider
import
db
from
inventory_provider.storage
import
external_inventory
routes
=
Blueprint
(
"
inventory-opsdb-query-routes
"
,
__name__
)
routes
=
Blueprint
(
"
inventory-opsdb-query-routes
"
,
__name__
)
...
@@ -39,17 +39,6 @@ def _decode_utf8_dict(d):
...
@@ -39,17 +39,6 @@ def _decode_utf8_dict(d):
return
{
k
.
decode
(
'
utf8
'
):
json
.
loads
(
v
)
for
k
,
v
in
d
.
items
()}
return
{
k
.
decode
(
'
utf8
'
):
json
.
loads
(
v
)
for
k
,
v
in
d
.
items
()}
@routes.route
(
"
/circuit-hierarchy
"
,
methods
=
[
'
GET
'
,
])
@require_accepts_json
def
opsdb_circuit_hierarchy
():
# todo - Retrieve data from redis
result
=
[{
"
Parent Name
"
:
"
circuit 1
"
},
{
"
Parent Name
"
:
"
Circuit 2
"
}]
return
Response
(
json
.
dumps
(
result
),
mimetype
=
"
application/json
"
)
@routes.route
(
"
/interfaces
"
)
@routes.route
(
"
/interfaces
"
)
def
get_all_interface_details
():
def
get_all_interface_details
():
r
=
db
.
get_redis
()
r
=
db
.
get_redis
()
...
@@ -95,28 +84,29 @@ def get_all_equipment_locations():
...
@@ -95,28 +84,29 @@ def get_all_equipment_locations():
mimetype
=
"
application/json
"
)
mimetype
=
"
application/json
"
)
@routes.route
(
"
/equipment-location/<equipment_name>
"
)
@routes.route
(
"
/equipment-location/<
path:
equipment_name>
"
)
def
get_equipment_location
(
equipment_name
):
def
get_equipment_location
(
equipment_name
):
r
=
db
.
get_redis
()
r
=
db
.
get_redis
()
return
Response
(
return
Response
(
r
.
hget
(
equipment_locations_key
,
equipment_name
),
r
.
hget
(
equipment_locations_key
,
equipment_name
),
mimetype
=
"
application/json
"
)
mimetype
=
"
application/json
"
)
# todo - Add in the routes for the circuit hierarchy, the actual load of the data is already done
# todo - Below are temporary routes that need to be removed
@routes.route
(
"
/circuit-sql
"
)
def
get_circuits_sql
():
return
Response
(
opsdb
.
_generate_get_circuits_sql
(),
mimetype
=
"
text/plain
"
)
@routes.route
(
"
/circuit-hierarchy/children/<parent_id>
"
)
@routes.route
(
"
/infinera-circuit-sql
"
,
methods
=
[
'
GET
'
,])
def
get_children
(
parent_id
):
def
get_infinera_circuits_sql
():
r
=
db
.
get_redis
()
return
Response
(
opsdb
.
generate_infinera_sql
(),
mimetype
=
"
text/plain
"
)
return
Response
(
r
.
hget
(
external_inventory
.
service_parent_to_children_key
,
parent_id
),
mimetype
=
"
application/json
"
)
@routes.route
(
"
/equipment-location-sql
"
,
methods
=
[
'
GET
'
,])
@routes.route
(
"
/circuit-hierarchy/parents/<child_id>
"
)
def
get_equipment_location_sql
():
def
get_parents
(
child_id
):
return
Response
(
opsdb
.
equipment_location_query
,
mimetype
=
"
text/plain
"
)
r
=
db
.
get_redis
()
\ No newline at end of file
return
Response
(
r
.
hget
(
external_inventory
.
service_child_to_parents_key
,
child_id
),
mimetype
=
"
application/json
"
)
\ No newline at end of file
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