py3: Change sorted function usage
In Python3 it is needed to specify the 'key' argument
for the sorted function.
Backwards compatible with Python2.
Story: 2008454
Task: 42937
Signed-off-by: Bernardo Decco de Siqueira <bernardo.deccodesiqueira@windriver.com>
Change-Id: Ie970e102e44ae3806eded604a188a88ccbc2da16
(cherry picked from commit 43cd5881f8
)
This commit is contained in:
parent
2cd10430d1
commit
bfac69dd89
@ -38,6 +38,8 @@ from sysinv.common import disk_utils
|
|||||||
from sysinv.conductor import rpcapi as conductor_rpcapi
|
from sysinv.conductor import rpcapi as conductor_rpcapi
|
||||||
from sysinv.openstack.common import context
|
from sysinv.openstack.common import context
|
||||||
|
|
||||||
|
from functools import cmp_to_key
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
LOG = log.getLogger(__name__)
|
LOG = log.getLogger(__name__)
|
||||||
|
|
||||||
@ -837,7 +839,7 @@ def check_partitions(data, mode, pfile):
|
|||||||
sortable_partitions = [p for p in partitions if p.get('start_mib') is not None]
|
sortable_partitions = [p for p in partitions if p.get('start_mib') is not None]
|
||||||
|
|
||||||
for p in sorted(sortable_partitions,
|
for p in sorted(sortable_partitions,
|
||||||
lambda p, q: p.get('start_mib') - q.get('start_mib')):
|
key=cmp_to_key(lambda p, q: p.get('start_mib') - q.get('start_mib'))):
|
||||||
disk = _get_disk_device_path(p.get('device_path'))
|
disk = _get_disk_device_path(p.get('device_path'))
|
||||||
if _partition_exists(p.get('device_path')):
|
if _partition_exists(p.get('device_path')):
|
||||||
print('Partition {} already exists on disk {}'.format(
|
print('Partition {} already exists on disk {}'.format(
|
||||||
|
Loading…
Reference in New Issue
Block a user