Python 3: Use six.moves.range

The function `xrange` was renamed to `range` in Python 3.

* Remove `xrange` occurences so that Python 3 tests can pass. Use
  `six.moves.range` instead to get the right function in both cases.
* Generalize the use of the efficient `range` (ex-`xrange`) in
  critical sections (when iterating over large lists).
* Simplify code.
* Add a hacking check to prevent future usage of `xrange`.

Change-Id: I080acaaa1d4753619fbbb76dddba6d946d84e73f
Partially implements: blueprint neutron-python3
diff --git a/neutron/tests/tempest/common/glance_http.py b/neutron/tests/tempest/common/glance_http.py
index 6650477..6cdbadc 100644
--- a/neutron/tests/tempest/common/glance_http.py
+++ b/neutron/tests/tempest/common/glance_http.py
@@ -17,7 +17,6 @@
 
 import copy
 import hashlib
-from six.moves import http_client as httplib
 import json
 import posixpath
 import re
@@ -30,6 +29,7 @@
 import OpenSSL
 from oslo_log import log as logging
 from six import moves
+from six.moves import http_client as httplib
 from tempest_lib import exceptions as lib_exc
 
 from neutron.tests.tempest import exceptions as exc
@@ -260,7 +260,7 @@
 
         # Also try Subject Alternative Names for a match
         san_list = None
-        for i in moves.xrange(x509.get_extension_count()):
+        for i in moves.range(x509.get_extension_count()):
             ext = x509.get_extension(i)
             if ext.get_short_name() == 'subjectAltName':
                 san_list = str(ext)