Skip to content
Snippets Groups Projects
Commit dd0b9965 authored by Erik Reid's avatar Erik Reid
Browse files

move static methods out of InventoryTask

parent ce2fdfdf
No related branches found
No related tags found
No related merge requests found
......@@ -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')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment