summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2011-01-06 14:27:46 -0600
committerNarayan Desai <desai@mcs.anl.gov>2011-01-06 14:27:46 -0600
commitf384258af81136eacc85cf4adb01db34667600ab (patch)
treef73b4f28fd369d116ffcc52077f494ec426742d4 /src
parentbd5aebba93fbd67b61d1a6f3ec221bc7e94f1559 (diff)
parentf2f34ec086678222708535df74d9ee929f65a78a (diff)
downloadbcfg2-f384258af81136eacc85cf4adb01db34667600ab.tar.gz
bcfg2-f384258af81136eacc85cf4adb01db34667600ab.tar.bz2
bcfg2-f384258af81136eacc85cf4adb01db34667600ab.zip
Merge branch 'master' of git.mcs.anl.gov:bcfg2
Diffstat (limited to 'src')
-rw-r--r--src/lib/Options.py50
-rw-r--r--src/lib/Server/Admin/Backup.py4
-rw-r--r--src/lib/Server/Admin/Bundle.py6
-rw-r--r--src/lib/Server/Admin/Client.py10
-rw-r--r--src/lib/Server/Admin/Group.py10
-rw-r--r--src/lib/Server/Admin/Init.py110
-rw-r--r--src/lib/Server/Admin/Minestruct.py2
-rw-r--r--src/lib/Server/Admin/Perf.py2
-rw-r--r--src/lib/Server/Admin/Pull.py6
-rw-r--r--src/lib/Server/Admin/Snapshots.py15
-rw-r--r--src/lib/Server/Admin/Tidy.py2
-rw-r--r--src/lib/Server/Admin/Viz.py3
-rw-r--r--src/lib/Server/Admin/Xcmd.py2
-rw-r--r--src/lib/Server/Admin/__init__.py2
-rwxr-xr-xsrc/sbin/bcfg2-info136
15 files changed, 237 insertions, 123 deletions
diff --git a/src/lib/Options.py b/src/lib/Options.py
index 1dcad6427..4041ccf78 100644
--- a/src/lib/Options.py
+++ b/src/lib/Options.py
@@ -93,7 +93,7 @@ class Option(object):
def parse(self, opts, rawopts):
if self.cmd and opts:
- # processing getopted data
+ # Processing getopted data
optinfo = [opt[1] for opt in opts if opt[0] == self.cmd]
if optinfo:
if optinfo[0]:
@@ -105,7 +105,7 @@ class Option(object):
data = rawopts[rawopts.index(self.cmd) + 1]
self.value = self.get_cooked_value(data)
return
- # no command line option found
+ # No command line option found
if self.env and self.env in os.environ:
self.value = self.get_cooked_value(os.environ[self.env])
return
@@ -115,7 +115,7 @@ class Option(object):
return
except:
pass
- # default value not cooked
+ # Default value not cooked
self.value = self.default
class OptionSet(dict):
@@ -141,7 +141,7 @@ class OptionSet(dict):
raise SystemExit(code)
def parse(self, argv, do_getopt=True):
- '''Parse options'''
+ '''Parse options from command line.'''
if do_getopt:
try:
opts, args = getopt.getopt(argv, self.buildGetopt(),
@@ -171,7 +171,7 @@ def colon_split(c_string):
return c_string.split(':')
return []
-#General options
+# General options
CFILE = Option('Specify configuration file', DEFAULT_CONFIG_LOCATION, cmd='-C',
odesc='<conffile>')
LOCKFILE = Option('Specify lockfile',
@@ -187,7 +187,7 @@ INSTALL_PREFIX = Option('Installation location', cf=('server', 'prefix'),
default=DEFAULT_INSTALL_PREFIX, odesc='</path>')
SENDMAIL_PATH = Option('Path to sendmail', cf=('reports', 'sendmailpath'),
default='/usr/lib/sendmail')
-INTERACTIVE = Option('prompt the user for each change', default=False,
+INTERACTIVE = Option('Prompt the user for each change', default=False,
cmd='-I', )
ENCODING = Option('Encoding of cfg files', default=sys.getdefaultencoding(),
cmd='-E', odesc='<encoding>',
@@ -201,8 +201,8 @@ PARANOID_MAX_COPIES = Option('Specify the number of paranoid copies you want',
OMIT_LOCK_CHECK = Option('Omit lock check', default=False, cmd='-O')
CORE_PROFILE = Option('profile',
default=False, cmd='-p', )
-
-#Metadata options
+
+# Metadata options
MDATA_OWNER = Option('Default Path owner',
default='root', cf=('mdata', 'owner'),
odesc='owner permissions')
@@ -219,7 +219,7 @@ MDATA_PARANOID = Option('Default Path paranoid setting',
'false', cf=('mdata', 'paranoid'),
odesc='Path paranoid setting')
-#Server options
+# Server options
SERVER_REPOSITORY = Option('Server repository path', '/var/lib/bcfg2',
cf=('server', 'repository'), cmd='-Q',
odesc='<repository path>')
@@ -255,7 +255,7 @@ SERVER_PASSWORD = Option('Communication Password', cmd='-x', odesc='<password>',
cf=('communication', 'password'), default=False)
SERVER_PROTOCOL = Option('Server Protocol', cf=('communication', 'procotol'),
default='xmlrpc/ssl')
-#Client options
+# Client options
CLIENT_KEY = Option('Path to SSL key', cf=('communication', 'key'),
default=None, cmd="--ssl-key", odesc='<ssl key>',
long_arg=True)
@@ -265,44 +265,44 @@ CLIENT_CERT = Option('Path to SSL certificate', default=None, cmd="--ssl-cert",
CLIENT_CA = Option('Path to SSL CA Cert', default=None, cmd="--ca-cert",
cf=('communication', 'ca'), odesc='<ca cert>',
long_arg=True)
-CLIENT_SCNS = Option('list of server commonNames', default=None, cmd="--ssl-cns",
+CLIENT_SCNS = Option('List of server commonNames', default=None, cmd="--ssl-cns",
cf=('communication', 'serverCommonNames'),
odesc='<commonName1:commonName2>', cook=list_split,
long_arg=True)
-CLIENT_PROFILE = Option('assert the given profile for the host',
+CLIENT_PROFILE = Option('Assert the given profile for the host',
default=False, cmd='-p', odesc="<profile>")
-CLIENT_RETRIES = Option('the number of times to retry network communication',
+CLIENT_RETRIES = Option('The number of times to retry network communication',
default='3', cmd='-R', cf=('communication', 'retries'),
odesc="<retry count>")
-CLIENT_DRYRUN = Option('do not actually change the system',
+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',
+CLIENT_PARANOID = Option('Make automatic backups of config files',
default=False, cmd='-P', cf=('client', 'paranoid'))
CLIENT_DRIVERS = Option('Specify tool driver set', cmd='-D',
cf=('client', 'drivers'),
odesc="<driver1,driver2>", cook=list_split,
default=Bcfg2.Client.Tools.default)
-CLIENT_CACHE = Option('store the configuration in a file',
+CLIENT_CACHE = Option('Store the configuration in a file',
default=False, cmd='-c', odesc="<cache path>")
-CLIENT_REMOVE = Option('force removal of additional configuration items',
+CLIENT_REMOVE = Option('Force removal of additional configuration items',
default=False, cmd='-r', odesc="<entry type|all>")
-CLIENT_BUNDLE = Option('only configure the given bundle(s)', default=[],
+CLIENT_BUNDLE = Option('Only configure the given bundle(s)', default=[],
cmd='-b', odesc='<bundle:bundle>', cook=colon_split)
CLIENT_BUNDLEQUICK = Option('only verify/configure the given bundle(s)', default=False,
cmd='-Q')
-CLIENT_INDEP = Option('only configure the given bundle(s)', default=False,
+CLIENT_INDEP = Option('Only configure the given bundle(s)', default=False,
cmd='-z')
-CLIENT_KEVLAR = Option('run in kevlar (bulletproof) mode', default=False,
+CLIENT_KEVLAR = Option('Run in kevlar (bulletproof) mode', default=False,
cmd='-k', )
-CLIENT_DLIST = Option('run client in server decision list mode', default=False,
+CLIENT_DLIST = Option('Run client in server decision list mode', default=False,
cmd='-l', odesc='<whitelist|blacklist>')
-CLIENT_FILE = Option('configure from a file rather than querying the server',
+CLIENT_FILE = Option('Configure from a file rather than querying the server',
default=False, cmd='-f', odesc='<specification path>')
-CLIENT_QUICK = Option('disable some checksum verification', default=False,
+CLIENT_QUICK = Option('Disable some checksum verification', default=False,
cmd='-q', )
-CLIENT_USER = Option('the user to provide for authentication', default='root',
+CLIENT_USER = Option('The user to provide for authentication', default='root',
cmd='-u', cf=('communication', 'user'), odesc='<user>')
CLIENT_SERVICE_MODE = Option('Set client service mode', default='default',
cmd='-s', odesc='<default|disabled|build>')
@@ -316,7 +316,7 @@ CLIENT_APT_TOOLS_VAR_PATH = Option('Apt tools var path',
CLIENT_SYSTEM_ETC_PATH = Option('System etc path', cf=('APT', 'etc_path'),
default='/etc')
-#Logging options
+# Logging options
LOGGING_FILE_PATH = Option('Set path of file log', default=None,
cmd='-o', odesc='<path>', cf=('logging', 'path'))
diff --git a/src/lib/Server/Admin/Backup.py b/src/lib/Server/Admin/Backup.py
index 27a7fd8c8..fefc9fc9e 100644
--- a/src/lib/Server/Admin/Backup.py
+++ b/src/lib/Server/Admin/Backup.py
@@ -6,8 +6,8 @@ import Bcfg2.Server.Admin
import Bcfg2.Options
class Backup(Bcfg2.Server.Admin.MetadataCore):
- __shorthelp__ = "Make a backup of the Bcfg2 repository."
- __longhelp__ = (__shorthelp__ + "\n\nbcfg2-admin backup")
+ __shorthelp__ = "Make a backup of the Bcfg2 repository"
+ __longhelp__ = (__shorthelp__ + "\n\nbcfg2-admin backup\n")
#"\n\nbcfg2-admin backup restore")
__usage__ = ("bcfg2-admin backup")
diff --git a/src/lib/Server/Admin/Bundle.py b/src/lib/Server/Admin/Bundle.py
index 893fde489..96a7ba59d 100644
--- a/src/lib/Server/Admin/Bundle.py
+++ b/src/lib/Server/Admin/Bundle.py
@@ -11,8 +11,8 @@ class Bundle(Bcfg2.Server.Admin.MetadataCore):
__longhelp__ = (__shorthelp__ + #"\n\nbcfg2-admin bundle add <bundle> "
#"\n\nbcfg2-admin bundle del <bundle>"
"\n\nbcfg2-admin bundle list-xml"
- "\n\nbcfg2-admin bundle list-genshi"
- "\n\nbcfg2-admin bundle show")
+ "\nbcfg2-admin bundle list-genshi"
+ "\nbcfg2-admin bundle show\n")
__usage__ = ("bcfg2-admin bundle [options] [add|del] [group]")
def __init__(self, configfile):
@@ -23,7 +23,7 @@ class Bundle(Bcfg2.Server.Admin.MetadataCore):
Bcfg2.Server.Admin.MetadataCore.__call__(self, args)
reg='((?:[a-z][a-z\\.\\d\\-]+)\\.(?:[a-z][a-z\\-]+))(?![\\w\\.])'
- #Get all bundles out of the Bundle/ directory
+ # Get all bundles out of the Bundle/ directory
opts = {'repo': Bcfg2.Options.SERVER_REPOSITORY}
setup = Bcfg2.Options.OptionParser(opts)
setup.parse(sys.argv[1:])
diff --git a/src/lib/Server/Admin/Client.py b/src/lib/Server/Admin/Client.py
index 0eee22ae4..08bd34151 100644
--- a/src/lib/Server/Admin/Client.py
+++ b/src/lib/Server/Admin/Client.py
@@ -5,11 +5,11 @@ from Bcfg2.Server.Plugins.Metadata import MetadataConsistencyError
class Client(Bcfg2.Server.Admin.MetadataCore):
__shorthelp__ = "Create, delete, or modify client entries"
__longhelp__ = (__shorthelp__ + "\n\nbcfg2-admin client add <client> "
- "attr1=val1 attr2=val2\n"
- "\n\nbcfg2-admin client update <client> "
- "attr1=val1 attr2=val2\n"
- "\n\nbcfg2-admin client list\n"
- "bcfg2-admin client del <client>")
+ "attr1=val1 attr2=val2"
+ "\nbcfg2-admin client update <client> "
+ "attr1=val1 attr2=val2"
+ "\nbcfg2-admin client list"
+ "\nbcfg2-admin client del <client>\n")
__usage__ = ("bcfg2-admin client [options] [add|del|update|list] [attr=val]")
def __init__(self, configfile):
diff --git a/src/lib/Server/Admin/Group.py b/src/lib/Server/Admin/Group.py
index 6a1c13775..d4024686d 100644
--- a/src/lib/Server/Admin/Group.py
+++ b/src/lib/Server/Admin/Group.py
@@ -5,11 +5,11 @@ from Bcfg2.Server.Plugins.Metadata import MetadataConsistencyError
class Group(Bcfg2.Server.Admin.MetadataCore):
__shorthelp__ = "Create, delete, or modify group entries"
__longhelp__ = (__shorthelp__ + "\n\nbcfg2-admin group add <group> "
- "attr1=val1 attr2=val2\n"
- "\n\nbcfg2-admin group update <group> "
- "attr1=val1 attr2=val2\n"
- "\n\nbcfg2-admin group list\n"
- "bcfg2-admin group del <group>")
+ "attr1=val1 attr2=val2"
+ "\nbcfg2-admin group update <group> "
+ "attr1=val1 attr2=val2"
+ "\nbcfg2-admin group list"
+ "bcfg2-admin group del <group>\n")
__usage__ = ("bcfg2-admin group [options] [add|del|update|list] [attr=val]")
def __init__(self, configfile):
diff --git a/src/lib/Server/Admin/Init.py b/src/lib/Server/Admin/Init.py
index c6d1f9e3d..aee91b244 100644
--- a/src/lib/Server/Admin/Init.py
+++ b/src/lib/Server/Admin/Init.py
@@ -76,15 +76,44 @@ os_list = [
]
# Complete list of plugins
-plugin_list = ['Account', 'Base', 'Bundler', 'Cfg',
- 'Decisions', 'Deps', 'Metadata', 'Packages',
- 'Pkgmgr', 'Probes', 'Properties', 'Rules',
- 'Snapshots', 'SSHbase', 'Statistics', 'Svcmgr',
- 'TCheetah', 'TGenshi']
+plugin_list = [
+ 'Account',
+ 'Base',
+ 'Bundler',
+ 'Bzr',
+ 'Cfg',
+ 'Decisions',
+ 'Deps',
+ 'Git',
+ 'Guppy',
+ 'Hg',
+ 'Metadata',
+ 'NagiosGen',
+ 'Ohai',
+ 'Packages',
+ 'Pkgmgr',
+ 'Probes',
+ 'Properties',
+ 'Rules',
+ 'Snapshots',
+ 'SSHbase',
+ 'SSLCA',
+ 'Statistics',
+ 'Svcmgr',
+ 'TCheetah',
+ 'TGenshi'
+ ]
# Default list of plugins to use
-default_plugins = ['SSHbase', 'Cfg', 'Pkgmgr', 'Rules',
- 'Metadata', 'Base', 'Bundler']
+default_plugins = [
+ 'Base',
+ 'Bundler'
+ 'Cfg',
+ 'Metadata',
+ 'Pkgmgr',
+ 'Rules',
+ 'SSHbase'
+ ]
def gen_password(length):
"""Generates a random alphanumeric password with length characters."""
@@ -94,16 +123,16 @@ def gen_password(length):
newpasswd = newpasswd + random.choice(chars)
return newpasswd
-def create_key(hostname, keypath, certpath):
+def create_key(hostname, keypath, certpath, country, state, location):
"""Creates a bcfg2.key at the directory specifed by keypath."""
- kcstr = "openssl req -batch -x509 -nodes -subj '/C=US/ST=Illinois/L=Argonne/CN=%s' -days 1000 -newkey rsa:2048 -keyout %s -noout" % (hostname, keypath)
+ kcstr = "openssl req -batch -x509 -nodes -subj '/C=%s/ST=%s/L=%s/CN=%s' -days 1000 -newkey rsa:2048 -keyout %s -noout" % (country, state, location, hostname, keypath)
subprocess.call((kcstr), shell=True)
- ccstr = "openssl req -batch -new -subj '/C=US/ST=Illinois/L=Argonne/CN=%s' -key %s | openssl x509 -req -days 1000 -signkey %s -out %s" % (hostname, keypath, keypath, certpath)
+ ccstr = "openssl req -batch -new -subj '/C=%s/ST=%s/L=%s/CN=%s' -key %s | openssl x509 -req -days 1000 -signkey %s -out %s" % (country, state, location, hostname, keypath, keypath, certpath)
subprocess.call((ccstr), shell=True)
os.chmod(keypath, 0600)
def create_conf(confpath, confdata):
- # don't overwrite existing bcfg2.conf file
+ # Don't overwrite existing bcfg2.conf file
if os.path.exists(confpath):
result = raw_input("\nWarning: %s already exists. "
"Overwrite? [y/N]: " % confpath)
@@ -115,7 +144,7 @@ def create_conf(confpath, confdata):
os.chmod(confpath, 0600)
except Exception, e:
print("Error %s occured while trying to write configuration "
- "file to '%s'\n" %
+ "file to '%s'.\n" %
(e, confpath))
raise SystemExit(1)
@@ -159,13 +188,16 @@ class Init(Bcfg2.Server.Admin.Mode):
self._prompt_hostname()
self._prompt_server()
self._prompt_groups()
+ # self._prompt_plugins()
+ self._prompt_certificate()
# Initialize the repository
self.init_repo()
def _prompt_hostname(self):
"""Ask for the server hostname."""
- data = raw_input("What is the server's hostname [%s]: " % socket.getfqdn())
+ data = raw_input("What is the server's hostname [%s]: " %
+ socket.getfqdn())
if data != '':
self.shostname = data
else:
@@ -173,7 +205,7 @@ class Init(Bcfg2.Server.Admin.Mode):
def _prompt_config(self):
"""Ask for the configuration file path."""
- newconfig = raw_input("Store bcfg2 configuration in [%s]: " %
+ newconfig = raw_input("Store Bcfg2 configuration in [%s]: " %
self.configfile)
if newconfig != '':
self.configfile = newconfig
@@ -181,12 +213,12 @@ class Init(Bcfg2.Server.Admin.Mode):
def _prompt_repopath(self):
"""Ask for the repository path."""
while True:
- newrepo = raw_input("Location of bcfg2 repository [%s]: " %
+ newrepo = raw_input("Location of Bcfg2 repository [%s]: " %
self.repopath)
if newrepo != '':
self.repopath = newrepo
if os.path.isdir(self.repopath):
- response = raw_input("Directory %s exists. Overwrite? [y/N]:"\
+ response = raw_input("Directory %s exists. Overwrite? [y/N]:" \
% self.repopath)
if response.lower().strip() == 'y':
break
@@ -203,7 +235,8 @@ class Init(Bcfg2.Server.Admin.Mode):
def _prompt_server(self):
"""Ask for the server name."""
- newserver = raw_input("Input the server location [%s]: " % self.server_uri)
+ newserver = raw_input("Input the server location [%s]: " %
+ self.server_uri)
if newserver != '':
self.server_uri = newserver
@@ -221,7 +254,8 @@ class Init(Bcfg2.Server.Admin.Mode):
continue
def _prompt_plugins(self):
- default = raw_input("Use default plugins? (%s) [Y/n]: " % ''.join(default_plugins)).lower()
+ default = raw_input("Use default plugins? (%s) [Y/n]: " %
+ ''.join(default_plugins)).lower()
if default != 'y' or default != '':
while True:
plugins_are_valid = True
@@ -231,15 +265,45 @@ class Init(Bcfg2.Server.Admin.Mode):
plugin = plugin.strip()
if not plugin in plugin_list:
plugins_are_valid = False
- print "ERROR: plugin %s not recognized" % plugin
+ print "ERROR: Plugin %s not recognized" % plugin
if plugins_are_valid:
break
+ def _prompt_certificate(self):
+ """Ask for the key details (country, state, and location)."""
+ print "The following questions affects the certificate."
+ print "If there are no data provided the default values are used."
+ newcountry = raw_input("Country name (2 letter code) for certificate: ")
+ if newcountry != '':
+ if len(newcountry) == 2:
+ self.country = newcountry
+ else:
+ while len(newcountry) != 2:
+ newcountry = raw_input("2 letter country code (eg. US): ")
+ if len(newcountry) == 2:
+ self.country = newcountry
+ break
+ else:
+ self.country = 'US'
+
+ newstate = raw_input("State or Province Name (full name) for certificate: ")
+ if newstate != '':
+ self.state = newstate
+ else:
+ self.state = 'Illinois'
+
+ newlocation = raw_input("Locality Name (eg, city) for certificate: ")
+ if newlocation != '':
+ self.location = newlocation
+ else:
+ self.location = 'Argonne'
+
def _init_plugins(self):
"""Initialize each plugin-specific portion of the repository."""
for plugin in self.plugins:
if plugin == 'Metadata':
- Bcfg2.Server.Plugins.Metadata.Metadata.init_repo(self.repopath, groups, self.os_sel, clients)
+ Bcfg2.Server.Plugins.Metadata.Metadata.init_repo(self.repopath,
+ groups, self.os_sel, clients)
else:
try:
module = __import__("Bcfg2.Server.Plugins.%s" % plugin, '',
@@ -247,7 +311,8 @@ class Init(Bcfg2.Server.Admin.Mode):
cls = getattr(module, plugin)
cls.init_repo(self.repopath)
except Exception, e:
- print 'Plugin setup for %s failed: %s\n Check that dependencies are installed?' % (plugin, e)
+ print 'Plugin setup for %s failed: %s'
+ print 'Check that dependencies are installed?' % (plugin, e)
def init_repo(self):
"""Setup a new repo and create the content of the configuration file."""
@@ -268,7 +333,8 @@ class Init(Bcfg2.Server.Admin.Mode):
create_conf(self.configfile, confdata)
kpath = keypath + '/bcfg2.key'
cpath = keypath + '/bcfg2.crt'
- create_key(self.shostname, kpath, cpath)
+ create_key(self.shostname, kpath, cpath, self.country,
+ self.state, self.location)
# Create the repository
path = "%s/%s" % (self.repopath, 'etc')
diff --git a/src/lib/Server/Admin/Minestruct.py b/src/lib/Server/Admin/Minestruct.py
index 02edf2b75..abe1d5a7a 100644
--- a/src/lib/Server/Admin/Minestruct.py
+++ b/src/lib/Server/Admin/Minestruct.py
@@ -9,7 +9,7 @@ class Minestruct(Bcfg2.Server.Admin.StructureMode):
__shorthelp__ = "Extract extra entry lists from statistics"
__longhelp__ = (__shorthelp__ +
"\n\nbcfg2-admin minestruct [-f filename] "
- "[-g groups] client")
+ "[-g groups] client\n")
__usage__ = ("bcfg2-admin minestruct [options] <client>\n\n"
" %-25s%s\n"
" %-25s%s\n" %
diff --git a/src/lib/Server/Admin/Perf.py b/src/lib/Server/Admin/Perf.py
index 6f1cb8dbb..095180592 100644
--- a/src/lib/Server/Admin/Perf.py
+++ b/src/lib/Server/Admin/Perf.py
@@ -6,7 +6,7 @@ import sys
class Perf(Bcfg2.Server.Admin.Mode):
__shorthelp__ = ("Query server for performance data")
- __longhelp__ = (__shorthelp__ + "\n\nbcfg2-admin perf")
+ __longhelp__ = (__shorthelp__ + "\n\nbcfg2-admin perf\n")
__usage__ = ("bcfg2-admin perf")
def __init__(self, configfile):
diff --git a/src/lib/Server/Admin/Pull.py b/src/lib/Server/Admin/Pull.py
index 289852f79..926eda1b3 100644
--- a/src/lib/Server/Admin/Pull.py
+++ b/src/lib/Server/Admin/Pull.py
@@ -9,7 +9,7 @@ class Pull(Bcfg2.Server.Admin.MetadataCore):
__shorthelp__ = ("Integrate configuration information "
"from clients into the server repository")
__longhelp__ = (__shorthelp__ + "\n\nbcfg2-admin pull [-v] [-f][-I] [-s] "
- "<client> <entry type> <entry name>")
+ "<client> <entry type> <entry name>\n")
__usage__ = ("bcfg2-admin pull [options] <client> <entry type> "
"<entry name>\n\n"
" %-25s%s\n"
@@ -117,7 +117,7 @@ class Pull(Bcfg2.Server.Admin.MetadataCore):
new_entry = self.BuildNewEntry(client, etype, ename)
meta = self.bcore.build_metadata(client)
- # find appropriate plugin in bcore
+ # Find appropriate plugin in bcore
glist = [gen for gen in self.bcore.generators if
ename in gen.Entries.get(etype, {})]
if len(glist) != 1:
@@ -135,7 +135,7 @@ class Pull(Bcfg2.Server.Admin.MetadataCore):
except Bcfg2.Server.Plugin.PluginExecutionError:
self.errExit("Configuration upload not supported by plugin %s" \
% (plugin.name))
- # commit if running under a VCS
+ # Commit if running under a VCS
for vcsplugin in self.bcore.plugins.values():
if isinstance(vcsplugin, Bcfg2.Server.Plugin.Version):
files = "%s/%s" % (plugin.data, ename)
diff --git a/src/lib/Server/Admin/Snapshots.py b/src/lib/Server/Admin/Snapshots.py
index 004de0ddb..d58873174 100644
--- a/src/lib/Server/Admin/Snapshots.py
+++ b/src/lib/Server/Admin/Snapshots.py
@@ -1,7 +1,7 @@
from datetime import date
import sys
-# prereq issues can be signaled with ImportError, so no try needed
+# Prereq issues can be signaled with ImportError, so no try needed
import sqlalchemy, sqlalchemy.orm
import Bcfg2.Server.Admin
import Bcfg2.Server.Snapshots
@@ -11,14 +11,15 @@ from Bcfg2.Server.Snapshots.model import Snapshot, Client, Metadata, Base, \
class Snapshots(Bcfg2.Server.Admin.Mode):
__shorthelp__ = "Interact with the Snapshots system"
- __longhelp__ = (__shorthelp__)
+ __longhelp__ = (__shorthelp__ + "\n\nbcfg2-admin snapshots init"
+ "\nbcfg2-admin query qtype\n")
__usage__ = ("bcfg2-admin snapshots [init|query qtype]")
- q_dispatch = {'client':Client,
- 'group':Group,
- 'metadata':Metadata,
- 'package':Package,
- 'snapshot':Snapshot}
+ q_dispatch = {'client': Client,
+ 'group': Group,
+ 'metadata': Metadata,
+ 'package': Package,
+ 'snapshot': Snapshot}
def __init__(self, configfile):
Bcfg2.Server.Admin.Mode.__init__(self, configfile)
diff --git a/src/lib/Server/Admin/Tidy.py b/src/lib/Server/Admin/Tidy.py
index c02ddf110..cc8ab4f5e 100644
--- a/src/lib/Server/Admin/Tidy.py
+++ b/src/lib/Server/Admin/Tidy.py
@@ -6,7 +6,7 @@ import Bcfg2.Server.Admin
class Tidy(Bcfg2.Server.Admin.Mode):
__shorthelp__ = "Clean up useless files in the repo"
- __longhelp__ = __shorthelp__ + "\n\nbcfg2-admin tidy [-f] [-I]"
+ __longhelp__ = __shorthelp__ + "\n\nbcfg2-admin tidy [-f] [-I]\n"
__usage__ = ("bcfg2-admin tidy [options]\n\n"
" %-25s%s\n"
" %-25s%s\n" %
diff --git a/src/lib/Server/Admin/Viz.py b/src/lib/Server/Admin/Viz.py
index 245ca8398..e3daea84b 100644
--- a/src/lib/Server/Admin/Viz.py
+++ b/src/lib/Server/Admin/Viz.py
@@ -6,7 +6,7 @@ class Viz(Bcfg2.Server.Admin.MetadataCore):
__shorthelp__ = "Produce graphviz diagrams of metadata structures"
__longhelp__ = (__shorthelp__ + "\n\nbcfg2-admin viz [--includehosts] "
"[--includebundles] [--includekey] "
- "[-o output.png] [--raw]")
+ "[-o output.png] [--raw]\n")
__usage__ = ("bcfg2-admin viz [options]\n\n"
" %-25s%s\n"
" %-25s%s\n"
@@ -24,6 +24,7 @@ class Viz(Bcfg2.Server.Admin.MetadataCore):
colors = ['steelblue1', 'chartreuse', 'gold', 'magenta',
'indianred1', 'limegreen', 'orange1', 'lightblue2',
'green1', 'blue1', 'yellow1', 'darkturquoise', 'gray66']
+
plugin_blacklist = ['DBStats', 'Snapshots', 'Cfg', 'Pkgmgr', 'Packages',
'Rules', 'Account', 'Decisions', 'Deps', 'Git', 'Svn',
'Fossil', 'Bzr', 'Bundler', 'TGenshi', 'SGenshi', 'Base']
diff --git a/src/lib/Server/Admin/Xcmd.py b/src/lib/Server/Admin/Xcmd.py
index 80d5cfb25..8ea98b79c 100644
--- a/src/lib/Server/Admin/Xcmd.py
+++ b/src/lib/Server/Admin/Xcmd.py
@@ -7,7 +7,7 @@ import xmlrpclib
class Xcmd(Bcfg2.Server.Admin.Mode):
__shorthelp__ = ("XML-RPC Command Interface")
- __longhelp__ = (__shorthelp__ + "\n\nbcfg2-admin xcmd command")
+ __longhelp__ = (__shorthelp__ + "\n\nbcfg2-admin xcmd command\n")
__usage__ = ("bcfg2-admin xcmd <command>")
def __call__(self, args):
diff --git a/src/lib/Server/Admin/__init__.py b/src/lib/Server/Admin/__init__.py
index a22d8521a..dc3dc8c01 100644
--- a/src/lib/Server/Admin/__init__.py
+++ b/src/lib/Server/Admin/__init__.py
@@ -94,7 +94,7 @@ class Mode(object):
item in col]) for col in cols]
borderline = vdelim.join([w*hdelim for w in colWidths])
- # print out the table
+ # Print out the table
print(borderline)
for row in rows:
print(vdelim.join([justify(str(item), width) for \
diff --git a/src/sbin/bcfg2-info b/src/sbin/bcfg2-info
index f379a51bb..47fdf82d3 100755
--- a/src/sbin/bcfg2-info
+++ b/src/sbin/bcfg2-info
@@ -29,6 +29,7 @@ import Bcfg2.Server.Plugin
logger = logging.getLogger('bcfg2-info')
class dummyError(Exception):
+ """This is just a dummy."""
pass
class FileNotBuilt(Exception):
@@ -56,12 +57,14 @@ def displayTrace(trace, num=80, sort=('time', 'calls')):
stats.print_stats(200)
def write_config_file(outputdir, cfg):
- """Store file content of an <ConfigFile name='/path/to/file' ...>...</ConfigFile> entry
+ """
+ Store file content of an
+ <Path type='file' ...>...</Path> entry
in the appropriate directory under the output directory.
"""
name = cfg.get('name')
- # directory creation
+ # Directory creation
try:
os.makedirs(os.path.dirname(outputdir + name))
except OSError, err:
@@ -70,16 +73,17 @@ def write_config_file(outputdir, cfg):
except:
raise
- # write config file
+ # Write config file
config_file = open(outputdir + name, "w")
try:
config_file.write(cfg.text)
- except: # plugin throw an exception and therefore there is no content => None
+ # Plugin throw an exception and therefore there is no content => None
+ except:
raise FileNotBuilt(name)
config_file.close()
class infoCore(cmd.Cmd, Bcfg2.Server.Core.Core):
-
+ """Main class for bcfg2-info."""
def __init__(self, repo, plgs, passwd, encoding, event_debug):
cmd.Cmd.__init__(self)
try:
@@ -95,6 +99,7 @@ class infoCore(cmd.Cmd, Bcfg2.Server.Core.Core):
self.fam.handle_events_in_interval(4)
def do_loop(self):
+ """Looping."""
self.cont = True
while self.cont:
try:
@@ -110,9 +115,10 @@ class infoCore(cmd.Cmd, Bcfg2.Server.Core.Core):
except dummyError:
continue
except:
- logger.error("command failure", exc_info=1)
+ logger.error("Command failure", exc_info=1)
def do_debug(self, args):
+ """Debugging mode for more details."""
try:
opts, _ = getopt.getopt(args.split(), 'nf:')
except:
@@ -133,7 +139,7 @@ class infoCore(cmd.Cmd, Bcfg2.Server.Core.Core):
if command:
sh.push(command)
if interactive:
- print("dropping to python interpreter; press ^D to resume")
+ print("Dropping to python interpreter; press ^D to resume")
try:
import IPython
shell = IPython.Shell.IPShell(argv=[], user_ns=locals())
@@ -156,28 +162,29 @@ class infoCore(cmd.Cmd, Bcfg2.Server.Core.Core):
def do_help(self, _):
"""Print out usage info."""
print 'Commands:'
- print 'build <hostname> <filename> - build config for hostname, writing to filename'
- print 'builddir <hostname> <dirname> - build config for hostname, writing separate files to dirname'
- print 'buildall <directory> - build configs for all clients in directory'
- print 'buildfile <filename> <hostname> - build config file for hostname (not written to disk)'
- print 'bundles - print out group/bundle information'
- print 'clients - print out client/profile information'
- print 'debug - shell out to native python interpreter'
- print 'event_debug - display filesystem events as they are processed'
- print 'generators - list current versions of generators'
- print 'groups - list groups'
- print 'help - print this list of available commands'
- print 'mappings <type*> <name*> - print generator mappings for optional type and name'
- print 'profile <command> <args> - profile a single bcfg2-info command'
+ print 'build <hostname> <filename> - Build config for hostname, writing to filename'
+ print 'builddir <hostname> <dirname> - Build config for hostname, writing separate files to dirname'
+ print 'buildall <directory> - Build configs for all clients in directory'
+ print 'buildfile <filename> <hostname> - Build config file for hostname (not written to disk)'
+ print 'bundles - Print out group/bundle information'
+ print 'clients - Print out client/profile information'
+ print 'config - Print out the configuration of the Bcfg2 server'
+ print 'debug - Shell out to native python interpreter'
+ print 'event_debug - Display filesystem events as they are processed'
+ print 'generators - List current versions of generators'
+ print 'groups - List groups'
+ print 'help - Print this list of available commands'
+ print 'mappings <type*> <name*> - Print generator mappings for optional type and name'
+ print 'profile <command> <args> - Profile a single bcfg2-info command'
print 'quit - Exit the bcfg2-info command line'
- print 'showentries <hostname> <type> - show abstract configuration entries for a given host'
- print 'showclient <client1> <client2> - show metadata for given hosts'
- print 'update - process pending file events'
- print 'version - print version of this tool'
+ print 'showentries <hostname> <type> - Show abstract configuration entries for a given host'
+ print 'showclient <client1> <client2> - Show metadata for given hosts'
+ print 'update - Process pending file events'
+ print 'version - Print version of this tool'
def do_update(self, _):
- """Process pending fs events."""
+ """Process pending filesystem events."""
self.fam.handle_events_in_interval(0.1)
def do_version(self, _):
@@ -215,10 +222,10 @@ class infoCore(cmd.Cmd, Bcfg2.Server.Core.Core):
print('rooted under /tmp unless the -f argument is provided, in')
print('which case it can be located anywhere.')
print('')
- print('NOTE: Currently only handles ConfigFile entries and writes')
+ print('NOTE: Currently only handles file entries and writes')
print('all content with the default owner and permissions. These')
print('could be much more permissive than would be created by the')
- print('bcfg2 client itself.')
+ print('Bcfg2 client itself.')
def do_builddir(self, args):
"""Build client configuration as separate files within a dir."""
@@ -237,21 +244,22 @@ class infoCore(cmd.Cmd, Bcfg2.Server.Core.Core):
print("Building client configuration failed.")
return
- # handle <Path type='file'> entries
- for configfile in [cfile for cfile in client_config.xpath(".//Path[@type = 'file']")]:
+ # Handle <Path type='file'> entries
+ for configfile in [cfile for cfile in
+ client_config.xpath(".//Path[@type = 'file']")]:
try:
write_config_file(odir, configfile)
except FileNotBuilt, ex:
- print("Warning: No file content generated for ConfigFile %s!" % ex)
+ print("Warning: No file content generated for file %s!" % ex)
pass
except Exception, ex:
- print("unknown error, I give up: %s" %ex)
+ print("Unknown error, giving up: %s" %ex)
return
print("Config for %s written to %s" % (client, odir))
else:
- print('Error: Incorrect number of parameters')
+ print('Error: Incorrect number of parameters.')
self.help_builddir()
def do_buildall(self, args):
@@ -272,7 +280,8 @@ class infoCore(cmd.Cmd, Bcfg2.Server.Core.Core):
entry = lxml.etree.Element('Path', type='file', name=fname)
metadata = self.build_metadata(client)
self.Bind(entry, metadata)
- print(lxml.etree.tostring(entry, encoding="UTF-8", xml_declaration=True))
+ print(lxml.etree.tostring(entry, encoding="UTF-8",
+ xml_declaration=True))
else:
print('Usage: buildfile filename hostname')
@@ -295,6 +304,26 @@ class infoCore(cmd.Cmd, Bcfg2.Server.Core.Core):
data.append((client, self.metadata.clients[client]))
printTabular(data)
+ def do_config(self, _):
+ """Print out the current configuration of Bcfg2."""
+ output = [
+ ('Description', 'Value'),
+ ('Path Bcfg2 repository', setup['repo']),
+ ('Plugins', setup['plugins']),
+ ('Password', setup['password']),
+ ('Server Metadata Connector', setup['mconnect']),
+ ('Filemonitor', setup['filemonitor']),
+ ('Server address', setup['location']),
+ ('Static', setup['static']),
+ ('Path to key', setup['key']),
+ ('Path to SSL certificate', setup['cert']),
+ ('Path to SSL CA certificate', setup['ca']),
+ ('Protocol', setup['protocol']),
+ ('Logging', setup['logging'])
+ ]
+ printTabular(output)
+
+
def do_generators(self, _):
"""Print out generator info."""
for generator in self.generators:
@@ -377,7 +406,7 @@ class infoCore(cmd.Cmd, Bcfg2.Server.Core.Core):
def do_mappings(self, args):
"""Print out mapping info."""
- # dump all mappings unless type specified
+ # Dump all mappings unless type specified
data = [('Plugin', 'Type', 'Name')]
arglen = len(args.split())
for generator in self.generators:
@@ -386,14 +415,14 @@ class infoCore(cmd.Cmd, Bcfg2.Server.Core.Core):
else:
etypes = [args.split()[0]]
if arglen == 2:
- interested = [(etype, [args.split()[1]]) \
+ interested = [(etype, [args.split()[1]])
for etype in etypes]
else:
- interested = [(etype, generator.Entries[etype]) \
- for etype in etypes \
+ interested = [(etype, generator.Entries[etype])
+ for etype in etypes
if etype in generator.Entries]
for etype, names in interested:
- for name in [name for name in names if name in \
+ for name in [name for name in names if name in
generator.Entries.get(etype, {})]:
data.append((generator.name, etype, name))
printTabular(data)
@@ -410,7 +439,8 @@ class infoCore(cmd.Cmd, Bcfg2.Server.Core.Core):
structures = self.GetStructures(meta)
for clist in [struct.findall('Path') for struct in structures]:
for cfile in clist:
- if cfile.get('name') in self.plugins['Cfg'].Entries['ConfigFile']:
+ if cfile.get('name') in \
+ self.plugins['Cfg'].Entries['ConfigFile']:
cset = self.plugins['Cfg'].entries[cfile.get('name')]
cand = cset.get_matching(meta)
fields = ['all', 'group']
@@ -424,8 +454,9 @@ class infoCore(cmd.Cmd, Bcfg2.Server.Core.Core):
print(cand[0].name)
def do_profile(self, arg):
+ """."""
if not have_profile:
- print("Profiling functionality not available")
+ print("Profiling functionality not available.")
return
tracefname = tempfile.mktemp()
p = profile.Profile()
@@ -433,6 +464,7 @@ class infoCore(cmd.Cmd, Bcfg2.Server.Core.Core):
displayTrace(p)
def Run(self, args):
+ """."""
if args:
self.onecmd(" ".join(args))
os._exit(0)
@@ -445,12 +477,26 @@ if __name__ == '__main__':
'configfile': Bcfg2.Options.CFILE,
'help': Bcfg2.Options.HELP,
}
- optinfo.update({'repo': Bcfg2.Options.SERVER_REPOSITORY,
- 'plugins': Bcfg2.Options.SERVER_PLUGINS,
- 'password': Bcfg2.Options.SERVER_PASSWORD,
+ optinfo.update({
'event debug': Bcfg2.Options.DEBUG,
'profile': Bcfg2.Options.CORE_PROFILE,
- 'encoding': Bcfg2.Options.ENCODING})
+ 'encoding': Bcfg2.Options.ENCODING,
+ # Server options
+ 'repo': Bcfg2.Options.SERVER_REPOSITORY,
+ 'plugins': Bcfg2.Options.SERVER_PLUGINS,
+ 'password': Bcfg2.Options.SERVER_PASSWORD,
+ 'mconnect': Bcfg2.Options.SERVER_MCONNECT,
+ 'filemonitor': Bcfg2.Options.SERVER_FILEMONITOR,
+ 'location': Bcfg2.Options.SERVER_LOCATION,
+ 'static': Bcfg2.Options.SERVER_STATIC,
+ 'key': Bcfg2.Options.SERVER_KEY,
+ 'cert': Bcfg2.Options.SERVER_CERT,
+ 'ca': Bcfg2.Options.SERVER_CA,
+ 'password': Bcfg2.Options.SERVER_PASSWORD,
+ 'protocol': Bcfg2.Options.SERVER_PROTOCOL,
+ # More options
+ 'logging': Bcfg2.Options.LOGGING_FILE_PATH
+ })
setup = Bcfg2.Options.OptionParser(optinfo)
setup.parse(sys.argv[1:])
if setup['profile'] and have_profile:
@@ -461,7 +507,7 @@ if __name__ == '__main__':
displayTrace(prof)
else:
if setup['profile']:
- print("Profiling functionality not available")
+ print("Profiling functionality not available.")
loop = infoCore(setup['repo'], setup['plugins'], setup['password'],
setup['encoding'], setup['event debug'])