summaryrefslogtreecommitdiffstats
path: root/src/lib/Server/Admin
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2009-03-02 04:05:06 +0000
committerNarayan Desai <desai@mcs.anl.gov>2009-03-02 04:05:06 +0000
commit1e3f8604797459a1cb45db617958256557cde9d8 (patch)
treefcfb160553e87f92ab7e62758961e436023424cb /src/lib/Server/Admin
parent795301a3646637aa3a8a1cd8a46863d76422e2ee (diff)
downloadbcfg2-1e3f8604797459a1cb45db617958256557cde9d8.tar.gz
bcfg2-1e3f8604797459a1cb45db617958256557cde9d8.tar.bz2
bcfg2-1e3f8604797459a1cb45db617958256557cde9d8.zip
Snapshots update - storage of packages works from clients (old-style statistics)
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5092 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/Server/Admin')
-rw-r--r--src/lib/Server/Admin/Snapshots.py29
-rw-r--r--src/lib/Server/Admin/__init__.py2
2 files changed, 30 insertions, 1 deletions
diff --git a/src/lib/Server/Admin/Snapshots.py b/src/lib/Server/Admin/Snapshots.py
new file mode 100644
index 000000000..17db0af62
--- /dev/null
+++ b/src/lib/Server/Admin/Snapshots.py
@@ -0,0 +1,29 @@
+import Bcfg2.Server.Admin
+import sqlalchemy, sqlalchemy.orm
+import Bcfg2.Server.Snapshots
+import Bcfg2.Server.Snapshots.model
+
+class Snapshots(Bcfg2.Server.Admin.Mode):
+ __shorthelp__ = "Interact with the Snapshots system"
+ __longhelp__ = (__shorthelp__)
+ __usage__ = ("bcfg2-admin snapshots [init|query qtype] ")
+
+ q_dispatch = {'client':Bcfg2.Server.Snapshots.model.Client,
+ 'group':Bcfg2.Server.Snapshots.model.Group,
+ 'snapshot':Bcfg2.Server.Snapshots.model.Snapshot,
+ }
+
+ def __init__(self, configfile):
+ Bcfg2.Server.Admin.Mode.__init__(self, configfile)
+ self.session = Bcfg2.Server.Snapshots.setup_session(debug=True)
+
+ def __call__(self, args):
+ if args[0] == 'query':
+ if args[1] in self.q_dispatch:
+ q_obj = self.q_dispatch[args[1]]
+ results = self.session.query(q_obj).all()
+ else:
+ print 'error'
+ raise SystemExit, 1
+ for result in results:
+ print result.name
diff --git a/src/lib/Server/Admin/__init__.py b/src/lib/Server/Admin/__init__.py
index 075822a56..e92020e5d 100644
--- a/src/lib/Server/Admin/__init__.py
+++ b/src/lib/Server/Admin/__init__.py
@@ -1,7 +1,7 @@
__revision__ = '$Revision$'
__all__ = ['Mode', 'Client', 'Compare', 'Fingerprint', 'Init', 'Minestruct',
- 'Pull', 'Query', 'Tidy', 'Viz']
+ 'Pull', 'Query', 'Snapshots', 'Tidy', 'Viz']
import ConfigParser, lxml.etree, logging, sys
import Bcfg2.Server.Core