diff options
author | Sol Jerome <solj@ices.utexas.edu> | 2009-08-16 19:57:11 +0000 |
---|---|---|
committer | Sol Jerome <solj@ices.utexas.edu> | 2009-08-16 19:57:11 +0000 |
commit | a5767685db4d864cc356b302886b4113d9daf167 (patch) | |
tree | 56cd230abc84aff2f4f33dde2b9c0aedfb66f267 /src/lib | |
parent | cc4c455ade877ef2b2345a59e2e0f12e8cbc7abe (diff) | |
download | bcfg2-a5767685db4d864cc356b302886b4113d9daf167.tar.gz bcfg2-a5767685db4d864cc356b302886b4113d9daf167.tar.bz2 bcfg2-a5767685db4d864cc356b302886b4113d9daf167.zip |
Client tools: Remove unnecessary extra whitespace
Signed-off-by: Sol Jerome <solj@ices.utexas.edu>
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5408 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/Client/Tools/APT.py | 10 | ||||
-rw-r--r-- | src/lib/Client/Tools/Action.py | 4 | ||||
-rw-r--r-- | src/lib/Client/Tools/Blast.py | 2 | ||||
-rw-r--r-- | src/lib/Client/Tools/Chkconfig.py | 2 | ||||
-rw-r--r-- | src/lib/Client/Tools/DebInit.py | 4 | ||||
-rw-r--r-- | src/lib/Client/Tools/IPS.py | 2 | ||||
-rw-r--r-- | src/lib/Client/Tools/POSIX.py | 8 | ||||
-rw-r--r-- | src/lib/Client/Tools/Portage.py | 8 | ||||
-rw-r--r-- | src/lib/Client/Tools/RPMng.py | 116 | ||||
-rw-r--r-- | src/lib/Client/Tools/SMF.py | 2 | ||||
-rw-r--r-- | src/lib/Client/Tools/SYSV.py | 2 | ||||
-rw-r--r-- | src/lib/Client/Tools/YUMng.py | 16 | ||||
-rw-r--r-- | src/lib/Client/Tools/__init__.py | 6 | ||||
-rw-r--r-- | src/lib/Client/Tools/launchd.py | 2 | ||||
-rwxr-xr-x | src/lib/Client/Tools/rpmtools.py | 154 | ||||
-rw-r--r-- | src/lib/Server/Plugins/__init__.py | 2 |
16 files changed, 170 insertions, 170 deletions
diff --git a/src/lib/Client/Tools/APT.py b/src/lib/Client/Tools/APT.py index 074b9f1ca..14568aa7f 100644 --- a/src/lib/Client/Tools/APT.py +++ b/src/lib/Client/Tools/APT.py @@ -15,9 +15,9 @@ class APT(Bcfg2.Client.Tools.Tool): name = 'APT' __execs__ = ['/usr/bin/debsums', '/usr/bin/apt-get', '/usr/bin/dpkg'] __important__ = ["/etc/apt/sources.list", - "/var/cache/debconf/config.dat", + "/var/cache/debconf/config.dat", "/var/cache/debconf/templates.dat", - '/etc/passwd', '/etc/group', + '/etc/passwd', '/etc/group', '/etc/apt/apt.conf', '/etc/dpkg/dpkg.cfg'] __handles__ = [('Package', 'deb')] __req__ = {'Package': ['name', 'version']} @@ -28,7 +28,7 @@ class APT(Bcfg2.Client.Tools.Tool): '-q=2 ' + \ '--force-yes ' + \ '-y install %s' - + def __init__(self, logger, cfg, setup): Bcfg2.Client.Tools.Tool.__init__(self, logger, cfg, setup) self.cfg = cfg @@ -99,7 +99,7 @@ class APT(Bcfg2.Client.Tools.Tool): self.logger.info("Package %s not installed" % (entry.get('name'))) entry.set('current_exists', 'false') return False - + pkg = self.pkg_cache[pkgname] if entry.get('version') == 'auto': if self.pkg_cache._depcache.IsUpgradable(pkg._pkg): @@ -144,7 +144,7 @@ class APT(Bcfg2.Client.Tools.Tool): self.pkg_cache = apt.cache.Cache() self.modified += packages self.extra = self.FindExtra() - + def Install(self, packages, states): # it looks like you can't install arbitrary versions of software # out of the pkg cache, we will still need to call apt-get diff --git a/src/lib/Client/Tools/Action.py b/src/lib/Client/Tools/Action.py index 0731ec191..e997865f0 100644 --- a/src/lib/Client/Tools/Action.py +++ b/src/lib/Client/Tools/Action.py @@ -32,7 +32,7 @@ class Action(Bcfg2.Client.Tools.Tool): return rc == 0 else: return False - + def VerifyAction(self, dummy, _): '''Actions always verify true''' return True @@ -57,7 +57,7 @@ class Action(Bcfg2.Client.Tools.Tool): for action in bundle.findall("Action"): if action.get('timing') in ['post', 'both']: states[action] = self.RunAction(action) - + def BundleNotUpdated(self, bundle, states): '''Run Actions when bundles have not been updated''' for action in bundle.findall("Action"): diff --git a/src/lib/Client/Tools/Blast.py b/src/lib/Client/Tools/Blast.py index cd926accd..acad1d961 100644 --- a/src/lib/Client/Tools/Blast.py +++ b/src/lib/Client/Tools/Blast.py @@ -22,7 +22,7 @@ class Blast(Bcfg2.Client.Tools.SYSV.SYSV): noaskfile.write(Bcfg2.Client.Tools.SYSV.noask) except: pass - + # VerifyPackage comes from Bcfg2.Client.Tools.SYSV # Install comes from Bcfg2.Client.Tools.PkgTool # Extra comes from Bcfg2.Client.Tools.Tool diff --git a/src/lib/Client/Tools/Chkconfig.py b/src/lib/Client/Tools/Chkconfig.py index f3945596e..718f22bf2 100644 --- a/src/lib/Client/Tools/Chkconfig.py +++ b/src/lib/Client/Tools/Chkconfig.py @@ -67,7 +67,7 @@ class Chkconfig(Bcfg2.Client.Tools.SvcTool): def InstallService(self, entry): '''Install Service entry''' - rcmd = "/sbin/chkconfig %s %s" + rcmd = "/sbin/chkconfig %s %s" self.cmd.run("/sbin/chkconfig --add %s"%(entry.attrib['name'])) self.logger.info("Installing Service %s" % (entry.get('name'))) pass1 = True diff --git a/src/lib/Client/Tools/DebInit.py b/src/lib/Client/Tools/DebInit.py index cd5b7c784..9bf8bb048 100644 --- a/src/lib/Client/Tools/DebInit.py +++ b/src/lib/Client/Tools/DebInit.py @@ -22,7 +22,7 @@ class DebInit(Bcfg2.Client.Tools.SvcTool): kill_sequence = 100 - start_sequence else: start_sequence = None - + for filename in rawfiles: match = self.svcre.match(filename) if not match: @@ -59,7 +59,7 @@ class DebInit(Bcfg2.Client.Tools.SvcTool): except OSError: self.logger.debug("Init script for service %s does not exist" % entry.get('name')) return False - + if entry.get('status') == 'off': self.cmd.run("/usr/sbin/invoke-rc.d %s stop" % (entry.get('name'))) cmdrc = self.cmd.run("/usr/sbin/update-rc.d -f %s remove" % entry.get('name'))[0] diff --git a/src/lib/Client/Tools/IPS.py b/src/lib/Client/Tools/IPS.py index 78fe9776f..bd71e50e8 100644 --- a/src/lib/Client/Tools/IPS.py +++ b/src/lib/Client/Tools/IPS.py @@ -55,6 +55,6 @@ class IPS(Bcfg2.Client.Tools.PkgTool): % (pname, self.installed[pname], entry.get('version'))) return False - + # need to implement pkg chksum validation return True diff --git a/src/lib/Client/Tools/POSIX.py b/src/lib/Client/Tools/POSIX.py index f9a36cb15..8576f49fa 100644 --- a/src/lib/Client/Tools/POSIX.py +++ b/src/lib/Client/Tools/POSIX.py @@ -234,7 +234,7 @@ class POSIX(Bcfg2.Client.Tools.Tool): nnqtext += '\nInstall %s %s: (y/N) ' % (entry.tag, entry.get('name')) entry.set('qtext', nnqtext) return pTrue and pruneTrue - + def InstallDirectory(self, entry): '''Install Directory Entry''' @@ -291,7 +291,7 @@ class POSIX(Bcfg2.Client.Tools.Tool): if entry.get('prune', 'false') == 'true' and entry.get("qtest"): for pname in entry.get("qtest").split(":"): ulfailed = False - if os.path.isdir(pname): + if os.path.isdir(pname): self.logger.info("Not removing extra directory %s, please check and remove manually" % pname) continue try: @@ -404,12 +404,12 @@ class POSIX(Bcfg2.Client.Tools.Tool): eudiff = udiff.encode('ascii') except: eudiff = "Binary file: no diff printed" - + nqtext = entry.get('qtext', '') if nqtext: nqtext += '\n' - nqtext += eudiff + nqtext += eudiff else: entry.set('current_bfile', binascii.b2a_base64(content)) nqtext = entry.get('qtext', '') diff --git a/src/lib/Client/Tools/Portage.py b/src/lib/Client/Tools/Portage.py index 5ea0b18fc..f5224c06a 100644 --- a/src/lib/Client/Tools/Portage.py +++ b/src/lib/Client/Tools/Portage.py @@ -15,13 +15,13 @@ class Portage(Bcfg2.Client.Tools.PkgTool): pkgtype = 'ebuild' # requires a working PORTAGE_BINHOST in make.conf pkgtool = ('emerge --getbinpkgonly %s', ('=%s-%s', ['name', 'version'])) - + def __init__(self, logger, cfg, setup): Bcfg2.Client.Tools.PkgTool.__init__(self, logger, cfg, setup) self.cfg = cfg self.installed = {} self.RefreshPackages() - + def RefreshPackages(self): '''Refresh memory hashes of packages''' cache = self.cmd.run("equery -q list")[1] @@ -66,5 +66,5 @@ class Portage(Bcfg2.Client.Tools.PkgTool): self.cmd.run("emerge --unmerge --quiet =%s" % " =".join(packages)) self.RefreshPackages() self.extra = self.FindExtraPackages() - - + + diff --git a/src/lib/Client/Tools/RPMng.py b/src/lib/Client/Tools/RPMng.py index bf04940e4..a575a5c34 100644 --- a/src/lib/Client/Tools/RPMng.py +++ b/src/lib/Client/Tools/RPMng.py @@ -23,14 +23,14 @@ class RPMng(Bcfg2.Client.Tools.PkgTool): __req__ = {'Package': ['name', 'version']} __ireq__ = {'Package': ['url']} - + __new_req__ = {'Package': ['name'], 'Instance': ['version', 'release', 'arch']} __new_ireq__ = {'Package': ['uri'], \ 'Instance': ['simplefile']} - + __gpg_req__ = {'Package': ['name', 'version']} __gpg_ireq__ = {'Package': ['name', 'version']} - + __new_gpg_req__ = {'Package': ['name'], 'Instance': ['version', 'release']} __new_gpg_ireq__ = {'Package': ['name'], 'Instance': ['version', 'release']} @@ -150,7 +150,7 @@ class RPMng(Bcfg2.Client.Tools.PkgTool): ''' self.installed = {} refresh_ts = rpmtools.rpmtransactionset() - # Don't bother with signature checks at this stage. The GPG keys might + # Don't bother with signature checks at this stage. The GPG keys might # not be installed. refresh_ts.setVSFlags(rpm._RPMVSF_NODIGESTS|rpm._RPMVSF_NOSIGNATURES) for nevra in rpmtools.rpmpackagelist(refresh_ts): @@ -160,7 +160,7 @@ class RPMng(Bcfg2.Client.Tools.PkgTool): for name, instances in list(self.installed.items()): self.logger.debug(" " + name) for inst in instances: - self.logger.debug(" %s" %self.str_evra(inst)) + self.logger.debug(" %s" %self.str_evra(inst)) refresh_ts.closeDB() del refresh_ts @@ -234,7 +234,7 @@ class RPMng(Bcfg2.Client.Tools.PkgTool): self.logger.error("got any version") 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': flags = inst.get('verify_flags', '').split(',') + self.verify_flags @@ -245,24 +245,24 @@ class RPMng(Bcfg2.Client.Tools.PkgTool): % (pkg.get('name'), self.str_evra(pkg), \ pkg.get('gpgkeyid', ''))) self.logger.debug(' Disabling signature check.') - + if self.setup.get('quick', False): if rpmtools.prelink_exists: flags += ['nomd5', 'nosize'] else: flags += ['nomd5'] - self.logger.debug(" verify_flags = %s" % flags) - + self.logger.debug(" verify_flags = %s" % flags) + vp_ts = rpmtools.rpmtransactionset() self.instance_status[inst]['verify'] = \ rpmtools.rpm_verify( vp_ts, pkg, flags) vp_ts.closeDB() del vp_ts - + if self.instance_status[inst]['installed'] == False: self.logger.info(" Package %s %s not installed." % \ (entry.get('name'), self.str_evra(inst))) - + qtext_versions = qtext_versions + 'I(%s) ' % self.str_evra(inst) entry.set('current_exists', 'false') else: @@ -270,7 +270,7 @@ class RPMng(Bcfg2.Client.Tools.PkgTool): for inst in instances: self.instance_status.setdefault(inst, {})['installed'] = False self.instance_status[inst]['version_fail'] = False - + # Only installed packages with the same architecture are # relevant. if inst.get('arch', None) == None: @@ -278,7 +278,7 @@ class RPMng(Bcfg2.Client.Tools.PkgTool): else: arch_match = [pkg for pkg in self.installed[entry.get('name')] \ if pkg.get('arch', None) == inst.get('arch', None)] - + if len(arch_match) > 1: self.logger.error("Multiple instances of package %s installed with the same achitecture." % \ (entry.get('name'))) @@ -290,7 +290,7 @@ class RPMng(Bcfg2.Client.Tools.PkgTool): self.inst_evra_equal(inst, pkg): 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': flags = inst.get('verify_flags', '').split(',') + self.verify_flags @@ -301,26 +301,26 @@ class RPMng(Bcfg2.Client.Tools.PkgTool): % (pkg.get('name'), self.str_evra(pkg), \ pkg.get('gpgkeyid', ''))) self.logger.info(' Disabling signature check.') - + if self.setup.get('quick', False): if rpmtools.prelink_exists: flags += ['nomd5', 'nosize'] else: flags += ['nomd5'] - self.logger.debug(" verify_flags = %s" % flags) - + self.logger.debug(" verify_flags = %s" % flags) + vp_ts = rpmtools.rpmtransactionset() self.instance_status[inst]['verify'] = \ rpmtools.rpm_verify( vp_ts, pkg, flags ) vp_ts.closeDB() del vp_ts - + else: # Wrong version installed. self.instance_status[inst]['version_fail'] = True self.logger.info(" Wrong version installed. Want %s, but have %s"\ % (self.str_evra(inst), self.str_evra(pkg))) - + qtext_versions = qtext_versions + 'U(%s -> %s) ' % \ (self.str_evra(pkg), self.str_evra(inst)) elif len(arch_match) == 0: @@ -328,32 +328,32 @@ class RPMng(Bcfg2.Client.Tools.PkgTool): self.instance_status[inst]['installed'] = False self.logger.info(" %s is not installed." % self.str_evra(inst)) qtext_versions = qtext_versions + 'I(%s) ' % self.str_evra(inst) - + # Check the rpm verify results. for inst in instances: instance_fail = False - # Dump the rpm verify results. + # Dump the rpm verify results. #****Write something to format this nicely.***** if self.setup['debug'] and self.instance_status[inst].get('verify', None): self.logger.debug(self.instance_status[inst]['verify']) - + self.instance_status[inst]['verify_fail'] = False if self.instance_status[inst].get('verify', None): if len(self.instance_status[inst].get('verify')) > 1: self.logger.info("WARNING: Verification of more than one package instance.") - + for result in self.instance_status[inst]['verify']: - + # Check header results if result.get('hdr', None): instance_fail = True self.instance_status[inst]['verify_fail'] = True - + # Check dependency results if result.get('deps', None): instance_fail = True self.instance_status[inst]['verify_fail'] = True - + # Check the rpm verify file results against the modlist # and per Instance Ignores. for file_result in result.get('files', []): @@ -365,7 +365,7 @@ class RPMng(Bcfg2.Client.Tools.PkgTool): else: self.logger.debug(" Modlist/Ignore match: %s" % \ (file_result[-1])) - + if instance_fail == True: self.logger.debug("*** Instance %s failed RPM verification ***" % \ self.str_evra(inst)) @@ -374,14 +374,14 @@ class RPMng(Bcfg2.Client.Tools.PkgTool): # Attach status structure for return to server for reporting. inst.set('verify_status', str(self.instance_status[inst])) - + if self.instance_status[inst]['installed'] == False or \ self.instance_status[inst].get('version_fail', False)== True or \ self.instance_status[inst].get('verify_fail', False) == True: package_fail = True self.instance_status[inst]['pkg'] = entry self.modlists[entry] = modlist - + # Find Installed Instances that are not in the Config. extra_installed = self.FindExtraInstances(entry, self.installed[entry.get('name')]) if extra_installed != None: @@ -390,25 +390,25 @@ class RPMng(Bcfg2.Client.Tools.PkgTool): for inst in extra_installed.findall('Instance'): qtext_versions = qtext_versions + 'D(%s) ' % self.str_evra(inst) self.logger.debug("Found Extra Instances %s" % qtext_versions) - + if package_fail == True: self.logger.info(" Package %s failed verification." % \ (entry.get('name'))) qtext = 'Install/Upgrade/delete Package %s instance(s) - %s (y/N) ' % \ (entry.get('name'), qtext_versions) entry.set('qtext', qtext) - + bcfg2_versions = '' for bcfg2_inst in [inst for inst in instances if inst.tag == 'Instance']: bcfg2_versions = bcfg2_versions + '(%s) ' % self.str_evra(bcfg2_inst) if bcfg2_versions != '': entry.set('version', bcfg2_versions) installed_versions = '' - + for installed_inst in self.installed[entry.get('name')]: installed_versions = installed_versions + '(%s) ' % \ self.str_evra(installed_inst) - + entry.set('current_version', installed_versions) return False @@ -436,7 +436,7 @@ class RPMng(Bcfg2.Client.Tools.PkgTool): ''' Remove specified entries. - packages is a list of Package Entries with Instances generated + packages is a list of Package Entries with Instances generated by FindExtraPackages(). ''' self.logger.debug('Running RPMng.RemovePackages()') @@ -460,7 +460,7 @@ class RPMng(Bcfg2.Client.Tools.PkgTool): self.logger.info(" This package will be deleted in a future version of the RPMng driver.") #pkgspec_list.append(pkg_spec) - erase_results = rpmtools.rpm_erase(pkgspec_list, self.erase_flags) + erase_results = rpmtools.rpm_erase(pkgspec_list, self.erase_flags) if erase_results == []: self.modified += packages for pkg in pkgspec_list: @@ -488,7 +488,7 @@ class RPMng(Bcfg2.Client.Tools.PkgTool): % (pkgspec.get('name'), self.str_evra(pkgspec))) self.logger.info(" This package will be deleted in a future version of the RPMng driver.") continue # Don't delete the gpg-pubkey packages for now. - erase_results = rpmtools.rpm_erase([pkgspec], self.erase_flags) + erase_results = rpmtools.rpm_erase([pkgspec], self.erase_flags) if erase_results == []: pkg_modified = True self.logger.info("Deleted %s %s" % \ @@ -505,7 +505,7 @@ class RPMng(Bcfg2.Client.Tools.PkgTool): def FixInstance(self, instance, inst_status): ''' - Control if a reinstall of a package happens or not based on the + Control if a reinstall of a package happens or not based on the results from RPMng.VerifyPackage(). Return True to reinstall, False to not reintstall. @@ -535,14 +535,14 @@ class RPMng(Bcfg2.Client.Tools.PkgTool): if instance.get('verify_fail_action', 'reinstall') == "reinstall" and \ self.verify_fail_action == "reinstall": for inst in inst_status.get('verify'): - # This needs to be a for loop rather than a straight get() + # This needs to be a for loop rather than a straight get() # because the underlying routines handle multiple packages # and return a list of results. self.logger.debug('reinstall_check: %s %s:%s-%s.%s' % inst.get('nevra')) if inst.get("hdr", False): fix = True - + elif inst.get('files', False): # Parse rpm verify file results for file_result in inst.get('files', []): @@ -560,24 +560,24 @@ class RPMng(Bcfg2.Client.Tools.PkgTool): self.str_evra(instance))) return fix - + def Install(self, packages, states): ''' - Try and fix everything that RPMng.VerifyPackages() found wrong for - each Package Entry. This can result in individual RPMs being - installed (for the first time), reinstalled, deleted, downgraded + Try and fix everything that RPMng.VerifyPackages() found wrong for + each Package Entry. This can result in individual RPMs being + installed (for the first time), reinstalled, deleted, downgraded or upgraded. - packages is a list of Package Elements that has + packages is a list of Package Elements that has states[<Package Element>] == False The following effects occur: - states{} is conditionally updated for each package. - self.installed{} is rebuilt, possibly multiple times. - - self.instance_statusi{} is conditionally updated for each instance + - self.instance_statusi{} is conditionally updated for each instance of a package. - - Each package will be added to self.modified[] if its states{} - entry is set to True. + - Each package will be added to self.modified[] if its states{} + entry is set to True. ''' self.logger.info('Runing RPMng.Install()') @@ -789,13 +789,13 @@ class RPMng(Bcfg2.Client.Tools.PkgTool): def canVerify(self, entry): ''' Test if entry has enough information to be verified. - + Three types of entries are checked. Old style Package New style Package with Instances pgp-pubkey packages - Also the old style entries get modified after the first + Also the old style entries get modified after the first VerifyPackage() run, so there needs to be a second test. ''' if not self.handlesEntry(entry): @@ -816,7 +816,7 @@ class RPMng(Bcfg2.Client.Tools.PkgTool): if not instances: # Old non Instance format, unmodified. if entry.get('name') == 'gpg-pubkey': - # gpg-pubkey packages aren't really pacakges, so we have to do + # gpg-pubkey packages aren't really pacakges, so we have to do # something a little different. # Check that the Package Level has what we need for verification. if [attr for attr in self.__gpg_req__[entry.tag] if attr not in entry.attrib]: @@ -830,7 +830,7 @@ class RPMng(Bcfg2.Client.Tools.PkgTool): return False else: if entry.get('name') == 'gpg-pubkey': - # gpg-pubkey packages aren't really pacakges, so we have to do + # gpg-pubkey packages aren't really pacakges, so we have to do # something a little different. # Check that the Package Level has what we need for verification. if [attr for attr in self.__new_gpg_req__[entry.tag] if attr not in entry.attrib]: @@ -944,14 +944,14 @@ class RPMng(Bcfg2.Client.Tools.PkgTool): Convert evra dict entries to a string. ''' if instance.get('epoch', '*') in ['*', None]: - return '%s-%s.%s' % (instance.get('version', '*'), + return '%s-%s.%s' % (instance.get('version', '*'), instance.get('release', '*'), - instance.get('arch', '*')) - else: + instance.get('arch', '*')) + else: return '%s:%s-%s.%s' % (instance.get('epoch', '*'), - instance.get('version', '*'), + instance.get('version', '*'), instance.get('release', '*'), - instance.get('arch', '*')) + instance.get('arch', '*')) def pkg_vr_equal(self, config_entry, installed_entry): ''' @@ -987,12 +987,12 @@ class RPMng(Bcfg2.Client.Tools.PkgTool): return False def getinstalledgpg(self): - ''' + ''' Create a list of installed GPG key IDs. The pgp-pubkey package version is the least significant 4 bytes (big-endian) of the key ID which is good enough for our purposes. - ''' + ''' init_ts = rpmtools.rpmtransactionset() init_ts.setVSFlags(rpm._RPMVSF_NODIGESTS|rpm._RPMVSF_NOSIGNATURES) gpg_hdrs = rpmtools.getheadersbykeyword(init_ts, **{'name':'gpg-pubkey'}) diff --git a/src/lib/Client/Tools/SMF.py b/src/lib/Client/Tools/SMF.py index bbe9a3055..b58cb7a85 100644 --- a/src/lib/Client/Tools/SMF.py +++ b/src/lib/Client/Tools/SMF.py @@ -36,7 +36,7 @@ class SMF(Bcfg2.Client.Tools.SvcTool): entry.get('name')) return False return True - + def VerifyService(self, entry, _): '''Verify SMF Service Entry''' if not self.GetFMRI(entry): diff --git a/src/lib/Client/Tools/SYSV.py b/src/lib/Client/Tools/SYSV.py index 23875d4f9..1c20ea76f 100644 --- a/src/lib/Client/Tools/SYSV.py +++ b/src/lib/Client/Tools/SYSV.py @@ -59,7 +59,7 @@ class SYSV(Bcfg2.Client.Tools.PkgTool): desiredVersion = entry.get('version') if desiredVersion == 'any': desiredVersion = self.installed.get(entry.get('name'), desiredVersion) - + cmdrc = self.cmd.run("/usr/bin/pkginfo -q -v \"%s\" %s" % \ (desiredVersion, entry.get('name')))[0] diff --git a/src/lib/Client/Tools/YUMng.py b/src/lib/Client/Tools/YUMng.py index e81b4ee7d..b30d6cdcc 100644 --- a/src/lib/Client/Tools/YUMng.py +++ b/src/lib/Client/Tools/YUMng.py @@ -52,11 +52,11 @@ class YUMng(Bcfg2.Client.Tools.RPMng.RPMng): name = 'YUMng' __execs__ = ['/usr/bin/yum', '/var/lib/rpm'] __handles__ = [('Package', 'yum'), ('Package', 'rpm')] - + __req__ = {'Package': ['name', 'version']} __ireq__ = {'Package': ['name']} #__ireq__ = {'Package': ['name', 'version']} - + __new_req__ = {'Package': ['name'], 'Instance': ['version', 'release', 'arch']} __new_ireq__ = {'Package': ['name'], \ 'Instance': []} @@ -121,13 +121,13 @@ class YUMng(Bcfg2.Client.Tools.RPMng.RPMng): release=rel, epoch=epoch) return Bcfg2.Client.Tools.RPMng.RPMng.VerifyPackage(self, entry, modlist) - + def Install(self, packages, states): ''' Try and fix everything that RPMng.VerifyPackages() found wrong for each Package Entry. This can result in individual RPMs being installed (for the first time), deleted, downgraded - or upgraded. + or upgraded. NOTE: YUM can not reinstall a package that it thinks is already installed. @@ -183,8 +183,8 @@ class YUMng(Bcfg2.Client.Tools.RPMng.RPMng): install_pkgs.append(pkg) # Install GPG keys. - # Alternatively specify the required keys using 'gpgkey' in the - # repository definition in yum.conf. YUM will install the keys + # Alternatively specify the required keys using 'gpgkey' in the + # repository definition in yum.conf. YUM will install the keys # automatically. if len(gpg_keys) > 0: for inst in gpg_keys: @@ -221,7 +221,7 @@ class YUMng(Bcfg2.Client.Tools.RPMng.RPMng): for inst in install_pkgs: pkg_arg = self.instance_status[inst].get('pkg').get('name') install_args.append(build_yname(pkg_arg, inst)) - + cmdrc, output = self.cmd.run(pkgtool % " ".join(install_args)) if cmdrc == 0: # The yum command succeeded. All packages installed. @@ -257,7 +257,7 @@ class YUMng(Bcfg2.Client.Tools.RPMng.RPMng): for inst in upgrade_pkgs: pkg_arg = build_yname(self.instance_status[inst].get('pkg').get('name'), inst) upgrade_args.append(pkg_arg) - + cmdrc, output = self.cmd.run(pkgtool % " ".join(upgrade_args)) if cmdrc == 0: # The yum command succeeded. All packages installed. diff --git a/src/lib/Client/Tools/__init__.py b/src/lib/Client/Tools/__init__.py index 105cff3cf..d857962a2 100644 --- a/src/lib/Client/Tools/__init__.py +++ b/src/lib/Client/Tools/__init__.py @@ -238,9 +238,9 @@ class PkgTool(Tool): def Install(self, packages, states): ''' - Run a one-pass install, followed by - single pkg installs in case of failure - ''' + Run a one-pass install, followed by + single pkg installs in case of failure + ''' self.logger.info("Trying single pass package install for pkgtype %s" % \ self.pkgtype) diff --git a/src/lib/Client/Tools/launchd.py b/src/lib/Client/Tools/launchd.py index 90bc14aa5..baca30bdd 100644 --- a/src/lib/Client/Tools/launchd.py +++ b/src/lib/Client/Tools/launchd.py @@ -86,7 +86,7 @@ class launchd(Bcfg2.Client.Tools.Tool): def Remove(self, svcs): '''Remove Extra launchd entries''' pass - + def FindExtra(self): diff --git a/src/lib/Client/Tools/rpmtools.py b/src/lib/Client/Tools/rpmtools.py index d399e316c..7660946d2 100755 --- a/src/lib/Client/Tools/rpmtools.py +++ b/src/lib/Client/Tools/rpmtools.py @@ -1,6 +1,6 @@ #!/usr/bin/python """ - Module that uses rpm-python to implement the following rpm + Module that uses rpm-python to implement the following rpm functionality for the bcfg2 RPM and YUM client drivers: rpm -qa @@ -11,8 +11,8 @@ The code was written to be used in the bcfg2 RPM/YUM drivers. - Some command line options have been provided to assist with - testing and development, but the output isn't pretty and looks + Some command line options have been provided to assist with + testing and development, but the output isn't pretty and looks nothing like rpm output. Run 'rpmtools' -h for the options. @@ -40,14 +40,14 @@ except ImportError: isprelink_imported = False #print '*********************** isprelink not loaded ***********************' -# If the prelink command is installed on the system then we need to do +# If the prelink command is installed on the system then we need to do # prelink -y on files. if os.access('/usr/sbin/prelink', os.X_OK): prelink_exists = True else: prelink_exists = False -# If we don't have isprelink then we will use the prelink configuration file to +# If we don't have isprelink then we will use the prelink configuration file to # filter what we have to put through prelink -y. import re blacklist = [] @@ -75,7 +75,7 @@ blacklist_re = re.compile('|'.join(blacklist)) whitelist_re = re.compile('|'.join(whitelist)) # Flags that are not defined in rpm-python. -# They are defined in lib/rpmcli.h +# They are defined in lib/rpmcli.h # Bit(s) for verifyFile() attributes. # RPMVERIFY_NONE = 0 # /*!< */ @@ -135,11 +135,11 @@ VERIFY_ALL = \ # Some masks for what checks to NOT do on these file types. -# The C code actiually resets these up for every file. +# The C code actiually resets these up for every file. DIR_FLAGS = ~(RPMVERIFY_MD5 | RPMVERIFY_FILESIZE | RPMVERIFY_MTIME | \ RPMVERIFY_LINKTO) -# These file types all have the same mask, but hopefully this will make the +# These file types all have the same mask, but hopefully this will make the # code more readable. FIFO_FLAGS = CHR_FLAGS = BLK_FLAGS = GHOST_FLAGS = DIR_FLAGS @@ -161,14 +161,14 @@ def rpmpackagelist(rts): Equivalent of rpm -qa. Intended for RefreshPackages() in the RPM Driver. Requires rpmtransactionset() to be run first to get a ts. Returns a list of pkgspec dicts. - + e.g. [ {'name':'foo', 'epoch':'20', 'version':'1.2', 'release':'5', 'arch':'x86_64' }, {'name':'bar', 'epoch':'10', 'version':'5.2', 'release':'2', 'arch':'x86_64' } ] """ - return [ { 'name':header[rpm.RPMTAG_NAME], + return [ { 'name':header[rpm.RPMTAG_NAME], 'epoch':header[rpm.RPMTAG_EPOCH], - 'version':header[rpm.RPMTAG_VERSION], + 'version':header[rpm.RPMTAG_VERSION], 'release':header[rpm.RPMTAG_RELEASE], 'arch':header[rpm.RPMTAG_ARCH], 'gpgkeyid':header.sprintf("%|SIGGPG?{%{SIGGPG:pgpsig}}:{None}|").split()[-1] } @@ -178,8 +178,8 @@ def getindexbykeyword(index_ts, **kwargs): """ Return list of indexs from the rpmdb matching keywords ex: getHeadersByKeyword(name='foo', version='1', release='1') - - Can be passed any structure that can be indexed by the pkgspec + + Can be passed any structure that can be indexed by the pkgspec keyswords as other keys are filtered out. """ @@ -216,8 +216,8 @@ def getheadersbykeyword(header_ts, **kwargs): Return list of headers from the rpmdb matching keywords ex: getHeadersByKeyword(name='foo', version='1', release='1') - - Can be passed any structure that can be indexed by the pkgspec + + Can be passed any structure that can be indexed by the pkgspec keyswords as other keys are filtered out. """ @@ -249,7 +249,7 @@ def getheadersbykeyword(header_ts, **kwargs): def prelink_md5_check(filename): """ - Checks if a file is prelinked. If it is run it through prelink -y + Checks if a file is prelinked. If it is run it through prelink -y to get the unprelinked md5 and file size. Return 0 if the file was not prelinked, otherwise return the file size. @@ -297,7 +297,7 @@ def prelink_size_check(filename): """ This check is only done if the prelink_md5_check() is not done first. - Checks if a file is prelinked. If it is run it through prelink -y + Checks if a file is prelinked. If it is run it through prelink -y to get the unprelinked file size. Return 0 if the file was not prelinked, otherwise return the file size. @@ -413,14 +413,14 @@ def rpm_verify_file(fileinfo, rpmlinktos, omitmask): """ Verify all the files in a package. - Returns a list of error flags, the file type and file name. The list - entries are strings that are the same as the labels for the bitwise + Returns a list of error flags, the file type and file name. The list + entries are strings that are the same as the labels for the bitwise flags used in the C code. """ (fname, fsize, fmode, fmtime, fflags, frdev, finode, fnlink, fstate, \ vflags, fuser, fgroup, fmd5) = fileinfo - + # 1. rpmtsRootDir stuff. What does it do and where to I get it from? file_results = [] @@ -441,7 +441,7 @@ def rpm_verify_file(fileinfo, rpmlinktos, omitmask): return file_results # 5. Contexts? SELinux stuff? - + # Setup what checks to do. This is straight out of the C code. if stat.S_ISDIR(lstat.st_mode): flags &= DIR_FLAGS @@ -458,7 +458,7 @@ def rpm_verify_file(fileinfo, rpmlinktos, omitmask): if (fflags & rpm.RPMFILE_GHOST): flags &= GHOST_FLAGS - + flags &= ~(omitmask | RPMVERIFY_FAILURES) # 8. SELinux stuff. @@ -483,7 +483,7 @@ def rpm_verify_file(fileinfo, rpmlinktos, omitmask): if flags & RPMVERIFY_FILESIZE: if not (flags & RPMVERIFY_MD5): # prelink check hasn't been done. - prelink_size = prelink_size_check(fname) + prelink_size = prelink_size_check(fname) if (prelink_size != 0): # This is a prelinked file. if (prelink_size != fsize): file_results.append('RPMVERIFY_FILESIZE') @@ -531,7 +531,7 @@ def rpm_verify_file(fileinfo, rpmlinktos, omitmask): group = None if not group or not fgroup or (group != fgroup): file_results.append('RPMVERIFY_GROUP') - + return file_results def rpm_verify_dependencies(header): @@ -540,11 +540,11 @@ def rpm_verify_dependencies(header): Don't like opening another ts to do this, but it was the only way I could find of clearing the ts - out. + out. + + Have asked on the rpm-maint list on how to do + this the right way (28 Feb 2007). - Have asked on the rpm-maint list on how to do - this the right way (28 Feb 2007). - ts.check() returns: ((name, version, release), (reqname, reqversion), \ @@ -560,7 +560,7 @@ def rpm_verify_dependencies(header): def rpm_verify_package(vp_ts, header, verify_options): """ Verify a single package specified by header. Header is an rpm.hdr. - + If errors are found it returns a dictionary of errors. """ @@ -609,21 +609,21 @@ def rpm_verify_package(vp_ts, header, verify_options): dep_stat = rpm_verify_dependencies(header) if dep_stat: package_results['deps'] = dep_stat - + # Check all the package files. if 'nofiles' not in verify_options: vp_fi = header.fiFromHeader() for fileinfo in vp_fi: - # Do not bother doing anything with ghost files. + # Do not bother doing anything with ghost files. # This is what RPM does. if fileinfo[4] & rpm.RPMFILE_GHOST: continue - # This is only needed because of an inconsistency in the + # This is only needed because of an inconsistency in the # rpm.fi interface. linktos = vp_fi.FLink() - file_stat = rpm_verify_file(fileinfo, linktos, omitmask) + file_stat = rpm_verify_file(fileinfo, linktos, omitmask) #if len(file_stat) > 0 or options.verbose: if len(file_stat) > 0: @@ -642,7 +642,7 @@ def rpm_verify_package(vp_ts, header, verify_options): file_stat.append('r') else: file_stat.append(' ') - + file_stat.append(fileinfo[0]) # The filename. package_results.setdefault('files', []).append(file_stat) @@ -673,7 +673,7 @@ def rpm_verify(verify_ts, verify_pkgspec, verify_options=[]): Requires rpmtransactionset() to be run first to get a ts. pkgspec is a dict specifying the package - e.g.: + e.g.: For a single package { name='foo', epoch='20', version='1', release='1', arch='x86_64'} @@ -684,27 +684,27 @@ def rpm_verify(verify_ts, verify_pkgspec, verify_options=[]): options is a list of 'rpm --verify' options. Default is to check everything. e.g.: - [ 'nodeps', 'nodigest', 'nofiles', 'noscripts', 'nosignature', - 'nolinkto' 'nomd5', 'nosize', 'nouser', 'nogroup', 'nomtime', + [ 'nodeps', 'nodigest', 'nofiles', 'noscripts', 'nosignature', + 'nolinkto' 'nomd5', 'nosize', 'nouser', 'nogroup', 'nomtime', 'nomode', 'nordev' ] - Returns a list. One list entry per package. Each list entry is a - dictionary. Dict keys are 'files', 'deps', 'nevra' and 'hdr'. - Entries only get added for the failures. If nothing failed, None is + Returns a list. One list entry per package. Each list entry is a + dictionary. Dict keys are 'files', 'deps', 'nevra' and 'hdr'. + Entries only get added for the failures. If nothing failed, None is returned. Its all a bit messy and probably needs reviewing. [ { 'hdr': [???], - 'deps: [((name, version, release), (reqname, reqversion), + 'deps: [((name, version, release), (reqname, reqversion), flags, suggest, sense), .... ] - 'files': [ ['filename1', 'RPMVERIFY_GROUP', 'RPMVERIFY_USER' ], + 'files': [ ['filename1', 'RPMVERIFY_GROUP', 'RPMVERIFY_USER' ], ['filename2', 'RPMVERFIY_LSTATFAIL']] 'nevra': ['name1', 'epoch1', 'version1', 'release1', 'arch1'] } { 'hdr': [???], - 'deps: [((name, version, release), (reqname, reqversion), + 'deps: [((name, version, release), (reqname, reqversion), flags, suggest, sense), .... ] - 'files': [ ['filename', 'RPMVERIFY_GROUP', 'RPMVERIFY_USER" ], + 'files': [ ['filename', 'RPMVERIFY_GROUP', 'RPMVERIFY_USER" ], ['filename2', 'RPMVERFIY_LSTATFAIL']] 'nevra': ['name2', 'epoch2', 'version2', 'release2', 'arch2'] } ] @@ -715,7 +715,7 @@ def rpm_verify(verify_ts, verify_pkgspec, verify_options=[]): result = rpm_verify_package(verify_ts, header, verify_options) if result: verify_results.append(result) - + return verify_results def rpmtransactionset(): @@ -730,10 +730,10 @@ def rpmtransactionset(): class Rpmtscallback(object): """ Callback for ts.run(). Used for adding, upgrading and removing packages. - Starting with all possible reasons codes, but bcfg2 will probably only + Starting with all possible reasons codes, but bcfg2 will probably only make use of a few of them. - Mostly just printing stuff at the moment to understand how the callback + Mostly just printing stuff at the moment to understand how the callback is used. """ @@ -796,13 +796,13 @@ class Rpmtscallback(object): #print 'rpm.RPMCALLBACK_UNKNOWN' else: print('ERROR - Fell through callBack') - + #print reason, amount, total, key, client_data def rpm_erase(erase_pkgspecs, erase_flags): """ pkgspecs is a list of pkgspec dicts specifying packages - e.g.: + e.g.: For a single package { name='foo', epoch='20', version='1', release='1', arch='x86_64'} @@ -836,7 +836,7 @@ def rpm_erase(erase_pkgspecs, erase_flags): if erase_problems == []: erase_ts.order() - erase_callback = Rpmtscallback() + erase_callback = Rpmtscallback() erase_ts.run(erase_callback.callback, 'Erase') #else: # print 'ERROR - Dependency failures on package erase' @@ -862,12 +862,12 @@ def display_verify_file(file_results): result_string = result_string + 'S' else: result_string = result_string + '.' - + if 'RPMVERIFY_MODE' in file_results: result_string = result_string + 'M' else: result_string = result_string + '.' - + if 'RPMVERIFY_MD5' in file_results: if 'RPMVERIFY_READFAIL' in file_results: result_string = result_string + '?' @@ -875,12 +875,12 @@ def display_verify_file(file_results): result_string = result_string + '5' else: result_string = result_string + '.' - + if 'RPMVERIFY_RDEV' in file_results: result_string = result_string + 'D' else: result_string = result_string + '.' - + if 'RPMVERIFY_LINKTO' in file_results: if 'RPMVERIFY_READLINKFAIL' in file_results: result_string = result_string + '?' @@ -888,22 +888,22 @@ def display_verify_file(file_results): result_string = result_string + 'L' else: result_string = result_string + '.' - + if 'RPMVERIFY_USER' in file_results: result_string = result_string + 'U' else: result_string = result_string + '.' - + if 'RPMVERIFY_GROUP' in file_results: result_string = result_string + 'G' else: result_string = result_string + '.' - + if 'RPMVERIFY_MTIME' in file_results: result_string = result_string + 'T' else: result_string = result_string + '.' - + print(result_string + ' ' + filetype + ' ' + filename) sys.stdout.flush() @@ -916,13 +916,13 @@ if __name__ == "__main__": p.add_option('--name', action='store', \ default=None, \ - help='''Package name to verify. + help='''Package name to verify. ****************************************** NOT SPECIFYING A NAME MEANS 'ALL' PACKAGES. ****************************************** - The specified operation will be carried out on all + The specified operation will be carried out on all instances of packages that match the package specification (name, epoch, version, release, arch).''') @@ -945,24 +945,24 @@ if __name__ == "__main__": p.add_option('--erase', '-e', action='store_true', \ default=None, \ help='''**************************************************** - REMOVE PACKAGES. THERE ARE NO WARNINGS. MULTIPLE - PACKAGES WILL BE REMOVED IF A FULL PACKAGE SPEC IS NOT + REMOVE PACKAGES. THERE ARE NO WARNINGS. MULTIPLE + PACKAGES WILL BE REMOVED IF A FULL PACKAGE SPEC IS NOT GIVEN. E.G. IF JUST A NAME IS GIVEN ALL INSTALLED - INSTANCES OF THAT PACKAGE WILL BE REMOVED PROVIDED - DEPENDENCY CHECKS PASS. IF JUST AN EPOCH IS GIVEN + INSTANCES OF THAT PACKAGE WILL BE REMOVED PROVIDED + DEPENDENCY CHECKS PASS. IF JUST AN EPOCH IS GIVEN ALL PACKAGE INSTANCES WITH THAT EPOCH WILL BE REMOVED. ****************************************************''') p.add_option('--list', '-l', action='store_true', \ - help='''List package identity info. rpm -qa ish equivalent + help='''List package identity info. rpm -qa ish equivalent intended for use in RefreshPackages().''') p.add_option('--verify', action='store_true', \ - help='''Verify Package(s). Output is only produced after all + help='''Verify Package(s). Output is only produced after all packages has been verified. Be patient.''') p.add_option('--verbose', '-v', action='store_true', \ - help='''Verbose output for --verify option. Output is the + help='''Verbose output for --verify option. Output is the same as rpm -v --verify.''') p.add_option('--nodeps', action='store_true', \ @@ -985,11 +985,11 @@ if __name__ == "__main__": help='Do not do symlink tests.') p.add_option('--nomd5', action='store_true', \ - help='''Do not do MD5 checksums on files. Note that this does + help='''Do not do MD5 checksums on files. Note that this does not work for prelink files yet.''') p.add_option('--nosize', action='store_true', \ - help='''Do not do file size tests. Note that this does not work + help='''Do not do file size tests. Note that this does not work for prelink files yet.''') p.add_option('--nouser', action='store_true', \ @@ -1011,15 +1011,15 @@ if __name__ == "__main__": help='Do not do not generate triggers on erase.') p.add_option('--repackage', action='store_true', \ - help='''Do repackage on erase.i Packages are put + help='''Do repackage on erase.i Packages are put in /var/spool/repackage.''') p.add_option('--allmatches', action='store_true', \ - help='''Remove all package instances that match the - pkgspec. + help='''Remove all package instances that match the + pkgspec. *************************************************** - NO WARNINGS ARE GIVEN. IF THERE IS NO PACKAGE SPEC + NO WARNINGS ARE GIVEN. IF THERE IS NO PACKAGE SPEC THAT MEANS ALL PACKAGES!!!! ***************************************************''') @@ -1072,9 +1072,9 @@ if __name__ == "__main__": if options.allmatches: rpm_options.append('allmatches') - + main_ts = rpmtransactionset() - + cmdline_pkgspec = {} if options.name != 'all': if options.name: @@ -1089,12 +1089,12 @@ if __name__ == "__main__": cmdline_pkgspec['arch'] = str(options.arch) if options.verify: - results = rpm_verify(main_ts, cmdline_pkgspec, rpm_options) + results = rpm_verify(main_ts, cmdline_pkgspec, rpm_options) for r in results: files = r.get('files', '') for f in files: display_verify_file(f) - + elif options.list: for p in rpmpackagelist(main_ts): print(p) diff --git a/src/lib/Server/Plugins/__init__.py b/src/lib/Server/Plugins/__init__.py index c95f6714d..0d54fc873 100644 --- a/src/lib/Server/Plugins/__init__.py +++ b/src/lib/Server/Plugins/__init__.py @@ -4,5 +4,5 @@ __revision__ = '$Revision$' __all__ = ['Account', 'Base', 'Bundler', 'Cfg', 'Decisions', 'GBundler', 'Git', 'Hostbase', 'Metadata', 'NagiosGen', 'Packages', 'Properties', 'Probes', 'Pkgmgr', 'Rules', 'SSHbase', 'Snapshots' 'Statistics', - 'Svcmgr', 'Svn', 'TCheetah', 'Trigger', 'SGenshi', 'TGenshi', + 'Svcmgr', 'Svn', 'TCheetah', 'Trigger', 'SGenshi', 'TGenshi', 'GroupPatterns', 'Ohai'] |