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
9599a175
Commit
9599a175
authored
4 years ago
by
Robert Latta
Browse files
Options
Downloads
Patches
Plain Diff
added job to update redis ims:interface_service info
parent
84d0c1cc
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
inventory_provider/tasks/ims_worker.py
+36
-0
36 additions, 0 deletions
inventory_provider/tasks/ims_worker.py
with
36 additions
and
0 deletions
inventory_provider/tasks/ims_worker.py
+
36
−
0
View file @
9599a175
...
...
@@ -3,6 +3,7 @@ import json
import
logging
import
subprocess
import
tempfile
from
collections
import
defaultdict
from
datetime
import
datetime
from
enum
import
IntFlag
from
pathlib
import
Path
...
...
@@ -21,6 +22,41 @@ environment.setup_logging()
logger
=
logging
.
getLogger
(
__name__
)
@app.task
(
base
=
InventoryTask
,
bind
=
True
,
name
=
'
update_interfaces_to_services_ims
'
)
@log_task_entry_and_exit
def
update_interfaces_to_services_ims
(
self
,
use_current
=
False
):
interface_services
=
defaultdict
(
list
)
c
=
InventoryTask
.
config
[
"
ims
"
]
ds
=
IMS
(
c
[
'
api
'
],
c
[
'
username
'
],
c
[
'
password
'
])
for
service
in
ims_data
.
get_interface_services
(
ds
):
equipment_interface
=
'
%s:%s
'
%
(
service
[
'
equipment
'
],
service
[
'
interface_name
'
])
interface_services
[
equipment_interface
].
append
(
service
)
if
use_current
:
r
=
get_current_redis
(
InventoryTask
.
config
)
# scan with bigger batches, to mitigate network latency effects
else
:
r
=
get_next_redis
(
InventoryTask
.
config
)
rp
=
r
.
pipeline
()
# scan with bigger batches, to mitigate network latency effects
for
key
in
r
.
scan_iter
(
'
ims:interface_services:*
'
,
count
=
1000
):
rp
.
delete
(
key
)
rp
.
execute
()
rp
=
r
.
pipeline
()
for
equipment_interface
,
services
in
interface_services
.
items
():
rp
.
set
(
f
'
ims:interface_services:
{
equipment_interface
}
'
,
json
.
dumps
(
services
))
rp
.
execute
()
@app.task
(
base
=
InventoryTask
,
bind
=
True
,
name
=
'
update_circuit_hierarchy_ims
'
)
@log_task_entry_and_exit
def
update_circuit_hierarchy_ims
(
self
,
use_current
=
False
):
...
...
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