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
4821b780
Commit
4821b780
authored
4 years ago
by
Robert Latta
Browse files
Options
Downloads
Patches
Plain Diff
added all circuits to cache
parent
be0352ba
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
inventory_provider/db/ims_data.py
+8
-31
8 additions, 31 deletions
inventory_provider/db/ims_data.py
test/test_ims_data.py
+5
-13
5 additions, 13 deletions
test/test_ims_data.py
with
13 additions
and
44 deletions
inventory_provider/db/ims_data.py
+
8
−
31
View file @
4821b780
...
...
@@ -73,19 +73,6 @@ def get_fibre_info(ds: IMS):
def
get_port_id_services
(
ds
:
IMS
):
# this is the only place that speeds are used,
# products are used else where to define services, so a relevant list of
# products has been moved to the ims module as IMS_SERVICE_NAMES
# The products here are all the products we need to be able to build map
# ports to services
products
=
copy
(
IMS_SERVICE_NAMES
)
products
.
add
(
'
ETHERNET
'
)
speeds
=
{
'
L3VPN
'
,
'
LAG
'
,
'
FIBRE_ROUTE
'
,
# 'BGP',
}
circuit_nav_props
=
[
ims
.
CIRCUIT_PROPERTIES
[
'
Customer
'
],
ims
.
CIRCUIT_PROPERTIES
[
'
Speed
'
],
...
...
@@ -95,26 +82,16 @@ def get_port_id_services(ds: IMS):
]
def
_get_circuits
():
for
st
in
products
:
for
c
in
ds
.
get_filtered_entities
(
'
Circuit
'
,
f
'
product.name ==
"
{
st
}
"'
,
circuit_nav_props
,
step_count
=
2000
):
if
c
[
'
product
'
][
'
name
'
]
in
IMS_SERVICE_NAMES
:
c
[
'
circuit_type
'
]
=
'
service
'
else
:
c
[
'
circuit_type
'
]
=
'
circuit
'
yield
c
for
spd
in
speeds
:
for
c
in
ds
.
get_filtered_entities
(
'
Circuit
'
,
f
'
speed.name ==
"
{
spd
}
"'
,
circuit_nav_props
,
step_count
=
2000
):
for
c
in
ds
.
get_all_entities
(
'
Circuit
'
,
circuit_nav_props
,
step_count
=
2000
):
if
c
[
'
product
'
][
'
name
'
]
in
IMS_SERVICE_NAMES
:
c
[
'
circuit_type
'
]
=
'
service
'
else
:
c
[
'
circuit_type
'
]
=
'
circuit
'
yield
c
yield
c
circuits
=
_get_circuits
()
...
...
This diff is collapsed.
Click to expand it.
test/test_ims_data.py
+
5
−
13
View file @
4821b780
...
...
@@ -101,21 +101,13 @@ def test_get_port_details(mocker):
def
test_get_port_id_services
(
mocker
):
called
=
False
def
_se
(
a
,
b
,
c
,
step_count
):
nonlocal
called
if
called
:
return
{}
else
:
called
=
True
with
open
(
'
test/data/ims_port_id_services_data.json
'
)
as
data
:
return
json
.
load
(
data
)
with
open
(
'
test/data/ims_port_id_services_data.json
'
)
as
data
:
d
=
json
.
load
(
data
)
mocker
.
patch
.
object
(
inventory_provider
.
db
.
ims
.
IMS
,
'
get_
filtered
_entities
'
,
side_effect
=
_se
'
get_
all
_entities
'
,
side_effect
=
[
d
]
)
ds
=
inventory_provider
.
db
.
ims
.
IMS
(
...
...
@@ -125,7 +117,7 @@ def test_get_port_id_services(mocker):
# this is the number of different product types that are considered service
# and speed types that that cover circuit types that have relevant circuits
# and ethernet product type as other relevant circuits also need tracking
assert
ds
.
get_
filtered
_entities
.
call_count
==
20
assert
ds
.
get_
all
_entities
.
call_count
==
1
predicted
=
[
{
'
id
'
:
663060
,
...
...
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