summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Server/Plugin.py
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2012-07-31 09:12:01 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2012-07-31 09:12:07 -0400
commit111193ef96adb711b1b1b4859291c77197eb8ea8 (patch)
tree6e5fbb39ec3aca1daffc107407fddf58260983b6 /src/lib/Bcfg2/Server/Plugin.py
parent211864073d9254f9d116ee052092f1949775f544 (diff)
downloadbcfg2-111193ef96adb711b1b1b4859291c77197eb8ea8.tar.gz
bcfg2-111193ef96adb711b1b1b4859291c77197eb8ea8.tar.bz2
bcfg2-111193ef96adb711b1b1b4859291c77197eb8ea8.zip
unified Metadata/DBMetadata plugins
made django optional
Diffstat (limited to 'src/lib/Bcfg2/Server/Plugin.py')
-rw-r--r--src/lib/Bcfg2/Server/Plugin.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/lib/Bcfg2/Server/Plugin.py b/src/lib/Bcfg2/Server/Plugin.py
index 696dacc06..2a68ea3b7 100644
--- a/src/lib/Bcfg2/Server/Plugin.py
+++ b/src/lib/Bcfg2/Server/Plugin.py
@@ -11,9 +11,14 @@ import sys
import threading
import Bcfg2.Server
from Bcfg2.Bcfg2Py3k import ConfigParser
-
import Bcfg2.Options
+try:
+ import django
+ has_django = True
+except ImportError:
+ has_django = False
+
# py3k compatibility
if sys.hexversion >= 0x03000000:
from functools import reduce
@@ -106,6 +111,20 @@ class DatabaseBacked(object):
def __init__(self):
pass
+ @property
+ def _use_db(self):
+ use_db = self.core.setup.cfp.getboolean(self.name.lower(),
+ "use_database",
+ default=False)
+ if use_db and has_django:
+ return True
+ elif not use_db:
+ return False
+ else:
+ self.logger.error("use_database is true but django not found")
+ return False
+
+
class PluginDatabaseModel(object):
class Meta: