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

use db.get_redis

parent 57cffe85
No related branches found
No related tags found
No related merge requests found
import functools import functools
from flask import request, Response, current_app from flask import request, Response
import redis
def require_accepts_json(f): def require_accepts_json(f):
...@@ -21,14 +20,3 @@ def require_accepts_json(f): ...@@ -21,14 +20,3 @@ def require_accepts_json(f):
mimetype="text/html") mimetype="text/html")
return f(*args, **kwargs) return f(*args, **kwargs)
return decorated_function return decorated_function
def redis_connection():
"""
just a common place for acquiring a redis connection
:return: a redis connection
"""
redis_config = current_app.config["INVENTORY_PROVIDER_CONFIG"]["redis"]
return redis.StrictRedis(
host=redis_config["hostname"],
port=redis_config["port"])
...@@ -2,6 +2,7 @@ import json ...@@ -2,6 +2,7 @@ import json
from flask import Blueprint, Response, jsonify from flask import Blueprint, Response, jsonify
from lxml import etree from lxml import etree
from inventory_provider import db
from inventory_provider import juniper from inventory_provider import juniper
from inventory_provider.routes import common from inventory_provider.routes import common
...@@ -11,7 +12,7 @@ routes = Blueprint('poller-support-routes', __name__) ...@@ -11,7 +12,7 @@ routes = Blueprint('poller-support-routes', __name__)
@routes.route('/interfaces/<hostname>', methods=['GET', 'POST']) @routes.route('/interfaces/<hostname>', methods=['GET', 'POST'])
@common.require_accepts_json @common.require_accepts_json
def poller_interface_oids(hostname): def poller_interface_oids(hostname):
r = common.redis_connection() r = db.get_redis()
netconf_string = r.hget(hostname, 'netconf') netconf_string = r.hget(hostname, 'netconf')
if not netconf_string: if not netconf_string:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment