summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/lib/Options.py43
-rwxr-xr-xsrc/sbin/bcfg286
2 files changed, 67 insertions, 62 deletions
diff --git a/src/lib/Options.py b/src/lib/Options.py
index edf5116e9..cf076dfc0 100644
--- a/src/lib/Options.py
+++ b/src/lib/Options.py
@@ -39,7 +39,10 @@ class Option(object):
self.odesc = odesc
self.env = env
self.cf = cf
- self.cook = cook
+ if not odesc and not cook:
+ self.cook = bool_cook
+ else:
+ self.cook = cook
def buildHelpMessage(self):
msg = ''
@@ -142,7 +145,7 @@ SERVER_LOCATION = Option('Server Location', cf=('components', 'bcfg2'),
SERVER_STATIC = Option('Server runs on static port', cf=('components', 'bcfg2'),
default='', cook=bool_cook)
SERVER_KEY = Option('Path to SSL key', cf=('communication', 'key'),
- default=False)
+ default=False, cmd='-K', odesc='<ssl key file>')
SERVER_PASSWORD = Option('Communication Password', cmd='-x',
cf=('communication', 'password'), default=False)
INSTALL_PREFIX = Option('Installation location', cf=('server', 'prefix'),
@@ -152,6 +155,42 @@ SERVER_PROTOCOL = Option('Server Protocol', cf=('communication', 'procotol'),
SENDMAIL_PATH = Option('Path to sendmail', cf=('reports', 'sendmailpath'),
default='/usr/lib/sendmail')
+CLIENT_PROFILE = Option('assert the given profile for the host',
+ default='False', cmd='-p')
+CLIENT_RETRIES = Option('the number of times to retry network communication',
+ default='3', cmd='-R', cf=('communication', 'retries'))
+CLIENT_DRYRUN = Option('do not actually change the system',
+ default='False', cmd='-n', )
+CLIENT_EXTRA_DISPLAY = Option('enable extra entry output',
+ default='False', cmd='-e', )
+CLIENT_PARANOID = Option('make automatic backups of config files',
+ default='False', cmd='-P', )
+CLIENT_AGENT = Option('run in agent (continuous) mode, wait for reconfigure command from server', default='False', cmd='-A', )
+CLIENT_DRIVERS = Option('Specify tool driver set', default='False',
+ cmd='-D', cf=('client', 'drivers'))
+CLIENT_CACHE = Option('store the configuration in a file',
+ default='False', cmd='-c', )
+CLIENT_REMOVE = Option('force removal of additional configuration items',
+ default='False', cmd='-r', )
+CLIENT_BUNDLE = Option('only configure the given bundle', default='False',
+ cmd='-b', )
+CLIENT_KEVLAR = Option('run in kevlar (bulletproof) mode', default='False',
+ cmd='-k', )
+CLIENT_BUILD = Option('run in build mode', default='False', cmd='-B', )
+CLIENT_FILE = Option('configure from a file rather than querying the server',
+ default='False', cmd='-f', )
+SERVER_FINGERPRINT = Option('Server Fingerprint', default='False', cmd='-F',
+ cf=('communication', 'fingerprint'))
+CLIENT_QUICK = Option('disable some checksum verification', default='False',
+ cmd='-q', )
+CLIENT_BACKGROUND = Option('Daemonize the agent', default='False', cmd='-i', )
+CLIENT_PORT = Option('the port on which to bind for agent mode', default='6789',
+ cmd='-g', cf=('communication', 'agent-port'))
+CLIENT_USER = Option('the user to provide for authentication', default='False',
+ cmd='-u', cf=('communication', 'user'))
+INTERACTIVE = Option('prompt the user for each change', default='False',
+ cmd='-I', )
+
class OptionParser(OptionSet):
'''OptionParser bootstraps option parsing, getting the value of the config file'''
def __init__(self, args):
diff --git a/src/sbin/bcfg2 b/src/sbin/bcfg2
index 62f2e1775..4749d699d 100755
--- a/src/sbin/bcfg2
+++ b/src/sbin/bcfg2
@@ -43,71 +43,37 @@ class Client:
optinfo = {
# 'optname': (('-a', argdesc, optdesc),
# env, cfpath, default, boolean)),
- 'verbose': (('-v', False, "enable verbose output"),
- False, False, False, True),
- 'extra': (('-e', False, "enable extra entry output"),
- False, False, False, True),
- 'quick': (('-q', False, "disable some checksum verification"),
- False, False, False, True),
- 'debug': (('-d', False, "enable debugging output"),
- False, False, False, True),
- 'drivers': (('-D', '<driver1>,<driver2>', "Specify tool driver set"),
- False, ('client', 'drivers'), False, False),
- 'fingerprint': (('-F', '<server fingerprint>', "Server Fingerprint"),
- False, ('communication', 'fingerprint'), False, False),
- 'dryrun': (('-n', False, "do not actually change the system"),
- False, False, False, True),
- 'build': (('-B', False, "run in build mode"),
- False, False, False, True),
- 'paranoid': (('-P', False, "make automatic backups of config files"),
- False, False, False, True),
- 'bundle': (('-b', '<bundle>', "only configure the given bundle"),
- False, False, False, False),
- 'file': (('-f', "<configspec>", "configure from a file rather than querying the server"),
- False, False, False, False),
- 'interactive': (('-I', False, "prompt the user for each change"),
- False, False, False, True),
- 'cache': (('-c', "<configspec>", "store the configuration in a file"),
- False, False, False, False),
- 'profile': (('-p', '<profile>', "assert the given profile for the host"),
- False, False, False, False),
- 'remove': (('-r', '(packages|services|all)', "force removal of additional configuration items"),
- False, False, False, False),
- 'help': (('-h', False, "print this help message"),
- False, False, False, True),
- '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'), False, False),
- 'user': (('-u', '<user>', 'the user to provide for authentication'),
- False, ('communication', 'user'), False, False),
- 'password': (('-x', '<password>', 'the password to provide for authentication'),
- 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"),
- False, False, False, True),
- 'agent': (('-A', False, "run in agent (continuous) mode, wait for reconfigure command from server"),
- False, False, False, True),
- 'agent-port': (('-g', '<agent tcp port>', 'the port on which to bind for agent mode'),
- False, ('communication', 'agent-port'), '6789', False),
- 'agent-background': (('-i', '<pidfile name>', "Daemonize the agent"),
- False, False, False, False),
- 'key': (('-K', '<client key file>', 'ssl cert + private key for agent mode xmlrpc server'),
- False, ('communication', 'key'), False, False),
+ 'verbose': Bcfg2.Options.VERBOSE,
+ 'extra': Bcfg2.Options.CLIENT_EXTRA_DISPLAY,
+ 'quick': Bcfg2.Options.CLIENT_QUICK,
+ 'debug': Bcfg2.Options.DEBUG,
+ 'drivers': Bcfg2.Options.CLIENT_DRIVERS,
+ 'fingerprint': Bcfg2.Options.SERVER_FINGERPRINT,
+ 'dryrun': Bcfg2.Options.CLIENT_DRYRUN,
+ 'build': Bcfg2.Options.CLIENT_BUILD,
+ 'paranoid': Bcfg2.Options.CLIENT_PARANOID,
+ 'bundle': Bcfg2.Options.CLIENT_BUNDLE,
+ 'file': Bcfg2.Options.CLIENT_FILE,
+ 'interactive': Bcfg2.Options.INTERACTIVE,
+ 'cache': Bcfg2.Options.CLIENT_CACHE,
+ 'profile': Bcfg2.Options.CLIENT_PROFILE,
+ 'remove': Bcfg2.Options.CLIENT_REMOVE,
+ 'help': Bcfg2.Options.HELP,
+ 'setup': Bcfg2.Options.CFILE,
+ 'server': Bcfg2.Options.SERVER_LOCATION,
+ 'user': Bcfg2.Options.CLIENT_USER,
+ 'password': Bcfg2.Options.SERVER_PASSWORD,
+ 'retries': Bcfg2.Options.CLIENT_RETRIES,
+ 'kevlar': Bcfg2.Options.CLIENT_KEVLAR,
+ 'agent': Bcfg2.Options.CLIENT_AGENT,
+ 'agent-port': Bcfg2.Options.CLIENT_PORT,
+ 'agent-background': Bcfg2.Options.CLIENT_BACKGROUND,
+ 'key': Bcfg2.Options.SERVER_KEY,
}
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"
- print optparser.helpmsg
- raise SystemExit(1)
level = 30
if self.setup['verbose']:
level = 20