From 42683e17842fca91e8b6aecde08b726a3b24cda8 Mon Sep 17 00:00:00 2001 From: lizheming Date: Fri, 17 Jan 2014 11:58:42 +0800 Subject: [PATCH] Fix bug:range() is not same in py3.x and py2.x in python3.x, there is no method named xrange(), it has replaced by range(),which is equal to xrange() in python2.x. so we must fix this issue.we use six module to fix this issue. Change-Id: I9cee3f0df2d8abbf6f66d7c5a3a0fed98df622e8 Closes-Bug: #1268439 --- neutron/db/sqlalchemyutils.py | 1 + neutron/plugins/bigswitch/tests/test_server.py | 1 + neutron/plugins/brocade/vlanbm.py | 1 + neutron/plugins/cisco/db/n1kv_db_v2.py | 1 + neutron/plugins/hyperv/db.py | 1 + neutron/plugins/linuxbridge/db/l2network_db_v2.py | 2 +- neutron/plugins/ml2/drivers/type_gre.py | 1 + neutron/plugins/ml2/drivers/type_vlan.py | 1 + neutron/plugins/mlnx/db/mlnx_db_v2.py | 1 + neutron/plugins/openvswitch/agent/ovs_neutron_agent.py | 1 + neutron/plugins/openvswitch/ovs_db_v2.py | 1 + neutron/services/loadbalancer/drivers/haproxy/cfg.py | 1 + neutron/tests/functional/agent/linux/test_async_process.py | 2 ++ neutron/tests/unit/bigswitch/test_router_db.py | 1 + neutron/tests/unit/cisco/n1kv/test_n1kv_db.py | 1 + neutron/tests/unit/linuxbridge/test_lb_db.py | 1 + neutron/tests/unit/ml2/test_type_gre.py | 1 + neutron/tests/unit/ml2/test_type_vxlan.py | 1 + neutron/tests/unit/mlnx/test_mlnx_db.py | 1 + neutron/tests/unit/nec/test_nec_agent.py | 1 + neutron/tests/unit/nec/test_trema_driver.py | 1 + neutron/tests/unit/openvswitch/test_ovs_db.py | 1 + .../services/loadbalancer/drivers/test_agent_driver_base.py | 1 + neutron/tests/unit/test_post_mortem_debug.py | 1 + 24 files changed, 25 insertions(+), 1 deletion(-) diff --git a/neutron/db/sqlalchemyutils.py b/neutron/db/sqlalchemyutils.py index d012a85a1..23dd6447f 100644 --- a/neutron/db/sqlalchemyutils.py +++ b/neutron/db/sqlalchemyutils.py @@ -15,6 +15,7 @@ # License for the specific language governing permissions and limitations # under the License. +from six.moves import xrange import sqlalchemy from sqlalchemy.orm.properties import RelationshipProperty diff --git a/neutron/plugins/bigswitch/tests/test_server.py b/neutron/plugins/bigswitch/tests/test_server.py index a3bfccded..8725adbb6 100755 --- a/neutron/plugins/bigswitch/tests/test_server.py +++ b/neutron/plugins/bigswitch/tests/test_server.py @@ -27,6 +27,7 @@ from __future__ import print_function import json import re +from six.moves import xrange from wsgiref.simple_server import make_server diff --git a/neutron/plugins/brocade/vlanbm.py b/neutron/plugins/brocade/vlanbm.py index 37a43a112..ecb334478 100644 --- a/neutron/plugins/brocade/vlanbm.py +++ b/neutron/plugins/brocade/vlanbm.py @@ -21,6 +21,7 @@ """A Vlan Bitmap class to handle allocation/de-allocation of vlan ids.""" +from six.moves import xrange from neutron.common import constants from neutron.plugins.brocade.db import models as brocade_db diff --git a/neutron/plugins/cisco/db/n1kv_db_v2.py b/neutron/plugins/cisco/db/n1kv_db_v2.py index 3299d0cb7..76a99de3f 100644 --- a/neutron/plugins/cisco/db/n1kv_db_v2.py +++ b/neutron/plugins/cisco/db/n1kv_db_v2.py @@ -21,6 +21,7 @@ import netaddr import re +from six.moves import xrange from sqlalchemy.orm import exc from sqlalchemy.sql import and_ diff --git a/neutron/plugins/hyperv/db.py b/neutron/plugins/hyperv/db.py index fae554a3f..97ac59ab2 100644 --- a/neutron/plugins/hyperv/db.py +++ b/neutron/plugins/hyperv/db.py @@ -16,6 +16,7 @@ # under the License. # @author: Alessandro Pilotti, Cloudbase Solutions Srl +from six.moves import xrange from sqlalchemy.orm import exc from neutron.common import exceptions as n_exc diff --git a/neutron/plugins/linuxbridge/db/l2network_db_v2.py b/neutron/plugins/linuxbridge/db/l2network_db_v2.py index 3178e4588..4ad72bb9c 100644 --- a/neutron/plugins/linuxbridge/db/l2network_db_v2.py +++ b/neutron/plugins/linuxbridge/db/l2network_db_v2.py @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. - +from six.moves import xrange from sqlalchemy.orm import exc from neutron.common import exceptions as n_exc diff --git a/neutron/plugins/ml2/drivers/type_gre.py b/neutron/plugins/ml2/drivers/type_gre.py index 4af801507..850f1f1a0 100644 --- a/neutron/plugins/ml2/drivers/type_gre.py +++ b/neutron/plugins/ml2/drivers/type_gre.py @@ -14,6 +14,7 @@ # under the License. from oslo.config import cfg +from six.moves import xrange import sqlalchemy as sa from sqlalchemy.orm import exc as sa_exc diff --git a/neutron/plugins/ml2/drivers/type_vlan.py b/neutron/plugins/ml2/drivers/type_vlan.py index 1855d8e67..7bdc81525 100644 --- a/neutron/plugins/ml2/drivers/type_vlan.py +++ b/neutron/plugins/ml2/drivers/type_vlan.py @@ -16,6 +16,7 @@ import sys from oslo.config import cfg +from six.moves import xrange import sqlalchemy as sa from neutron.common import constants as q_const diff --git a/neutron/plugins/mlnx/db/mlnx_db_v2.py b/neutron/plugins/mlnx/db/mlnx_db_v2.py index b197d6899..856d1e44b 100644 --- a/neutron/plugins/mlnx/db/mlnx_db_v2.py +++ b/neutron/plugins/mlnx/db/mlnx_db_v2.py @@ -15,6 +15,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from six.moves import xrange from sqlalchemy.orm import exc from neutron.common import exceptions as n_exc diff --git a/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py b/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py index 9028b23fb..9df64a061 100644 --- a/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py +++ b/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py @@ -21,6 +21,7 @@ import time import eventlet import netaddr from oslo.config import cfg +from six.moves import xrange from neutron.agent import l2population_rpc from neutron.agent.linux import ip_lib diff --git a/neutron/plugins/openvswitch/ovs_db_v2.py b/neutron/plugins/openvswitch/ovs_db_v2.py index e162565ab..6054b134a 100644 --- a/neutron/plugins/openvswitch/ovs_db_v2.py +++ b/neutron/plugins/openvswitch/ovs_db_v2.py @@ -13,6 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. +from six.moves import xrange from sqlalchemy import func from sqlalchemy.orm import exc diff --git a/neutron/services/loadbalancer/drivers/haproxy/cfg.py b/neutron/services/loadbalancer/drivers/haproxy/cfg.py index 74447c6b5..8e7b4090a 100644 --- a/neutron/services/loadbalancer/drivers/haproxy/cfg.py +++ b/neutron/services/loadbalancer/drivers/haproxy/cfg.py @@ -17,6 +17,7 @@ # @author: Mark McClain, DreamHost import itertools +from six.moves import xrange from neutron.agent.linux import utils from neutron.plugins.common import constants as qconstants diff --git a/neutron/tests/functional/agent/linux/test_async_process.py b/neutron/tests/functional/agent/linux/test_async_process.py index 062cbc523..3d829d689 100644 --- a/neutron/tests/functional/agent/linux/test_async_process.py +++ b/neutron/tests/functional/agent/linux/test_async_process.py @@ -17,6 +17,8 @@ import eventlet import fixtures +from six.moves import xrange + from neutron.agent.linux import async_process from neutron.tests import base diff --git a/neutron/tests/unit/bigswitch/test_router_db.py b/neutron/tests/unit/bigswitch/test_router_db.py index c18168e10..0b1384cf5 100644 --- a/neutron/tests/unit/bigswitch/test_router_db.py +++ b/neutron/tests/unit/bigswitch/test_router_db.py @@ -23,6 +23,7 @@ import copy from mock import patch from oslo.config import cfg +from six.moves import xrange from webob import exc from neutron.common.test_lib import test_config diff --git a/neutron/tests/unit/cisco/n1kv/test_n1kv_db.py b/neutron/tests/unit/cisco/n1kv/test_n1kv_db.py index 07c059aef..8acec2b8d 100644 --- a/neutron/tests/unit/cisco/n1kv/test_n1kv_db.py +++ b/neutron/tests/unit/cisco/n1kv/test_n1kv_db.py @@ -18,6 +18,7 @@ # @author: Abhishek Raut, Cisco Systems Inc. # @author: Rudrajit Tapadar, Cisco Systems Inc. +from six.moves import xrange from sqlalchemy.orm import exc as s_exc from testtools import matchers diff --git a/neutron/tests/unit/linuxbridge/test_lb_db.py b/neutron/tests/unit/linuxbridge/test_lb_db.py index 63b216c7d..59d1086f6 100644 --- a/neutron/tests/unit/linuxbridge/test_lb_db.py +++ b/neutron/tests/unit/linuxbridge/test_lb_db.py @@ -14,6 +14,7 @@ # limitations under the License. from oslo.config import cfg +from six.moves import xrange import testtools from testtools import matchers diff --git a/neutron/tests/unit/ml2/test_type_gre.py b/neutron/tests/unit/ml2/test_type_gre.py index dd52f0dbf..b45ed8378 100644 --- a/neutron/tests/unit/ml2/test_type_gre.py +++ b/neutron/tests/unit/ml2/test_type_gre.py @@ -13,6 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. +from six.moves import xrange import testtools from testtools import matchers diff --git a/neutron/tests/unit/ml2/test_type_vxlan.py b/neutron/tests/unit/ml2/test_type_vxlan.py index 1aad48e75..4fa9fbee9 100644 --- a/neutron/tests/unit/ml2/test_type_vxlan.py +++ b/neutron/tests/unit/ml2/test_type_vxlan.py @@ -15,6 +15,7 @@ # @author: Kyle Mestery, Cisco Systems, Inc. from oslo.config import cfg +from six.moves import xrange import testtools from testtools import matchers diff --git a/neutron/tests/unit/mlnx/test_mlnx_db.py b/neutron/tests/unit/mlnx/test_mlnx_db.py index ec2621453..51aadb9db 100644 --- a/neutron/tests/unit/mlnx/test_mlnx_db.py +++ b/neutron/tests/unit/mlnx/test_mlnx_db.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from six.moves import xrange from testtools import matchers from neutron.common import exceptions as n_exc diff --git a/neutron/tests/unit/nec/test_nec_agent.py b/neutron/tests/unit/nec/test_nec_agent.py index 341eaf774..51c8c0b6f 100644 --- a/neutron/tests/unit/nec/test_nec_agent.py +++ b/neutron/tests/unit/nec/test_nec_agent.py @@ -21,6 +21,7 @@ import time import mock from oslo.config import cfg +from six.moves import xrange import testtools from neutron.agent.linux import ovs_lib diff --git a/neutron/tests/unit/nec/test_trema_driver.py b/neutron/tests/unit/nec/test_trema_driver.py index 16b838e4c..8c8ce987c 100644 --- a/neutron/tests/unit/nec/test_trema_driver.py +++ b/neutron/tests/unit/nec/test_trema_driver.py @@ -18,6 +18,7 @@ import random import mock +from six.moves import xrange from neutron.openstack.common import uuidutils from neutron.plugins.nec.common import ofc_client diff --git a/neutron/tests/unit/openvswitch/test_ovs_db.py b/neutron/tests/unit/openvswitch/test_ovs_db.py index 5ebb0c0f2..f9896e4ac 100644 --- a/neutron/tests/unit/openvswitch/test_ovs_db.py +++ b/neutron/tests/unit/openvswitch/test_ovs_db.py @@ -17,6 +17,7 @@ import mock from oslo.config import cfg +from six.moves import xrange import testtools from testtools import matchers diff --git a/neutron/tests/unit/services/loadbalancer/drivers/test_agent_driver_base.py b/neutron/tests/unit/services/loadbalancer/drivers/test_agent_driver_base.py index de9e8fbd6..6614ab9f1 100644 --- a/neutron/tests/unit/services/loadbalancer/drivers/test_agent_driver_base.py +++ b/neutron/tests/unit/services/loadbalancer/drivers/test_agent_driver_base.py @@ -19,6 +19,7 @@ import contextlib import mock +from six.moves import xrange from webob import exc from neutron.common import exceptions diff --git a/neutron/tests/unit/test_post_mortem_debug.py b/neutron/tests/unit/test_post_mortem_debug.py index 458170924..ffef668bb 100644 --- a/neutron/tests/unit/test_post_mortem_debug.py +++ b/neutron/tests/unit/test_post_mortem_debug.py @@ -18,6 +18,7 @@ import sys import mock +from six.moves import xrange from neutron.tests import base from neutron.tests import post_mortem_debug