diff --git a/sahara/plugins/mapr/versions/version_handler_factory.py b/sahara/plugins/mapr/versions/version_handler_factory.py index 2e48c384..cc905c13 100644 --- a/sahara/plugins/mapr/versions/version_handler_factory.py +++ b/sahara/plugins/mapr/versions/version_handler_factory.py @@ -26,14 +26,13 @@ def _load_versions(): def mapper(v_dir): return m_template % v_dir - def reducer(versions, m_name): - m = __import__(m_name, fromlist=['sahara']) - versions[m.version] = getattr(m, 'VersionHandler')() - return versions - v_dirs = filter(predicate, os.listdir(d_name)) m_names = map(mapper, v_dirs) - return reduce(reducer, m_names, {}) + versions = {} + for m_name in m_names: + m = __import__(m_name, fromlist=['sahara']) + versions[m.version] = getattr(m, 'VersionHandler')() + return versions class VersionHandlerFactory(object): diff --git a/sahara/plugins/utils.py b/sahara/plugins/utils.py index f480f300..4f2a9e83 100644 --- a/sahara/plugins/utils.py +++ b/sahara/plugins/utils.py @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import itertools + from oslo_utils import netutils from six.moves.urllib import parse as urlparse @@ -32,7 +34,7 @@ def get_instances_count(cluster, node_process=None): def get_instances(cluster, node_process=None): nodes = get_node_groups(cluster, node_process) - return reduce(lambda a, b: a + b.instances, nodes, []) + return list(itertools.chain(*[node.instances for node in nodes])) def get_instance(cluster, node_process): diff --git a/sahara/service/validations/base.py b/sahara/service/validations/base.py index fe67a630..0b59c8d3 100644 --- a/sahara/service/validations/base.py +++ b/sahara/service/validations/base.py @@ -14,7 +14,6 @@ # limitations under the License. import collections -import operator import novaclient.exceptions as nova_ex from oslo_config import cfg @@ -170,9 +169,11 @@ def check_flavor_exists(flavor_id): def check_security_groups_exist(security_groups): security_group_list = nova.client().security_groups.list() - allowed_groups = set(reduce( - operator.add, [[six.text_type(sg.id), sg.name] - for sg in security_group_list], [])) + allowed_groups = set() + for sg in security_group_list: + allowed_groups.add(six.text_type(sg.id)) + allowed_groups.add(sg.name) + for sg in security_groups: if sg not in allowed_groups: raise ex.NotFoundException(