diff options
author | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2013-08-12 08:26:50 -0400 |
---|---|---|
committer | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2013-08-12 08:29:53 -0400 |
commit | 5c573e00a168c90c5c718566c75aadf736566676 (patch) | |
tree | 0dba4d9411304f4d29daf3569535227be8939abf /src/lib/Bcfg2/Server/Plugins | |
parent | 0f7edd60e67d32438a8be42002faacde4e4a7649 (diff) | |
download | bcfg2-5c573e00a168c90c5c718566c75aadf736566676.tar.gz bcfg2-5c573e00a168c90c5c718566c75aadf736566676.tar.bz2 bcfg2-5c573e00a168c90c5c718566c75aadf736566676.zip |
testsuite: fixed more unit tests
Diffstat (limited to 'src/lib/Bcfg2/Server/Plugins')
-rw-r--r-- | src/lib/Bcfg2/Server/Plugins/Git.py | 1 | ||||
-rw-r--r-- | src/lib/Bcfg2/Server/Plugins/Metadata.py | 7 | ||||
-rw-r--r-- | src/lib/Bcfg2/Server/Plugins/Packages/Yum.py | 31 | ||||
-rw-r--r-- | src/lib/Bcfg2/Server/Plugins/Packages/YumHelper.py | 4 | ||||
-rw-r--r-- | src/lib/Bcfg2/Server/Plugins/Packages/__init__.py | 30 | ||||
-rw-r--r-- | src/lib/Bcfg2/Server/Plugins/Probes.py | 4 |
6 files changed, 23 insertions, 54 deletions
diff --git a/src/lib/Bcfg2/Server/Plugins/Git.py b/src/lib/Bcfg2/Server/Plugins/Git.py index d0502ed6a..3144a4f97 100644 --- a/src/lib/Bcfg2/Server/Plugins/Git.py +++ b/src/lib/Bcfg2/Server/Plugins/Git.py @@ -2,6 +2,7 @@ git. """ import sys +import Bcfg2.Options from Bcfg2.Server.Plugin import Version, PluginExecutionError try: diff --git a/src/lib/Bcfg2/Server/Plugins/Metadata.py b/src/lib/Bcfg2/Server/Plugins/Metadata.py index e2da2a6d4..3d82beb87 100644 --- a/src/lib/Bcfg2/Server/Plugins/Metadata.py +++ b/src/lib/Bcfg2/Server/Plugins/Metadata.py @@ -40,13 +40,13 @@ def load_django_models(): HAS_DJANGO = False return - class MetadataClientModel(models.Model, + class MetadataClientModel(models.Model, # pylint: disable=W0621 Bcfg2.Server.Plugin.PluginDatabaseModel): """ django model for storing clients in the database """ hostname = models.CharField(max_length=255, primary_key=True) version = models.CharField(max_length=31, null=True) - class ClientVersions(MutableMapping, + class ClientVersions(MutableMapping, # pylint: disable=W0621,W0612 Bcfg2.Server.Plugin.DatabaseBacked): """ dict-like object to make it easier to access client bcfg2 versions from the database """ @@ -559,7 +559,8 @@ class Metadata(Bcfg2.Server.Plugin.Metadata, self.negated_groups = dict() # mapping of hostname -> version string if self._use_db: - self.versions = ClientVersions(core, datastore) + self.versions = ClientVersions(core, # pylint: disable=E1102 + datastore) else: self.versions = dict() self.uuid = {} diff --git a/src/lib/Bcfg2/Server/Plugins/Packages/Yum.py b/src/lib/Bcfg2/Server/Plugins/Packages/Yum.py index 0d49473c6..5f66cb8a0 100644 --- a/src/lib/Bcfg2/Server/Plugins/Packages/Yum.py +++ b/src/lib/Bcfg2/Server/Plugins/Packages/Yum.py @@ -107,7 +107,8 @@ PULPSERVER = None PULPCONFIG = None -options = [ +options = [ # pylint: disable=C0103 + Bcfg2.Options.Common.client_timeout, Bcfg2.Options.PathOption( cf=("packages:yum", "helper"), dest="yum_helper", help="Path to the bcfg2-yum-helper executable"), @@ -307,7 +308,7 @@ class YumCollection(Collection): if not os.path.exists(self.cachefile): self.debug_log("Creating common cache %s" % self.cachefile) os.mkdir(self.cachefile) - if not self.disableMetaData: + if Bcfg2.Options.setup.packages_metadata: self.setup_data() self.cmd = Executor() else: @@ -334,26 +335,6 @@ class YumCollection(Collection): self.__class__.pulp_cert_set = PulpCertificateSet(certdir) @property - def disableMetaData(self): - """ Report whether or not metadata processing is enabled. - This duplicates code in Packages/__init__.py, and can probably - be removed in Bcfg2 1.4 when we have a module-level setup - object. """ - if self.setup is None: - return True - try: - return not self.setup.cfp.getboolean("packages", "resolver") - except (ConfigParser.NoSectionError, ConfigParser.NoOptionError): - return False - except ValueError: - # for historical reasons we also accept "enabled" and - # "disabled" - return self.setup.cfp.get( - "packages", - "metadata", - default="enabled").lower() == "disabled" - - @property def __package_groups__(self): return True @@ -935,10 +916,12 @@ class YumCollection(Collection): self.debug_log("Packages: running %s" % " ".join(cmd)) if inputdata: - result = self.cmd.run(cmd, timeout=self.setup['client_timeout'], + result = self.cmd.run(cmd, + timeout=Bcfg2.Options.setup.client_timeout, inputdata=json.dumps(inputdata)) else: - result = self.cmd.run(cmd, timeout=self.setup['client_timeout']) + result = self.cmd.run(cmd, + timeout=Bcfg2.Options.setup.client_timeout) if not result.success: self.logger.error("Packages: error running bcfg2-yum-helper: %s" % result.error) diff --git a/src/lib/Bcfg2/Server/Plugins/Packages/YumHelper.py b/src/lib/Bcfg2/Server/Plugins/Packages/YumHelper.py index dcb8718a0..48304d26e 100644 --- a/src/lib/Bcfg2/Server/Plugins/Packages/YumHelper.py +++ b/src/lib/Bcfg2/Server/Plugins/Packages/YumHelper.py @@ -306,7 +306,7 @@ class HelperSubcommand(Bcfg2.Options.Subcommand): raise NotImplementedError -class DepSolverSubcommand(HelperSubcommand): +class DepSolverSubcommand(HelperSubcommand): # pylint: disable=W0223 """ Base class for helper commands that use the depsolver (i.e., only resolve dependencies, don't modify the cache) """ @@ -316,7 +316,7 @@ class DepSolverSubcommand(HelperSubcommand): self.verbosity) -class CacheManagerSubcommand(HelperSubcommand): +class CacheManagerSubcommand(HelperSubcommand): # pylint: disable=W0223 """ Base class for helper commands that use the cachemanager (i.e., modify the cache) """ fallback = False diff --git a/src/lib/Bcfg2/Server/Plugins/Packages/__init__.py b/src/lib/Bcfg2/Server/Plugins/Packages/__init__.py index efd0bbe4a..7dcc2dccc 100644 --- a/src/lib/Bcfg2/Server/Plugins/Packages/__init__.py +++ b/src/lib/Bcfg2/Server/Plugins/Packages/__init__.py @@ -29,6 +29,7 @@ def packages_boolean(value): class PackagesBackendAction(Bcfg2.Options.ComponentAction): + """ ComponentAction to load Packages backends """ bases = ['Bcfg2.Server.Plugins.Packages'] module = True @@ -218,25 +219,6 @@ class Packages(Bcfg2.Server.Plugin.Plugin, return rv set_debug.__doc__ = Bcfg2.Server.Plugin.Plugin.set_debug.__doc__ - @property - def disableResolver(self): - """ Report the state of the resolver. This can be disabled in - the configuration. Note that disabling metadata (see - :attr:`disableMetaData`) implies disabling the resolver. - - This property cannot be set. """ - # disabling metadata without disabling the resolver Breaks - # Things - return not Bcfg2.Options.setup.packages_metadata or \ - not Bcfg2.Options.setup.packages_resolver - - @property - def disableMetaData(self): - """ Report whether or not metadata processing is enabled. - - This property cannot be set. """ - return not Bcfg2.Options.setup.packages_metadata - def create_config(self, entry, metadata): """ Create yum/apt config for the specified client. @@ -376,8 +358,10 @@ class Packages(Bcfg2.Server.Plugin.Plugin, :func:`get_collection` :type collection: Bcfg2.Server.Plugins.Packages.Collection.Collection """ - if self.disableResolver: - # Config requests no resolver + if (not Bcfg2.Options.setup.packages_metadata or + not Bcfg2.Options.setup.packages_resolver): + # Config requests no resolver. Note that disabling + # metadata implies disabling the resolver. for struct in structures: for pkg in struct.xpath('//Package | //BoundPackage'): if pkg.get("group"): @@ -484,7 +468,7 @@ class Packages(Bcfg2.Server.Plugin.Plugin, for collection in list(self.collections.values()): cachefiles.update(collection.cachefiles) - if not self.disableMetaData: + if Bcfg2.Options.setup.packages_metadata: collection.setup_data(force_update) # clear Collection and package caches @@ -495,7 +479,7 @@ class Packages(Bcfg2.Server.Plugin.Plugin, for source in self.sources.entries: cachefiles.add(source.cachefile) - if not self.disableMetaData: + if Bcfg2.Options.setup.packages_metadata: source.setup_data(force_update) for cfile in glob.glob(os.path.join(self.cachepath, "cache-*")): diff --git a/src/lib/Bcfg2/Server/Plugins/Probes.py b/src/lib/Bcfg2/Server/Plugins/Probes.py index 012c1958a..f75d88d8f 100644 --- a/src/lib/Bcfg2/Server/Plugins/Probes.py +++ b/src/lib/Bcfg2/Server/Plugins/Probes.py @@ -31,7 +31,7 @@ def load_django_models(): HAS_DJANGO = False return - class ProbesDataModel(models.Model, + class ProbesDataModel(models.Model, # pylint: disable=W0621,W0612 Bcfg2.Server.Plugin.PluginDatabaseModel): """ The database model for storing probe data """ hostname = models.CharField(max_length=255) @@ -39,7 +39,7 @@ def load_django_models(): timestamp = models.DateTimeField(auto_now=True) data = models.TextField(null=True) - class ProbesGroupsModel(models.Model, + class ProbesGroupsModel(models.Model, # pylint: disable=W0621,W0612 Bcfg2.Server.Plugin.PluginDatabaseModel): """ The database model for storing probe groups """ hostname = models.CharField(max_length=255) |