diff options
author | Tim Laszlo <tim.laszlo@gmail.com> | 2010-08-03 21:43:20 +0000 |
---|---|---|
committer | Sol Jerome <sol.jerome@gmail.com> | 2010-08-04 16:59:36 -0500 |
commit | 9ae740ec11040a07d3ebf5556955cb815c0d7826 (patch) | |
tree | 5faf633a4c3a45b894bafd3267567ba8b9c4c543 /src | |
parent | 96714d720ce568aafac6ac45b35fe1341a8d38d5 (diff) | |
download | bcfg2-9ae740ec11040a07d3ebf5556955cb815c0d7826.tar.gz bcfg2-9ae740ec11040a07d3ebf5556955cb815c0d7826.tar.bz2 bcfg2-9ae740ec11040a07d3ebf5556955cb815c0d7826.zip |
Packages: Resolver/Metadata options
Patch from Jack Neely to add enable/disable options to the resolver
and metadata pareser.
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5998 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/Server/Plugins/Packages.py | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/lib/Server/Plugins/Packages.py b/src/lib/Server/Plugins/Packages.py index c8b1add44..870a3f6b0 100644 --- a/src/lib/Server/Plugins/Packages.py +++ b/src/lib/Server/Plugins/Packages.py @@ -6,7 +6,9 @@ import logging import lxml.etree import os import re +import sys import urllib2 +import ConfigParser try: from hashlib import md5 @@ -72,6 +74,7 @@ def _fetch_url(url): class Source(object): basegroups = [] + def __init__(self, basepath, url, version, arches, components, groups, rawurl, blacklist, whitelist, recommended): self.basepath = basepath @@ -562,6 +565,32 @@ class Packages(Bcfg2.Server.Plugin.Plugin, self.sentinels = set() self.sources = [] + # Grab the config file location + # XXX: Ugh...we need some help with Bcfg2's Option stuff + cfile = '/etc/bcfg2.conf' + if '-C' in sys.argv: + inx = sys.argv.index('-C') + if len(sys.argv) > inx + 1: + cfile = sys.argv[inx + 1] + + CP = ConfigParser.ConfigParser() + CP.read(cfile) + + # Did the user configure off the resolver? + self.disableResolver = False + try: + if CP.get('packages', 'resolver').lower() in ['0', 'false', 'no']: + self.disableResolver = True + except (ConfigParser.NoOptionError, ConfigParser.NoSectionError): + pass + self.disableMetaData = False + try: + if CP.get('packages', 'metadata').lower() in ['0', 'false', 'no']: + self.disableMetaData = True + self.disableResolver = True + except (ConfigParser.NoOptionError, ConfigParser.NoSectionError): + pass + if not os.path.exists(self.cachepath): # create cache directory if needed os.makedirs(self.cachepath) @@ -647,6 +676,8 @@ class Packages(Bcfg2.Server.Plugin.Plugin, meta - client metadata instance structures - a list of structure-stage entry combinations ''' + if self.disableResolver: return # Config requests no resolver + initial = set([pkg.get('name') for struct in structures \ for pkg in struct.findall('Package') + struct.findall('BoundPackage')]) @@ -726,7 +757,7 @@ class Packages(Bcfg2.Server.Plugin.Plugin, cachefiles = [] for source in self.sources: cachefiles.append(source.cachefile) - source.setup_data(force_update) + if not self.disableMetaData: source.setup_data(force_update) self.sentinels.update(source.basegroups) for cfile in glob.glob("%s/cache-*" % self.cachepath): if cfile not in cachefiles: |