diff options
author | Fabian Affolter <fabian@bernewireless.net> | 2010-06-08 08:16:41 +0000 |
---|---|---|
committer | Sol Jerome <solj@ices.utexas.edu> | 2010-06-09 08:09:54 -0500 |
commit | a2755d2d1a111ad4e55f88a166a5b02856d363cd (patch) | |
tree | 82dabe1dbbe429e9d5cbe554ffb16702a79041d2 /src | |
parent | e31f5234256e5234348fc67cf45e6f3462e1fbb8 (diff) | |
download | bcfg2-a2755d2d1a111ad4e55f88a166a5b02856d363cd.tar.gz bcfg2-a2755d2d1a111ad4e55f88a166a5b02856d363cd.tar.bz2 bcfg2-a2755d2d1a111ad4e55f88a166a5b02856d363cd.zip |
Updated files to match PEP 257
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5904 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src')
30 files changed, 140 insertions, 125 deletions
diff --git a/src/lib/Server/Plugins/Account.py b/src/lib/Server/Plugins/Account.py index f73069de3..e3ea58761 100644 --- a/src/lib/Server/Plugins/Account.py +++ b/src/lib/Server/Plugins/Account.py @@ -1,18 +1,19 @@ -'''This handles authentication setup''' +"""This handles authentication setup.""" __revision__ = '$Revision$' import Bcfg2.Server.Plugin class Account(Bcfg2.Server.Plugin.Plugin, Bcfg2.Server.Plugin.Generator): - '''This module generates account config files, + """This module generates account config files, based on an internal data repo: static.(passwd|group|limits.conf) -> static entries dyn.(passwd|group) -> dynamic entries (usually acquired from yp or somesuch) useraccess -> users to be granted login access on some hosts superusers -> users to be granted root privs on all hosts rootlike -> users to be granted root privs on some hosts - ''' + + """ name = 'Account' __version__ = '$Id$' __author__ = 'bcfg-dev@mcs.anl.gov' @@ -33,7 +34,7 @@ class Account(Bcfg2.Server.Plugin.Plugin, raise Bcfg2.Server.Plugin.PluginInitError def from_yp_cb(self, entry, metadata): - '''Build password file from cached yp data''' + """Build password file from cached yp data.""" fname = entry.attrib['name'].split('/')[-1] entry.text = self.repository.entries["static.%s" % (fname)].data entry.text += self.repository.entries["dyn.%s" % (fname)].data @@ -42,7 +43,7 @@ class Account(Bcfg2.Server.Plugin.Plugin, perms.iteritems()] def gen_limits_cb(self, entry, metadata): - '''Build limits entries based on current ACLs''' + """Build limits entries based on current ACLs.""" entry.text = self.repository.entries["static.limits.conf"].data superusers = self.repository.entries["superusers"].data.split() useraccess = [line.split(':') for line in \ @@ -57,7 +58,7 @@ class Account(Bcfg2.Server.Plugin.Plugin, entry.text += "* hard maxlogins 0\n" def gen_root_keys_cb(self, entry, metadata): - '''Build root authorized keys file based on current ACLs''' + """Build root authorized keys file based on current ACLs.""" superusers = self.repository.entries['superusers'].data.split() try: rootlike = [line.split(':', 1) for line in \ @@ -75,7 +76,7 @@ class Account(Bcfg2.Server.Plugin.Plugin, in perms.iteritems()] def gen_sudoers(self, entry, metadata): - '''Build root authorized keys file based on current ACLs''' + """Build root authorized keys file based on current ACLs.""" superusers = self.repository.entries['superusers'].data.split() try: rootlike = [line.split(':', 1) for line in \ diff --git a/src/lib/Server/Plugins/BB.py b/src/lib/Server/Plugins/BB.py index dd23f6ec9..b243a6545 100644 --- a/src/lib/Server/Plugins/BB.py +++ b/src/lib/Server/Plugins/BB.py @@ -11,9 +11,9 @@ import socket logger = Bcfg2.Server.Plugin.logger class BBfile(Bcfg2.Server.Plugin.XMLFileBacked): - '''Class for bb files''' + """Class for bb files.""" def Index(self): - '''Build data into an xml object''' + """Build data into an xml object.""" try: self.data = lxml.etree.XML(self.data) @@ -60,7 +60,7 @@ class BBDirectoryBacked(Bcfg2.Server.Plugin.DirectoryBacked): class BB(Bcfg2.Server.Plugin.Plugin, Bcfg2.Server.Plugin.Connector): - '''The BB plugin maps users to machines and metadata to machines''' + """The BB plugin maps users to machines and metadata to machines.""" name = 'BB' version = '$Revision$' experimental = True diff --git a/src/lib/Server/Plugins/Base.py b/src/lib/Server/Plugins/Base.py index e6f124432..8e5ca1cd9 100644 --- a/src/lib/Server/Plugins/Base.py +++ b/src/lib/Server/Plugins/Base.py @@ -1,4 +1,4 @@ -'''This module sets up a base list of configuration entries''' +"""This module sets up a base list of configuration entries.""" __revision__ = '$Revision$' import Bcfg2.Server.Plugin @@ -8,14 +8,15 @@ import lxml.etree class Base(Bcfg2.Server.Plugin.Plugin, Bcfg2.Server.Plugin.Structure, Bcfg2.Server.Plugin.XMLDirectoryBacked): - '''This Structure is good for the pile of independent configs - needed for most actual systems''' + """This Structure is good for the pile of independent configs + needed for most actual systems. + """ name = 'Base' __version__ = '$Id$' __author__ = 'bcfg-dev@mcs.anl.gov' __child__ = Bcfg2.Server.Plugin.StructFile - '''base creates independent clauses based on client metadata''' + """Base creates independent clauses based on client metadata.""" def __init__(self, core, datastore): Bcfg2.Server.Plugin.Plugin.__init__(self, core, datastore) Bcfg2.Server.Plugin.Structure.__init__(self) @@ -28,7 +29,7 @@ class Base(Bcfg2.Server.Plugin.Plugin, raise Bcfg2.Server.Plugin.PluginInitError def BuildStructures(self, metadata): - '''Build structures for client described by metadata''' + """Build structures for client described by metadata.""" ret = lxml.etree.Element("Independent", version='2.0') fragments = reduce(lambda x, y: x+y, [base.Match(metadata) for base diff --git a/src/lib/Server/Plugins/Bundler.py b/src/lib/Server/Plugins/Bundler.py index 914da3cee..47cd7e2c4 100644 --- a/src/lib/Server/Plugins/Bundler.py +++ b/src/lib/Server/Plugins/Bundler.py @@ -1,4 +1,4 @@ -'''This provides bundle clauses with translation functionality''' +"""This provides bundle clauses with translation functionality.""" __revision__ = '$Revision$' import copy @@ -25,7 +25,7 @@ class BundleFile(Bcfg2.Server.Plugin.StructFile): class Bundler(Bcfg2.Server.Plugin.Plugin, Bcfg2.Server.Plugin.Structure, Bcfg2.Server.Plugin.XMLDirectoryBacked): - '''The bundler creates dependent clauses based on the bundle/translation scheme from bcfg1''' + """The bundler creates dependent clauses based on the bundle/translation scheme from Bcfg1.""" name = 'Bundler' __version__ = '$Id$' __author__ = 'bcfg-dev@mcs.anl.gov' @@ -53,7 +53,7 @@ class Bundler(Bcfg2.Server.Plugin.Plugin, self.encoding) def BuildStructures(self, metadata): - '''Build all structures for client (metadata)''' + """Build all structures for client (metadata).""" bundleset = [] for bundlename in metadata.bundles: entries = [item for (key, item) in self.entries.iteritems() if \ diff --git a/src/lib/Server/Plugins/Bzr.py b/src/lib/Server/Plugins/Bzr.py index 7f43be474..a9a5eb814 100644 --- a/src/lib/Server/Plugins/Bzr.py +++ b/src/lib/Server/Plugins/Bzr.py @@ -8,7 +8,7 @@ logger = logging.getLogger('Bcfg2.Plugins.Bzr') class Bzr(Bcfg2.Server.Plugin.Plugin, Bcfg2.Server.Plugin.Version): - """Bzr is a version plugin for dealing with bcfg2 repos""" + """Bzr is a version plugin for dealing with Bcfg2 repos.""" name = 'Bzr' __version__ = '$Id$' __author__ = 'bcfg-dev@mcs.anl.gov' @@ -24,7 +24,7 @@ class Bzr(Bcfg2.Server.Plugin.Plugin, logger.debug("Initialized Bazaar plugin with directory = %(dir)s at revision = %(rev)s" % {'dir': datastore, 'rev': revision}) def get_revision(self): - """Read Bazaar revision information for the BCFG2 repository""" + """Read Bazaar revision information for the Bcfg2 repository.""" try: working_tree = WorkingTree.open(self.datastore) revision = str(working_tree.branch.revno()) diff --git a/src/lib/Server/Plugins/Cfg.py b/src/lib/Server/Plugins/Cfg.py index 249dd5548..48e2d8bcf 100644 --- a/src/lib/Server/Plugins/Cfg.py +++ b/src/lib/Server/Plugins/Cfg.py @@ -1,4 +1,4 @@ -'''This module implements a config file repository''' +"""This module implements a config file repository.""" __revision__ = '$Revision$' import binascii @@ -142,7 +142,7 @@ class CfgEntrySet(Bcfg2.Server.Plugin.EntrySet): class Cfg(Bcfg2.Server.Plugin.GroupSpool, Bcfg2.Server.Plugin.PullTarget): - '''This generator in the configuration file repository for bcfg2''' + """This generator in the configuration file repository for Bcfg2.""" name = 'Cfg' __version__ = '$Id$' __author__ = 'bcfg-dev@mcs.anl.gov' diff --git a/src/lib/Server/Plugins/Darcs.py b/src/lib/Server/Plugins/Darcs.py index fa19b062e..eb34a52c4 100644 --- a/src/lib/Server/Plugins/Darcs.py +++ b/src/lib/Server/Plugins/Darcs.py @@ -8,7 +8,7 @@ logger = logging.getLogger('Bcfg2.Plugins.Darcs') class Darcs(Bcfg2.Server.Plugin.Plugin, Bcfg2.Server.Plugin.Version): - """Darcs is a version plugin for dealing with bcfg2 repos""" + """Darcs is a version plugin for dealing with Bcfg2 repos.""" name = 'Darcs' __version__ = '$Id$' __author__ = 'bcfg-dev@mcs.anl.gov' @@ -33,7 +33,7 @@ class Darcs(Bcfg2.Server.Plugin.Plugin, logger.debug("Initialized Darcs plugin with darcs directory = %s" % darcs_dir) def get_revision(self): - """Read Darcs changeset information for the bcfg2 repository""" + """Read Darcs changeset information for the Bcfg2 repository.""" try: data = Popen("env LC_ALL=C darcs changes", shell=True, diff --git a/src/lib/Server/Plugins/Decisions.py b/src/lib/Server/Plugins/Decisions.py index 1aba88840..1f9525a0e 100644 --- a/src/lib/Server/Plugins/Decisions.py +++ b/src/lib/Server/Plugins/Decisions.py @@ -13,12 +13,13 @@ class DecisionFile(Bcfg2.Server.Plugin.SpecificData): class DecisionSet(Bcfg2.Server.Plugin.EntrySet): def __init__(self, path, fam, encoding): - """Container for decision specification files + """Container for decision specification files. Arguments: - `path`: repository path - `fam`: reference to the file monitor - `encoding`: XML character encoding + """ pattern = '(white|black)list' Bcfg2.Server.Plugin.EntrySet.__init__(self, pattern, path, \ @@ -55,6 +56,7 @@ class Decisions(DecisionSet, Arguments: - `core`: Bcfg2.Core instance - `datastore`: File repository location + """ Bcfg2.Server.Plugin.Plugin.__init__(self, core, datastore) Bcfg2.Server.Plugin.Decision.__init__(self) diff --git a/src/lib/Server/Plugins/Deps.py b/src/lib/Server/Plugins/Deps.py index cdf23833b..088f8cdad 100644 --- a/src/lib/Server/Plugins/Deps.py +++ b/src/lib/Server/Plugins/Deps.py @@ -1,4 +1,4 @@ -'''This plugin provides automatic dependency handling''' +"""This plugin provides automatic dependency handling.""" __revision__ = '$Revision$' import lxml.etree @@ -6,7 +6,7 @@ import lxml.etree import Bcfg2.Server.Plugin class DNode(Bcfg2.Server.Plugin.INode): - '''DNode provides supports for single predicate types for dependencies''' + """DNode provides supports for single predicate types for dependencies.""" raw = {'Group':"lambda x:'%s' in x.groups and predicate(x)"} containers = ['Group'] diff --git a/src/lib/Server/Plugins/Editor.py b/src/lib/Server/Plugins/Editor.py index 76adaf4cb..bfd4d6e93 100644 --- a/src/lib/Server/Plugins/Editor.py +++ b/src/lib/Server/Plugins/Editor.py @@ -3,7 +3,7 @@ import re import lxml.etree def linesub(pattern, repl, filestring): - '''Substitutes instances of pattern with repl in filestring''' + """Substitutes instances of pattern with repl in filestring.""" if filestring == None: filestring = '' output = list() @@ -13,9 +13,9 @@ def linesub(pattern, repl, filestring): return '\n'.join(output) class EditDirectives(Bcfg2.Server.Plugin.SpecificData): - '''This object handles the editing directives''' + """This object handles the editing directives.""" def ProcessDirectives(self, input): - '''Processes a list of edit directives on input''' + """Processes a list of edit directives on input.""" temp = input for directive in self.data.split('\n'): directive = directive.split(',') diff --git a/src/lib/Server/Plugins/Fossil.py b/src/lib/Server/Plugins/Fossil.py index a7c9880f7..57d427673 100644 --- a/src/lib/Server/Plugins/Fossil.py +++ b/src/lib/Server/Plugins/Fossil.py @@ -8,7 +8,7 @@ logger = logging.getLogger('Bcfg2.Plugins.Fossil') class Fossil(Bcfg2.Server.Plugin.Plugin, Bcfg2.Server.Plugin.Version): - """Fossil is a version plugin for dealing with bcfg2 repos""" + """Fossil is a version plugin for dealing with Bcfg2 repos.""" name = 'Fossil' __version__ = '$Id$' __author__ = 'bcfg-dev@mcs.anl.gov' @@ -35,7 +35,7 @@ class Fossil(Bcfg2.Server.Plugin.Plugin, % {'ffile': fossil_file, 'frev': revision}) def get_revision(self): - """Read fossil revision information for the bcfg2 repository""" + """Read fossil revision information for the Bcfg2 repository.""" try: data = Popen("env LC_ALL=C fossil info", shell=True, diff --git a/src/lib/Server/Plugins/Git.py b/src/lib/Server/Plugins/Git.py index 9433c6481..aaeac12ae 100644 --- a/src/lib/Server/Plugins/Git.py +++ b/src/lib/Server/Plugins/Git.py @@ -1,4 +1,4 @@ -"""The Git plugin provides a revision interface for bcfg2 repos using git""" +"""The Git plugin provides a revision interface for Bcfg2 repos using git.""" import os from dulwich.repo import Repo @@ -11,7 +11,7 @@ logger = logging.getLogger('Bcfg2.Plugins.Git') class Git(Bcfg2.Server.Plugin.Plugin, Bcfg2.Server.Plugin.Version): - """Git is a version plugin for dealing with bcfg2 repos""" + """Git is a version plugin for dealing with Bcfg2 repos.""" name = 'Git' __version__ = '$Id$' __author__ = 'bcfg-dev@mcs.anl.gov' @@ -35,7 +35,7 @@ class Git(Bcfg2.Server.Plugin.Plugin, logger.debug("Initialized git plugin with git directory %s" % git_dir) def get_revision(self): - """Read git revision information for the bcfg2 repository""" + """Read git revision information for the Bcfg2 repository.""" try: repo = Repo(self.datastore) revision = repo.head() diff --git a/src/lib/Server/Plugins/Hg.py b/src/lib/Server/Plugins/Hg.py index 055e8034e..0822f6312 100644 --- a/src/lib/Server/Plugins/Hg.py +++ b/src/lib/Server/Plugins/Hg.py @@ -9,7 +9,7 @@ logger = logging.getLogger('Bcfg2.Plugins.Mercurial') class Hg(Bcfg2.Server.Plugin.Plugin, Bcfg2.Server.Plugin.Version): - """Mercurial is a version plugin for dealing with bcfg2 repos""" + """Mercurial is a version plugin for dealing with Bcfg2 repos.""" name = 'Mercurial' __version__ = '$Id$' __author__ = 'bcfg-dev@mcs.anl.gov' @@ -34,7 +34,7 @@ class Hg(Bcfg2.Server.Plugin.Plugin, logger.debug("Initialized hg plugin with hg directory = %s" % hg_dir) def get_revision(self): - """Read hg revision information for the bcfg2 repository""" + """Read hg revision information for the Bcfg2 repository.""" try: repo_path = "%s/" % self.datastore repo = hg.repository(ui.ui(), repo_path) diff --git a/src/lib/Server/Plugins/Hostbase.py b/src/lib/Server/Plugins/Hostbase.py index 0ad34208d..65992596d 100644 --- a/src/lib/Server/Plugins/Hostbase.py +++ b/src/lib/Server/Plugins/Hostbase.py @@ -16,7 +16,7 @@ import cStringIO class Hostbase(Bcfg2.Server.Plugin.Plugin, Bcfg2.Server.Plugin.Structure, Bcfg2.Server.Plugin.Generator): - '''The Hostbase plugin handles host/network info''' + """The Hostbase plugin handles host/network info.""" name = 'Hostbase' __version__ = '$Id$' __author__ = 'bcfg-dev@mcs.anl.gov' @@ -50,7 +50,7 @@ class Hostbase(Bcfg2.Server.Plugin.Plugin, raise PluginInitError def FetchFile(self, entry, metadata): - '''Return prebuilt file data''' + """Return prebuilt file data.""" fname = entry.get('name').split('/')[-1] if not fname in self.filedata: raise PluginExecutionError @@ -59,7 +59,7 @@ class Hostbase(Bcfg2.Server.Plugin.Plugin, entry.text = self.filedata[fname] def BuildStructures(self, metadata): - '''Build hostbase bundle''' + """Build hostbase bundle.""" if metadata.hostname not in self.dnsservers or metadata.hostname not in self.dhcpservers: return [] output = Element("Bundle", name='hostbase') @@ -72,8 +72,10 @@ class Hostbase(Bcfg2.Server.Plugin.Plugin, return [output] def rebuildState(self, _): - '''Pre-cache all state information for hostbase config files - callable as an XMLRPC function''' + """Pre-cache all state information for hostbase config files + callable as an XMLRPC function. + + """ self.buildZones() self.buildDHCP() self.buildHosts() @@ -83,7 +85,7 @@ class Hostbase(Bcfg2.Server.Plugin.Plugin, return True def buildZones(self): - '''Pre-build and stash zone files''' + """Pre-build and stash zone files.""" cursor = connection.cursor() cursor.execute("SELECT id, serial FROM hostbase_zone") @@ -314,7 +316,7 @@ class Hostbase(Bcfg2.Server.Plugin.Plugin, def buildDHCP(self): - '''Pre-build dhcpd.conf and stash in the filedata table''' + """Pre-build dhcpd.conf and stash in the filedata table.""" # fetches all the hosts with DHCP == True cursor = connection.cursor() @@ -362,7 +364,7 @@ class Hostbase(Bcfg2.Server.Plugin.Plugin, def buildHosts(self): - '''Pre-build and stash /etc/hosts file''' + """Pre-build and stash /etc/hosts file.""" append_data = [] diff --git a/src/lib/Server/Plugins/Metadata.py b/src/lib/Server/Plugins/Metadata.py index 6b2ad1d7b..0c5876d16 100644 --- a/src/lib/Server/Plugins/Metadata.py +++ b/src/lib/Server/Plugins/Metadata.py @@ -1,4 +1,5 @@ -'''This file stores persistent metadata for the Bcfg2 Configuration Repository''' +"""This file stores persistent metadata for the Bcfg2 Configuration Repository.""" + __revision__ = '$Revision$' import copy @@ -11,15 +12,15 @@ import time import Bcfg2.Server.Plugin class MetadataConsistencyError(Exception): - '''This error gets raised when metadata is internally inconsistent''' + """This error gets raised when metadata is internally inconsistent.""" pass class MetadataRuntimeError(Exception): - '''This error is raised when the metadata engine is called prior to reading enough data''' + """This error is raised when the metadata engine is called prior to reading enough data.""" pass class ClientMetadata(object): - '''This object contains client metadata''' + """This object contains client metadata.""" def __init__(self, client, profile, groups, bundles, aliases, addresses, categories, uuid, password, query): self.hostname = client @@ -35,7 +36,7 @@ class ClientMetadata(object): self.query = query def inGroup(self, group): - '''Test to see if client is a member of group''' + """Test to see if client is a member of group.""" return group in self.groups class MetadataQuery(object): @@ -59,7 +60,7 @@ class MetadataQuery(object): class Metadata(Bcfg2.Server.Plugin.Plugin, Bcfg2.Server.Plugin.Metadata, Bcfg2.Server.Plugin.Statistics): - '''This class contains data for bcfg2 server metadata''' + """This class contains data for bcfg2 server metadata.""" __version__ = '$Id$' __author__ = 'bcfg-dev@mcs.anl.gov' name = "Metadata" @@ -121,7 +122,7 @@ class Metadata(Bcfg2.Server.Plugin.Plugin, return root def search_group(self, group_name, tree): - '''find a group''' + """Find a group.""" for node in tree.findall("//Group"): if node.get("name") == group_name: return node @@ -131,7 +132,7 @@ class Metadata(Bcfg2.Server.Plugin.Plugin, return None def add_group(self, group_name, attribs): - '''add group to groups.xml''' + """Add group to groups.xml.""" tree = lxml.etree.parse(self.data + "/groups.xml") root = tree.getroot() element = lxml.etree.Element("Group", name=group_name) @@ -156,7 +157,7 @@ class Metadata(Bcfg2.Server.Plugin.Plugin, group_tree.close() def update_group(self, group_name, attribs): - '''Update a groups attributes''' + """Update a groups attributes.""" tree = lxml.etree.parse(self.data + "/groups.xml") root = tree.getroot() node = self.search_group(group_name, tree) @@ -178,7 +179,7 @@ class Metadata(Bcfg2.Server.Plugin.Plugin, group_tree.close() def remove_group(self, group_name): - '''Remove a group''' + """Remove a group.""" tree = lxml.etree.parse(self.data + "/groups.xml") root = tree.getroot() node = self.search_group(group_name, tree) @@ -200,7 +201,7 @@ class Metadata(Bcfg2.Server.Plugin.Plugin, group_tree.close() def add_bundle(self, bundle_name): - '''add bundle to groups.xml''' + """Add bundle to groups.xml.""" tree = lxml.etree.parse(self.data + "/groups.xml") root = tree.getroot() element = lxml.etree.Element("Bundle", name=bundle_name) @@ -223,7 +224,7 @@ class Metadata(Bcfg2.Server.Plugin.Plugin, group_tree.close() def remove_bundle(self, bundle_name): - '''Remove a bundle''' + """Remove a bundle.""" tree = lxml.etree.parse(self.data + "/groups.xml") root = tree.getroot() node = self.search_group(bundle_name, tree) @@ -245,7 +246,7 @@ class Metadata(Bcfg2.Server.Plugin.Plugin, group_tree.close() def search_client(self, client_name, tree): - '''find a client''' + """Find a client.""" for node in tree.findall("//Client"): if node.get("name") == client_name: return node @@ -255,7 +256,7 @@ class Metadata(Bcfg2.Server.Plugin.Plugin, return None def add_client(self, client_name, attribs): - '''add client to clients.xml''' + """Add client to clients.xml.""" tree = lxml.etree.parse(self.data + "/clients.xml") root = tree.getroot() element = lxml.etree.Element("Client", name=client_name) @@ -280,7 +281,7 @@ class Metadata(Bcfg2.Server.Plugin.Plugin, client_tree.close() def update_client(self, client_name, attribs): - '''Update a clients attributes''' + """Update a clients attributes.""" tree = lxml.etree.parse(self.data + "/clients.xml") root = tree.getroot() node = self.search_client(client_name, tree) @@ -302,7 +303,7 @@ class Metadata(Bcfg2.Server.Plugin.Plugin, client_tree.close() def HandleEvent(self, event): - '''Handle update events for data files''' + """Handle update events for data files.""" filename = event.filename.split('/')[-1] if filename in ['groups.xml', 'clients.xml']: dest = filename @@ -443,7 +444,7 @@ class Metadata(Bcfg2.Server.Plugin.Plugin, del self.bad_clients[bclient] def set_profile(self, client, profile, addresspair): - '''Set group parameter for provided client''' + """Set group parameter for provided client.""" self.logger.info("Asserting client %s profile to %s" % (client, profile)) if False in self.states.values(): raise MetadataRuntimeError @@ -472,7 +473,7 @@ class Metadata(Bcfg2.Server.Plugin.Plugin, self.write_back_clients() def write_back_clients(self): - '''Write changes to client.xml back to disk''' + """Write changes to client.xml back to disk.""" try: datafile = open("%s/%s" % (self.data, 'clients.xml.new'), 'w') except IOError: @@ -521,7 +522,7 @@ class Metadata(Bcfg2.Server.Plugin.Plugin, return False def resolve_client(self, addresspair): - '''Lookup address locally or in DNS to get a hostname''' + """Lookup address locally or in DNS to get a hostname.""" if addresspair in self.session_cache: (stamp, uuid) = self.session_cache[addresspair] if time.time() - stamp < 90: @@ -543,7 +544,7 @@ class Metadata(Bcfg2.Server.Plugin.Plugin, raise MetadataConsistencyError def get_initial_metadata(self, client): - '''Return the metadata for a given client''' + """Return the metadata for a given client.""" client = client.lower() if client in self.aliases: client = self.aliases[client] @@ -622,7 +623,7 @@ class Metadata(Bcfg2.Server.Plugin.Plugin, imd.connectors.append(source) def validate_client_address(self, client, addresspair): - '''Check address against client''' + """Check address against client.""" address = addresspair[0] if client in self.floating: self.debug_log("Client %s is floating" % client) @@ -645,7 +646,7 @@ class Metadata(Bcfg2.Server.Plugin.Plugin, return False def AuthenticateConnection(self, cert, user, password, address): - '''This function checks auth creds''' + """This function checks auth creds.""" if cert: id_method = 'cert' certinfo = dict([x[0] for x in cert['subject']]) @@ -713,7 +714,7 @@ class Metadata(Bcfg2.Server.Plugin.Plugin, return True def process_statistics(self, meta, _): - '''Hook into statistics interface to toggle clients in bootstrap mode''' + """Hook into statistics interface to toggle clients in bootstrap mode.""" client = meta.hostname if client in self.auth and self.auth[client] == 'bootstrap': self.logger.info("Asserting client %s auth mode to cert" % client) @@ -723,7 +724,7 @@ class Metadata(Bcfg2.Server.Plugin.Plugin, self.write_back_clients() def viz(self, hosts, bundles, key, colors): - '''admin mode viz support''' + """Admin mode viz support.""" groups_tree = lxml.etree.parse(self.data + "/groups.xml") try: groups_tree.xinclude() diff --git a/src/lib/Server/Plugins/NagiosGen.py b/src/lib/Server/Plugins/NagiosGen.py index 38934f090..f97085b1b 100644 --- a/src/lib/Server/Plugins/NagiosGen.py +++ b/src/lib/Server/Plugins/NagiosGen.py @@ -20,8 +20,9 @@ define host{ class NagiosGen(Bcfg2.Server.Plugin.Plugin, Bcfg2.Server.Plugin.Generator): - '''NagiosGen is a Bcfg2 plugin that dynamically generates - Nagios configuration file based on Bcfg2 data.''' + """NagiosGen is a Bcfg2 plugin that dynamically generates + Nagios configuration file based on Bcfg2 data. + """ name = 'NagiosGen' __version__ = '0.6' __author__ = 'bcfg-dev@mcs.anl.gov' @@ -45,7 +46,7 @@ class NagiosGen(Bcfg2.Server.Plugin.Plugin, 'perms':'0440'} def createhostconfig(self, entry, metadata): - '''Build host specific configuration file''' + """Build host specific configuration file.""" host_address = socket.gethostbyname(metadata.hostname) host_groups = [grp for grp in metadata.groups if \ os.path.isfile('%s/%s-group.cfg' % (self.data, grp))] @@ -81,7 +82,7 @@ class NagiosGen(Bcfg2.Server.Plugin.Plugin, LOGGER.error(ioerr) def createserverconfig(self, entry, _): - '''Build monolithic server configuration file''' + """Build monolithic server configuration file.""" host_configs = glob.glob('%s/*-host.cfg' % self.data) group_configs = glob.glob('%s/*-group.cfg' % self.data) host_data = "" diff --git a/src/lib/Server/Plugins/Ohai.py b/src/lib/Server/Plugins/Ohai.py index 3cd9534c5..0f7c7187f 100644 --- a/src/lib/Server/Plugins/Ohai.py +++ b/src/lib/Server/Plugins/Ohai.py @@ -50,6 +50,7 @@ class OhaiCache(object): class Ohai(Bcfg2.Server.Plugin.Plugin, Bcfg2.Server.Plugin.Probing, Bcfg2.Server.Plugin.Connector): + """The Ohai plugin is used to detect information about the client operating system.""" name = 'Ohai' experimental = True diff --git a/src/lib/Server/Plugins/POSIXCompat.py b/src/lib/Server/Plugins/POSIXCompat.py index 647e8e631..fc16e4b48 100644 --- a/src/lib/Server/Plugins/POSIXCompat.py +++ b/src/lib/Server/Plugins/POSIXCompat.py @@ -14,7 +14,7 @@ COMPAT_DICT = {'file': 'ConfigFile', class POSIXCompat(Bcfg2.Server.Plugin.Plugin, Bcfg2.Server.Plugin.GoalValidator): - """POSIXCompat is a goal validator plugin for POSIX entries""" + """POSIXCompat is a goal validator plugin for POSIX entries.""" name = 'POSIXCompat' __version__ = '$Id$' __author__ = 'bcfg-dev@mcs.anl.gov' @@ -25,7 +25,8 @@ class POSIXCompat(Bcfg2.Server.Plugin.Plugin, def validate_goals(self, metadata, goals): """Verify that we are generating correct old - Cfg/Directory/Symlink entries""" + Cfg/Directory/Symlink entries. + """ for goal in goals: for entry in goal.getchildren(): if entry.tag == 'Path' and \ diff --git a/src/lib/Server/Plugins/Pkgmgr.py b/src/lib/Server/Plugins/Pkgmgr.py index 7c334bea7..b58a7c91d 100644 --- a/src/lib/Server/Plugins/Pkgmgr.py +++ b/src/lib/Server/Plugins/Pkgmgr.py @@ -34,14 +34,14 @@ class FuzzyDict(dict): raise class PNode(Bcfg2.Server.Plugin.INode): - '''PNode has a list of packages available at a particular group intersection''' + """PNode has a list of packages available at a particular group intersection.""" splitters = {'rpm':re.compile('^(.*/)?(?P<name>[\w\+\d\.]+(-[\w\+\d\.]+)*)-' + \ '(?P<version>[\w\d\.]+-([\w\d\.]+))\.(?P<arch>\S+)\.rpm$'), 'encap':re.compile('^(?P<name>[\w-]+)-(?P<version>[\w\d\.+-]+).encap.*$')} ignore = ['Package'] def Match(self, metadata, data): - '''Return a dictionary of package mappings''' + """Return a dictionary of package mappings.""" if self.predicate(metadata): for key in self.contents: try: @@ -112,12 +112,12 @@ class PNode(Bcfg2.Server.Plugin.INode): class PkgSrc(Bcfg2.Server.Plugin.XMLSrc): - '''PkgSrc files contain a PNode hierarchy that returns matching package entries''' + """PkgSrc files contain a PNode hierarchy that returns matching package entries.""" __node__ = PNode __cacheobj__ = FuzzyDict class Pkgmgr(Bcfg2.Server.Plugin.PrioDir): - '''This is a generator that handles package assignments''' + """This is a generator that handles package assignments.""" name = 'Pkgmgr' __version__ = '$Id$' __author__ = 'bcfg-dev@mcs.anl.gov' @@ -137,7 +137,7 @@ class Pkgmgr(Bcfg2.Server.Plugin.PrioDir): self.BindEntry)]) def BindEntry(self, entry, metadata): - '''Bind data for entry, and remove instances that are not requested''' + """Bind data for entry, and remove instances that are not requested.""" pname = entry.get('name') Bcfg2.Server.Plugin.PrioDir.BindEntry(self, entry, metadata) if entry.findall('Instance'): diff --git a/src/lib/Server/Plugins/Probes.py b/src/lib/Server/Plugins/Probes.py index 42ae2fe37..22df03a64 100644 --- a/src/lib/Server/Plugins/Probes.py +++ b/src/lib/Server/Plugins/Probes.py @@ -50,6 +50,7 @@ class ProbeSet(Bcfg2.Server.Plugin.EntrySet): class Probes(Bcfg2.Server.Plugin.Plugin, Bcfg2.Server.Plugin.Probing, Bcfg2.Server.Plugin.Connector): + """A plugin to gather information from a client machine.""" name = 'Probes' __version__ = '$Id$' __author__ = 'bcfg-dev@mcs.anl.gov' @@ -70,7 +71,7 @@ class Probes(Bcfg2.Server.Plugin.Plugin, self.load_data() def write_data(self): - '''write probe data out for use with bcfg2-info''' + """Write probe data out for use with bcfg2-info.""" top = lxml.etree.Element("Probed") for client, probed in self.probedata.iteritems(): cx = lxml.etree.SubElement(top, 'Client', name=client) @@ -105,7 +106,7 @@ class Probes(Bcfg2.Server.Plugin.Plugin, self.cgroups[client.get('name')].append(pdata.get('name')) def GetProbes(self, meta, force=False): - '''Return a set of probes for execution on client''' + """Return a set of probes for execution on client.""" return self.probes.get_probe_data(meta) def ReceiveData(self, client, datalist): @@ -116,7 +117,7 @@ class Probes(Bcfg2.Server.Plugin.Plugin, self.write_data() def ReceiveDataItem(self, client, data): - '''Receive probe results pertaining to client''' + """Receive probe results pertaining to client.""" if not self.cgroups.has_key(client.hostname): self.cgroups[client.hostname] = [] if data.text == None: diff --git a/src/lib/Server/Plugins/Properties.py b/src/lib/Server/Plugins/Properties.py index 6d6ab1e8d..86330f6a0 100644 --- a/src/lib/Server/Plugins/Properties.py +++ b/src/lib/Server/Plugins/Properties.py @@ -5,10 +5,10 @@ import Bcfg2.Server.Plugin class PropertyFile(Bcfg2.Server.Plugin.XMLFileBacked): - '''Class for properties files''' + """Class for properties files.""" def Index(self): - '''Build data into an xml object''' + """Build data into an xml object.""" try: self.data = lxml.etree.XML(self.data) except lxml.etree.XMLSyntaxError: @@ -21,10 +21,10 @@ class PropDirectoryBacked(Bcfg2.Server.Plugin.DirectoryBacked): class Properties(Bcfg2.Server.Plugin.Plugin, Bcfg2.Server.Plugin.Connector): - ''' + """ The properties plugin maps property - files into client metadata instances - ''' + files into client metadata instances. + """ name = 'Properties' version = '$Revision$' diff --git a/src/lib/Server/Plugins/Rules.py b/src/lib/Server/Plugins/Rules.py index bd0850c49..eb0547cdb 100644 --- a/src/lib/Server/Plugins/Rules.py +++ b/src/lib/Server/Plugins/Rules.py @@ -1,11 +1,11 @@ -'''This generator provides rule-based entry mappings''' +"""This generator provides rule-based entry mappings.""" __revision__ = '$Revision$' import Bcfg2.Server.Plugin class Rules(Bcfg2.Server.Plugin.PrioDir): - '''This is a generator that handles service assignments''' + """This is a generator that handles service assignments.""" name = 'Rules' __version__ = '$Id$' __author__ = 'bcfg-dev@mcs.anl.gov' diff --git a/src/lib/Server/Plugins/SGenshi.py b/src/lib/Server/Plugins/SGenshi.py index 6f17e5ede..84fbb507d 100644 --- a/src/lib/Server/Plugins/SGenshi.py +++ b/src/lib/Server/Plugins/SGenshi.py @@ -37,7 +37,7 @@ class SGenshiEntrySet(Bcfg2.Server.Plugin.EntrySet): return self.handle_event(event) def BuildStructures(self, metadata): - '''Build SGenshi structures''' + """Build SGenshi structures.""" ret = [] for entry in self.get_matching(metadata): try: @@ -51,7 +51,7 @@ class SGenshiEntrySet(Bcfg2.Server.Plugin.EntrySet): class SGenshi(SGenshiEntrySet, Bcfg2.Server.Plugin.Plugin, Bcfg2.Server.Plugin.Structure): - '''The SGenshi plugin provides templated structures''' + """The SGenshi plugin provides templated structures.""" name = 'SGenshi' __version__ = '$Id$' __author__ = 'bcfg-dev@mcs.anl.gov' diff --git a/src/lib/Server/Plugins/SSHbase.py b/src/lib/Server/Plugins/SSHbase.py index e5cabfbd5..6d68ecb0a 100644 --- a/src/lib/Server/Plugins/SSHbase.py +++ b/src/lib/Server/Plugins/SSHbase.py @@ -14,7 +14,7 @@ class SSHbase(Bcfg2.Server.Plugin.Plugin, Bcfg2.Server.Plugin.Generator, Bcfg2.Server.Plugin.DirectoryBacked, Bcfg2.Server.Plugin.PullTarget): - ''' + """ The sshbase generator manages ssh host keys (both v1 and v2) for hosts. It also manages the ssh_known_hosts file. It can integrate host keys from other management domains and similarly @@ -31,7 +31,8 @@ class SSHbase(Bcfg2.Server.Plugin.Plugin, public key for (hostname) ssh_known_hosts -> the current known hosts file. this is regenerated each time a new key is generated. - ''' + + """ name = 'SSHbase' __version__ = '$Id$' __author__ = 'bcfg-dev@mcs.anl.gov' @@ -69,7 +70,7 @@ class SSHbase(Bcfg2.Server.Plugin.Plugin, self.__skn = False def get_skn(self): - '''build memory cache of the ssh known hosts file''' + """Build memory cache of the ssh known hosts file.""" if not self.__skn: self.__skn = "\n".join([value.data for key, value in \ self.entries.iteritems() if \ @@ -118,12 +119,12 @@ class SSHbase(Bcfg2.Server.Plugin.Plugin, return self.__skn def set_skn(self, value): - '''Set backing data for skn''' + """Set backing data for skn.""" self.__skn = value skn = property(get_skn, set_skn) def HandleEvent(self, event=None): - '''Local event handler that does skn regen on pubkey change''' + """Local event handler that does skn regen on pubkey change.""" Bcfg2.Server.Plugin.DirectoryBacked.HandleEvent(self, event) if event and '_key.pub.H_' in event.filename: self.skn = False @@ -134,21 +135,21 @@ class SSHbase(Bcfg2.Server.Plugin.Plugin, _ = self.skn def HandlesEntry(self, entry, _): - '''Handle key entries dynamically''' + """Handle key entries dynamically.""" return entry.tag == 'Path' and \ ([fpat for fpat in self.keypatterns if entry.get('name').endswith(fpat)] or entry.get('name').endswith('ssh_known_hosts')) def HandleEntry(self, entry, metadata): - '''Bind data''' + """Bind data.""" if entry.get('name').endswith('ssh_known_hosts'): return self.build_skn(entry, metadata) else: return self.build_hk(entry, metadata) def get_ipcache_entry(self, client): - '''build a cache of dns results''' + """Build a cache of dns results.""" if client in self.ipcache: if self.ipcache[client]: return self.ipcache[client] @@ -172,7 +173,7 @@ class SSHbase(Bcfg2.Server.Plugin.Plugin, raise socket.gaierror def get_namecache_entry(self, cip): - '''build a cache of name lookups from client IP addresses''' + """Build a cache of name lookups from client IP addresses.""" if cip in self.namecache: # lookup cached name from IP if self.namecache[cip]: @@ -195,7 +196,7 @@ class SSHbase(Bcfg2.Server.Plugin.Plugin, raise def build_skn(self, entry, metadata): - '''This function builds builds a host specific known_hosts file''' + """This function builds builds a host specific known_hosts file.""" client = metadata.hostname entry.text = self.skn hostkeys = [keytmpl % client for keytmpl in self.pubkeys \ @@ -211,7 +212,7 @@ class SSHbase(Bcfg2.Server.Plugin.Plugin, [entry.attrib.__setitem__(key, permdata[key]) for key in permdata] def build_hk(self, entry, metadata): - '''This binds host key data into entries''' + """This binds host key data into entries.""" client = metadata.hostname filename = "%s.H_%s" % (entry.get('name').split('/')[-1], client) if filename not in self.entries.keys(): @@ -234,7 +235,7 @@ class SSHbase(Bcfg2.Server.Plugin.Plugin, entry.text = keydata def GenerateHostKeys(self, client): - '''Generate new host keys for client''' + """Generate new host keys for client.""" keylist = [keytmpl % client for keytmpl in self.hostkeys] for hostkey in keylist: if 'ssh_host_rsa_key.H_' == hostkey[:19]: @@ -269,7 +270,7 @@ class SSHbase(Bcfg2.Server.Plugin.Plugin, return [Bcfg2.Server.Plugin.Specificity(hostname=metadata.hostname)] def AcceptPullData(self, specific, entry, log): - '''per-plugin bcfg2-admin pull support''' + """Per-plugin bcfg2-admin pull support.""" # specific will always be host specific filename = "%s/%s.H_%s" % (self.data, entry['name'].split('/')[-1], specific.hostname) diff --git a/src/lib/Server/Plugins/Statistics.py b/src/lib/Server/Plugins/Statistics.py index 74e676243..c7fa0e534 100644 --- a/src/lib/Server/Plugins/Statistics.py +++ b/src/lib/Server/Plugins/Statistics.py @@ -16,7 +16,7 @@ import Bcfg2.Server.Plugin class StatisticsStore(object): - '''Manages the memory and file copy of statistics collected about client runs''' + """Manages the memory and file copy of statistics collected about client runs.""" __min_write_delay__ = 0 def __init__(self, filename): @@ -28,7 +28,7 @@ class StatisticsStore(object): self.ReadFromFile() def WriteBack(self, force=0): - '''Write statistics changes back to persistent store''' + """Write statistics changes back to persistent store.""" if (self.dirty and (self.lastwrite + self.__min_write_delay__ <= time())) \ or force: try: @@ -43,7 +43,7 @@ class StatisticsStore(object): self.lastwrite = time() def ReadFromFile(self): - '''Reads current state regarding statistics''' + """Reads current state regarding statistics.""" try: fin = open(self.filename, 'r') data = fin.read() @@ -57,7 +57,7 @@ class StatisticsStore(object): self.dirty = 0 def updateStats(self, xml, client): - '''Updates the statistics of a current node with new data''' + """Updates the statistics of a current node with new data.""" # Current policy: # - Keep anything less than 24 hours old @@ -105,7 +105,7 @@ class StatisticsStore(object): self.WriteBack(force=1) def isOlderThan24h(self, testTime): - '''Helper function to determine if <time> string is older than 24 hours''' + """Helper function to determine if <time> string is older than 24 hours.""" now = time() utime = mktime(strptime(testTime)) secondsPerDay = 60*60*24 diff --git a/src/lib/Server/Plugins/Svcmgr.py b/src/lib/Server/Plugins/Svcmgr.py index 396c5145c..6d25c1a6d 100644 --- a/src/lib/Server/Plugins/Svcmgr.py +++ b/src/lib/Server/Plugins/Svcmgr.py @@ -1,11 +1,11 @@ -'''This generator provides service mappings''' +"""This generator provides service mappings.""" __revision__ = '$Revision$' import Bcfg2.Server.Plugin class Svcmgr(Bcfg2.Server.Plugin.PrioDir): - '''This is a generator that handles service assignments''' + """This is a generator that handles service assignments.""" name = 'Svcmgr' __version__ = '$Id$' __author__ = 'bcfg-dev@mcs.anl.gov' diff --git a/src/lib/Server/Plugins/Svn.py b/src/lib/Server/Plugins/Svn.py index 0765eb56c..cb4ab649b 100644 --- a/src/lib/Server/Plugins/Svn.py +++ b/src/lib/Server/Plugins/Svn.py @@ -9,7 +9,7 @@ logger = logging.getLogger('Bcfg2.Plugins.Svn') class Svn(Bcfg2.Server.Plugin.Plugin, Bcfg2.Server.Plugin.Version): - """Svn is a version plugin for dealing with bcfg2 repos""" + """Svn is a version plugin for dealing with Bcfg2 repos.""" name = 'Svn' __version__ = '$Id$' __author__ = 'bcfg-dev@mcs.anl.gov' @@ -32,7 +32,7 @@ class Svn(Bcfg2.Server.Plugin.Plugin, logger.debug("Initialized svn plugin with svn directory = %s" % svn_dir) def get_revision(self): - """Read svn revision information for the bcfg2 repository""" + """Read svn revision information for the Bcfg2 repository.""" try: data = Popen(("env LC_ALL=C svn info %s" % (self.datastore)), shell=True, diff --git a/src/lib/Server/Plugins/TCheetah.py b/src/lib/Server/Plugins/TCheetah.py index 8a0369eee..91c830620 100644 --- a/src/lib/Server/Plugins/TCheetah.py +++ b/src/lib/Server/Plugins/TCheetah.py @@ -17,7 +17,7 @@ except: class TemplateFile: - '''Template file creates Cheetah template structures for the loaded file''' + """Template file creates Cheetah template structures for the loaded file.""" def __init__(self, name, specific, encoding): self.name = name @@ -27,7 +27,7 @@ class TemplateFile: self.searchlist = dict() def handle_event(self, event): - '''Handle all fs events for this template''' + """Handle all fs events for this template.""" if event.code2str() == 'deleted': return try: @@ -40,7 +40,7 @@ class TemplateFile: logger.error(perror.report()) def bind_entry(self, entry, metadata): - '''Build literal file information''' + """Build literal file information.""" self.template.metadata = metadata self.searchlist['metadata'] = metadata self.template.path = entry.get('realname', entry.get('name')) @@ -65,7 +65,7 @@ class TemplateFile: class TCheetah(Bcfg2.Server.Plugin.GroupSpool): - '''The TCheetah generator implements a templating mechanism for configuration files''' + """The TCheetah generator implements a templating mechanism for configuration files.""" name = 'TCheetah' __version__ = '$Id$' __author__ = 'bcfg-dev@mcs.anl.gov' diff --git a/src/lib/Server/Plugins/TGenshi.py b/src/lib/Server/Plugins/TGenshi.py index 08100e8e8..b83f00b02 100644 --- a/src/lib/Server/Plugins/TGenshi.py +++ b/src/lib/Server/Plugins/TGenshi.py @@ -1,4 +1,4 @@ -'''This module implements a templating generator based on Genshi''' +"""This module implements a templating generator based on Genshi.""" __revision__ = '$Revision$' from genshi.template import TemplateLoader, \ @@ -25,7 +25,7 @@ def removecomment(stream): class TemplateFile: - '''Template file creates Genshi template structures for the loaded file''' + """Template file creates Genshi template structures for the loaded file.""" def __init__(self, name, specific, encoding): self.name = name @@ -49,7 +49,7 @@ class TemplateFile: self.HandleEvent = self.handle_event def handle_event(self, event=None): - '''Handle all fs events for this template''' + """Handle all fs events for this template.""" if event and event.code2str() == 'deleted': return try: @@ -65,7 +65,7 @@ class TemplateFile: logger.error('Genshi parse error: %s' % perror) def bind_entry(self, entry, metadata): - '''Build literal file information''' + """Build literal file information.""" fname = entry.get('realname', entry.get('name')) if entry.tag == 'Path': entry.set('type', 'file') @@ -104,10 +104,11 @@ class TemplateFile: class TGenshi(Bcfg2.Server.Plugin.GroupSpool): - ''' + """ The TGenshi generator implements a templating - mechanism for configuration files - ''' + mechanism for configuration files. + + """ name = 'TGenshi' __version__ = '$Id$' __author__ = 'jeff@ocjtech.us' diff --git a/src/lib/Server/Plugins/Trigger.py b/src/lib/Server/Plugins/Trigger.py index b45743134..f6dd47e12 100644 --- a/src/lib/Server/Plugins/Trigger.py +++ b/src/lib/Server/Plugins/Trigger.py @@ -15,8 +15,10 @@ def async_run(prog, args): class Trigger(Bcfg2.Server.Plugin.Plugin, Bcfg2.Server.Plugin.Statistics): + """Trigger is a plugin that calls external scripts (on the server).""" name = 'Trigger' __version__ = '$Id' + __author__ = 'bcfg-dev@mcs.anl.gov' def __init__(self, core, datastore): Bcfg2.Server.Plugin.Plugin.__init__(self, core, datastore) |