summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Server/Plugins
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2013-08-09 16:45:45 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2013-08-09 16:45:45 -0400
commit0f7edd60e67d32438a8be42002faacde4e4a7649 (patch)
tree2b11b02f5bf4f9e7a6e609136bf2a19c8f166cc4 /src/lib/Bcfg2/Server/Plugins
parentcc11ada6b8871d7719fd0ea8a2ff382bba8a3bc2 (diff)
downloadbcfg2-0f7edd60e67d32438a8be42002faacde4e4a7649.tar.gz
bcfg2-0f7edd60e67d32438a8be42002faacde4e4a7649.tar.bz2
bcfg2-0f7edd60e67d32438a8be42002faacde4e4a7649.zip
testsuite: fixed most pylint complaints
Diffstat (limited to 'src/lib/Bcfg2/Server/Plugins')
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py11
-rw-r--r--src/lib/Bcfg2/Server/Plugins/FileProbes.py4
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Metadata.py8
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Packages/Collection.py1
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Packages/Source.py1
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Packages/YumHelper.py17
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Packages/__init__.py3
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Probes.py5
-rw-r--r--src/lib/Bcfg2/Server/Plugins/SSHbase.py4
9 files changed, 43 insertions, 11 deletions
diff --git a/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py b/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py
index a7fa92201..99afac7eb 100644
--- a/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py
+++ b/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py
@@ -763,6 +763,7 @@ class CfgEntrySet(Bcfg2.Server.Plugin.EntrySet):
class CfgHandlerAction(Bcfg2.Options.ComponentAction):
+ """ Option parser action to load Cfg handlers """
bases = ['Bcfg2.Server.Plugins.Cfg']
@@ -796,10 +797,18 @@ class Cfg(Bcfg2.Server.Plugin.GroupSpool,
global CFG # pylint: disable=W0603
Bcfg2.Server.Plugin.GroupSpool.__init__(self, core, datastore)
Bcfg2.Server.Plugin.PullTarget.__init__(self)
-
+ self._handlers = None
CFG = self
__init__.__doc__ = Bcfg2.Server.Plugin.GroupSpool.__init__.__doc__
+ @property
+ def handlers(self):
+ """ A list of Cfg handler classes. """
+ if self._handlers is None:
+ self._handlers = Bcfg2.Options.setup.cfg_handlers
+ self._handlers.sort(key=operator.attrgetter("__priority__"))
+ return self._handlers
+
def has_generator(self, entry, metadata):
""" Return True if the given entry can be generated for the
given metadata; False otherwise
diff --git a/src/lib/Bcfg2/Server/Plugins/FileProbes.py b/src/lib/Bcfg2/Server/Plugins/FileProbes.py
index 45511eb52..51eb6e09a 100644
--- a/src/lib/Bcfg2/Server/Plugins/FileProbes.py
+++ b/src/lib/Bcfg2/Server/Plugins/FileProbes.py
@@ -147,7 +147,7 @@ class FileProbes(Bcfg2.Server.Plugin.Plugin,
self.write_file(fileloc, contents)
self.verify_file(filename, contents, metadata)
infoxml = os.path.join(cfg.data, filename.lstrip("/"), "info.xml")
- self.write_infoxml(infoxml, entry, data)
+ self.write_infoxml(infoxml, data)
elif entrydata == contents:
self.debug_log("Existing %s contents match probed contents" %
filename)
@@ -213,7 +213,7 @@ class FileProbes(Bcfg2.Server.Plugin.Plugin,
updated = True
tries += 1
- def write_infoxml(self, infoxml, entry, data):
+ def write_infoxml(self, infoxml, data):
""" write an info.xml for the file """
if os.path.exists(infoxml):
return
diff --git a/src/lib/Bcfg2/Server/Plugins/Metadata.py b/src/lib/Bcfg2/Server/Plugins/Metadata.py
index f27910eb8..e2da2a6d4 100644
--- a/src/lib/Bcfg2/Server/Plugins/Metadata.py
+++ b/src/lib/Bcfg2/Server/Plugins/Metadata.py
@@ -20,12 +20,18 @@ from Bcfg2.Compat import MutableMapping, all, wraps # pylint: disable=W0622
from Bcfg2.version import Bcfg2VersionInfo
+# pylint: disable=C0103
+ClientVersions = None
MetadataClientModel = None
+# pylint: enable=C0103
HAS_DJANGO = False
def load_django_models():
+ """ Load models for Django after option parsing has completed """
+ # pylint: disable=W0602
global MetadataClientModel, ClientVersions, HAS_DJANGO
+ # pylint: enable=W0602
try:
from django.db import models
@@ -674,7 +680,9 @@ class Metadata(Bcfg2.Server.Plugin.Metadata,
try:
client = MetadataClientModel.objects.get(hostname=client_name)
except MetadataClientModel.DoesNotExist:
+ # pylint: disable=E1102
client = MetadataClientModel(hostname=client_name)
+ # pylint: enable=E1102
client.save()
self.clients = self.list_clients()
return client
diff --git a/src/lib/Bcfg2/Server/Plugins/Packages/Collection.py b/src/lib/Bcfg2/Server/Plugins/Packages/Collection.py
index 0df8624f6..8b20df58a 100644
--- a/src/lib/Bcfg2/Server/Plugins/Packages/Collection.py
+++ b/src/lib/Bcfg2/Server/Plugins/Packages/Collection.py
@@ -595,7 +595,6 @@ def get_collection_class(source_type):
:type source_type: string
:returns: type - the Collection subclass that should be used to
instantiate an object to contain sources of the given type. """
- cls = None
for mod in Bcfg2.Options.setup.packages_backends:
if mod.__name__.endswith(".%s" % source_type.title()):
return getattr(mod, "%sCollection" % source_type.title())
diff --git a/src/lib/Bcfg2/Server/Plugins/Packages/Source.py b/src/lib/Bcfg2/Server/Plugins/Packages/Source.py
index e1659dbb3..4b6130f72 100644
--- a/src/lib/Bcfg2/Server/Plugins/Packages/Source.py
+++ b/src/lib/Bcfg2/Server/Plugins/Packages/Source.py
@@ -49,7 +49,6 @@ in your ``Source`` subclass. For an example of this kind of
import os
import re
import sys
-import Bcfg2.Server.Plugin
from Bcfg2.Logger import Debuggable
from Bcfg2.Compat import HTTPError, HTTPBasicAuthHandler, \
HTTPPasswordMgrWithDefaultRealm, install_opener, build_opener, urlopen, \
diff --git a/src/lib/Bcfg2/Server/Plugins/Packages/YumHelper.py b/src/lib/Bcfg2/Server/Plugins/Packages/YumHelper.py
index 32db0b32d..dcb8718a0 100644
--- a/src/lib/Bcfg2/Server/Plugins/Packages/YumHelper.py
+++ b/src/lib/Bcfg2/Server/Plugins/Packages/YumHelper.py
@@ -266,6 +266,8 @@ class CacheManager(YumHelper):
class HelperSubcommand(Bcfg2.Options.Subcommand):
+ """ Base class for all yum helper subcommands """
+
# the value to JSON encode and print out if the command fails
fallback = None
@@ -300,10 +302,14 @@ class HelperSubcommand(Bcfg2.Options.Subcommand):
return 0
def _run(self, setup, data):
+ """ Actually run the command """
raise NotImplementedError
class DepSolverSubcommand(HelperSubcommand):
+ """ Base class for helper commands that use the depsolver (i.e.,
+ only resolve dependencies, don't modify the cache) """
+
def __init__(self):
HelperSubcommand.__init__(self)
self.depsolver = DepSolver(Bcfg2.Options.setup.yum_config,
@@ -311,6 +317,8 @@ class DepSolverSubcommand(HelperSubcommand):
class CacheManagerSubcommand(HelperSubcommand):
+ """ Base class for helper commands that use the cachemanager
+ (i.e., modify the cache) """
fallback = False
accept_input = False
@@ -321,18 +329,22 @@ class CacheManagerSubcommand(HelperSubcommand):
class Clean(CacheManagerSubcommand):
+ """ Clean the cache """
def _run(self, setup, data): # pylint: disable=W0613
self.cachemgr.clean_cache()
return True
class MakeCache(CacheManagerSubcommand):
+ """ Update the on-disk cache """
def _run(self, setup, data): # pylint: disable=W0613
self.cachemgr.populate_cache()
return True
class Complete(DepSolverSubcommand):
+ """ Given an initial set of packages, get a complete set of
+ packages with all dependencies resolved """
fallback = dict(packages=[], unknown=[])
def _run(self, _, data):
@@ -344,6 +356,7 @@ class Complete(DepSolverSubcommand):
class GetGroups(DepSolverSubcommand):
+ """ Resolve the given package groups """
def _run(self, _, data):
rv = dict()
for gdata in data:
@@ -356,10 +369,11 @@ class GetGroups(DepSolverSubcommand):
return rv
-Get_Groups = GetGroups
+Get_Groups = GetGroups # pylint: disable=C0103
class CLI(Bcfg2.Options.CommandRegistry):
+ """ The bcfg2-yum-helper CLI """
options = [
Bcfg2.Options.PathOption(
"-c", "--yum-config", help="Yum config file"),
@@ -377,6 +391,7 @@ class CLI(Bcfg2.Options.CommandRegistry):
self.logger = logging.getLogger(parser.prog)
def run(self):
+ """ Run bcfg2-yum-helper """
if not os.path.exists(Bcfg2.Options.setup.yum_config):
self.logger.error("Config file %s not found" %
Bcfg2.Options.setup.yum_config)
diff --git a/src/lib/Bcfg2/Server/Plugins/Packages/__init__.py b/src/lib/Bcfg2/Server/Plugins/Packages/__init__.py
index e6240f39a..efd0bbe4a 100644
--- a/src/lib/Bcfg2/Server/Plugins/Packages/__init__.py
+++ b/src/lib/Bcfg2/Server/Plugins/Packages/__init__.py
@@ -124,7 +124,8 @@ class Packages(Bcfg2.Server.Plugin.Plugin,
Bcfg2.Options.PathOption(
cf=("packages", "apt_config"),
help="The default path for generated apt configs",
- default="/etc/apt/sources.list.d/bcfg2-packages-generated-sources.list")]
+ default=
+ "/etc/apt/sources.list.d/bcfg2-packages-generated-sources.list")]
#: Packages is an alternative to
#: :mod:`Bcfg2.Server.Plugins.Pkgmgr` and conflicts with it.
diff --git a/src/lib/Bcfg2/Server/Plugins/Probes.py b/src/lib/Bcfg2/Server/Plugins/Probes.py
index 21bb331cd..012c1958a 100644
--- a/src/lib/Bcfg2/Server/Plugins/Probes.py
+++ b/src/lib/Bcfg2/Server/Plugins/Probes.py
@@ -13,12 +13,17 @@ import Bcfg2.Server.FileMonitor
from Bcfg2.Server.Statistics import track_statistics
HAS_DJANGO = False
+# pylint: disable=C0103
ProbesDataModel = None
ProbesGroupsModel = None
+# pylint: enable=C0103
def load_django_models():
+ """ Load models for Django after option parsing has completed """
+ # pylint: disable=W0602
global ProbesDataModel, ProbesGroupsModel, HAS_DJANGO
+ # pylint: enable=W0602
try:
from django.db import models
HAS_DJANGO = True
diff --git a/src/lib/Bcfg2/Server/Plugins/SSHbase.py b/src/lib/Bcfg2/Server/Plugins/SSHbase.py
index c858b881b..8ce4e8a54 100644
--- a/src/lib/Bcfg2/Server/Plugins/SSHbase.py
+++ b/src/lib/Bcfg2/Server/Plugins/SSHbase.py
@@ -76,10 +76,6 @@ class HostKeyEntrySet(Bcfg2.Server.Plugin.EntrySet):
else:
self.metadata['mode'] = '0600'
- def get_keydata_object(self, filepath, specificity):
- return KeyData(filepath, specificity,
- self.encoding or Bcfg2.Options.setup.encoding)
-
class KnownHostsEntrySet(Bcfg2.Server.Plugin.EntrySet):
""" EntrySet to handle the ssh_known_hosts file """