From 9aa7737a2840b5ce6688731f84ed49d558e3dc30 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Tue, 14 Dec 2010 00:41:43 +0100 Subject: Plugins: Added missing plugins (cherry picked from commit 57a1e3b50e01c0c81047bea36ed862a11330d7e5) --- src/lib/Server/Admin/Init.py | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/src/lib/Server/Admin/Init.py b/src/lib/Server/Admin/Init.py index c6d1f9e3d..1f00ce2a0 100644 --- a/src/lib/Server/Admin/Init.py +++ b/src/lib/Server/Admin/Init.py @@ -76,11 +76,33 @@ 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', -- cgit v1.2.3-1-g7c22 From bc1ee763eef9caa66b1c4ab846c6884515dc93c4 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Tue, 14 Dec 2010 00:54:57 +0100 Subject: Plugins: Ordered defaults plugins (cherry picked from commit 99bbe3f9d130bf9939489c4cd959373b1f3ce43f) --- src/lib/Server/Admin/Init.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/lib/Server/Admin/Init.py b/src/lib/Server/Admin/Init.py index 1f00ce2a0..3a461681b 100644 --- a/src/lib/Server/Admin/Init.py +++ b/src/lib/Server/Admin/Init.py @@ -105,8 +105,15 @@ plugin_list = [ ] # 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.""" @@ -125,7 +132,7 @@ def create_key(hostname, keypath, certpath): 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) @@ -253,7 +260,7 @@ 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 -- cgit v1.2.3-1-g7c22 From fb726eeb63c669a6b96dfeb4876e8c6bb6dbf28f Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Sat, 18 Dec 2010 18:44:52 +0100 Subject: Merge (cherry picked from commit 841dbffb1802716cfb820759dab1120e4f7857d4) --- src/lib/Server/Admin/Bundle.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/Server/Admin/Bundle.py b/src/lib/Server/Admin/Bundle.py index 893fde489..efbe2b486 100644 --- a/src/lib/Server/Admin/Bundle.py +++ b/src/lib/Server/Admin/Bundle.py @@ -10,9 +10,9 @@ class Bundle(Bcfg2.Server.Admin.MetadataCore): __shorthelp__ = "Create or delete bundle entries" __longhelp__ = (__shorthelp__ + #"\n\nbcfg2-admin bundle add " #"\n\nbcfg2-admin bundle del " - "\n\nbcfg2-admin bundle list-xml" - "\n\nbcfg2-admin bundle list-genshi" - "\n\nbcfg2-admin bundle show") + "\nbcfg2-admin bundle list-xml" + "\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:]) -- cgit v1.2.3-1-g7c22 From ba00c6c88e23640445cb749d8f6d04511c9adc9b Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Sun, 19 Dec 2010 18:08:36 +0100 Subject: Prep for config stuff (cherry picked from commit 19d936d06d907e127bd678fa62372ac67f9cb374) --- src/sbin/bcfg2-info | 45 +++++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/src/sbin/bcfg2-info b/src/sbin/bcfg2-info index f379a51bb..ba340dbef 100755 --- a/src/sbin/bcfg2-info +++ b/src/sbin/bcfg2-info @@ -133,7 +133,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,24 +156,25 @@ class infoCore(cmd.Cmd, Bcfg2.Server.Core.Core): def do_help(self, _): """Print out usage info.""" print 'Commands:' - print 'build - build config for hostname, writing to filename' - print 'builddir - build config for hostname, writing separate files to dirname' - print 'buildall - build configs for all clients in directory' - print 'buildfile - 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 - print generator mappings for optional type and name' - print 'profile - profile a single bcfg2-info command' - print 'quit - Exit the bcfg2-info command line' - print 'showentries - show abstract configuration entries for a given host' - print 'showclient - show metadata for given hosts' - print 'update - process pending file events' - print 'version - print version of this tool' + print 'build - Build config for hostname, writing to filename.' + print 'builddir - Build config for hostname, writing separate files to dirname.' + print 'buildall - Build configs for all clients in directory.' + print 'buildfile - 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 information from bcf2.conf.' + 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 - Print generator mappings for optional type and name.' + print 'profile - Profile a single bcfg2-info command.' + print 'quit - Exit the bcfg2-info command line.' + print 'showentries - Show abstract configuration entries for a given host.' + print 'showclient - Show metadata for given hosts.' + print 'update - Process pending file events.' + print 'version - Print version of this tool.' def do_update(self, _): @@ -245,7 +246,7 @@ class infoCore(cmd.Cmd, Bcfg2.Server.Core.Core): print("Warning: No file content generated for ConfigFile %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)) @@ -295,6 +296,10 @@ 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 stored in bcfg2.conf.""" + print "Here the configuration should go..." + def do_generators(self, _): """Print out generator info.""" for generator in self.generators: -- cgit v1.2.3-1-g7c22 From 13ed2fadfafebfacec0f9284bdfbe5c852600e43 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Sun, 19 Dec 2010 23:02:21 +0100 Subject: Minor changes acc. PEP8 (cherry picked from commit e36006a033f9610382a4a0f233b14df246acd851) --- src/lib/Options.py | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 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='') LOCKFILE = Option('Specify lockfile', @@ -187,7 +187,7 @@ INSTALL_PREFIX = Option('Installation location', cf=('server', 'prefix'), default=DEFAULT_INSTALL_PREFIX, odesc='') 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='', @@ -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='') @@ -255,7 +255,7 @@ SERVER_PASSWORD = Option('Communication Password', cmd='-x', odesc='', 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='', 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='', 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='', 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="") -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="") -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="", 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="") -CLIENT_REMOVE = Option('force removal of additional configuration items', +CLIENT_REMOVE = Option('Force removal of additional configuration items', default=False, cmd='-r', odesc="") -CLIENT_BUNDLE = Option('only configure the given bundle(s)', default=[], +CLIENT_BUNDLE = Option('Only configure the given bundle(s)', default=[], cmd='-b', odesc='', 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='') -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='') -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='') CLIENT_SERVICE_MODE = Option('Set client service mode', default='default', cmd='-s', odesc='') @@ -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='', cf=('logging', 'path')) -- cgit v1.2.3-1-g7c22 From 7a88be280bca43e50e597f88e2d92083b889da5f Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Sun, 19 Dec 2010 23:04:58 +0100 Subject: Added option to show server configuration details (cherry picked from commit 4463d2dc9356685e1b22256a60b3e22eb69378e4) --- doc/server/bcfg2-info.txt | 17 ++++++---- man/bcfg2-info.8 | 6 +++- src/sbin/bcfg2-info | 84 ++++++++++++++++++++++++++++++++--------------- 3 files changed, 72 insertions(+), 35 deletions(-) diff --git a/doc/server/bcfg2-info.txt b/doc/server/bcfg2-info.txt index 35d176e96..201900ba9 100644 --- a/doc/server/bcfg2-info.txt +++ b/doc/server/bcfg2-info.txt @@ -19,7 +19,7 @@ plugins. Getting Started =============== -First, fire up the bcfg2-info interpreter. +First, fire up the ``bcfg2-info`` interpreter. .. code-block:: none @@ -45,14 +45,13 @@ displayed. For example, after a change to a file in the repository: .. code-block:: none - >update + > update Handled 1 events in 0.001s > update > This explicit update process allows you to control the update process, -as well as see the precise changes caused by repository -modifications. +as well as see the precise changes caused by repository modifications. ``bcfg2-info`` has several builtin commands that display the state of various internal server core state. These are most useful for @@ -60,14 +59,18 @@ examining the state of client metadata, either for a single client, or for clients overall. **clients** - displays a list of clients, along with their profile groups + Displays a list of clients, along with their profile groups **groups** - displays a list of groups, the inheritance hierarchy, profile + Displays a list of groups, the inheritance hierarchy, profile status, and category name, if there is one. **showclient** - displays full metadata information for a client, including + Displays full metadata information for a client, including profile group, group memberships, bundle list, and any connector data, like Probe values or Property info. +**config** + Displays the configuration of the Bcfg2 server. + +To leave the interactive shell, just type ``quit`` or ``exit``. Debugging Configuration Rules ============================= diff --git a/man/bcfg2-info.8 b/man/bcfg2-info.8 index d46e34def..a97f60c40 100644 --- a/man/bcfg2-info.8 +++ b/man/bcfg2-info.8 @@ -22,7 +22,7 @@ Specify the location of the configuration file (if it is not in .RE .B "\-E " .RS -Specify the encoding of cfg files. +Specify the encoding of config files. .RE .B "\-Q .RS @@ -71,6 +71,10 @@ Print out group/bundle information. .RS Print out client/profile information. .RE +.B config +.RS +Print out the configuration of the Bcfg2 server. +.RE .B debug .RS Shell out to native python interpreter. diff --git a/src/sbin/bcfg2-info b/src/sbin/bcfg2-info index ba340dbef..e41036130 100755 --- a/src/sbin/bcfg2-info +++ b/src/sbin/bcfg2-info @@ -156,25 +156,25 @@ class infoCore(cmd.Cmd, Bcfg2.Server.Core.Core): def do_help(self, _): """Print out usage info.""" print 'Commands:' - print 'build - Build config for hostname, writing to filename.' - print 'builddir - Build config for hostname, writing separate files to dirname.' - print 'buildall - Build configs for all clients in directory.' - print 'buildfile - 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 information from bcf2.conf.' - 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 - Print generator mappings for optional type and name.' - print 'profile - Profile a single bcfg2-info command.' - print 'quit - Exit the bcfg2-info command line.' - print 'showentries - Show abstract configuration entries for a given host.' - print 'showclient - Show metadata for given hosts.' - print 'update - Process pending file events.' - print 'version - Print version of this tool.' + print 'build - Build config for hostname, writing to filename' + print 'builddir - Build config for hostname, writing separate files to dirname' + print 'buildall - Build configs for all clients in directory' + print 'buildfile - 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 - Print generator mappings for optional type and name' + print 'profile - Profile a single bcfg2-info command' + print 'quit - Exit the bcfg2-info command line' + print 'showentries - Show abstract configuration entries for a given host' + print 'showclient - Show metadata for given hosts' + print 'update - Process pending file events' + print 'version - Print version of this tool' def do_update(self, _): @@ -297,8 +297,24 @@ class infoCore(cmd.Cmd, Bcfg2.Server.Core.Core): printTabular(data) def do_config(self, _): - """Print out the current configuration stored in bcfg2.conf.""" - print "Here the configuration should go..." + """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.""" @@ -382,7 +398,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: @@ -450,12 +466,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: @@ -466,7 +496,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']) -- cgit v1.2.3-1-g7c22 From 47df6f2dcd142e4a1335154fdff364a4962d30e8 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Sun, 19 Dec 2010 23:56:04 +0100 Subject: Some pylint stuff fixed (cherry picked from commit d5ec1109b1fee021b14966fff1b143217abc292d) --- src/sbin/bcfg2-info | 49 ++++++++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/src/sbin/bcfg2-info b/src/sbin/bcfg2-info index e41036130..77b70f7e5 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 ... entry + """ + Store file content of an + ... 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: @@ -178,7 +184,7 @@ class infoCore(cmd.Cmd, Bcfg2.Server.Core.Core): def do_update(self, _): - """Process pending fs events.""" + """Process pending filesystem events.""" self.fam.handle_events_in_interval(0.1) def do_version(self, _): @@ -219,7 +225,7 @@ class infoCore(cmd.Cmd, Bcfg2.Server.Core.Core): print('NOTE: Currently only handles ConfigFile 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.""" @@ -238,8 +244,9 @@ class infoCore(cmd.Cmd, Bcfg2.Server.Core.Core): print("Building client configuration failed.") return - # handle entries - for configfile in [cfile for cfile in client_config.xpath(".//Path[@type = 'file']")]: + # Handle entries + for configfile in [cfile for cfile in + client_config.xpath(".//Path[@type = 'file']")]: try: write_config_file(odir, configfile) except FileNotBuilt, ex: @@ -252,7 +259,7 @@ class infoCore(cmd.Cmd, Bcfg2.Server.Core.Core): 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): @@ -273,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') @@ -298,7 +306,7 @@ class infoCore(cmd.Cmd, Bcfg2.Server.Core.Core): def do_config(self, _): """Print out the current configuration of Bcfg2.""" - output=[ + output = [ ('Description', 'Value'), ('Path Bcfg2 repository', setup['repo']), ('Plugins', setup['plugins']), @@ -407,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) @@ -431,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'] @@ -445,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() @@ -454,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) -- cgit v1.2.3-1-g7c22 From b59e3c45b6c0fc0cadcc4bd0f2cf7550d77993c5 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Mon, 20 Dec 2010 08:02:11 +0100 Subject: Line break added (cherry picked from commit d20f2afc2d44c844b8e196647424e1ff72a27d64) --- src/lib/Server/Admin/Bundle.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/Server/Admin/Bundle.py b/src/lib/Server/Admin/Bundle.py index efbe2b486..96a7ba59d 100644 --- a/src/lib/Server/Admin/Bundle.py +++ b/src/lib/Server/Admin/Bundle.py @@ -10,7 +10,7 @@ class Bundle(Bcfg2.Server.Admin.MetadataCore): __shorthelp__ = "Create or delete bundle entries" __longhelp__ = (__shorthelp__ + #"\n\nbcfg2-admin bundle add " #"\n\nbcfg2-admin bundle del " - "\nbcfg2-admin bundle list-xml" + "\n\nbcfg2-admin bundle list-xml" "\nbcfg2-admin bundle list-genshi" "\nbcfg2-admin bundle show\n") __usage__ = ("bcfg2-admin bundle [options] [add|del] [group]") -- cgit v1.2.3-1-g7c22 From cf82c2d4ea0c3fe1ef272802086446592fdd2942 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Mon, 27 Dec 2010 16:23:00 +0100 Subject: Comment (cherry picked from commit 6dfdbbeb9b10694845ed0e246902e77c525f0e8c) --- src/lib/Server/Admin/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 \ -- cgit v1.2.3-1-g7c22 From b61afa3e10e9f6b1caa568bd9974e0e221a34f4b Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Mon, 27 Dec 2010 16:39:31 +0100 Subject: Description fixed (cherry picked from commit 8acbe8220c4fec09073933a5e461a06c00d99b81) --- src/lib/Server/Admin/Backup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/Server/Admin/Backup.py b/src/lib/Server/Admin/Backup.py index 27a7fd8c8..3297a4ae7 100644 --- a/src/lib/Server/Admin/Backup.py +++ b/src/lib/Server/Admin/Backup.py @@ -6,7 +6,7 @@ import Bcfg2.Server.Admin import Bcfg2.Options class Backup(Bcfg2.Server.Admin.MetadataCore): - __shorthelp__ = "Make a backup of the Bcfg2 repository." + __shorthelp__ = "Make a backup of the Bcfg2 repository" __longhelp__ = (__shorthelp__ + "\n\nbcfg2-admin backup") #"\n\nbcfg2-admin backup restore") __usage__ = ("bcfg2-admin backup") -- cgit v1.2.3-1-g7c22 From ac417d0d1fdcb6c8fd0c758746520519a4d726d7 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Mon, 27 Dec 2010 16:43:58 +0100 Subject: Help layout fixed (cherry picked from commit 4f7fedd6cb1c5a6c82f6bc28da6052e0c0f47312) --- src/lib/Server/Admin/Client.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 " - "attr1=val1 attr2=val2\n" - "\n\nbcfg2-admin client update " - "attr1=val1 attr2=val2\n" - "\n\nbcfg2-admin client list\n" - "bcfg2-admin client del ") + "attr1=val1 attr2=val2" + "\nbcfg2-admin client update " + "attr1=val1 attr2=val2" + "\nbcfg2-admin client list" + "\nbcfg2-admin client del \n") __usage__ = ("bcfg2-admin client [options] [add|del|update|list] [attr=val]") def __init__(self, configfile): -- cgit v1.2.3-1-g7c22 From 01af7fdea006b05925864b9feca137a30683c66b Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Mon, 27 Dec 2010 16:44:25 +0100 Subject: Help layout fixed (cherry picked from commit 54b6e4a1a79bace39de2ac542d132de2fc57682d) --- src/lib/Server/Admin/Group.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 " - "attr1=val1 attr2=val2\n" - "\n\nbcfg2-admin group update " - "attr1=val1 attr2=val2\n" - "\n\nbcfg2-admin group list\n" - "bcfg2-admin group del ") + "attr1=val1 attr2=val2" + "\nbcfg2-admin group update " + "attr1=val1 attr2=val2" + "\nbcfg2-admin group list" + "bcfg2-admin group del \n") __usage__ = ("bcfg2-admin group [options] [add|del|update|list] [attr=val]") def __init__(self, configfile): -- cgit v1.2.3-1-g7c22 From 47ab0c73a9d1863f11e30a073ae5be032d56af46 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Mon, 27 Dec 2010 16:44:53 +0100 Subject: Help layout fixed (cherry picked from commit 860352cc111fc01c42a86d1f648c9acad3a055c9) --- src/lib/Server/Admin/Backup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/Server/Admin/Backup.py b/src/lib/Server/Admin/Backup.py index 3297a4ae7..fefc9fc9e 100644 --- a/src/lib/Server/Admin/Backup.py +++ b/src/lib/Server/Admin/Backup.py @@ -7,7 +7,7 @@ import Bcfg2.Options class Backup(Bcfg2.Server.Admin.MetadataCore): __shorthelp__ = "Make a backup of the Bcfg2 repository" - __longhelp__ = (__shorthelp__ + "\n\nbcfg2-admin backup") + __longhelp__ = (__shorthelp__ + "\n\nbcfg2-admin backup\n") #"\n\nbcfg2-admin backup restore") __usage__ = ("bcfg2-admin backup") -- cgit v1.2.3-1-g7c22 From 0c62d0bba25006f76a2c184871f244f3860af016 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Mon, 27 Dec 2010 16:46:01 +0100 Subject: Help layout fixed (cherry picked from commit 96f3dc03d08b1322587971cd327c213834892aae) --- src/lib/Server/Admin/Xcmd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 ") def __call__(self, args): -- cgit v1.2.3-1-g7c22 From 3cc72a5edf5d9b3e1ac64658610e4cd38074b638 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Mon, 27 Dec 2010 16:46:53 +0100 Subject: Help layout fixed (cherry picked from commit 027abccc723a0985afa9096c31b1e071914583dc) --- src/lib/Server/Admin/Viz.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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'] -- cgit v1.2.3-1-g7c22 From 2c86aa91d280eb4e5982fc2233fd2dd205995da6 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Mon, 27 Dec 2010 16:47:28 +0100 Subject: Help layout fixed (cherry picked from commit 17eda76a2ca5d464b05a97e7e5e7356f221c390f) --- src/lib/Server/Admin/Tidy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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" % -- cgit v1.2.3-1-g7c22 From 9e7a2039f75b6cf0659d1b3c9ad076502f61edef Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Mon, 27 Dec 2010 16:49:49 +0100 Subject: Help layout fixed (cherry picked from commit 21fa57fc48e90c96849918fd7059d04daa01f123) --- src/lib/Server/Admin/Pull.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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] " - " ") + " \n") __usage__ = ("bcfg2-admin pull [options] " "\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) -- cgit v1.2.3-1-g7c22 From 106827dc521482fa25b7ad67e6658b3ec0caa518 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Mon, 27 Dec 2010 16:52:32 +0100 Subject: Longhelp added (cherry picked from commit e64dd5fc75ac7510e2cb43d53b9ecd23ee9ed405) --- src/lib/Server/Admin/Snapshots.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) 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) -- cgit v1.2.3-1-g7c22 From d6f1d689ea9df196a29d1cfb1a09df837fde92d0 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Mon, 27 Dec 2010 16:54:12 +0100 Subject: Help layout changed (cherry picked from commit de689dcca60543d6f3841afd11c05ce320df9da9) --- src/lib/Server/Admin/Perf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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): -- cgit v1.2.3-1-g7c22 From 70fc3466fd7e8071b7feafe66096ecef491dd867 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Sat, 1 Jan 2011 17:40:55 +0100 Subject: Line brake added (cherry picked from commit be37ebbe4d98f025bd54ab03dc5289e43889e521) --- src/lib/Server/Admin/Minestruct.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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] \n\n" " %-25s%s\n" " %-25s%s\n" % -- cgit v1.2.3-1-g7c22 From 00c320f0de5d45a4fb6adcf29405760b8826642a Mon Sep 17 00:00:00 2001 From: Your name Date: Mon, 3 Jan 2011 09:49:19 +0100 Subject: Ask for details about the key (cherry picked from commit fbabad08f4dbe98c74e55f5b6fa4a4e371fcea56) --- src/lib/Server/Admin/Init.py | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/src/lib/Server/Admin/Init.py b/src/lib/Server/Admin/Init.py index 3a461681b..fa4b2ae25 100644 --- a/src/lib/Server/Admin/Init.py +++ b/src/lib/Server/Admin/Init.py @@ -123,11 +123,11 @@ 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) @@ -144,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) @@ -188,6 +188,7 @@ class Init(Bcfg2.Server.Admin.Mode): self._prompt_hostname() self._prompt_server() self._prompt_groups() + self._prompt_key() # Initialize the repository self.init_repo() @@ -202,7 +203,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 @@ -210,7 +211,7 @@ 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 @@ -264,6 +265,26 @@ class Init(Bcfg2.Server.Admin.Mode): if plugins_are_valid: break + def _prompt_key(self): + """Ask for the key details (country, state, and location).""" + newcountry = raw_input("Country code for key: " + if newcountry != '': + self.country = newcountry + else + self.country = 'US' + + newstate = raw_input("State for key: " + if newstate != '': + self.state = newstate + else + self.state = 'Illinois' + + newlocation = raw_input("Location for key: " + 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: -- cgit v1.2.3-1-g7c22 From dc29201c675a13157397d33da423eb5f7ec9bdd8 Mon Sep 17 00:00:00 2001 From: Your name Date: Mon, 3 Jan 2011 10:00:00 +0100 Subject: Initial mistakes fixed (cherry picked from commit 892e6251a65f772d2abfaecae17c4e950c6f6ac7) --- src/lib/Server/Admin/Init.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/lib/Server/Admin/Init.py b/src/lib/Server/Admin/Init.py index fa4b2ae25..9ed62b53f 100644 --- a/src/lib/Server/Admin/Init.py +++ b/src/lib/Server/Admin/Init.py @@ -267,22 +267,22 @@ class Init(Bcfg2.Server.Admin.Mode): def _prompt_key(self): """Ask for the key details (country, state, and location).""" - newcountry = raw_input("Country code for key: " + newcountry = raw_input("Country code for key: ") if newcountry != '': self.country = newcountry - else + else: self.country = 'US' - newstate = raw_input("State for key: " + newstate = raw_input("State for key: ") if newstate != '': self.state = newstate - else + else: self.state = 'Illinois' - newlocation = raw_input("Location for key: " + newlocation = raw_input("Location for key: ") if newlocation != '': self.location = newlocation - else + else: self.location = 'Argonne' def _init_plugins(self): @@ -318,7 +318,7 @@ 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') -- cgit v1.2.3-1-g7c22 From 16bac4538fd1362dd23eb2f2b998033079e22837 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Mon, 3 Jan 2011 11:00:11 +0100 Subject: Description changed to match the standard openssl names (cherry picked from commit 6047e808b2f0e09560442a05da870475bcd2b7ec) Signed-off-by: Sol Jerome --- src/lib/Server/Admin/Init.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib/Server/Admin/Init.py b/src/lib/Server/Admin/Init.py index 9ed62b53f..c2dcd2184 100644 --- a/src/lib/Server/Admin/Init.py +++ b/src/lib/Server/Admin/Init.py @@ -188,7 +188,7 @@ class Init(Bcfg2.Server.Admin.Mode): self._prompt_hostname() self._prompt_server() self._prompt_groups() - self._prompt_key() + self._prompt_certificate() # Initialize the repository self.init_repo() @@ -265,21 +265,21 @@ class Init(Bcfg2.Server.Admin.Mode): if plugins_are_valid: break - def _prompt_key(self): + def _prompt_certificate(self): """Ask for the key details (country, state, and location).""" - newcountry = raw_input("Country code for key: ") + newcountry = raw_input("Country name (2 letter code) for certificate: ") if newcountry != '': self.country = newcountry else: self.country = 'US' - newstate = raw_input("State for key: ") + newstate = raw_input("State or Province Name (full name) for certificate: ") if newstate != '': self.state = newstate else: self.state = 'Illinois' - newlocation = raw_input("Location for key: ") + newlocation = raw_input("Locality Name (eg, city) for certificate: ") if newlocation != '': self.location = newlocation else: -- cgit v1.2.3-1-g7c22 From e8273b09264e9241b5c9c787a04f3f8bc6463c94 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Mon, 3 Jan 2011 12:46:57 +0100 Subject: Country code check added (cherry picked from commit a8352dc470ce0b0fe3400e9818d5c58c7116adca) Signed-off-by: Sol Jerome --- src/lib/Server/Admin/Init.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/lib/Server/Admin/Init.py b/src/lib/Server/Admin/Init.py index c2dcd2184..0c5b457cc 100644 --- a/src/lib/Server/Admin/Init.py +++ b/src/lib/Server/Admin/Init.py @@ -188,6 +188,7 @@ class Init(Bcfg2.Server.Admin.Mode): self._prompt_hostname() self._prompt_server() self._prompt_groups() + self._prompt_plugins() self._prompt_certificate() # Initialize the repository @@ -195,7 +196,8 @@ class Init(Bcfg2.Server.Admin.Mode): 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: @@ -233,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 @@ -251,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 @@ -267,9 +271,14 @@ class Init(Bcfg2.Server.Admin.Mode): def _prompt_certificate(self): """Ask for the key details (country, state, and location).""" + print "The following questions affects the certificate." + print "If there are data provided the default values are used." newcountry = raw_input("Country name (2 letter code) for certificate: ") if newcountry != '': - self.country = newcountry + if len(newcountry) > '2' or len(newcountry) < '2': + newcountry = raw_input("Country name (2 letter code) for certificate: ") + else: + self.country = newcountry else: self.country = 'US' @@ -289,7 +298,8 @@ class Init(Bcfg2.Server.Admin.Mode): """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, '', @@ -318,7 +328,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, self.country, self.state, self.location) + create_key(self.shostname, kpath, cpath, self.country, + self.state, self.location) # Create the repository path = "%s/%s" % (self.repopath, 'etc') -- cgit v1.2.3-1-g7c22 From 9bc2e3d9e744c0a2901a337c7c457ee2dcd5ce4c Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Mon, 3 Jan 2011 23:05:40 +0100 Subject: Check for country changed (cherry picked from commit be721375800bf740a26b83291086e2504d128e98) Signed-off-by: Sol Jerome --- src/lib/Server/Admin/Init.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/lib/Server/Admin/Init.py b/src/lib/Server/Admin/Init.py index 0c5b457cc..d49c19fa1 100644 --- a/src/lib/Server/Admin/Init.py +++ b/src/lib/Server/Admin/Init.py @@ -188,7 +188,7 @@ class Init(Bcfg2.Server.Admin.Mode): self._prompt_hostname() self._prompt_server() self._prompt_groups() - self._prompt_plugins() + # self._prompt_plugins() self._prompt_certificate() # Initialize the repository @@ -218,7 +218,7 @@ class Init(Bcfg2.Server.Admin.Mode): 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 @@ -272,15 +272,19 @@ class Init(Bcfg2.Server.Admin.Mode): def _prompt_certificate(self): """Ask for the key details (country, state, and location).""" print "The following questions affects the certificate." - print "If there are data provided the default values are used." + 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' or len(newcountry) < '2': - newcountry = raw_input("Country name (2 letter code) for certificate: ") + if len(newcountry) == 2: + country = newcountry else: - self.country = newcountry + while len(newcountry) != 2: + newcountry = raw_input("2 letter country code (eg. US): ") + if len(newcountry) == 2: + country = newcountry + break else: - self.country = 'US' + country = 'US' newstate = raw_input("State or Province Name (full name) for certificate: ") if newstate != '': @@ -307,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.""" -- cgit v1.2.3-1-g7c22 From 901ae62249665ed813f0978ef10ed2063992f674 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Mon, 3 Jan 2011 23:13:53 +0100 Subject: Small fix (cherry picked from commit 0743aa20d0ee4c7b9cff50d814503e80efe6d433) Signed-off-by: Sol Jerome --- src/lib/Server/Admin/Init.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/Server/Admin/Init.py b/src/lib/Server/Admin/Init.py index d49c19fa1..aee91b244 100644 --- a/src/lib/Server/Admin/Init.py +++ b/src/lib/Server/Admin/Init.py @@ -276,15 +276,15 @@ class Init(Bcfg2.Server.Admin.Mode): newcountry = raw_input("Country name (2 letter code) for certificate: ") if newcountry != '': if len(newcountry) == 2: - country = newcountry + self.country = newcountry else: while len(newcountry) != 2: newcountry = raw_input("2 letter country code (eg. US): ") if len(newcountry) == 2: - country = newcountry + self.country = newcountry break else: - country = 'US' + self.country = 'US' newstate = raw_input("State or Province Name (full name) for certificate: ") if newstate != '': -- cgit v1.2.3-1-g7c22 From 8acbadc0c12d78f6dbc6c379b219ce6fb8ce2965 Mon Sep 17 00:00:00 2001 From: Sol Jerome Date: Wed, 5 Jan 2011 20:46:11 -0600 Subject: Remove old references to ConfigFile Signed-off-by: Sol Jerome --- src/sbin/bcfg2-info | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sbin/bcfg2-info b/src/sbin/bcfg2-info index 77b70f7e5..47fdf82d3 100755 --- a/src/sbin/bcfg2-info +++ b/src/sbin/bcfg2-info @@ -59,7 +59,7 @@ def displayTrace(trace, num=80, sort=('time', 'calls')): def write_config_file(outputdir, cfg): """ Store file content of an - ... entry + ... entry in the appropriate directory under the output directory. """ name = cfg.get('name') @@ -222,7 +222,7 @@ 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.') @@ -250,7 +250,7 @@ class infoCore(cmd.Cmd, Bcfg2.Server.Core.Core): 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, giving up: %s" %ex) -- cgit v1.2.3-1-g7c22 From f2f34ec086678222708535df74d9ee929f65a78a Mon Sep 17 00:00:00 2001 From: Sol Jerome Date: Thu, 6 Jan 2011 10:36:38 -0600 Subject: doc: Add warning about outdated EPEL packages Signed-off-by: Sol Jerome --- doc/appendix/guides/centos.txt | 7 +++++++ doc/server/plugins/version/svn2.txt | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/doc/appendix/guides/centos.txt b/doc/appendix/guides/centos.txt index 1e3c90156..db463b210 100644 --- a/doc/appendix/guides/centos.txt +++ b/doc/appendix/guides/centos.txt @@ -24,6 +24,13 @@ building Bcfg2 from source and making your own packages. Using EPEL ---------- +.. warning:: + + EPEL has outdated versions of the server package for centos5 and + earlier. This guide is intended to be used with versions 1.0.0 and + higher. Please consider building a newer RPM if you are following + this guide. + Make sure EPEL_ is a valid repository on your server. The `instructions `_ on how to do this basically say:: diff --git a/doc/server/plugins/version/svn2.txt b/doc/server/plugins/version/svn2.txt index 773f39f8c..021ae4fd2 100644 --- a/doc/server/plugins/version/svn2.txt +++ b/doc/server/plugins/version/svn2.txt @@ -8,14 +8,14 @@ Svn2 The Svn2 plugin is useful if you would like to track changes to your bcfg2 repository using a `Subversion `_ -backend. It is a rewrite of the Svn plugin using the +backend. It is a rewrite of the Svn plugin using the `pysvn `_ api. Currently, it enables you to get revision information out of your repository for reporting purposes. Once the plugin is enabled, every time a client checks in, it will include the current repository revision in the reports/statistics. If any changes are made from the bcfg2-server, -the plugin will commit them back into the repositroy. For example, +the plugin will commit them back into the repositroy. For example, ``/usr/sbin/bcfg2-admin pull client Path /some/file`` will update the servers repository and commit the changes into svn. @@ -33,6 +33,6 @@ Auto Commit feautre Svn2 adds the ability to commit changes back into the repository. In order for this feature to work the repository should already be under version control and the user the bcfg2-server runs as must be able to commit without -any interaction. For example, a file base repository url +any interaction. For example, a file base repository url (``file:///path/to/repo``). -- cgit v1.2.3-1-g7c22