diff --git a/sahara/plugins/vanilla/v1_2_1/scaling.py b/sahara/plugins/vanilla/v1_2_1/scaling.py index 9beb8ff0..ab88d4e2 100644 --- a/sahara/plugins/vanilla/v1_2_1/scaling.py +++ b/sahara/plugins/vanilla/v1_2_1/scaling.py @@ -15,6 +15,8 @@ import os +import six + from sahara import context from sahara.openstack.common import timeutils from sahara.plugins.general import utils @@ -87,7 +89,7 @@ def parse_dfs_report(cmd_output): res = [] datanode_info = {} - for i in xrange(0, len(array)): + for i in six.moves.xrange(0, len(array)): if array[i]: idx = str.find(array[i], ':') name = array[i][0:idx] diff --git a/sahara/service/direct_engine.py b/sahara/service/direct_engine.py index 56e0554b..cead6410 100644 --- a/sahara/service/direct_engine.py +++ b/sahara/service/direct_engine.py @@ -15,6 +15,7 @@ from novaclient import exceptions as nova_exceptions from oslo.config import cfg +import six from sahara import conductor as c from sahara import context @@ -154,7 +155,7 @@ class DirectEngine(e.Engine): for node_group in cluster.node_groups: count = node_group.count conductor.node_group_update(ctx, node_group, {'count': 0}) - for idx in xrange(1, count + 1): + for idx in six.moves.xrange(1, count + 1): self._run_instance(cluster, node_group, idx, aa_groups) def _scale_cluster_instances(self, cluster, node_group_id_map): @@ -189,7 +190,7 @@ class DirectEngine(e.Engine): LOG.info(g.format_cluster_status(cluster)) for node_group in node_groups_to_enlarge: count = node_group_id_map[node_group.id] - for idx in xrange(node_group.count + 1, count + 1): + for idx in six.moves.xrange(node_group.count + 1, count + 1): instance_id = self._run_instance(cluster, node_group, idx, aa_groups) instances_to_add.append(instance_id) diff --git a/sahara/tests/unit/service/test_instances.py b/sahara/tests/unit/service/test_instances.py index 0bf8f35f..56fa2f85 100644 --- a/sahara/tests/unit/service/test_instances.py +++ b/sahara/tests/unit/service/test_instances.py @@ -16,6 +16,7 @@ import mock from novaclient import exceptions as nova_exceptions +import six from sahara import conductor as cond from sahara import context @@ -149,7 +150,7 @@ class NodePlacementTest(AbstractInstanceTest): create. """ different_hosts = [] - for instance_id in xrange(1, idx): + for instance_id in six.moves.xrange(1, idx): different_hosts.append(str(instance_id)) scheduler_hints = ({'different_host': different_hosts} if different_hosts else None) @@ -163,7 +164,7 @@ class NodePlacementTest(AbstractInstanceTest): # find instance names in instance create calls instance_names = [] - for idx in xrange(1, 4): + for idx in six.moves.xrange(1, 4): instance_name = _find_created_at(idx) if instance_name in instance_names: self.fail("Create instance was called twice with the same " diff --git a/sahara/tests/unit/utils/test_patches.py b/sahara/tests/unit/utils/test_patches.py index 0fca73fe..b369aca1 100644 --- a/sahara/tests/unit/utils/test_patches.py +++ b/sahara/tests/unit/utils/test_patches.py @@ -15,6 +15,7 @@ import xml.dom.minidom as xml +import six import unittest2 from sahara.utils import patches @@ -32,7 +33,7 @@ class MinidomPatchesTest(unittest2.TestCase): doc.insertBefore(pi, doc.firstChild) configuration = doc.createElement("root") doc.appendChild(configuration) - for idx in xrange(0, 5): + for idx in six.moves.xrange(0, 5): elem = doc.createElement("element") configuration.appendChild(elem) name = doc.createElement("name")