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
bf2211cf
Commit
bf2211cf
authored
3 years ago
by
Robert Latta
Browse files
Options
Downloads
Patches
Plain Diff
ensured all contacts are added to classification responses
parent
bc4eea18
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
inventory_provider/db/ims_data.py
+14
-1
14 additions, 1 deletion
inventory_provider/db/ims_data.py
inventory_provider/routes/classifier.py
+2
-2
2 additions, 2 deletions
inventory_provider/routes/classifier.py
inventory_provider/tasks/worker.py
+11
-9
11 additions, 9 deletions
inventory_provider/tasks/worker.py
with
27 additions
and
12 deletions
inventory_provider/db/ims_data.py
+
14
−
1
View file @
bf2211cf
...
...
@@ -2,7 +2,8 @@ import logging
import
re
from
collections
import
OrderedDict
,
defaultdict
from
copy
import
copy
from
itertools
import
chain
from
itertools
import
chain
,
groupby
from
operator
import
itemgetter
from
inventory_provider
import
environment
from
inventory_provider.db
import
ims
...
...
@@ -75,6 +76,18 @@ def get_customer_service_emails(ds: IMS):
yield
k
,
sorted
(
list
(
v
))
def
get_circuit_related_customer_ids
(
ds
:
IMS
):
relations
=
sorted
(
list
(
ds
.
get_filtered_entities
(
'
CircuitCustomerRelation
'
,
'
circuit.inventoryStatusId== 3
'
)
),
key
=
itemgetter
(
'
circuitid
'
))
return
{
k
:
[
c
[
'
customerid
'
]
for
c
in
v
]
for
k
,
v
in
groupby
(
relations
,
key
=
itemgetter
(
'
circuitid
'
))}
def
get_port_id_services
(
ds
:
IMS
):
circuit_nav_props
=
[
ims
.
CIRCUIT_PROPERTIES
[
'
Ports
'
],
...
...
This diff is collapsed.
Click to expand it.
inventory_provider/routes/classifier.py
+
2
−
2
View file @
bf2211cf
...
...
@@ -185,12 +185,12 @@ def get_interface_services_and_loc(ims_source_equipment, ims_interface, redis):
for
s
in
json
.
loads
(
raw_services
.
decode
(
'
utf-8
'
)):
related_services
.
update
(
{
r
[
'
id
'
]:
r
for
r
in
s
[
'
related-services
'
]})
contacts
.
update
(
set
(
s
.
pop
(
'
contacts
'
,
set
())))
if
s
[
'
circuit_type
'
]
==
'
service
'
:
contacts
.
update
(
set
(
s
.
pop
(
'
contacts
'
,
set
())))
_format_service
(
s
)
result
[
'
services
'
].
append
(
s
)
result
[
'
related-services
'
]
=
list
(
related_services
.
values
())
result
[
'
contacts
'
]
=
sorted
(
list
(
contacts
))
result
[
'
related-services
'
]
=
list
(
related_services
.
values
())
if
not
result
[
'
services
'
]:
result
.
pop
(
'
services
'
,
None
)
...
...
This diff is collapsed.
Click to expand it.
inventory_provider/tasks/worker.py
+
11
−
9
View file @
bf2211cf
...
...
@@ -574,6 +574,8 @@ def update_circuit_hierarchy_and_port_id_services(self, use_current=False):
{
k
:
v
for
k
,
v
in
ims_data
.
get_customer_service_emails
(
ds1
)}
circuit_ids_to_monitor
=
\
list
(
ims_data
.
get_monitored_circuit_ids
(
ds1
))
additional_circuit_customer_ids
=
\
ims_data
.
get_circuit_related_customer_ids
(
ds1
)
hierarchy
=
None
port_id_details
=
defaultdict
(
list
)
...
...
@@ -613,12 +615,18 @@ def update_circuit_hierarchy_and_port_id_services(self, use_current=False):
else
:
return
0
def
_get_circuit_contacts
(
c
):
customer_ids
=
{
c
[
'
customerid
'
]}
customer_ids
.
update
(
additional_circuit_customer_ids
.
get
(
c
[
'
id
'
],
[]))
return
set
().
union
(
*
[
customer_contacts
.
get
(
cid
,
[])
for
cid
in
customer_ids
])
def
_populate_hierarchy
():
nonlocal
hierarchy
hierarchy
=
{}
for
d
in
ims_data
.
get_circuit_hierarchy
(
ds1
):
d
[
'
contacts
'
]
=
customer_contacts
.
get
(
d
[
'
customerid
'
],
[])
hierarchy
[
d
[
'
id
'
]]
=
d
d
[
'
contacts
'
]
=
sorted
(
list
(
_get_circuit_contacts
(
d
)))
logger
.
debug
(
"
hierarchy complete
"
)
def
_populate_port_id_details
():
...
...
@@ -672,7 +680,7 @@ def update_circuit_hierarchy_and_port_id_services(self, use_current=False):
'
circuit_type
'
:
c
[
'
circuit-type
'
],
'
service_type
'
:
c
[
'
product
'
],
'
project
'
:
c
[
'
project
'
],
'
contacts
'
:
sorted
(
list
(
c
[
'
contacts
'
]
))
'
contacts
'
:
c
[
'
contacts
'
]
}
if
c
[
'
id
'
]
in
circuit_ids_to_monitor
:
rs
[
c
[
'
id
'
]][
'
status
'
]
=
c
[
'
status
'
]
...
...
@@ -737,13 +745,7 @@ def update_circuit_hierarchy_and_port_id_services(self, use_current=False):
circuits
=
port_id_services
.
get
(
details
[
'
port_id
'
],
[])
for
circ
in
circuits
:
contacts
=
set
()
contacts
.
update
(
customer_contacts
.
get
(
circ
[
'
customerid
'
],
[]
)
)
contacts
=
_get_circuit_contacts
(
circ
)
circ
[
'
fibre-routes
'
]
=
[]
for
x
in
set
(
_get_fibre_routes
(
circ
[
'
id
'
])):
c
=
{
...
...
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