summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/Bcfg2')
-rw-r--r--src/lib/Bcfg2/Server/Core.py8
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Base.py12
-rw-r--r--src/lib/Bcfg2/Server/Plugins/SSHbase.py15
3 files changed, 16 insertions, 19 deletions
diff --git a/src/lib/Bcfg2/Server/Core.py b/src/lib/Bcfg2/Server/Core.py
index 040036fb2..37da4a4b6 100644
--- a/src/lib/Bcfg2/Server/Core.py
+++ b/src/lib/Bcfg2/Server/Core.py
@@ -16,7 +16,8 @@ import Bcfg2.Logger
import Bcfg2.Server.FileMonitor
from Bcfg2.Cache import Cache
import Bcfg2.Statistics
-from Bcfg2.Compat import xmlrpclib, reduce # pylint: disable=W0622
+from itertools import chain
+from Bcfg2.Compat import xmlrpclib # pylint: disable=W0622
from Bcfg2.Server.Plugin import PluginInitError, PluginExecutionError, \
track_statistics
@@ -493,9 +494,8 @@ class BaseCore(object):
:type metadata: Bcfg2.Server.Plugins.Metadata.ClientMetadata
:returns: list of :class:`lxml.etree._Element` objects
"""
- structures = reduce(lambda x, y: x + y,
- [struct.BuildStructures(metadata)
- for struct in self.structures], [])
+ structures = list(chain(*[struct.BuildStructures(metadata)
+ for struct in self.structures]))
sbundles = [b.get('name') for b in structures if b.tag == 'Bundle']
missing = [b for b in metadata.bundles if b not in sbundles]
if missing:
diff --git a/src/lib/Bcfg2/Server/Plugins/Base.py b/src/lib/Bcfg2/Server/Plugins/Base.py
index 66515ede2..d662da60a 100644
--- a/src/lib/Bcfg2/Server/Plugins/Base.py
+++ b/src/lib/Bcfg2/Server/Plugins/Base.py
@@ -2,9 +2,8 @@
import copy
import lxml.etree
-import sys
-from Bcfg2.Compat import reduce
import Bcfg2.Server.Plugin
+from itertools import chain
class Base(Bcfg2.Server.Plugin.Plugin,
@@ -18,7 +17,6 @@ class Base(Bcfg2.Server.Plugin.Plugin,
__child__ = Bcfg2.Server.Plugin.StructFile
deprecated = True
- """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)
@@ -33,8 +31,8 @@ class Base(Bcfg2.Server.Plugin.Plugin,
def BuildStructures(self, 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
- in list(self.entries.values())], [])
- [ret.append(copy.copy(frag)) for frag in fragments]
+ fragments = list(chain(*[base.Match(metadata)
+ for base in list(self.entries.values())]))
+ for frag in fragments:
+ ret.append(copy.copy(frag))
return [ret]
diff --git a/src/lib/Bcfg2/Server/Plugins/SSHbase.py b/src/lib/Bcfg2/Server/Plugins/SSHbase.py
index feb76aa57..c7db67301 100644
--- a/src/lib/Bcfg2/Server/Plugins/SSHbase.py
+++ b/src/lib/Bcfg2/Server/Plugins/SSHbase.py
@@ -7,10 +7,11 @@ import socket
import shutil
import logging
import tempfile
+from itertools import chain
from subprocess import Popen, PIPE
import Bcfg2.Server.Plugin
from Bcfg2.Server.Plugin import PluginExecutionError
-from Bcfg2.Compat import any, u_str, reduce, b64encode # pylint: disable=W0622
+from Bcfg2.Compat import any, u_str, b64encode # pylint: disable=W0622
LOGGER = logging.getLogger(__name__)
@@ -200,15 +201,13 @@ class SSHbase(Bcfg2.Server.Plugin.Plugin,
if specific.hostname and specific.hostname in names:
hostnames = names[specific.hostname]
elif specific.group:
- hostnames = \
- reduce(lambda x, y: x + y,
- [names[cmeta.hostname]
- for cmeta in \
- mquery.by_groups([specific.group])], [])
+ hostnames = list(chain(
+ *[names[cmeta.hostname]
+ for cmeta in \
+ mquery.by_groups([specific.group])]))
elif specific.all:
# a generic key for all hosts? really?
- hostnames = reduce(lambda x, y: x + y,
- list(names.values()), [])
+ hostnames = list(chain(*list(names.values())))
if not hostnames:
if specific.hostname:
key = specific.hostname