summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Reporting/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/Bcfg2/Reporting/models.py')
-rw-r--r--src/lib/Bcfg2/Reporting/models.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/lib/Bcfg2/Reporting/models.py b/src/lib/Bcfg2/Reporting/models.py
index 71fa66086..ae6f6731b 100644
--- a/src/lib/Bcfg2/Reporting/models.py
+++ b/src/lib/Bcfg2/Reporting/models.py
@@ -3,7 +3,7 @@ import sys
from django.core.exceptions import ImproperlyConfigured
try:
- from django.db import models, backend, connection
+ from django.db import models, backend, connections
except ImproperlyConfigured:
e = sys.exc_info()[1]
print("Reports: unable to import django models: %s" % e)
@@ -12,6 +12,7 @@ except ImproperlyConfigured:
from django.core.cache import cache
from datetime import datetime, timedelta
from Bcfg2.Compat import cPickle
+from Bcfg2.DBSettings import get_db_label
TYPE_GOOD = 0
@@ -61,7 +62,8 @@ def _quote(value):
global _our_backend
if not _our_backend:
try:
- _our_backend = backend.DatabaseOperations(connection)
+ _our_backend = backend.DatabaseOperations(
+ connections[get_db_label('Reporting')])
except TypeError:
_our_backend = backend.DatabaseOperations()
return _our_backend.quote_name(value)
@@ -91,8 +93,8 @@ class InteractionManager(models.Manager):
maxdate -- datetime object. Most recent date to pull. (default None)
"""
- from django.db import connection
- cursor = connection.cursor()
+ from django.db import connections
+ cursor = connections[get_db_label('Reporting')].cursor()
cfilter = "expiration is null"
sql = 'select ri.id, x.client_id from ' + \
@@ -381,7 +383,7 @@ class BaseEntry(models.Model):
@classmethod
def entry_from_type(cls, etype):
- for entry_cls in ENTRY_CLASSES:
+ for entry_cls in ENTRY_TYPES:
if etype == entry_cls.ENTRY_TYPE:
return entry_cls
else: