summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Server/Admin
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/Bcfg2/Server/Admin')
-rw-r--r--src/lib/Bcfg2/Server/Admin/Init.py4
-rw-r--r--src/lib/Bcfg2/Server/Admin/Minestruct.py5
-rw-r--r--src/lib/Bcfg2/Server/Admin/Perf.py8
-rw-r--r--src/lib/Bcfg2/Server/Admin/Pull.py12
-rw-r--r--src/lib/Bcfg2/Server/Admin/Xcmd.py2
-rw-r--r--src/lib/Bcfg2/Server/Admin/__init__.py30
6 files changed, 24 insertions, 37 deletions
diff --git a/src/lib/Bcfg2/Server/Admin/Init.py b/src/lib/Bcfg2/Server/Admin/Init.py
index 884405786..870a31480 100644
--- a/src/lib/Bcfg2/Server/Admin/Init.py
+++ b/src/lib/Bcfg2/Server/Admin/Init.py
@@ -231,8 +231,8 @@ class Init(Bcfg2.Server.Admin.Mode):
def _prompt_password(self):
"""Ask for a password or generate one if none is provided."""
newpassword = getpass.getpass(
- "Input password used for communication verification "
- "(without echoing; leave blank for a random): ").strip()
+ "Input password used for communication verification "
+ "(without echoing; leave blank for a random): ").strip()
if len(newpassword) != 0:
self.data['password'] = newpassword
diff --git a/src/lib/Bcfg2/Server/Admin/Minestruct.py b/src/lib/Bcfg2/Server/Admin/Minestruct.py
index 6d0dab106..93e42305c 100644
--- a/src/lib/Bcfg2/Server/Admin/Minestruct.py
+++ b/src/lib/Bcfg2/Server/Admin/Minestruct.py
@@ -3,6 +3,7 @@ import getopt
import lxml.etree
import sys
import Bcfg2.Server.Admin
+from Bcfg2.Server.Plugin import PullSource
class Minestruct(Bcfg2.Server.Admin.StructureMode):
@@ -39,12 +40,12 @@ class Minestruct(Bcfg2.Server.Admin.StructureMode):
try:
extra = set()
- for source in self.bcore.pull_sources:
+ for source in self.bcore.plugins_by_type(PullSource):
for item in source.GetExtra(client):
extra.add(item)
except:
self.log.error("Failed to find extra entry info for client %s" %
- client)
+ client)
raise SystemExit(1)
root = lxml.etree.Element("Base")
self.log.info("Found %d extra entries" % (len(extra)))
diff --git a/src/lib/Bcfg2/Server/Admin/Perf.py b/src/lib/Bcfg2/Server/Admin/Perf.py
index a7e67c956..1a772e6fc 100644
--- a/src/lib/Bcfg2/Server/Admin/Perf.py
+++ b/src/lib/Bcfg2/Server/Admin/Perf.py
@@ -31,8 +31,8 @@ class Perf(Bcfg2.Server.Admin.Mode):
timeout=setup['timeout'])
data = proxy.get_statistics()
for key in sorted(data.keys()):
- output.append((key, ) +
- tuple(["%.06f" % item
- for item in data[key][:-1]] + \
- [data[key][-1]]))
+ output.append(
+ (key, ) +
+ tuple(["%.06f" % item
+ for item in data[key][:-1]] + [data[key][-1]]))
self.print_table(output)
diff --git a/src/lib/Bcfg2/Server/Admin/Pull.py b/src/lib/Bcfg2/Server/Admin/Pull.py
index 1905fac3c..e883c432f 100644
--- a/src/lib/Bcfg2/Server/Admin/Pull.py
+++ b/src/lib/Bcfg2/Server/Admin/Pull.py
@@ -6,6 +6,7 @@ import sys
import getopt
import select
import Bcfg2.Server.Admin
+from Bcfg2.Server.Plugin import PullSource, Generator
from Bcfg2.Compat import input # pylint: disable=W0622
@@ -62,13 +63,14 @@ class Pull(Bcfg2.Server.Admin.MetadataCore):
given client/entry from statistics.
"""
new_entry = {'type': etype, 'name': ename}
- for plugin in self.bcore.pull_sources:
+ pull_sources = self.bcore.plugins_by_type(PullSource)
+ for plugin in pull_sources:
try:
(owner, group, mode, contents) = \
- plugin.GetCurrentEntry(client, etype, ename)
+ plugin.GetCurrentEntry(client, etype, ename)
break
except Bcfg2.Server.Plugin.PluginExecutionError:
- if plugin == self.bcore.pull_sources[-1]:
+ if plugin == pull_sources[-1]:
print("Pull Source failure; could not fetch current state")
raise SystemExit(1)
@@ -121,8 +123,8 @@ class Pull(Bcfg2.Server.Admin.MetadataCore):
meta = self.bcore.build_metadata(client)
# Find appropriate plugin in bcore
- glist = [gen for gen in self.bcore.generators if
- ename in gen.Entries.get(etype, {})]
+ glist = [gen for gen in self.bcore.plugins_by_type(Generator)
+ if ename in gen.Entries.get(etype, {})]
if len(glist) != 1:
self.errExit("Got wrong numbers of matching generators for entry:"
"%s" % ([g.name for g in glist]))
diff --git a/src/lib/Bcfg2/Server/Admin/Xcmd.py b/src/lib/Bcfg2/Server/Admin/Xcmd.py
index 6f411c2e4..ba4777c93 100644
--- a/src/lib/Bcfg2/Server/Admin/Xcmd.py
+++ b/src/lib/Bcfg2/Server/Admin/Xcmd.py
@@ -51,5 +51,5 @@ class Xcmd(Bcfg2.Server.Admin.Mode):
print("Proxy Error: %s" % err)
return
- if data != None:
+ if data is not None:
print(data)
diff --git a/src/lib/Bcfg2/Server/Admin/__init__.py b/src/lib/Bcfg2/Server/Admin/__init__.py
index 0c4764642..3fbdf8fa8 100644
--- a/src/lib/Bcfg2/Server/Admin/__init__.py
+++ b/src/lib/Bcfg2/Server/Admin/__init__.py
@@ -1,30 +1,14 @@
""" Base classes for admin modes """
-__all__ = [
- 'Backup',
- 'Bundle',
- 'Client',
- 'Compare',
- 'Group',
- 'Init',
- 'Minestruct',
- 'Perf',
- 'Pull',
- 'Query',
- 'Reports',
- 'Syncdb',
- 'Tidy',
- 'Viz',
- 'Xcmd'
- ]
-
import re
import sys
import logging
import lxml.etree
import Bcfg2.Server.Core
import Bcfg2.Options
-from Bcfg2.Compat import ConfigParser
+from Bcfg2.Compat import ConfigParser, walk_packages
+
+__all__ = [m[1] for m in walk_packages(path=__path__)]
class Mode(object):
@@ -104,15 +88,15 @@ class Mode(object):
# Calculate column widths (longest item in each column
# plus padding on both sides)
cols = list(zip(*rows))
- col_widths = [max([len(str(item)) + 2 * padding for \
- item in col]) for col in cols]
+ col_widths = [max([len(str(item)) + 2 * padding
+ for item in col]) for col in cols]
borderline = vdelim.join([w * hdelim for w in col_widths])
# Print out the table
print(borderline)
for row in rows:
- print(vdelim.join([justify(str(item), width) for \
- (item, width) in zip(row, col_widths)]))
+ print(vdelim.join([justify(str(item), width)
+ for (item, width) in zip(row, col_widths)]))
if hdr:
print(borderline)
hdr = False