summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2012-05-24 09:56:38 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2012-06-01 09:42:33 -0400
commiteae8bbd6d211d711be4f414f108aa597b38891e0 (patch)
tree900fa4c05538ecfec773e848bad86b4c78b3cf8d /src
parentd04670f08578d8be2b88d0d736c85361ec81e335 (diff)
downloadbcfg2-eae8bbd6d211d711be4f414f108aa597b38891e0.tar.gz
bcfg2-eae8bbd6d211d711be4f414f108aa597b38891e0.tar.bz2
bcfg2-eae8bbd6d211d711be4f414f108aa597b38891e0.zip
fixed typo
Diffstat (limited to 'src')
-rw-r--r--src/lib/Bcfg2/Client/Tools/APT.py45
-rw-r--r--src/lib/Bcfg2/Client/Tools/Portage.py27
-rw-r--r--src/lib/Bcfg2/Client/Tools/RPMng.py122
-rw-r--r--src/lib/Bcfg2/Client/Tools/YUM24.py21
-rw-r--r--src/lib/Bcfg2/Client/Tools/YUMng.py51
-rw-r--r--src/lib/Bcfg2/Options.py205
-rwxr-xr-xsrc/sbin/bcfg271
7 files changed, 277 insertions, 265 deletions
diff --git a/src/lib/Bcfg2/Client/Tools/APT.py b/src/lib/Bcfg2/Client/Tools/APT.py
index 6b839ffbc..0ad42748c 100644
--- a/src/lib/Bcfg2/Client/Tools/APT.py
+++ b/src/lib/Bcfg2/Client/Tools/APT.py
@@ -6,22 +6,7 @@ warnings.filterwarnings("ignore", "apt API not stable yet",
FutureWarning)
import apt.cache
import os
-
import Bcfg2.Client.Tools
-import Bcfg2.Options
-
-# Options for tool locations
-opts = {'install_path': Bcfg2.Options.CLIENT_APT_TOOLS_INSTALL_PATH,
- 'var_path': Bcfg2.Options.CLIENT_APT_TOOLS_VAR_PATH,
- 'etc_path': Bcfg2.Options.CLIENT_SYSTEM_ETC_PATH}
-setup = Bcfg2.Options.OptionParser(opts)
-setup.parse([])
-install_path = setup['install_path']
-var_path = setup['var_path']
-etc_path = setup['etc_path']
-DEBSUMS = '%s/bin/debsums' % install_path
-APTGET = '%s/bin/apt-get' % install_path
-DPKG = '%s/bin/dpkg' % install_path
class APT(Bcfg2.Client.Tools.Tool):
"""The Debian toolset implements package and service operations and inherits
@@ -29,17 +14,26 @@ class APT(Bcfg2.Client.Tools.Tool):
"""
name = 'APT'
- __execs__ = [DEBSUMS, APTGET, DPKG]
+ __execs__ = []
__handles__ = [('Package', 'deb'), ('Path', 'ignore')]
__req__ = {'Package': ['name', 'version'], 'Path': ['type']}
def __init__(self, logger, setup, config):
Bcfg2.Client.Tools.Tool.__init__(self, logger, setup, config)
+
+ self.install_path = setup.get('apt_install_path', '/usr')
+ self.var_path = setup.get('apt_var_path', '/var')
+ self.etc_path = setup.get('apt_etc_path', '/etc')
+ self.debsums = '%s/bin/debsums' % self.install_path
+ self.aptget = '%s/bin/apt-get' % self.install_path
+ self.dpkg = '%s/bin/dpkg' % self.install_path
+ self.__execs__ = [self.debsums, self.aptget, self.dpkg]
+
path_entries = os.environ['PATH'].split(':')
for reqdir in ['/sbin', '/usr/sbin']:
if reqdir not in path_entries:
os.environ['PATH'] = os.environ['PATH'] + ':' + reqdir
- self.pkgcmd = '%s ' % APTGET + \
+ self.pkgcmd = '%s ' % self.aptget + \
'-o DPkg::Options::=--force-overwrite ' + \
'-o DPkg::Options::=--force-confold ' + \
'-o DPkg::Options::=--force-confmiss ' + \
@@ -53,21 +47,21 @@ class APT(Bcfg2.Client.Tools.Tool):
if entry.tag == 'Path' and \
entry.get('type') == 'ignore']
self.__important__ = self.__important__ + \
- ["%s/cache/debconf/config.dat" % var_path,
- "%s/cache/debconf/templates.dat" % var_path,
+ ["%s/cache/debconf/config.dat" % self.var_path,
+ "%s/cache/debconf/templates.dat" % self.var_path,
'/etc/passwd', '/etc/group',
- '%s/apt/apt.conf' % etc_path,
- '%s/dpkg/dpkg.cfg' % etc_path] + \
+ '%s/apt/apt.conf' % self.etc_path,
+ '%s/dpkg/dpkg.cfg' % self.etc_path] + \
[entry.get('name') for struct in config for entry in struct \
if entry.tag == 'Path' and \
- entry.get('name').startswith('%s/apt/sources.list' % etc_path)]
+ entry.get('name').startswith('%s/apt/sources.list' % self.etc_path)]
self.nonexistent = [entry.get('name') for struct in config for entry in struct \
if entry.tag == 'Path' and entry.get('type') == 'nonexistent']
os.environ["DEBIAN_FRONTEND"] = 'noninteractive'
self.actions = {}
if self.setup['kevlar'] and not self.setup['dryrun']:
- self.cmd.run("%s --force-confold --configure --pending" % DPKG)
- self.cmd.run("%s clean" % APTGET)
+ self.cmd.run("%s --force-confold --configure --pending" % self.dpkg)
+ self.cmd.run("%s clean" % self.aptget)
try:
self.pkg_cache = apt.cache.Cache()
except SystemError:
@@ -95,7 +89,8 @@ class APT(Bcfg2.Client.Tools.Tool):
for (name, version) in extras]
def VerifyDebsums(self, entry, modlist):
- output = self.cmd.run("%s -as %s" % (DEBSUMS, entry.get('name')))[1]
+ output = self.cmd.run("%s -as %s" % (self.debsums,
+ entry.get('name')))[1]
if len(output) == 1 and "no md5sums for" in output[0]:
self.logger.info("Package %s has no md5sums. Cannot verify" % \
entry.get('name'))
diff --git a/src/lib/Bcfg2/Client/Tools/Portage.py b/src/lib/Bcfg2/Client/Tools/Portage.py
index 4516f419d..36d48b8d3 100644
--- a/src/lib/Bcfg2/Client/Tools/Portage.py
+++ b/src/lib/Bcfg2/Client/Tools/Portage.py
@@ -2,8 +2,6 @@
import re
import Bcfg2.Client.Tools
-from Bcfg2.Bcfg2Py3k import ConfigParser
-
class Portage(Bcfg2.Client.Tools.PkgTool):
"""The Gentoo toolset implements package and service operations and
@@ -27,30 +25,11 @@ class Portage(Bcfg2.Client.Tools.PkgTool):
self._ebuild_pattern = re.compile('(ebuild|binary)')
self.cfg = cfg
self.installed = {}
- self._binpkgonly = True
-
- # Used to get options from configuration file
- parser = ConfigParser.ConfigParser()
- parser.read(self.setup.get('setup'))
- for opt in ['binpkgonly']:
- if parser.has_option(self.name, opt):
- setattr(self, ('_%s' % opt),
- self._StrToBoolIfBool(parser.get(self.name, opt)))
-
+ self._binpkgonly = self.setup.get('portage_binpkgonly', False)
if self._binpkgonly:
self.pkgtool = self._binpkgtool
self.RefreshPackages()
- def _StrToBoolIfBool(self, s):
- """Returns a boolean if the string specifies a boolean value.
- Returns a string otherwise"""
- if s.lower() in ('true', 'yes', 't', 'y', '1'):
- return True
- elif s.lower() in ('false', 'no', 'f', 'n', '0'):
- return False
- else:
- return s
-
def RefreshPackages(self):
"""Refresh memory hashes of packages."""
if not self._initialised:
@@ -83,8 +62,8 @@ class Portage(Bcfg2.Client.Tools.PkgTool):
entry.set('current_version', version)
if not self.setup['quick']:
- if ('verify' not in entry.attrib) or \
- self._StrToBoolIfBool(entry.get('verify')):
+ if ('verify' not in entry.attrib or
+ entry.get('verify').lower == 'true'):
# Check the package if:
# - Not running in quick mode
diff --git a/src/lib/Bcfg2/Client/Tools/RPMng.py b/src/lib/Bcfg2/Client/Tools/RPMng.py
index 00dd00d71..d6e5e82c5 100644
--- a/src/lib/Bcfg2/Client/Tools/RPMng.py
+++ b/src/lib/Bcfg2/Client/Tools/RPMng.py
@@ -4,8 +4,6 @@ import os.path
import rpm
import rpmtools
import Bcfg2.Client.Tools
-# Compatibility import
-from Bcfg2.Bcfg2Py3k import ConfigParser
class RPMng(Bcfg2.Client.Tools.PkgTool):
"""Support for RPM packages."""
@@ -44,82 +42,42 @@ class RPMng(Bcfg2.Client.Tools.PkgTool):
self.modlists = {}
self.gpg_keyids = self.getinstalledgpg()
- # Process thee RPMng section from the config file.
- RPMng_CP = ConfigParser.ConfigParser()
- RPMng_CP.read(self.setup.get('setup'))
-
- # installonlypackages
- self.installOnlyPkgs = []
- if RPMng_CP.has_option(self.name, 'installonlypackages'):
- for i in RPMng_CP.get(self.name, 'installonlypackages').split(','):
- self.installOnlyPkgs.append(i.strip())
- if self.installOnlyPkgs == []:
- self.installOnlyPkgs = ['kernel', 'kernel-bigmem', 'kernel-enterprise', 'kernel-smp',
- 'kernel-modules', 'kernel-debug', 'kernel-unsupported',
- 'kernel-source', 'kernel-devel', 'kernel-default',
- 'kernel-largesmp-devel', 'kernel-largesmp', 'kernel-xen',
- 'gpg-pubkey']
+ opt_prefix = self.name.lower()
+ self.installOnlyPkgs = self.setup["%s_installonly" % opt_prefix]
if 'gpg-pubkey' not in self.installOnlyPkgs:
self.installOnlyPkgs.append('gpg-pubkey')
- self.logger.debug('installOnlyPackages = %s' % self.installOnlyPkgs)
-
- # erase_flags
- self.erase_flags = []
- if RPMng_CP.has_option(self.name, 'erase_flags'):
- for i in RPMng_CP.get(self.name, 'erase_flags').split(','):
- self.erase_flags.append(i.strip())
- if self.erase_flags == []:
- self.erase_flags = ['allmatches']
- self.logger.debug('erase_flags = %s' % self.erase_flags)
-
- # pkg_checks
- if RPMng_CP.has_option(self.name, 'pkg_checks'):
- self.pkg_checks = RPMng_CP.get(self.name, 'pkg_checks').lower()
- else:
- self.pkg_checks = 'true'
- self.logger.debug('pkg_checks = %s' % self.pkg_checks)
-
- # pkg_verify
- if RPMng_CP.has_option(self.name, 'pkg_verify'):
- self.pkg_verify = RPMng_CP.get(self.name, 'pkg_verify').lower()
- else:
- self.pkg_verify = 'true'
- self.logger.debug('pkg_verify = %s' % self.pkg_verify)
-
- # installed_action
- if RPMng_CP.has_option(self.name, 'installed_action'):
- self.installed_action = RPMng_CP.get(self.name, 'installed_action').lower()
- else:
- self.installed_action = 'install'
- self.logger.debug('installed_action = %s' % self.installed_action)
-
- # version_fail_action
- if RPMng_CP.has_option(self.name, 'version_fail_action'):
- self.version_fail_action = RPMng_CP.get(self.name, 'version_fail_action').lower()
- else:
- self.version_fail_action = 'upgrade'
- self.logger.debug('version_fail_action = %s' % self.version_fail_action)
-
- # verify_fail_action
- if self.name == "RPMng":
- if RPMng_CP.has_option(self.name, 'verify_fail_action'):
- self.verify_fail_action = RPMng_CP.get(self.name, 'verify_fail_action').lower()
- else:
- self.verify_fail_action = 'reinstall'
- else: # yum can't reinstall packages.
- self.verify_fail_action = 'none'
- self.logger.debug('verify_fail_action = %s' % self.verify_fail_action)
-
- # version_fail_action
- if RPMng_CP.has_option(self.name, 'verify_flags'):
- self.verify_flags = RPMng_CP.get(self.name, 'verify_flags').lower().split(',')
- else:
- self.verify_flags = []
+ self.erase_flags = self.setup['%s_erase_flags' % opt_prefix]
+ self.pkg_checks = self.setup['%s_pkg_checks' % opt_prefix]
+ self.pkg_verify = self.setup['%s_pkg_verify' % opt_prefix]
+ self.installed_action = self.setup['%s_installed_action' % opt_prefix]
+ self.version_fail_action = self.setup['%s_version_fail_action' %
+ opt_prefix]
+ self.verify_fail_action = self.setup['%s_verify_fail_action' %
+ opt_prefix]
+ self.verify_flags = self.setup['%s_verify_flags' % opt_prefix]
if '' in self.verify_flags:
self.verify_flags.remove('')
- self.logger.debug('version_fail_action = %s' % self.version_fail_action)
+
+ self.logger.debug('%s: installOnlyPackages = %s' %
+ (self.name, self.installOnlyPkgs))
+ self.logger.debug('%s: erase_flags = %s' %
+ (self.name, self.erase_flags))
+ self.logger.debug('%s: pkg_checks = %s' %
+ (self.name, self.pkg_checks))
+ self.logger.debug('%s: pkg_verify = %s' %
+ (self.name, self.pkg_verify))
+ self.logger.debug('%s: installed_action = %s' %
+ (self.name, self.installed_action))
+ self.logger.debug('%s: version_fail_action = %s' %
+ (self.name, self.version_fail_action))
+ self.logger.debug('%s: verify_fail_action = %s' %
+ (self.name, self.verify_fail_action))
+ self.logger.debug('%s: verify_flags = %s' %
+ (self.name, self.verify_flags))
+
# Force a re- prelink of all packages if prelink exists.
- # Many, if not most package verifies can be caused by out of date prelinking.
+ # Many, if not most package verifies can be caused by out of
+ # date prelinking.
if os.path.isfile('/usr/sbin/prelink') and not self.setup['dryrun']:
cmdrc, output = self.cmd.run('/usr/sbin/prelink -a -mR')
if cmdrc == 0:
@@ -193,7 +151,8 @@ class RPMng(Bcfg2.Client.Tools.PkgTool):
instance = Bcfg2.Client.XML.SubElement(entry, 'Package')
for attrib in list(entry.attrib.keys()):
instance.attrib[attrib] = entry.attrib[attrib]
- if self.pkg_checks == 'true' and entry.get('pkg_checks', 'true') == 'true':
+ if (self.pkg_checks and
+ entry.get('pkg_checks', 'true').lower() == 'true'):
if 'any' in [entry.get('version'), pinned_version]:
version, release = 'any', 'any'
elif entry.get('version') == 'auto':
@@ -215,7 +174,8 @@ class RPMng(Bcfg2.Client.Tools.PkgTool):
if entry.get('name') in self.installed:
# There is at least one instance installed.
- if self.pkg_checks == 'true' and entry.get('pkg_checks', 'true') == 'true':
+ if (self.pkg_checks and
+ entry.get('pkg_checks', 'true').lower() == 'true'):
rpmTs = rpm.TransactionSet()
rpmHeader = None
for h in rpmTs.dbMatch(rpm.RPMTAG_NAME, entry.get('name')):
@@ -243,8 +203,8 @@ class RPMng(Bcfg2.Client.Tools.PkgTool):
self.logger.debug(" %s" % self.str_evra(inst))
self.instance_status[inst]['installed'] = True
- if self.pkg_verify == 'true' and \
- inst.get('pkg_verify', 'true') == 'true':
+ if (self.pkg_verify and
+ inst.get('pkg_verify', 'true').lower() == 'true'):
flags = inst.get('verify_flags', '').split(',') + self.verify_flags
if pkg.get('gpgkeyid', '')[-8:] not in self.gpg_keyids and \
entry.get('name') != 'gpg-pubkey':
@@ -302,8 +262,8 @@ class RPMng(Bcfg2.Client.Tools.PkgTool):
self.logger.debug(" %s" % self.str_evra(inst))
self.instance_status[inst]['installed'] = True
- if self.pkg_verify == 'true' and \
- inst.get('pkg_verify', 'true') == 'true':
+ if (self.pkg_verify and
+ inst.get('pkg_verify', 'true').lower() == 'true'):
flags = inst.get('verify_flags', '').split(',') + self.verify_flags
if pkg.get('gpgkeyid', '')[-8:] not in self.gpg_keyids and \
'nosignature' not in flags:
@@ -824,8 +784,8 @@ class RPMng(Bcfg2.Client.Tools.PkgTool):
return False
# We don't want to do any checks so we don't care what the entry has in it.
- if self.pkg_checks == 'false' or \
- entry.get('pkg_checks', 'true').lower() == 'false':
+ if (not self.pkg_checks or
+ entry.get('pkg_checks', 'true').lower() == 'false'):
return True
instances = entry.findall('Instance')
diff --git a/src/lib/Bcfg2/Client/Tools/YUM24.py b/src/lib/Bcfg2/Client/Tools/YUM24.py
index 4e488b9da..2bc821db3 100644
--- a/src/lib/Bcfg2/Client/Tools/YUM24.py
+++ b/src/lib/Bcfg2/Client/Tools/YUM24.py
@@ -6,20 +6,6 @@ import sys
import yum
import Bcfg2.Client.XML
import Bcfg2.Client.Tools.RPMng
-# Compatibility import
-from Bcfg2.Bcfg2Py3k import ConfigParser
-
-YAD = True
-CP = ConfigParser.ConfigParser()
-try:
- if '-C' in sys.argv:
- CP.read([sys.argv[sys.argv.index('-C') + 1]])
- else:
- CP.read(['/etc/bcfg2.conf'])
- if CP.get('YUMng', 'autodep').lower() == 'false':
- YAD = False
-except:
- pass
if not hasattr(Bcfg2.Client.Tools.RPMng, 'RPMng'):
raise ImportError
@@ -79,6 +65,7 @@ class YUM24(Bcfg2.Client.Tools.RPMng.RPMng):
(entry.get('name').startswith('/etc/yum.d') \
or entry.get('name').startswith('/etc/yum.repos.d')) \
or entry.get('name') == '/etc/yum.conf']
+ self.autodep = setup.get("yum24_autodep")
self.yum_avail = dict()
self.yum_installed = dict()
self.yb = yum.YumBase()
@@ -273,7 +260,7 @@ class YUM24(Bcfg2.Client.Tools.RPMng.RPMng):
if len(install_pkgs) > 0:
self.logger.info("Attempting to install packages")
- if YAD:
+ if self.autodep:
pkgtool = "/usr/bin/yum -d0 -y install %s"
else:
pkgtool = "/usr/bin/yum -d0 install %s"
@@ -309,7 +296,7 @@ class YUM24(Bcfg2.Client.Tools.RPMng.RPMng):
if len(upgrade_pkgs) > 0:
self.logger.info("Attempting to upgrade packages")
- if YAD:
+ if self.autodep:
pkgtool = "/usr/bin/yum -d0 -y update %s"
else:
pkgtool = "/usr/bin/yum -d0 update %s"
@@ -359,7 +346,7 @@ class YUM24(Bcfg2.Client.Tools.RPMng.RPMng):
"""
self.logger.debug('Running YUMng.RemovePackages()')
- if YAD:
+ if self.autodep:
pkgtool = "/usr/bin/yum -d0 -y erase %s"
else:
pkgtool = "/usr/bin/yum -d0 erase %s"
diff --git a/src/lib/Bcfg2/Client/Tools/YUMng.py b/src/lib/Bcfg2/Client/Tools/YUMng.py
index 6dc2940f3..aba556bbd 100644
--- a/src/lib/Bcfg2/Client/Tools/YUMng.py
+++ b/src/lib/Bcfg2/Client/Tools/YUMng.py
@@ -12,9 +12,6 @@ import yum.misc
import rpmUtils.arch
import Bcfg2.Client.XML
import Bcfg2.Client.Tools
-# Compatibility import
-from Bcfg2.Bcfg2Py3k import ConfigParser
-
def build_yname(pkgname, inst):
"""Build yum appropriate package name."""
@@ -58,20 +55,6 @@ def nevraString(p):
return ret
-class Parser(ConfigParser.ConfigParser):
-
- def get(self, section, option, default):
- """
- Override ConfigParser.get: If the request option is not in the
- config file then return the value of default rather than raise
- an exception. We still raise exceptions on missing sections.
- """
- try:
- return ConfigParser.ConfigParser.get(self, section, option)
- except (ConfigParser.NoOptionError, ConfigParser.NoSectionError):
- return default
-
-
class RPMDisplay(yum.rpmtrans.RPMBaseCallback):
"""We subclass the default RPM transaction callback so that we
can control Yum's verbosity and pipe it through the right logger."""
@@ -224,38 +207,24 @@ class YUMng(Bcfg2.Client.Tools.PkgTool):
def _loadConfig(self):
# Process the YUMng section from the config file.
- CP = Parser()
- CP.read(self.setup.get('setup'))
- truth = ['true', 'yes', '1']
-
# These are all boolean flags, either we do stuff or we don't
- self.pkg_checks = CP.get(self.name, "pkg_checks", "true").lower() \
- in truth
- self.pkg_verify = CP.get(self.name, "pkg_verify", "true").lower() \
- in truth
- self.doInstall = CP.get(self.name, "installed_action",
- "install").lower() == "install"
- self.doUpgrade = CP.get(self.name,
- "version_fail_action", "upgrade").lower() == "upgrade"
- self.doReinst = CP.get(self.name, "verify_fail_action",
- "reinstall").lower() == "reinstall"
- self.verifyFlags = CP.get(self.name, "verify_flags",
- "").lower().replace(' ', ',')
+ self.pkg_checks = self.setup["yumng_pkg_checks"]
+ self.pkg_verify = self.setup["yumng_pkg_verify"]
+ self.doInstall = self.setup["yumng_installed_action"] == "install"
+ self.doUpgrade = self.setup["yumng_version_action"] == "upgrade"
+ self.doReinst = self.setup["yumng_verify_action"] == "reinstall"
+ self.verifyFlags = self.setup["yumng_verify_flags"]
self.installOnlyPkgs = self.yb.conf.installonlypkgs
if 'gpg-pubkey' not in self.installOnlyPkgs:
self.installOnlyPkgs.append('gpg-pubkey')
- self.logger.debug("YUMng: Install missing: %s" \
- % self.doInstall)
+ self.logger.debug("YUMng: Install missing: %s" % self.doInstall)
self.logger.debug("YUMng: pkg_checks: %s" % self.pkg_checks)
self.logger.debug("YUMng: pkg_verify: %s" % self.pkg_verify)
- self.logger.debug("YUMng: Upgrade on version fail: %s" \
- % self.doUpgrade)
- self.logger.debug("YUMng: Reinstall on verify fail: %s" \
- % self.doReinst)
- self.logger.debug("YUMng: installOnlyPkgs: %s" \
- % str(self.installOnlyPkgs))
+ self.logger.debug("YUMng: Upgrade on version fail: %s" % self.doUpgrade)
+ self.logger.debug("YUMng: Reinstall on verify fail: %s" % self.doReinst)
+ self.logger.debug("YUMng: installOnlyPkgs: %s" % self.installOnlyPkgs)
self.logger.debug("YUMng: verify_flags: %s" % self.verifyFlags)
def _fixAutoVersion(self, entry):
diff --git a/src/lib/Bcfg2/Options.py b/src/lib/Bcfg2/Options.py
index ae79e1dd0..0791ce343 100644
--- a/src/lib/Bcfg2/Options.py
+++ b/src/lib/Bcfg2/Options.py
@@ -11,13 +11,6 @@ import Bcfg2.Client.Tools
from Bcfg2.Bcfg2Py3k import ConfigParser
-def bool_cook(x):
- if x:
- return True
- else:
- return False
-
-
class OptionFailure(Exception):
pass
@@ -83,7 +76,7 @@ class Option(object):
self.env = env
self.cf = cf
self.boolean = False
- if not odesc and not cook:
+ if not odesc and not cook and isinstance(self.default, bool):
self.boolean = True
self.cook = cook
@@ -271,7 +264,7 @@ VERBOSE = \
cmd='-v')
DAEMON = \
Option("Daemonize process, storing pid",
- default=False,
+ default=None,
cmd='-D',
odesc='<pidfile>')
INSTALL_PREFIX = \
@@ -310,7 +303,7 @@ OMIT_LOCK_CHECK = \
CORE_PROFILE = \
Option('profile',
default=False,
- cmd='-p', )
+ cmd='-p')
SCHEMA_PATH = \
Option('Path to XML Schema files',
default='%s/share/bcfg2/schemas' % DEFAULT_INSTALL_PREFIX,
@@ -360,14 +353,7 @@ SERVER_REPOSITORY = \
SERVER_PLUGINS = \
Option('Server plugin list',
# default server plugins
- default=[
- 'Bundler',
- 'Cfg',
- 'Metadata',
- 'Pkgmgr',
- 'Rules',
- 'SSHbase',
- ],
+ default=['Bundler', 'Cfg', 'Metadata', 'Pkgmgr', 'Rules', 'SSHbase'],
cf=('server', 'plugins'),
cook=list_split)
SERVER_MCONNECT = \
@@ -382,24 +368,14 @@ SERVER_FILEMONITOR = \
cf=('server', 'filemonitor'))
SERVER_FAM_IGNORE = \
Option('File globs to ignore',
- default=[
- '*~',
- '*#',
- '.#*',
- '*.swp',
- '.*.swx',
- 'SCCS',
- '.svn',
- '4913',
- '.gitignore',
- ],
+ default=['*~', '*#', '.#*', '*.swp', '.*.swx', 'SCCS', '.svn',
+ '4913', '.gitignore',],
cf=('server', 'ignore_files'),
cook=list_split)
SERVER_LISTEN_ALL = \
Option('Listen on all interfaces',
default=False,
cmd='--listen-all',
- odesc='True|False',
cf=('server', 'listen_all'),
cook=get_bool,
long_arg=True)
@@ -412,11 +388,10 @@ SERVER_LOCATION = \
SERVER_STATIC = \
Option('Server runs on static port',
default=False,
- cf=('components', 'bcfg2'),
- cook=bool_cook)
+ cf=('components', 'bcfg2'))
SERVER_KEY = \
Option('Path to SSL key',
- default=False,
+ default=None,
cmd='--ssl-key',
odesc='<ssl key>',
cf=('communication', 'key'),
@@ -433,7 +408,7 @@ SERVER_CA = \
cf=('communication', 'ca'))
SERVER_PASSWORD = \
Option('Communication Password',
- default=False,
+ default=None,
cmd='-x',
odesc='<password>',
cf=('communication', 'password'))
@@ -474,7 +449,7 @@ CLIENT_SCNS = \
long_arg=True)
CLIENT_PROFILE = \
Option('Assert the given profile for the host',
- default=False,
+ default=None,
cmd='-p',
odesc='<profile>')
CLIENT_RETRIES = \
@@ -506,12 +481,12 @@ CLIENT_DRIVERS = \
cook=list_split)
CLIENT_CACHE = \
Option('Store the configuration in a file',
- default=False,
+ default=None,
cmd='-c',
odesc='<cache path>')
CLIENT_REMOVE = \
Option('Force removal of additional configuration items',
- default=False,
+ default=None,
cmd='-r',
odesc='<entry type|all>')
CLIENT_BUNDLE = \
@@ -521,7 +496,7 @@ CLIENT_BUNDLE = \
odesc='<bundle:bundle>',
cook=colon_split)
CLIENT_BUNDLEQUICK = \
- Option('only verify/configure the given bundle(s)',
+ Option('Only verify/configure the given bundle(s)',
default=False,
cmd='-Q')
CLIENT_INDEP = \
@@ -534,7 +509,7 @@ CLIENT_KEVLAR = \
cmd='-k', )
CLIENT_FILE = \
Option('Configure from a file rather than querying the server',
- default=False,
+ default=None,
cmd='-f',
odesc='<specification path>')
CLIENT_QUICK = \
@@ -605,7 +580,7 @@ LINT_FILES_ON_STDIN = \
cmd='--stdin',
long_arg=True)
-# APT client tool options
+# individual client tool options
CLIENT_APT_TOOLS_INSTALL_PATH = \
Option('Apt tools install path',
default='/usr',
@@ -618,6 +593,125 @@ CLIENT_SYSTEM_ETC_PATH = \
Option('System etc path',
default='/etc',
cf=('APT', 'etc_path'))
+CLIENT_PORTAGE_BINPKGONLY = \
+ Option('Portage binary packages only',
+ default=False,
+ cf=('Portage', 'binpkgonly'),
+ cook=get_bool)
+CLIENT_RPMNG_INSTALLONLY = \
+ Option('RPMng install-only packages',
+ default=['kernel', 'kernel-bigmem', 'kernel-enterprise',
+ 'kernel-smp', 'kernel-modules', 'kernel-debug',
+ 'kernel-unsupported', 'kernel-devel', 'kernel-source',
+ 'kernel-default', 'kernel-largesmp-devel',
+ 'kernel-largesmp', 'kernel-xen', 'gpg-pubkey'],
+ cf=('RPMng', 'installonlypackages'),
+ cook=list_split)
+CLIENT_RPMNG_PKG_CHECKS = \
+ Option("Perform RPMng package checks",
+ default=True,
+ cf=('RPMng', 'pkg_checks'),
+ cook=get_bool)
+CLIENT_RPMNG_PKG_VERIFY = \
+ Option("Perform RPMng package verify",
+ default=True,
+ cf=('RPMng', 'pkg_verify'),
+ cook=get_bool)
+CLIENT_RPMNG_INSTALLED_ACTION = \
+ Option("RPMng installed action",
+ default="install",
+ cf=('RPMng', 'installed_action'))
+CLIENT_RPMNG_ERASE_FLAGS = \
+ Option("RPMng erase flags",
+ default=["allmatches"],
+ cf=('RPMng', 'erase_flags'),
+ cook=list_split)
+CLIENT_RPMNG_VERSION_FAIL_ACTION = \
+ Option("RPMng version fail action",
+ default="upgrade",
+ cf=('RPMng', 'version_fail_action'))
+CLIENT_RPMNG_VERIFY_FAIL_ACTION = \
+ Option("RPMng verify fail action",
+ default="reinstall",
+ cf=('RPMng', 'verify_fail_action'))
+CLIENT_RPMNG_VERIFY_FLAGS = \
+ Option("RPMng verify flags",
+ default=[],
+ cf=('RPMng', 'verify_flags'),
+ cook=list_split)
+CLIENT_YUM24_INSTALLONLY = \
+ Option('RPMng install-only packages',
+ default=['kernel', 'kernel-bigmem', 'kernel-enterprise',
+ 'kernel-smp', 'kernel-modules', 'kernel-debug',
+ 'kernel-unsupported', 'kernel-devel', 'kernel-source',
+ 'kernel-default', 'kernel-largesmp-devel',
+ 'kernel-largesmp', 'kernel-xen', 'gpg-pubkey'],
+ cf=('RPMng', 'installonlypackages'),
+ cook=list_split)
+CLIENT_YUM24_PKG_CHECKS = \
+ Option("Perform YUM24 package checks",
+ default=True,
+ cf=('YUM24', 'pkg_checks'),
+ cook=get_bool)
+CLIENT_YUM24_PKG_VERIFY = \
+ Option("Perform YUM24 package verify",
+ default=True,
+ cf=('YUM24', 'pkg_verify'),
+ cook=get_bool)
+CLIENT_YUM24_INSTALLED_ACTION = \
+ Option("YUM24 installed action",
+ default="install",
+ cf=('YUM24', 'installed_action'))
+CLIENT_YUM24_ERASE_FLAGS = \
+ Option("YUM24 erase flags",
+ default=["allmatches"],
+ cf=('YUM24', 'erase_flags'),
+ cook=list_split)
+CLIENT_YUM24_VERSION_FAIL_ACTION = \
+ Option("YUM24 version fail action",
+ cf=('YUM24', 'version_fail_action'),
+ default="upgrade")
+CLIENT_YUM24_VERIFY_FAIL_ACTION = \
+ Option("YUM24 verify fail action",
+ default="reinstall",
+ cf=('YUM24', 'verify_fail_action'))
+CLIENT_YUM24_VERIFY_FLAGS = \
+ Option("YUM24 verify flags",
+ default=[],
+ cf=('YUM24', 'verify_flags'),
+ cook=list_split)
+CLIENT_YUM24_AUTODEP = \
+ Option("YUM24 autodependency processing",
+ default=True,
+ cf=('YUM24', 'autodep'),
+ cook=get_bool)
+CLIENT_YUMNG_PKG_CHECKS = \
+ Option("Perform YUMng package checks",
+ default=True,
+ cf=('YUMng', 'pkg_checks'),
+ cook=get_bool)
+CLIENT_YUMNG_PKG_VERIFY = \
+ Option("Perform YUMng package verify",
+ default=True,
+ cf=('YUMng', 'pkg_verify'),
+ cook=get_bool)
+CLIENT_YUMNG_INSTALLED_ACTION = \
+ Option("YUMng installed action",
+ default="install",
+ cf=('YUMng', 'installed_action'))
+CLIENT_YUMNG_VERSION_FAIL_ACTION = \
+ Option("YUMng version fail action",
+ default="upgrade",
+ cf=('YUMng', 'version_fail_action'))
+CLIENT_YUMNG_VERIFY_FAIL_ACTION = \
+ Option("YUMng verify fail action",
+ default="reinstall",
+ cf=('YUMng', 'verify_fail_action'))
+CLIENT_YUMNG_VERIFY_FLAGS = \
+ Option("YUMng verify flags",
+ default=[],
+ cf=('YUMng', 'verify_flags'),
+ cook=list_split)
# Logging options
LOGGING_FILE_PATH = \
@@ -633,7 +727,8 @@ CFG_VALIDATION = \
default=True,
cmd='--cfg-validation',
cf=('cfg', 'validation'),
- long_arg=True, cook=get_bool)
+ long_arg=True,
+ cook=get_bool)
# Option groups
@@ -659,6 +754,34 @@ SERVER_COMMON_OPTIONS = dict(repo=SERVER_REPOSITORY,
ca=SERVER_CA,
protocol=SERVER_PROTOCOL)
+DRIVER_OPTIONS = \
+ dict(apt_install_path=CLIENT_APT_TOOLS_INSTALL_PATH,
+ apt_var_path=CLIENT_APT_TOOLS_VAR_PATH,
+ apt_etc_path=CLIENT_SYSTEM_ETC_PATH,
+ portage_binpkgonly=CLIENT_PORTAGE_BINPKGONLY,
+ rpmng_installonly=CLIENT_RPMNG_INSTALLONLY,
+ rpmng_pkg_checks=CLIENT_RPMNG_PKG_CHECKS,
+ rpmng_pkg_verify=CLIENT_RPMNG_PKG_VERIFY,
+ rpmng_installed_action=CLIENT_RPMNG_INSTALLED_ACTION,
+ rpmng_erase_flags=CLIENT_RPMNG_ERASE_FLAGS,
+ rpmng_version_fail_action=CLIENT_RPMNG_VERSION_FAIL_ACTION,
+ rpmng_verify_fail_action=CLIENT_RPMNG_VERIFY_FAIL_ACTION,
+ rpmng_verify_flags=CLIENT_RPMNG_VERIFY_FLAGS,
+ yum24_installonly=CLIENT_YUM24_INSTALLONLY,
+ yum24_pkg_checks=CLIENT_YUM24_PKG_CHECKS,
+ yum24_pkg_verify=CLIENT_YUM24_PKG_VERIFY,
+ yum24_installed_action=CLIENT_YUM24_INSTALLED_ACTION,
+ yum24_erase_flags=CLIENT_YUM24_ERASE_FLAGS,
+ yum24_version_fail_action=CLIENT_YUM24_VERSION_FAIL_ACTION,
+ yum24_verify_fail_action=CLIENT_YUM24_VERIFY_FAIL_ACTION,
+ yum24_verify_flags=CLIENT_YUM24_VERIFY_FLAGS,
+ yum24_autodep=CLIENT_YUM24_AUTODEP,
+ yumng_pkg_checks=CLIENT_YUMNG_PKG_CHECKS,
+ yumng_pkg_verify=CLIENT_YUMNG_PKG_VERIFY,
+ yumng_installed_action=CLIENT_YUMNG_INSTALLED_ACTION,
+ yumng_version_fail_action=CLIENT_YUMNG_VERSION_FAIL_ACTION,
+ yumng_verify_fail_action=CLIENT_YUMNG_VERIFY_FAIL_ACTION,
+ yumng_verify_flags=CLIENT_YUMNG_VERIFY_FLAGS)
class OptionParser(OptionSet):
"""
diff --git a/src/sbin/bcfg2 b/src/sbin/bcfg2
index d27e601b6..3b5877c09 100755
--- a/src/sbin/bcfg2
+++ b/src/sbin/bcfg2
@@ -35,35 +35,37 @@ class Client:
self.toolset = None
self.config = None
- optinfo = dict(extra=Bcfg2.Options.CLIENT_EXTRA_DISPLAY,
- quick=Bcfg2.Options.CLIENT_QUICK,
- lockfile=Bcfg2.Options.LOCKFILE,
- drivers=Bcfg2.Options.CLIENT_DRIVERS,
- dryrun=Bcfg2.Options.CLIENT_DRYRUN,
- paranoid=Bcfg2.Options.CLIENT_PARANOID,
- bundle=Bcfg2.Options.CLIENT_BUNDLE,
- bundle_quick=Bcfg2.Options.CLIENT_BUNDLEQUICK,
- indep=Bcfg2.Options.CLIENT_INDEP,
- file=Bcfg2.Options.CLIENT_FILE,
- interactive=Bcfg2.Options.INTERACTIVE,
- cache=Bcfg2.Options.CLIENT_CACHE,
- profile=Bcfg2.Options.CLIENT_PROFILE,
- remove=Bcfg2.Options.CLIENT_REMOVE,
- server=Bcfg2.Options.SERVER_LOCATION,
- user=Bcfg2.Options.CLIENT_USER,
- password=Bcfg2.Options.SERVER_PASSWORD,
- retries=Bcfg2.Options.CLIENT_RETRIES,
- kevlar=Bcfg2.Options.CLIENT_KEVLAR,
- omit_lock_check=Bcfg2.Options.OMIT_LOCK_CHECK,
- decision=Bcfg2.Options.CLIENT_DLIST,
- servicemode=Bcfg2.Options.CLIENT_SERVICE_MODE,
- key=Bcfg2.Options.CLIENT_KEY,
- certificate=Bcfg2.Options.CLIENT_CERT,
- ca=Bcfg2.Options.CLIENT_CA,
- serverCN=Bcfg2.Options.CLIENT_SCNS,
- timeout=Bcfg2.Options.CLIENT_TIMEOUT,
- decision_list=Bcfg2.Options.CLIENT_DECISION_LIST)
+ optinfo = \
+ dict(extra=Bcfg2.Options.CLIENT_EXTRA_DISPLAY,
+ quick=Bcfg2.Options.CLIENT_QUICK,
+ lockfile=Bcfg2.Options.LOCKFILE,
+ drivers=Bcfg2.Options.CLIENT_DRIVERS,
+ dryrun=Bcfg2.Options.CLIENT_DRYRUN,
+ paranoid=Bcfg2.Options.CLIENT_PARANOID,
+ bundle=Bcfg2.Options.CLIENT_BUNDLE,
+ bundle_quick=Bcfg2.Options.CLIENT_BUNDLEQUICK,
+ indep=Bcfg2.Options.CLIENT_INDEP,
+ file=Bcfg2.Options.CLIENT_FILE,
+ interactive=Bcfg2.Options.INTERACTIVE,
+ cache=Bcfg2.Options.CLIENT_CACHE,
+ profile=Bcfg2.Options.CLIENT_PROFILE,
+ remove=Bcfg2.Options.CLIENT_REMOVE,
+ server=Bcfg2.Options.SERVER_LOCATION,
+ user=Bcfg2.Options.CLIENT_USER,
+ password=Bcfg2.Options.SERVER_PASSWORD,
+ retries=Bcfg2.Options.CLIENT_RETRIES,
+ kevlar=Bcfg2.Options.CLIENT_KEVLAR,
+ omit_lock_check=Bcfg2.Options.OMIT_LOCK_CHECK,
+ decision=Bcfg2.Options.CLIENT_DLIST,
+ servicemode=Bcfg2.Options.CLIENT_SERVICE_MODE,
+ key=Bcfg2.Options.CLIENT_KEY,
+ certificate=Bcfg2.Options.CLIENT_CERT,
+ ca=Bcfg2.Options.CLIENT_CA,
+ serverCN=Bcfg2.Options.CLIENT_SCNS,
+ timeout=Bcfg2.Options.CLIENT_TIMEOUT,
+ decision_list=Bcfg2.Options.CLIENT_DECISION_LIST)
optinfo.update(Bcfg2.Options.CLI_COMMON_OPTIONS)
+ optinfo.update(Bcfg2.Options.DRIVER_OPTIONS)
self.setup = Bcfg2.Options.OptionParser(optinfo)
self.setup.parse(sys.argv[1:])
@@ -86,7 +88,7 @@ class Client:
if self.setup['bundle'] == []:
self.logger.error("-Q option requires -b")
raise SystemExit(1)
- elif self.setup['remove'] != False:
+ elif self.setup['remove']:
self.logger.error("-Q option incompatible with -r")
raise SystemExit(1)
if 'drivers' in self.setup and self.setup['drivers'] == 'help':
@@ -95,14 +97,11 @@ class Client:
raise SystemExit(0)
if self.setup['remove'] and 'services' in self.setup['remove']:
self.logger.error("Service removal is nonsensical; removed services will only be disabled")
- if self.setup['remove'] not in [False,
- 'all',
- 'Services',
- 'Packages',
- 'services',
- 'packages']:
+ if self.setup['remove'] not in [None, 'all',
+ 'Services', 'Packages',
+ 'services', 'packages']:
self.logger.error("Got unknown argument %s for -r" % (self.setup['remove']))
- if (self.setup["file"] != False) and (self.setup["cache"] != False):
+ if self.setup["file"] and self.setup["cache"]:
print("cannot use -f and -c together")
raise SystemExit(1)
if not self.setup['server'].startswith('https://'):