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
4562c974
Commit
4562c974
authored
4 years ago
by
Robert Latta
Browse files
Options
Downloads
Patches
Plain Diff
added vmport and vminternalport details; loaded service types from IMS
parent
70cc6b31
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/db/ims_data.py
+57
-10
57 additions, 10 deletions
inventory_provider/db/ims_data.py
with
57 additions
and
10 deletions
inventory_provider/db/ims_data.py
+
57
−
10
View file @
4562c974
...
...
@@ -2,11 +2,12 @@ import logging
import
re
from
collections
import
OrderedDict
,
defaultdict
from
copy
import
copy
from
functools
import
lru_cache
from
itertools
import
chain
from
inventory_provider
import
environment
from
inventory_provider.db
import
ims
from
inventory_provider.db.ims
import
InventoryStatus
,
IMS
,
IMS_SERVICE_NAMES
from
inventory_provider.db.ims
import
InventoryStatus
,
IMS
environment
.
setup_logging
()
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -23,6 +24,14 @@ IMS_OPSDB_STATUS_MAP = {
}
@lru_cache
(
64
,
typed
=
False
)
def
get_service_types
(
ds
:
IMS
):
for
d
in
ds
.
get_filtered_entities
(
'
ComboBoxData
'
,
'
name ==
"
PW_INFORM_PRODUCTCODE
"'
):
yield
d
[
'
selection
'
]
def
get_fibre_info
(
ds
:
IMS
):
# get all the wdm ots circuits where each node is in a different location
...
...
@@ -74,12 +83,18 @@ def get_fibre_info(ds: IMS):
def
get_port_id_services
(
ds
:
IMS
):
circuit_nav_props
=
[
ims
.
CIRCUIT_PROPERTIES
[
'
Customer
'
],
ims
.
CIRCUIT_PROPERTIES
[
'
Speed
'
],
ims
.
CIRCUIT_PROPERTIES
[
'
Product
'
],
ims
.
CIRCUIT_PROPERTIES
[
'
Ports
'
],
ims
.
CIRCUIT_PROPERTIES
[
'
InternalPorts
'
],
]
ims_service_names
=
list
(
get_service_types
(
ds
))
customers
=
{
c
[
'
id
'
]:
c
[
'
name
'
]
for
c
in
ds
.
get_all_entities
(
'
customer
'
)}
products
=
{
p
[
'
id
'
]:
p
[
'
name
'
]
for
p
in
ds
.
get_all_entities
(
'
product
'
)}
def
_get_circuit_type
(
c
):
if
products
[
c
[
'
productid
'
]]
in
ims_service_names
:
return
'
service
'
else
:
return
'
circuit
'
def
_get_circuits
():
...
...
@@ -87,10 +102,7 @@ def get_port_id_services(ds: IMS):
'
Circuit
'
,
circuit_nav_props
,
step_count
=
2000
):
if
c
[
'
product
'
][
'
name
'
]
in
IMS_SERVICE_NAMES
:
c
[
'
circuit_type
'
]
=
'
service
'
else
:
c
[
'
circuit_type
'
]
=
'
circuit
'
c
[
'
circuit_type
'
]
=
_get_circuit_type
(
c
)
yield
c
circuits
=
_get_circuits
()
...
...
@@ -135,8 +147,8 @@ def get_port_id_services(ds: IMS):
'
status
'
:
IMS_OPSDB_STATUS_MAP
.
get
(
InventoryStatus
(
circuit
[
'
inventorystatusid
'
]),
'
unknown
'
),
'
circuit_type
'
:
circuit
[
'
circuit_type
'
],
'
service_type
'
:
circuit
[
'
product
'
]
[
'
name
'
],
'
project
'
:
circuit
[
'
customer
'
]
[
'
name
'
]
'
service_type
'
:
products
[
circuit
[
'
product
id
'
]],
'
project
'
:
customers
[
circuit
[
'
customer
id
'
]]
}
ports
=
[]
if
circuit
[
'
internalports
'
]:
...
...
@@ -151,6 +163,34 @@ def get_port_id_services(ds: IMS):
ports
=
[
circuit
[
'
portaid
'
],
circuit
[
'
portbid
'
]]
yield
from
_populate_end_info
(
cd
,
ports
)
for
portrelate
in
chain
(
ds
.
get_all_entities
(
'
vmportrelate
'
,
ims
.
VM_PORT_RELATE_PROPERTIES
[
'
Circuit
'
],
step_count
=
2000
),
ds
.
get_all_entities
(
'
vminternalportrelate
'
,
ims
.
VM_INTERNAL_PORT_RELATE_PROPERTIES
[
'
Circuit
'
],
step_count
=
2000
)
):
circuit
=
portrelate
[
'
circuit
'
]
if
circuit
:
yield
{
'
id
'
:
circuit
[
'
id
'
],
'
name
'
:
circuit
[
'
name
'
],
'
status
'
:
IMS_OPSDB_STATUS_MAP
.
get
(
InventoryStatus
(
circuit
[
'
inventorystatusid
'
]),
'
unknown
'
),
'
circuit_type
'
:
_get_circuit_type
(
circuit
),
'
service_type
'
:
products
[
circuit
[
'
productid
'
]],
'
project
'
:
customers
[
circuit
[
'
customerid
'
]],
'
port_a_id
'
:
portrelate
.
get
(
'
portid
'
,
portrelate
.
get
(
'
internalportid
'
,
''
))
}
def
get_port_details
(
ds
:
IMS
):
port_nav_props
=
[
...
...
@@ -199,7 +239,13 @@ def get_circuit_hierarchy(ds: IMS):
]
circuits
=
ds
.
get_all_entities
(
'
Circuit
'
,
circuit_nav_props
,
step_count
=
1000
)
service_types
=
list
(
get_service_types
(
ds
))
for
circuit
in
circuits
:
if
circuit
[
'
product
'
][
'
name
'
]
in
service_types
:
circuit_type
=
'
service
'
else
:
circuit_type
=
'
circuit
'
sub_circuits
=
[
c
[
'
subcircuitid
'
]
for
c
in
circuit
[
'
subcircuits
'
]]
carrier_circuits
=
\
[
c
[
'
carriercircuitid
'
]
for
c
in
circuit
[
'
carriercircuits
'
]]
...
...
@@ -211,6 +257,7 @@ def get_circuit_hierarchy(ds: IMS):
'
product
'
:
circuit
[
'
product
'
][
'
name
'
],
'
speed
'
:
circuit
[
'
speed
'
][
'
name
'
],
'
project
'
:
circuit
[
'
customer
'
][
'
name
'
],
'
circuit-type
'
:
circuit_type
,
'
sub-circuits
'
:
sub_circuits
,
'
carrier-circuits
'
:
carrier_circuits
}
...
...
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