summaryrefslogtreecommitdiffstats
path: root/src/lib/Server
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/Server')
-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
13 files changed, 121 insertions, 53 deletions
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 \