summaryrefslogtreecommitdiffstats
path: root/openstack/common
diff options
context:
space:
mode:
authorChuck Short <chuck.short@canonical.com>2013-07-12 13:47:30 -0400
committerChuck Short <chuck.short@canonical.com>2013-07-17 16:30:23 -0400
commitc0d052a743b7f35c229b1024cbdc47be142658d5 (patch)
treed1554d40ca51c239f0b7a352a825e252d696b918 /openstack/common
parentb4148c2b88069f50eb0b215daf71d798fd0d892c (diff)
downloadoslo-c0d052a743b7f35c229b1024cbdc47be142658d5.tar.gz
oslo-c0d052a743b7f35c229b1024cbdc47be142658d5.tar.xz
oslo-c0d052a743b7f35c229b1024cbdc47be142658d5.zip
python3: Add basic compatibility support.
Add python2/python3 compatibility support: - Change basestring to use six.string_type so that six will either use str() or basestring(). - Use six.iteritems to replace dictionary.iteritems() on python2 or dictionary.items() on python3. Change-Id: I3a8eb1ba5b2fb2859169299d37ae6eeb9bb4cac0 Signed-off-by: Chuck Short <chuck.short@canonical.com>
Diffstat (limited to 'openstack/common')
-rw-r--r--openstack/common/scheduler/filters/capabilities_filter.py5
-rw-r--r--openstack/common/scheduler/filters/json_filter.py4
2 files changed, 6 insertions, 3 deletions
diff --git a/openstack/common/scheduler/filters/capabilities_filter.py b/openstack/common/scheduler/filters/capabilities_filter.py
index 89e2bdb..704ebe8 100644
--- a/openstack/common/scheduler/filters/capabilities_filter.py
+++ b/openstack/common/scheduler/filters/capabilities_filter.py
@@ -13,11 +13,12 @@
# License for the specific language governing permissions and limitations
# under the License.
+import six
+
from openstack.common import log as logging
from openstack.common.scheduler import filters
from openstack.common.scheduler.filters import extra_specs_ops
-
LOG = logging.getLogger(__name__)
@@ -32,7 +33,7 @@ class CapabilitiesFilter(filters.BaseHostFilter):
if not extra_specs:
return True
- for key, req in extra_specs.iteritems():
+ for key, req in six.iteritems(extra_specs):
# Either not scope format, or in capabilities scope
scope = key.split(':')
if len(scope) > 1 and scope[0] != "capabilities":
diff --git a/openstack/common/scheduler/filters/json_filter.py b/openstack/common/scheduler/filters/json_filter.py
index bc4b4fd..6c90055 100644
--- a/openstack/common/scheduler/filters/json_filter.py
+++ b/openstack/common/scheduler/filters/json_filter.py
@@ -16,6 +16,8 @@
import operator
+import six
+
from openstack.common import jsonutils
from openstack.common.scheduler import filters
@@ -117,7 +119,7 @@ class JsonFilter(filters.BaseHostFilter):
for arg in query[1:]:
if isinstance(arg, list):
arg = self._process_filter(arg, host_state)
- elif isinstance(arg, basestring):
+ elif isinstance(arg, six.string_types):
arg = self._parse_string(arg, host_state)
if arg is not None:
cooked_args.append(arg)