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
dd0b9965
Commit
dd0b9965
authored
6 years ago
by
Erik Reid
Browse files
Options
Downloads
Patches
Plain Diff
move static methods out of InventoryTask
parent
ce2fdfdf
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/tasks/worker.py
+19
-35
19 additions, 35 deletions
inventory_provider/tasks/worker.py
with
19 additions
and
35 deletions
inventory_provider/tasks/worker.py
+
19
−
35
View file @
dd0b9965
...
...
@@ -31,39 +31,23 @@ class InventoryTask(Task):
def
__init__
(
self
):
pass
# @staticmethod
# def save_key(hostname, key, value):
# assert isinstance(value, str), \
# "sanity failure: expected string data as value"
# r = get_redis(InventoryTask.config)
# r.hset(
# name=hostname,
# key=key,
# value=value)
# InventoryTask.logger.debug(
# "saved %s, key %s" % (hostname, key))
# return "OK"
@staticmethod
def
save_value
(
key
,
value
):
assert
isinstance
(
value
,
str
),
\
"
sanity failure: expected string data as value
"
r
=
get_redis
(
InventoryTask
.
config
)
r
.
set
(
name
=
key
,
value
=
value
)
# InventoryTask.logger.debug("saved %s" % key)
return
"
OK
"
def
_save_value
(
key
,
value
):
assert
isinstance
(
value
,
str
),
\
"
sanity failure: expected string data as value
"
r
=
get_redis
(
InventoryTask
.
config
)
r
.
set
(
name
=
key
,
value
=
value
)
# InventoryTask.logger.debug("saved %s" % key)
return
"
OK
"
@staticmethod
def
save_value_json
(
key
,
data_obj
):
InventoryTask
.
save_value
(
key
,
json
.
dumps
(
data_obj
))
def
_save_value_json
(
key
,
data_obj
):
_save_value
(
key
,
json
.
dumps
(
data_obj
))
@staticmethod
def
save_value_etree
(
key
,
xml_doc
):
InventoryTask
.
save_value
(
key
,
etree
.
tostring
(
xml_doc
,
encoding
=
'
unicode
'
))
def
_save_value_etree
(
key
,
xml_doc
):
_save_value
(
key
,
etree
.
tostring
(
xml_doc
,
encoding
=
'
unicode
'
))
class
WorkerArgs
(
bootsteps
.
Step
):
...
...
@@ -94,7 +78,7 @@ def snmp_refresh_interfaces(hostname, community):
task_logger
.
debug
(
'
>>> snmp_refresh_interfaces(%r, %r)
'
%
(
hostname
,
community
))
InventoryTask
.
save_value_json
(
_
save_value_json
(
'
snmp-interfaces:
'
+
hostname
,
list
(
snmp
.
get_router_interfaces
(
hostname
,
...
...
@@ -110,7 +94,7 @@ def netconf_refresh_config(hostname):
task_logger
=
logging
.
getLogger
(
constants
.
TASK_LOGGER_NAME
)
task_logger
.
debug
(
'
>>> netconf_refresh_config(%r)
'
%
hostname
)
InventoryTask
.
save_value_etree
(
_
save_value_etree
(
'
netconf:
'
+
hostname
,
juniper
.
load_config
(
hostname
,
InventoryTask
.
config
[
"
ssh
"
]))
...
...
@@ -200,7 +184,7 @@ def update_interface_statuses():
csr
,
service
[
"
equipment
"
],
service
[
"
interface_name
"
])
InventoryTask
.
save_value
(
key
,
status
)
_
save_value
(
key
,
status
)
task_logger
.
debug
(
'
<<< update_interface_statuses
'
)
...
...
@@ -279,7 +263,7 @@ def refresh_vpn_rr_peers(hostname, netconf):
juniper
.
vpn_rr_peers
(
netconf
))
@app.task
@app.task
(
base
=
ReleaseTask
,
bind
=
True
))
def
reload_router_config
(
hostname
):
task_logger
=
logging
.
getLogger
(
constants
.
TASK_LOGGER_NAME
)
task_logger
.
debug
(
'
>>> update_router_config
'
)
...
...
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