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
187be507
Commit
187be507
authored
2 years ago
by
Bjarke Madsen
Browse files
Options
Downloads
Patches
Plain Diff
Add SIDs to services from ports
parent
6a9a582e
No related branches found
No related tags found
1 merge request
!4
Add feature to raise SIDs defined on ports to services on those ports
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
inventory_provider/db/ims_data.py
+26
-5
26 additions, 5 deletions
inventory_provider/db/ims_data.py
inventory_provider/tasks/worker.py
+35
-23
35 additions, 23 deletions
inventory_provider/tasks/worker.py
with
61 additions
and
28 deletions
inventory_provider/db/ims_data.py
+
26
−
5
View file @
187be507
...
...
@@ -140,7 +140,7 @@ def get_circuit_related_customers(ds: IMS):
'
id
'
:
c
[
'
customer
'
][
'
id
'
],
'
name
'
:
c
[
'
customer
'
][
'
name
'
]
}
for
c
in
v
]
for
k
,
v
in
groupby
(
relations
,
key
=
itemgetter
(
'
circuitid
'
))}
groupby
(
relations
,
key
=
itemgetter
(
'
circuitid
'
))}
def
get_port_id_services
(
ds
:
IMS
):
...
...
@@ -211,7 +211,7 @@ def get_port_id_services(ds: IMS):
'
id
'
:
circuit
[
'
id
'
],
'
name
'
:
circuit
[
'
name
'
],
'
status
'
:
IMS_OPSDB_STATUS_MAP
.
get
(
InventoryStatus
(
circuit
[
'
inventorystatusid
'
]),
'
unknown
'
),
InventoryStatus
(
circuit
[
'
inventorystatusid
'
]),
'
unknown
'
),
'
circuit_type
'
:
circuit
[
'
circuit_type
'
],
'
service_type
'
:
products
[
circuit
[
'
productid
'
]],
'
project
'
:
customers
[
circuit
[
'
customerid
'
]],
...
...
@@ -284,6 +284,16 @@ def get_port_details(ds: IMS):
ims
.
PORT_PROPERTIES
[
'
Shelf
'
]
}
_port_sids
=
{
p
[
'
objectid
'
]:
p
[
'
value
'
]
for
p
in
ds
.
get_filtered_entities
(
'
ExtraFieldValue
'
,
'
extrafieldid == 3249 | value <>
""'
,
step_count
=
10000
)}
_internal_port_sids
=
{
p
[
'
objectid
'
]:
p
[
'
value
'
]
for
p
in
ds
.
get_filtered_entities
(
'
ExtraFieldValue
'
,
'
extrafieldid == 3250 | value <>
""'
,
step_count
=
10000
)}
# this is here instead of chaining to make debugging easier
def
_process_ports
(
ports
,
p_type
):
for
p
in
ports
:
...
...
@@ -304,11 +314,22 @@ def get_port_details(ds: IMS):
if
not
interface_name
:
interface_name
=
p
[
'
name
'
]
data
=
{
'
port_id
'
:
p
[
'
id
'
],
'
equipment_name
'
:
p
[
'
node
'
][
'
name
'
],
'
interface_name
'
:
interface_name
}
_port_sid
=
None
if
p_type
==
'
internal
'
and
p
[
'
id
'
]
in
_internal_port_sids
:
_port_sid
=
_internal_port_sids
[
p
[
'
id
'
]]
elif
p_type
==
'
external
'
and
p
[
'
id
'
]
in
_port_sids
:
_port_sid
=
_port_sids
.
get
(
p
[
'
id
'
])
if
_port_sid
is
not
None
:
data
[
'
sid
'
]
=
_port_sid
yield
data
yield
from
_process_ports
(
ds
.
get_all_entities
(
...
...
@@ -477,8 +498,8 @@ def lookup_lg_routers(ds: IMS):
pass
# no alias - ignore silently
eq
=
{
'
equipment name
'
:
node
[
'
name
'
],
'
type
'
:
'
equipment name
'
:
node
[
'
name
'
],
'
type
'
:
'
INTERNAL
'
if
site
[
'
name
'
]
in
INTERNAL_POP_NAMES
else
'
CORE
'
,
...
...
@@ -490,8 +511,8 @@ def lookup_lg_routers(ds: IMS):
'
abbreviation
'
:
abbreviation
,
'
longitude
'
:
site
[
'
longitude
'
],
'
latitude
'
:
site
[
'
latitude
'
],
}
}
}
yield
eq
...
...
This diff is collapsed.
Click to expand it.
inventory_provider/tasks/worker.py
+
35
−
23
View file @
187be507
...
...
@@ -78,8 +78,8 @@ class InventoryTask(Task):
with
open
(
os
.
environ
[
'
INVENTORY_PROVIDER_CONFIG_FILENAME
'
])
as
f
:
logging
.
info
(
"
Initializing worker with config from: %r
"
%
os
.
environ
[
'
INVENTORY_PROVIDER_CONFIG_FILENAME
'
])
"
Initializing worker with config from: %r
"
%
os
.
environ
[
'
INVENTORY_PROVIDER_CONFIG_FILENAME
'
])
InventoryTask
.
config
=
config
.
load
(
f
)
logging
.
debug
(
"
loaded config: %r
"
%
InventoryTask
.
config
)
...
...
@@ -1038,29 +1038,41 @@ def transform_ims_data(data):
f
"
{
circ
[
'
equipment
'
]
}
/
{
circ
[
'
other_end_equipment
'
]
}
"
][
circ
[
'
id
'
]]
=
circ
sid
=
None
if
circ
[
'
id
'
]
in
circuit_ids_and_sids
:
sid
=
circuit_ids_and_sids
[
circ
[
'
id
'
]]
circ
[
'
sid
'
]
=
sid
if
circ
[
'
circuit_type
'
]
==
'
circuit
'
:
logger
.
info
(
f
'
SID (
{
sid
}
) Circuit (
{
circ
[
"
id
"
]
}
)
'
f
'
Name (
{
circ
[
"
name
"
]
}
) not a service
'
)
else
:
sid_info
=
{
'
circuit_id
'
:
circ
[
'
id
'
],
'
sid
'
:
sid
,
'
status
'
:
circ
[
'
original_status
'
],
'
monitored
'
:
circ
[
'
monitored
'
],
'
name
'
:
circ
[
'
name
'
],
'
speed
'
:
circ
[
'
calculated-speed
'
],
'
service_type
'
:
circ
[
'
service_type
'
],
'
project
'
:
circ
[
'
project
'
],
'
customer
'
:
circ
[
'
customer
'
],
'
equipment
'
:
circ
[
'
equipment
'
],
'
port
'
:
circ
[
'
port
'
],
'
geant_equipment
'
:
circ
[
'
equipment
'
]
in
geant_nodes
}
if
sid_info
not
in
sid_services
[
sid
]:
sid_services
[
sid
].
append
(
sid_info
)
elif
'
sid
'
in
details
:
if
len
(
circuits
)
>
1
:
# we don't know which circuit
# to give the SID in this case, so skip
continue
sid
=
details
[
'
sid
'
]
if
sid
is
None
:
continue
circ
[
'
sid
'
]
=
sid
# if circ['circuit_type'] == 'circuit':
# logger.info(f'SID ({sid}) Circuit ({circ["id"]})'
# f' Name ({circ["name"]}) not a service')
# else:
sid_info
=
{
'
circuit_id
'
:
circ
[
'
id
'
],
'
sid
'
:
sid
,
'
status
'
:
circ
[
'
original_status
'
],
'
monitored
'
:
circ
[
'
monitored
'
],
'
name
'
:
circ
[
'
name
'
],
'
speed
'
:
circ
[
'
calculated-speed
'
],
'
service_type
'
:
circ
[
'
service_type
'
],
'
project
'
:
circ
[
'
project
'
],
'
customer
'
:
circ
[
'
customer
'
],
'
equipment
'
:
circ
[
'
equipment
'
],
'
port
'
:
circ
[
'
port
'
],
'
geant_equipment
'
:
circ
[
'
equipment
'
]
in
geant_nodes
}
if
sid_info
not
in
sid_services
[
sid
]:
sid_services
[
sid
].
append
(
sid_info
)
interface_services
[
k
].
extend
(
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