Merge "py3: Fix for python2/python3 compatibility"
This commit is contained in:
@@ -141,7 +141,7 @@ class Resource(object):
|
||||
return result
|
||||
|
||||
def __repr__(self):
|
||||
reprkeys = sorted(k for k in self.__dict__.keys() if k[0] != '_' and
|
||||
reprkeys = sorted(k for k in list(self.__dict__.keys()) if k[0] != '_' and
|
||||
k != 'manager')
|
||||
info = ", ".join("%s=%s" % (k, getattr(self, k)) for k in reprkeys)
|
||||
return "<%s %s>" % (self.__class__.__name__, info)
|
||||
|
||||
@@ -48,6 +48,8 @@ from oslo_utils import importutils
|
||||
|
||||
from cgtsclient.common import wrapping_formatters
|
||||
from six.moves import input
|
||||
from six.moves import map
|
||||
from six.moves import zip
|
||||
|
||||
|
||||
class HelpFormatter(argparse.HelpFormatter):
|
||||
|
||||
@@ -28,6 +28,7 @@ import textwrap
|
||||
from cgtsclient.common.cli_no_wrap import is_nowrap_set
|
||||
from cgtsclient.common.cli_no_wrap import set_no_wrap
|
||||
from prettytable import _get_size
|
||||
from six.moves import range
|
||||
|
||||
UUID_MIN_LENGTH = 36
|
||||
|
||||
@@ -669,7 +670,7 @@ def build_wrapping_formatters(objs, fields, field_labels, format_spec, add_blank
|
||||
else:
|
||||
format_spec = build_best_guess_formatters_using_average_widths(objs, fields, field_labels)
|
||||
|
||||
for k in format_spec.keys():
|
||||
for k in list(format_spec.keys()):
|
||||
if k not in fields:
|
||||
raise Exception("Error in buildWrappingFormatters: format_spec "
|
||||
"specifies a field {} that is not specified "
|
||||
|
||||
@@ -106,7 +106,7 @@ def do_drbdsync_modify(cc, args):
|
||||
wait_interval = 8
|
||||
configuration_timeout = 90
|
||||
do_wait = True
|
||||
LOOP_MAX = int(configuration_timeout / wait_interval)
|
||||
LOOP_MAX = int(configuration_timeout // wait_interval)
|
||||
for x in range(0, LOOP_MAX):
|
||||
ihosts = cc.ihost.list_personality(personality=CONTROLLER)
|
||||
do_wait = False
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
from six.moves import range
|
||||
|
||||
from cgtsclient._i18n import _
|
||||
from cgtsclient.common import base
|
||||
|
||||
@@ -197,7 +197,7 @@ def do_host_if_add(cc, args):
|
||||
user_specified_fields = dict((k, v) for (k, v) in vars(args).items()
|
||||
if k in field_list and not (v is None))
|
||||
|
||||
if 'iftype' in user_specified_fields.keys():
|
||||
if 'iftype' in list(user_specified_fields.keys()):
|
||||
if args.iftype == 'ae' or args.iftype == 'vlan':
|
||||
uses = args.portsorifaces
|
||||
portnamesoruuids = None
|
||||
@@ -309,7 +309,7 @@ def do_host_if_modify(cc, args):
|
||||
fields.update(user_specified_fields)
|
||||
|
||||
# Allow setting an interface back to a None type
|
||||
if 'ifclass' in user_specified_fields.keys():
|
||||
if 'ifclass' in list(user_specified_fields.keys()):
|
||||
if args.ifclass == 'none':
|
||||
iinterface_utils._get_ports(cc, ihost, interface)
|
||||
if interface.ports or interface.uses:
|
||||
|
||||
@@ -125,7 +125,7 @@ def do_host_lvg_add(cc, args):
|
||||
user_specified_fields = dict((k, v) for (k, v) in vars(args).items()
|
||||
if k in field_list and not (v is None))
|
||||
|
||||
if 'lvm_vg_name' in user_specified_fields.keys():
|
||||
if 'lvm_vg_name' in list(user_specified_fields.keys()):
|
||||
user_specified_fields['lvm_vg_name'] =\
|
||||
user_specified_fields['lvm_vg_name'].replace(" ", "")
|
||||
fields.update(user_specified_fields)
|
||||
|
||||
@@ -322,7 +322,7 @@ def get_storconfig_detailed(iprofile):
|
||||
if stor.function == 'journal' and count > 1:
|
||||
str += " %s" % journals[stor.uuid]
|
||||
if stor.function == 'osd':
|
||||
str += ", ceph journal: size %s GiB, " % (stor.journal_size_mib / 1024)
|
||||
str += ", ceph journal: size %s GiB, " % (stor.journal_size_mib // 1024)
|
||||
if stor.journal_location == stor.uuid:
|
||||
str += "collocated on osd stor"
|
||||
else:
|
||||
|
||||
@@ -55,7 +55,7 @@ def do_host_stor_show(cc, args):
|
||||
|
||||
# convert journal size from mib to gib when display
|
||||
if i.journal_size_mib:
|
||||
i.journal_size_mib = i.journal_size_mib / 1024
|
||||
i.journal_size_mib = i.journal_size_mib // 1024
|
||||
|
||||
_print_istor_show(i)
|
||||
|
||||
@@ -73,7 +73,7 @@ def do_host_stor_list(cc, args):
|
||||
|
||||
# convert journal size from mib to gib when display
|
||||
if i.journal_size_mib:
|
||||
i.journal_size_mib = i.journal_size_mib / 1024
|
||||
i.journal_size_mib = i.journal_size_mib // 1024
|
||||
|
||||
field_labels = ['uuid', 'function', 'osdid', 'state',
|
||||
'idisk_uuid', 'journal_path', 'journal_node',
|
||||
@@ -129,15 +129,15 @@ def do_host_stor_add(cc, args):
|
||||
raise exc.CommandError('Journal size must be an integer '
|
||||
'greater than 0: %s' % user_specified_fields[f])
|
||||
|
||||
if 'journal_size' in user_specified_fields.keys():
|
||||
if 'journal_size' in list(user_specified_fields.keys()):
|
||||
user_specified_fields['journal_size_mib'] = \
|
||||
user_specified_fields.pop('journal_size') * 1024
|
||||
|
||||
if 'function' in user_specified_fields.keys():
|
||||
if 'function' in list(user_specified_fields.keys()):
|
||||
user_specified_fields['function'] = \
|
||||
user_specified_fields['function'].replace(" ", "")
|
||||
|
||||
if 'tier_uuid' in user_specified_fields.keys():
|
||||
if 'tier_uuid' in list(user_specified_fields.keys()):
|
||||
user_specified_fields['tier_uuid'] = \
|
||||
user_specified_fields['tier_uuid'].replace(" ", "")
|
||||
|
||||
@@ -195,7 +195,7 @@ def do_host_stor_update(cc, args):
|
||||
raise exc.CommandError('Journal size must be an integer '
|
||||
'greater than 0: %s' % user_specified_fields[f])
|
||||
|
||||
if 'journal_size' in user_specified_fields.keys():
|
||||
if 'journal_size' in list(user_specified_fields.keys()):
|
||||
user_specified_fields['journal_size_mib'] = \
|
||||
user_specified_fields.pop('journal_size') * 1024
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ class LoadManager(base.Manager):
|
||||
return None
|
||||
|
||||
def _create_load(self, load, path):
|
||||
if set(load.keys()) != set(CREATION_ATTRIBUTES):
|
||||
if set(list(load.keys())) != set(CREATION_ATTRIBUTES):
|
||||
raise exc.InvalidAttribute()
|
||||
|
||||
return self._create(path, load)
|
||||
|
||||
@@ -16,7 +16,7 @@ OP_LOOKUP = {'!=': 'ne',
|
||||
'<': 'lt',
|
||||
'=': 'eq'}
|
||||
|
||||
OP_LOOKUP_KEYS = '|'.join(sorted(OP_LOOKUP.keys(), key=len, reverse=True))
|
||||
OP_LOOKUP_KEYS = '|'.join(sorted(list(OP_LOOKUP.keys()), key=len, reverse=True))
|
||||
OP_SPLIT_RE = re.compile(r'(%s)' % OP_LOOKUP_KEYS)
|
||||
|
||||
DATA_TYPE_RE = re.compile(r'^(string|integer|float|datetime|boolean)(::)(.+)$')
|
||||
|
||||
Reference in New Issue
Block a user