Merge "Don't use reduce for python3 compatibility"
This commit is contained in:
commit
6aaea960e1
@ -26,15 +26,14 @@ def _load_versions():
|
||||
def mapper(v_dir):
|
||||
return m_template % v_dir
|
||||
|
||||
def reducer(versions, m_name):
|
||||
v_dirs = filter(predicate, os.listdir(d_name))
|
||||
m_names = map(mapper, v_dirs)
|
||||
versions = {}
|
||||
for m_name in m_names:
|
||||
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, {})
|
||||
|
||||
|
||||
class VersionHandlerFactory(object):
|
||||
instance = None
|
||||
|
@ -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):
|
||||
|
@ -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(
|
||||
|
Loading…
Reference in New Issue
Block a user