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
from flask import request, Response, current_app
import redis
from flask import request, Response
def require_accepts_json(f):
......@@ -21,14 +20,3 @@ def require_accepts_json(f):
mimetype="text/html")
return f(*args, **kwargs)
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
from flask import Blueprint, Response, jsonify
from lxml import etree
from inventory_provider import db
from inventory_provider import juniper
from inventory_provider.routes import common
......@@ -11,7 +12,7 @@ routes = Blueprint('poller-support-routes', __name__)
@routes.route('/interfaces/<hostname>', methods=['GET', 'POST'])
@common.require_accepts_json
def poller_interface_oids(hostname):
r = common.redis_connection()
r = db.get_redis()
netconf_string = r.hget(hostname, 'netconf')
if not netconf_string:
......
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