summaryrefslogtreecommitdiffstats
path: root/src/lib/Server
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/Server')
-rw-r--r--src/lib/Server/Admin/Init.py26
-rw-r--r--src/lib/Server/Admin/__init__.py25
-rw-r--r--src/lib/Server/Core.py30
-rw-r--r--src/lib/Server/Plugins/Metadata.py4
4 files changed, 54 insertions, 31 deletions
diff --git a/src/lib/Server/Admin/Init.py b/src/lib/Server/Admin/Init.py
index 0a76f44a7..d057fc1ff 100644
--- a/src/lib/Server/Admin/Init.py
+++ b/src/lib/Server/Admin/Init.py
@@ -1,7 +1,6 @@
import os, socket
import Bcfg2.Server.Admin
-
-from Bcfg2.Settings import settings
+import Bcfg2.Options
config = '''
[server]
@@ -69,11 +68,19 @@ os_list = [('Redhat/Fedora/RHEL/RHAS/Centos', 'redhat'),
class Init(Bcfg2.Server.Admin.Mode):
__shorthelp__ = 'bcfg2-admin init'
__longhelp__ = __shorthelp__ + '\n\tCompare two client specifications or directories of specifications'
+ options = {'repo': Bcfg2.Options.SERVER_REPOSITORY,
+ 'struct': Bcfg2.Options.SERVER_STRUCTURES,
+ 'gens': Bcfg2.Options.SERVER_GENERATORS,
+ 'proto': Bcfg2.Options.SERVER_PROTOCOL,
+ 'sendmail': Bcfg2.Options.SENDMAIL_PATH}
+
def __call__(self, args):
Bcfg2.Server.Admin.Mode.__call__(self, args)
- repopath = raw_input( "location of bcfg2 repository [%s]: " % settings.SERVER_REPOSITORY )
+ opts = Bcfg2.Options.OptionParser(options)
+ opts.parse([])
+ repopath = raw_input("location of bcfg2 repository [%s]: " % opts['repo'])
if repopath == '':
- repopath = settings.SERVER_REPOSITORY
+ repopath = opts['repo']
password = ''
while ( password == '' ):
password = raw_input(
@@ -88,18 +95,15 @@ class Init(Bcfg2.Server.Admin.Mode):
prompt += "%d: \n" % (os_list.index(entry) + 1, entry[0])
prompt += ': '
os_sel = os_list[int(raw_input(prompt))-1][1]
- self.initializeRepo(repopath, server, password, os_sel)
+ self.initializeRepo(repopath, server, password, os_sel, opts)
print "Repository created successfuly in %s" % (repopath)
- def initializeRepo(self, repo, server_uri, password, os_selection):
+ def initializeRepo(self, repo, server_uri, password, os_selection, opts):
'''Setup a new repo'''
keypath = os.path.dirname(os.path.abspath(settings.CONFIG_FILE))
confdata = config % (
- repo,
- settings.SERVER_STRUCTURES,
- settings.SERVER_GENERATORS,
- settings.SENDMAIL_PATH,
- settings.COMMUNICATION_PROTOCOL,
+ repo, opts['struct'], opts['gens'],
+ opts['sendmail'], opts['proto']
password, keypath, server_uri
)
diff --git a/src/lib/Server/Admin/__init__.py b/src/lib/Server/Admin/__init__.py
index dcab5876f..57b9d2a86 100644
--- a/src/lib/Server/Admin/__init__.py
+++ b/src/lib/Server/Admin/__init__.py
@@ -4,27 +4,40 @@ __all__ = ['Mode', 'Client', 'Compare', 'Fingerprint', 'Init', 'Minestruct',
'Pull', 'Tidy', 'Viz']
import ConfigParser, lxml.etree, logging
-from Bcfg2.Settings import settings
class Mode(object):
'''Help message has not yet been added for mode'''
__shorthelp__ = 'Shorthelp not defined yet'
__longhelp__ = 'Longhelp not defined yet'
__args__ = []
-
- def __init__(self):
+ def __init__(self, configfile):
+ self.configfile = configfile
+ self.__cfp = False
self.log = logging.getLogger('Bcfg2.Server.Admin.Mode')
- self.repo_path = settings.SERVER_REPOSITORY
+
+ def getCFP(self):
+ if not self.__cfp:
+ self.__cfp = ConfigParser.ConfigParser()
+ self.__cfp.read(self.configfile)
+ return self.__cfp
+
+ cfp = property(getCFP)
def __call__(self, args):
- return
+ if args[0] == 'help':
+ print self.__longhelp__
+ raise SystemExit(0)
def errExit(self, emsg):
print emsg
raise SystemExit(1)
+ def get_repo_path(self):
+ '''return repository path'''
+ return self.cfp.get('server', 'repository')
+
def load_stats(self, client):
- stats = lxml.etree.parse("%s/etc/statistics.xml" % (self.repo_path))
+ stats = lxml.etree.parse("%s/etc/statistics.xml" % (self.get_repo_path()))
hostent = stats.xpath('//Node[@name="%s"]' % client)
if not hostent:
self.errExit("Could not find stats for client %s" % (client))
diff --git a/src/lib/Server/Core.py b/src/lib/Server/Core.py
index 7e347bc23..56f4087dd 100644
--- a/src/lib/Server/Core.py
+++ b/src/lib/Server/Core.py
@@ -4,11 +4,12 @@ __revision__ = '$Revision$'
from time import time
from Bcfg2.Server.Plugin import PluginInitError, PluginExecutionError
from Bcfg2.Server.Statistics import Statistics
-from Bcfg2.Settings import settings
-import logging, lxml.etree, os, stat, ConfigParser
+import logging, lxml.etree, os, stat
import Bcfg2.Server.Plugins.Metadata
+import Bcfg2.Options
+
logger = logging.getLogger('Bcfg2.Core')
def ShouldIgnore(event):
@@ -199,9 +200,18 @@ except ImportError:
class Core(object):
'''The Core object is the container for all Bcfg2 Server logic, and modules'''
+ options = {'repo': Bcfg2.Options.SERVER_REPOSITORY,
+ 'svn': Bcfg2.Options.SERVER_SVN,
+ 'structures': Bcfg2.Options.SERVER_STRUCTURES,
+ 'generators': Bcfg2.Options.SERVER_GENERATORS,
+ 'password': Bcfg2.Options.SERVER_PASSWORD}
+
def __init__(self):
object.__init__(self)
- self.datastore = settings.SERVER_REPOSITORY
+ opts = Bcfg2.Options.OptionParser(self.options)
+ opts.parse([])
+ self.datastore = opts['repo']
+ self.opts = opts
try:
self.fam = monitor()
except IOError:
@@ -213,19 +223,17 @@ class Core(object):
self.plugins = {}
self.revision = '-1'
+ self.svn = opts['svn']
try:
- if settings.SERVER_SVN:
+ if self.svn:
self.read_svn_revision()
except:
- settings.SERVER_SVN = False
-
- self.svn = settings.SERVER_SVN
+ self.svn = False
- mpath = settings.SERVER_REPOSITORY
- self.stats = Statistics("%s/etc/statistics.xml" % (mpath))
+ self.stats = Statistics("%s/etc/statistics.xml" % (self.datastore))
- structures = settings.SERVER_STRUCTURES
- generators = settings.SERVER_GENERATORS
+ structures = opts['structures']
+ generators = opts['generators']
[data.remove('') for data in [structures, generators] if '' in data]
for plugin in structures + generators + ['Metadata']:
diff --git a/src/lib/Server/Plugins/Metadata.py b/src/lib/Server/Plugins/Metadata.py
index 5f3262ec0..9e991251b 100644
--- a/src/lib/Server/Plugins/Metadata.py
+++ b/src/lib/Server/Plugins/Metadata.py
@@ -1,8 +1,6 @@
'''This file stores persistent metadata for the BCFG Configuration Repository'''
__revision__ = '$Revision$'
-from Bcfg2.Settings import settings
-
import lxml.etree, re, socket, time, sys
import Bcfg2.Server.Plugin
@@ -69,7 +67,7 @@ class Metadata(Bcfg2.Server.Plugin.Plugin):
self.ptimes = {}
self.pctime = 0
self.extra = {'groups.xml':[], 'clients.xml':[]}
- self.password = settings.COMMUNICATION_PASSWORD
+ self.password = core.opts['password']
def HandleEvent(self, event):
'''Handle update events for data files'''