summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Server/Admin/Syncdb.py
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2012-07-30 10:24:12 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2012-07-30 10:24:12 -0400
commit8b438fda3ae2d9516dbfb6014c280b68036c17e1 (patch)
treeb8acb22b313e4b57797a227b42f69b95b54bd976 /src/lib/Bcfg2/Server/Admin/Syncdb.py
parent7a008a0b1b4d3b819da5a6544ac15faab3cbb28a (diff)
downloadbcfg2-8b438fda3ae2d9516dbfb6014c280b68036c17e1.tar.gz
bcfg2-8b438fda3ae2d9516dbfb6014c280b68036c17e1.tar.bz2
bcfg2-8b438fda3ae2d9516dbfb6014c280b68036c17e1.zip
Metadata and other improvements:
* Added support for Client tag in groups.xml * Added support for nested Group tags in groups.xml * Added support for negated groups in groups.xml * Added DatabaseBacked plugin mixin to easily allow plugins to connect to a database specified in global database settings in bcfg2.conf * Added DBMetadata plugin that uses relational DB to store client records instead of writing to clients.xml
Diffstat (limited to 'src/lib/Bcfg2/Server/Admin/Syncdb.py')
-rw-r--r--src/lib/Bcfg2/Server/Admin/Syncdb.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/lib/Bcfg2/Server/Admin/Syncdb.py b/src/lib/Bcfg2/Server/Admin/Syncdb.py
new file mode 100644
index 000000000..73dc5b8b2
--- /dev/null
+++ b/src/lib/Bcfg2/Server/Admin/Syncdb.py
@@ -0,0 +1,33 @@
+import Bcfg2.settings
+import Bcfg2.Options
+import Bcfg2.Server.Admin
+from django.core.management import setup_environ
+
+class Syncdb(Bcfg2.Server.Admin.Mode):
+ __shorthelp__ = ("Sync the Django ORM with the configured database")
+ __longhelp__ = __shorthelp__ + "\n\nbcfg2-admin syncdb"
+ __usage__ = "bcfg2-admin syncdb"
+ options = {'configfile': Bcfg2.Options.CFILE,
+ 'repo': Bcfg2.Options.SERVER_REPOSITORY}
+
+ def __call__(self, args):
+ Bcfg2.Server.Admin.Mode.__call__(self, args)
+
+ # Parse options
+ self.opts = Bcfg2.Options.OptionParser(self.options)
+ self.opts.parse(args)
+
+ # we have to set up the django environment before we import
+ # the syncdb command, but we have to wait to set up the
+ # environment until we've read the config, which has to wait
+ # until we've parsed options. it's a windy, twisting road.
+ Bcfg2.settings.read_config(cfile=self.opts['configfile'],
+ repo=self.opts['repo'])
+ setup_environ(Bcfg2.settings)
+ import Bcfg2.Server.models
+ Bcfg2.Server.models.load_models(cfile=self.opts['configfile'])
+
+ from django.core.management.commands import syncdb
+
+ cmd = syncdb.Command()
+ cmd.handle_noargs(interactive=False)