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

add sanity assertion on redis value type

parent 45245f59
No related branches found
No related tags found
No related merge requests found
import logging
import sys
from inventory_provider import constants
from celery import Celery from celery import Celery
logging.basicConfig(stream=sys.stderr, level=logging.WARNING)
logging.getLogger(constants.SNMP_LOGGER_NAME).setLevel(logging.DEBUG)
logging.getLogger(constants.TASK_LOGGER_NAME).setLevel(logging.DEBUG)
logging.getLogger(constants.JUNIPER_LOGGER_NAME).setLevel(logging.DEBUG)
logging.getLogger(constants.DATABASE_LOGGER_NAME).setLevel(logging.DEBUG)
app = Celery("app") app = Celery("app")
app.config_from_object("inventory_provider.tasks.config") app.config_from_object("inventory_provider.tasks.config")
...@@ -28,6 +28,8 @@ class InventoryTask(Task): ...@@ -28,6 +28,8 @@ class InventoryTask(Task):
@staticmethod @staticmethod
def save_key(hostname, key, value): def save_key(hostname, key, value):
assert isinstance(value, str), \
"sanity failure: expected string data as value"
r = redis.StrictRedis( r = redis.StrictRedis(
host=InventoryTask.config["redis"]["hostname"], host=InventoryTask.config["redis"]["hostname"],
port=InventoryTask.config["redis"]["port"]) port=InventoryTask.config["redis"]["port"])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment