From a738db564d19184b61d45fca3985dc285ee03ba8 Mon Sep 17 00:00:00 2001 From: Narayan Desai Date: Fri, 6 Mar 2009 21:13:08 +0000 Subject: Snapshots: Add some convenience functions for getting access to latest snapshot git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5109 ce84e21b-d406-0410-9b95-82705330c041 --- src/lib/Server/Admin/Snapshots.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/lib/Server/Admin/Snapshots.py') diff --git a/src/lib/Server/Admin/Snapshots.py b/src/lib/Server/Admin/Snapshots.py index fc3334c11..13897fcd2 100644 --- a/src/lib/Server/Admin/Snapshots.py +++ b/src/lib/Server/Admin/Snapshots.py @@ -2,15 +2,16 @@ import Bcfg2.Server.Admin import sqlalchemy, sqlalchemy.orm import Bcfg2.Server.Snapshots import Bcfg2.Server.Snapshots.model +from Bcfg2.Server.Snapshots.model import Snapshot, Client, Metadata, Base, Group 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, + q_dispatch = {'client':Client, 'group':Bcfg2.Server.Snapshots.model.Group, - 'snapshot':Bcfg2.Server.Snapshots.model.Snapshot, + 'snapshot':Snapshot, } def __init__(self, configfile): @@ -30,9 +31,12 @@ class Snapshots(Bcfg2.Server.Admin.Mode): elif args[0] == 'init': dbpath = Bcfg2.Server.Snapshots.db_from_config() engine = sqlalchemy.create_engine(dbpath, echo=True) - metadata = Bcfg2.Server.Snapshots.model.Base.metadata + metadata = Base.metadata metadata.create_all(engine) Session = sqlalchemy.orm.sessionmaker() Session.configure(bind=engine) session = Session() session.commit() + elif args[0] == 'dump': + client, etype, ename = args[1:] + snap = Snapshot.get_current(self.session, client) -- cgit v1.2.3-1-g7c22