summaryrefslogtreecommitdiffstats
path: root/src/sbin
diff options
context:
space:
mode:
authorRobert Gogolok <gogo@cs.uni-sb.de>2007-12-30 19:26:51 +0000
committerRobert Gogolok <gogo@cs.uni-sb.de>2007-12-30 19:26:51 +0000
commite8c9ba57d10d174c79ac1aae9b53661ee8464d0f (patch)
tree65cb5f7b0c699e6c97eb365ec83c76155a023f7e /src/sbin
parent73ba22f7e519694dbf7010810de69b3b845f634f (diff)
downloadbcfg2-e8c9ba57d10d174c79ac1aae9b53661ee8464d0f.tar.gz
bcfg2-e8c9ba57d10d174c79ac1aae9b53661ee8464d0f.tar.bz2
bcfg2-e8c9ba57d10d174c79ac1aae9b53661ee8464d0f.zip
Settings class to remove redundant code for parsing config file.
If a module wants to access bcfg2 settings: from Bcfg2.Settings import settings git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@4131 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/sbin')
-rwxr-xr-xsrc/sbin/bcfg210
-rwxr-xr-xsrc/sbin/bcfg2-info10
-rwxr-xr-xsrc/sbin/bcfg2-server9
3 files changed, 21 insertions, 8 deletions
diff --git a/src/sbin/bcfg2 b/src/sbin/bcfg2
index a25bab65f..62f2e1775 100755
--- a/src/sbin/bcfg2
+++ b/src/sbin/bcfg2
@@ -78,11 +78,11 @@ class Client:
'setup': (('-C', '<configfile>', "use given config file (default /etc/bcfg2.conf)"),
False, False, '/etc/bcfg2.conf', False),
'server': (('-S', '<server url>', 'the server hostname to connect to'),
- False, ('components', 'bcfg2'), 'https://localhost:6789', False),
+ False, ('components', 'bcfg2'), False, False),
'user': (('-u', '<user>', 'the user to provide for authentication'),
- False, ('communication', 'user'), 'root', False),
+ False, ('communication', 'user'), False, False),
'password': (('-x', '<password>', 'the password to provide for authentication'),
- False, ('communication', 'password'), 'password', False),
+ False, ('communication', 'password'), False, False),
'retries': (('-R', '<numretries>', 'the number of times to retry network communication'),
False, ('communication', 'retries'), '3', False),
'kevlar': (('-k', False, "run in kevlar (bulletproof) mode"),
@@ -99,6 +99,10 @@ class Client:
optparser = Bcfg2.Options.OptionParser('bcfg2', optinfo)
self.setup = optparser.parse()
+
+ # override default settings
+ settings.read_config_file(self.setup['setup'])
+
if getopt.getopt(sys.argv[1:],
optparser.shortopt, optparser.longopt)[1]:
print "Bcfg2 takes no arguments, only options"
diff --git a/src/sbin/bcfg2-info b/src/sbin/bcfg2-info
index f40ef3e60..6693efea2 100755
--- a/src/sbin/bcfg2-info
+++ b/src/sbin/bcfg2-info
@@ -6,6 +6,7 @@ import copy, logging, lxml.etree, sys, time, cmd
import Bcfg2.Logging, Bcfg2.Server.Core, os
import Bcfg2.Server.Plugins.Metadata, Bcfg2.Server.Plugin
import Bcfg2.Options
+from Bcfg2.Settings import settings
logger = logging.getLogger('bcfg2-info')
@@ -23,10 +24,10 @@ def printTabular(rows):
print fstring % row
class infoCore(cmd.Cmd, Bcfg2.Server.Core.Core):
- def __init__(self, cfpath):
+ def __init__(self):
cmd.Cmd.__init__(self)
try:
- Bcfg2.Server.Core.Core.__init__(self, {}, cfpath)
+ Bcfg2.Server.Core.Core.__init__(self)
except Bcfg2.Server.Core.CoreInitError, msg:
print "Core load failed because %s" % msg
raise SystemExit(1)
@@ -270,6 +271,9 @@ if __name__ == '__main__':
optparser = Bcfg2.Options.OptionParser('bcfg2-info', optinfo)
setup = optparser.parse()
- loop = infoCore(setup['configfile'])
+ # override default settings
+ settings.read_config_file(setup['configfile'])
+
+ loop = infoCore()
loop.plugins['Metadata'].load_probedata()
loop.do_loop()
diff --git a/src/sbin/bcfg2-server b/src/sbin/bcfg2-server
index e6a00efbc..554a5ae24 100755
--- a/src/sbin/bcfg2-server
+++ b/src/sbin/bcfg2-server
@@ -5,6 +5,7 @@ __revision__ = '$Revision$'
import Bcfg2.Server.Plugins.Metadata
+from Bcfg2.Settings import settings
from Bcfg2.Server.Core import Core, CoreInitError
from xmlrpclib import Fault
from lxml.etree import XML, Element, tostring
@@ -39,7 +40,7 @@ class Bcfg2Serv(Bcfg2.Component.Component):
raise SetupError
try:
- self.Core = Core(setup, setup['configfile'])
+ self.Core = Core()
except CoreInitError, msg:
logger.critical("Fatal error: %s" % (msg))
raise SystemExit, 1
@@ -184,7 +185,7 @@ if __name__ == '__main__':
'daemon': (('-D', '<pidfile>', 'daemonize the server, storing PID'),
False, False, False, False),
'configfile': (('-C', '<conffile>', 'use this config file'),
- False, False, '/etc/bcfg2.conf', False),
+ False, False, False, False),
}
SSETUP = Bcfg2.Options.OptionParser('bcfg2', OPTINFO).parse()
@@ -195,6 +196,10 @@ if __name__ == '__main__':
Bcfg2.Logging.setup_logging('bcfg2-server', level=level)
if SSETUP['daemon']:
Bcfg2.Daemon.daemonize(SSETUP['daemon'])
+
+ # override default settings
+ settings.read_config_file(SSETUP['configfile'])
+
try:
BSERV = Bcfg2Serv(SSETUP)
except SetupError: