diff options
-rw-r--r-- | src/lib/Component.py | 8 | ||||
-rw-r--r-- | src/lib/Server/Admin/Snapshots.py | 5 | ||||
-rw-r--r-- | src/lib/Server/Core.py | 4 | ||||
-rw-r--r-- | src/lib/Server/Plugins/Snapshots.py | 2 | ||||
-rw-r--r-- | src/lib/Server/Snapshots/__init__.py | 8 | ||||
-rwxr-xr-x | src/sbin/bcfg2-server | 1 |
6 files changed, 16 insertions, 12 deletions
diff --git a/src/lib/Component.py b/src/lib/Component.py index 727952c6f..33ed635af 100644 --- a/src/lib/Component.py +++ b/src/lib/Component.py @@ -24,9 +24,9 @@ class NoExposedMethod (Exception): """There is no method exposed with the given name.""" def run_component(component_cls, location, daemon, pidfile_name, to_file, - argv=None, register=True, state_name=False, cls_kwargs={}, - extra_getopt='', time_out=10, protocol='xmlrpc/ssl', - certfile=None, keyfile=None, ca=None): + cfile='/etc/bcfg2.conf', argv=None, register=True, + state_name=False, cls_kwargs={}, extra_getopt='', time_out=10, + protocol='xmlrpc/ssl', certfile=None, keyfile=None, ca=None): # default settings level = logging.INFO @@ -59,7 +59,7 @@ def run_component(component_cls, location, daemon, pidfile_name, to_file, print >> pidfile, os.getpid() pidfile.close() - component = component_cls(**cls_kwargs) + component = component_cls(cfile=cfile, **cls_kwargs) up = urlparse.urlparse(location) port = tuple(up[1].split(':')) port = (port[0], int(port[1])) diff --git a/src/lib/Server/Admin/Snapshots.py b/src/lib/Server/Admin/Snapshots.py index a68dec30d..004de0ddb 100644 --- a/src/lib/Server/Admin/Snapshots.py +++ b/src/lib/Server/Admin/Snapshots.py @@ -23,7 +23,8 @@ class Snapshots(Bcfg2.Server.Admin.Mode): def __init__(self, configfile): Bcfg2.Server.Admin.Mode.__init__(self, configfile) #self.session = Bcfg2.Server.Snapshots.setup_session(debug=True) - self.session = Bcfg2.Server.Snapshots.setup_session() + self.session = Bcfg2.Server.Snapshots.setup_session(configfile) + self.cfile = configfile def __call__(self, args): Bcfg2.Server.Admin.Mode.__call__(self, args) @@ -59,7 +60,7 @@ class Snapshots(Bcfg2.Server.Admin.Mode): raise SystemExit(1) elif args[0] == 'init': # Initialize the Snapshots database - dbpath = Bcfg2.Server.Snapshots.db_from_config() + dbpath = Bcfg2.Server.Snapshots.db_from_config(self.cfile) engine = sqlalchemy.create_engine(dbpath, echo=True) metadata = Base.metadata metadata.create_all(engine) diff --git a/src/lib/Server/Core.py b/src/lib/Server/Core.py index efb6f10a3..712c87c8e 100644 --- a/src/lib/Server/Core.py +++ b/src/lib/Server/Core.py @@ -36,7 +36,8 @@ class Core(Component): name = 'bcfg2-server' implementation = 'bcfg2-server' - def __init__(self, repo, plugins, password, encoding, ca=None, + def __init__(self, repo, plugins, password, encoding, + cfile='/etc/bcfg2.conf', ca=None, filemonitor='default', start_fam_thread=False): Component.__init__(self) self.datastore = repo @@ -51,6 +52,7 @@ class Core(Component): raise CoreInitError, "failed to instantiate fam driver (used %s)" % \ filemonitor self.pubspace = {} + self.cfile = cfile self.cron = {} self.plugins = {} self.revision = '-1' diff --git a/src/lib/Server/Plugins/Snapshots.py b/src/lib/Server/Plugins/Snapshots.py index 5ee1e6d62..a4489ae95 100644 --- a/src/lib/Server/Plugins/Snapshots.py +++ b/src/lib/Server/Plugins/Snapshots.py @@ -65,7 +65,7 @@ class Snapshots(Bcfg2.Server.Plugin.Statistics, def __init__(self, core, datastore): Bcfg2.Server.Plugin.Plugin.__init__(self, core, datastore) Bcfg2.Server.Plugin.Statistics.__init__(self) - self.session = Bcfg2.Server.Snapshots.setup_session() + self.session = Bcfg2.Server.Snapshots.setup_session(core.cfile) self.work_queue = Queue.Queue() self.loader = threading.Thread(target=self.load_snapshot) self.loader.start() diff --git a/src/lib/Server/Snapshots/__init__.py b/src/lib/Server/Snapshots/__init__.py index c13dee42e..6018377cb 100644 --- a/src/lib/Server/Snapshots/__init__.py +++ b/src/lib/Server/Snapshots/__init__.py @@ -5,9 +5,9 @@ import sqlalchemy.orm import ConfigParser -def db_from_config(fname='/etc/bcfg2.conf'): +def db_from_config(cfile): cp = ConfigParser.ConfigParser() - cp.read([fname]) + cp.read([cfile]) driver = cp.get('snapshots', 'driver') if driver == 'sqlite': path = cp.get('snapshots', 'database') @@ -22,8 +22,8 @@ def db_from_config(fname='/etc/bcfg2.conf'): raise Exception, "unsupported db driver %s" % driver -def setup_session(debug=False): - engine = sqlalchemy.create_engine(db_from_config(), +def setup_session(cfile, debug=False): + engine = sqlalchemy.create_engine(db_from_config(cfile), echo=debug) Session = sqlalchemy.orm.sessionmaker() Session.configure(bind=engine) diff --git a/src/sbin/bcfg2-server b/src/sbin/bcfg2-server index a19c5ba3f..5c058bc2a 100755 --- a/src/sbin/bcfg2-server +++ b/src/sbin/bcfg2-server @@ -51,6 +51,7 @@ if __name__ == '__main__': pidfile_name = setup['daemon'], protocol = setup['protocol'], to_file=setup['to_file'], + cfile=setup['configfile'], register=False, cls_kwargs={'repo':setup['repo'], 'plugins':setup['plugins'], |