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
48e65a4f
Commit
48e65a4f
authored
5 years ago
by
Erik Reid
Browse files
Options
Downloads
Patches
Plain Diff
ensure location dict is a common structure
parent
1eded5c7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
inventory_provider/routes/classifier.py
+28
-25
28 additions, 25 deletions
inventory_provider/routes/classifier.py
with
28 additions
and
25 deletions
inventory_provider/routes/classifier.py
+
28
−
25
View file @
48e65a4f
...
...
@@ -13,6 +13,14 @@ routes = Blueprint("inventory-data-classifier-support-routes", __name__)
logger
=
logging
.
getLogger
(
__name__
)
def
_LOCATION
(
equipment
,
name
,
abbreviation
):
return
{
'
equipment
'
:
equipment
,
'
name
'
:
name
,
'
abbreviation
'
:
abbreviation
}
def
_unique_dicts_from_list
(
l
):
tmp_dict
=
dict
([(
json
.
dumps
(
item
,
sort_keys
=
True
),
item
)
for
item
in
l
])
return
list
(
tmp_dict
.
values
())
...
...
@@ -31,32 +39,29 @@ def _location_from_router(router_name):
return
None
return
{
'
a
'
:
{
'
equipment
'
:
result
[
0
][
'
equipment-name
'
],
'
name
'
:
result
[
0
][
'
pop
'
][
'
name
'
],
'
abbreviation
'
:
result
[
0
][
'
pop
'
][
'
abbreviation
'
]
}
'
a
'
:
_LOCATION
(
equipment
=
result
[
0
][
'
equipment-name
'
],
name
=
result
[
0
][
'
pop
'
][
'
name
'
],
abbreviation
=
result
[
0
][
'
pop
'
][
'
abbreviation
'
])
}
def
_location_from_service_dict
(
s
):
location
=
{
'
a
'
:
{
'
equipment
'
:
s
[
'
equipment
'
],
'
name
'
:
s
[
'
pop_name
'
],
'
abbreviation
'
:
s
[
'
pop_abbreviation
'
]
}
'
a
'
:
_LOCATION
(
equipment
=
s
[
'
equipment
'
],
name
=
s
[
'
pop_name
'
],
abbreviation
=
s
[
'
pop_abbreviation
'
])
}
if
all
(
s
[
n
]
for
n
in
(
'
other_end_equipment
'
,
'
other_end_pop_name
'
,
'
other_end_pop_abbreviation
'
)):
location
[
'
b
'
]
=
{
'
equipment
'
:
s
[
'
other_end_equipment
'
],
'
name
'
:
s
[
'
other_end_pop_name
'
],
'
abbreviation
'
:
s
[
'
other_end_pop_abbreviation
'
]
}
location
[
'
b
'
]
=
_LOCATION
(
equipment
=
s
[
'
other_end_equipment
'
],
name
=
s
[
'
other_end_pop_name
'
],
abbreviation
=
s
[
'
other_end_pop_abbreviation
'
])
return
location
...
...
@@ -441,16 +446,14 @@ def get_coriant_info(equipment_name, entity_string):
if
path
:
result
[
'
path
'
]
=
path
result
[
'
locations
'
]
+=
[{
'
a
'
:
{
'
equipment
'
:
path
[
'
a
'
][
'
equipment name
'
],
'
name
'
:
path
[
'
a
'
][
'
pop
'
][
'
name
'
],
'
abbreviation
'
:
path
[
'
a
'
][
'
pop
'
][
'
abbreviation
'
]
},
'
b
'
:
{
'
equipment
'
:
path
[
'
b
'
][
'
equipment name
'
],
'
name
'
:
path
[
'
b
'
][
'
pop
'
][
'
name
'
],
'
abbreviation
'
:
path
[
'
b
'
][
'
pop
'
][
'
abbreviation
'
]
}
'
a
'
:
_LOCATION
(
equipment
=
path
[
'
a
'
][
'
equipment name
'
],
name
=
path
[
'
a
'
][
'
pop
'
][
'
name
'
],
abbreviation
=
path
[
'
a
'
][
'
pop
'
][
'
abbreviation
'
]),
'
b
'
:
_LOCATION
(
equipment
=
path
[
'
b
'
][
'
equipment name
'
],
name
=
path
[
'
b
'
][
'
pop
'
][
'
name
'
],
abbreviation
=
path
[
'
b
'
][
'
pop
'
][
'
abbreviation
'
]),
}]
top_level_services
=
get_top_level_services
(
path
[
'
id
'
],
r
)
...
...
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