Merge "python3 compatibility changes"

This commit is contained in:
Zuul 2018-09-17 05:46:00 +00:00 committed by Gerrit Code Review
commit f9b3e026c7
3 changed files with 15 additions and 10 deletions

View File

@ -274,7 +274,17 @@ class SortingEmulatedHelper(SortingHelper):
def sort(self, items):
def cmp_func(obj1, obj2):
for key, direction in self.sort_dict:
ret = cmp(obj1[key], obj2[key])
o1 = obj1[key]
o2 = obj2[key]
if o1 is None and o2 is None:
ret = 0
elif o1 is None and o2 is not None:
ret = -1
elif o1 is not None and o2 is None:
ret = 1
else:
ret = (o1 > o2) - (o1 < o2)
if ret:
return ret * (1 if direction else -1)
return 0

View File

@ -18,7 +18,6 @@ Tacker base exception handling.
"""
from oslo_utils import excutils
import six
from tacker._i18n import _
@ -43,10 +42,6 @@ class TackerException(Exception):
# at least get the core message out if something happened
super(TackerException, self).__init__(self.message)
if six.PY2:
def __unicode__(self):
return unicode(self.msg)
def __str__(self):
return self.msg

View File

@ -628,7 +628,7 @@ class OpenStack_Driver(abstract_vim_driver.VimAbstractDriver,
neutronclient_.port_pair_group_delete(old_ppgs_dict[ppg_name])
port_pairs = ppg_info['port_pair_group']['port_pairs']
if port_pairs and len(port_pairs):
for j in xrange(0, len(port_pairs)):
for j in range(0, len(port_pairs)):
pp_id = port_pairs[j]
neutronclient_.port_pair_delete(pp_id)
return pc_id
@ -788,7 +788,7 @@ class OpenStack_Driver(abstract_vim_driver.VimAbstractDriver,
new_port_pairs = new_ppg_info['port_pair_group'][
'port_pairs']
if new_port_pairs and len(new_port_pairs):
for j in xrange(0, len(new_port_pairs)):
for j in range(0, len(new_port_pairs)):
new_pp_id = new_port_pairs[j]
neutronclient.port_pair_delete(new_pp_id)
# clean flow classifiers
@ -933,7 +933,7 @@ class NeutronClient(object):
self.client.list_sfc_port_chains()['port_chains']
ppg_list = port_chain['port_chain'].get('port_pair_groups')
if ppg_list and len(ppg_list):
for i in xrange(0, len(ppg_list)):
for i in range(0, len(ppg_list)):
ppg_in_use = False
# Firstly, Tacker delete port chain, if a port pair
# group still belong to other port chains, Tacker
@ -951,7 +951,7 @@ class NeutronClient(object):
port_pairs = \
ppg['port_pair_group']['port_pairs']
if port_pairs and len(port_pairs):
for j in xrange(0, len(port_pairs)):
for j in range(0, len(port_pairs)):
pp_id = port_pairs[j]
self.client.delete_sfc_port_pair(pp_id)
except nc_exceptions.NotFound: