Cleanup pylint error: redefined-outer-name
un-suppress the pylint error check for redefined-outer-name, and update the code to fix that error Test Plan: PASS: system host-show controller-0 PASS: system device-label-list PASS: system host-device-label-list PASS: system host-pv-add Story: 2008943 Task: 44050 Signed-off-by: Jia Hu <jia.hu@windriver.com> Change-Id: I7e367b5735e1a8b0c174d0cd416925d72c5d4244
This commit is contained in:
parent
ced5ccd805
commit
5923349485
|
@ -546,8 +546,8 @@ def find_resource(manager, name_or_id):
|
|||
raise exc.CommandError(msg)
|
||||
|
||||
|
||||
def string_to_bool(arg):
|
||||
return arg.strip().lower() in ('t', 'true', 'yes', '1')
|
||||
def string_to_bool(s):
|
||||
return s.strip().lower() in ('t', 'true', 'yes', '1')
|
||||
|
||||
|
||||
def env(*vars, **kwargs):
|
||||
|
|
|
@ -46,9 +46,9 @@ def do_device_label_list(cc, args):
|
|||
setattr(dl, 'devicename', "")
|
||||
setattr(dl, 'hostname', "")
|
||||
else:
|
||||
pci_device = cc.pci_device.get(dl.pcidevice_uuid)
|
||||
setattr(dl, 'devicename', getattr(pci_device, 'name'))
|
||||
host = ihost_utils._find_ihost(cc, getattr(pci_device, 'host_uuid'))
|
||||
pci_device_name = cc.pci_device.get(dl.pcidevice_uuid)
|
||||
setattr(dl, 'devicename', getattr(pci_device_name, 'name'))
|
||||
host = ihost_utils._find_ihost(cc, getattr(pci_device_name, 'host_uuid'))
|
||||
setattr(dl, 'hostname', host.hostname)
|
||||
field_labels = ['hostname', 'PCI device name', 'label key', 'label value']
|
||||
fields = ['hostname', 'devicename', 'label_key', 'label_value']
|
||||
|
|
|
@ -63,10 +63,10 @@ def get_disk_display_name(d):
|
|||
return '(' + str(d.uuid)[-8:] + ')'
|
||||
|
||||
|
||||
def _find_disk(cc, ihost, idisk):
|
||||
if utils.is_uuid_like(idisk):
|
||||
def _find_disk(cc, ihost, idisk_id):
|
||||
if utils.is_uuid_like(idisk_id):
|
||||
try:
|
||||
disk = cc.idisk.get(idisk)
|
||||
disk = cc.idisk.get(idisk_id)
|
||||
except exc.HTTPNotFound:
|
||||
return None
|
||||
else:
|
||||
|
@ -74,7 +74,7 @@ def _find_disk(cc, ihost, idisk):
|
|||
else:
|
||||
disklist = cc.idisk.list(ihost.uuid)
|
||||
for disk in disklist:
|
||||
if disk.device_node == idisk or disk.device_path == idisk:
|
||||
if disk.device_node == idisk_id or disk.device_path == idisk_id:
|
||||
return disk
|
||||
else:
|
||||
return None
|
||||
|
|
|
@ -153,18 +153,18 @@ class ihostManager(base.Manager):
|
|||
return self.resource_class(self, body)
|
||||
|
||||
|
||||
def _find_ihost(cc, ihost):
|
||||
if ihost.isdigit() or utils.is_uuid_like(ihost):
|
||||
def _find_ihost(cc, ihost_id):
|
||||
if ihost_id.isdigit() or utils.is_uuid_like(ihost_id):
|
||||
try:
|
||||
h = cc.ihost.get(ihost)
|
||||
h = cc.ihost.get(ihost_id)
|
||||
except exc.HTTPNotFound:
|
||||
raise exc.CommandError('host not found: %s' % ihost)
|
||||
raise exc.CommandError('host not found: %s' % ihost_id)
|
||||
else:
|
||||
return h
|
||||
else:
|
||||
hostlist = cc.ihost.list()
|
||||
for h in hostlist:
|
||||
if h.hostname == ihost:
|
||||
if h.hostname == ihost_id:
|
||||
return h
|
||||
else:
|
||||
raise exc.CommandError('host not found: %s' % ihost)
|
||||
raise exc.CommandError('host not found: %s' % ihost_id)
|
||||
|
|
|
@ -54,22 +54,22 @@ class ilvgManager(base.Manager):
|
|||
return self._update(path, patch)
|
||||
|
||||
|
||||
def _find_ilvg(cc, ihost, ilvg):
|
||||
def _find_ilvg(cc, ihost, ilvg_id):
|
||||
if ilvg.isdigit():
|
||||
try:
|
||||
lvg = cc.ilvg.get(ilvg)
|
||||
lvg = cc.ilvg.get(ilvg_id)
|
||||
except exc.HTTPNotFound:
|
||||
raise exc.CommandError('Local volume group not found by id: %s'
|
||||
% ilvg)
|
||||
% ilvg_id)
|
||||
else:
|
||||
return lvg
|
||||
else:
|
||||
lvglist = cc.ilvg.list(ihost.uuid)
|
||||
for lvg in lvglist:
|
||||
if lvg.lvm_vg_name == ilvg:
|
||||
if lvg.lvm_vg_name == ilvg_id:
|
||||
return lvg
|
||||
if lvg.uuid == ilvg:
|
||||
if lvg.uuid == ilvg_id:
|
||||
return lvg
|
||||
else:
|
||||
raise exc.CommandError('Local volume group not found by name or '
|
||||
'uuid: %s' % ilvg)
|
||||
'uuid: %s' % ilvg_id)
|
||||
|
|
|
@ -62,18 +62,18 @@ def _get_disks(cc, ihost, pv):
|
|||
pv.disks = disk_list
|
||||
|
||||
|
||||
def _find_ipv(cc, ihost, ipv):
|
||||
def _find_ipv(cc, ihost, ipv_id):
|
||||
if ipv.isdigit():
|
||||
try:
|
||||
pv = cc.ipv.get(ipv)
|
||||
pv = cc.ipv.get(ipv_id)
|
||||
except exc.HTTPNotFound:
|
||||
raise exc.CommandError('physical volume not found: %s' % ipv)
|
||||
raise exc.CommandError('physical volume not found: %s' % ipv_id)
|
||||
else:
|
||||
return pv
|
||||
else:
|
||||
pvlist = cc.ipv.list(ihost.uuid)
|
||||
for pv in pvlist:
|
||||
if pv.uuid == ipv:
|
||||
if pv.uuid == ipv_id:
|
||||
return pv
|
||||
else:
|
||||
raise exc.CommandError('physical volume not found: %s' % ipv)
|
||||
raise exc.CommandError('physical volume not found: %s' % ipv_id)
|
||||
|
|
|
@ -55,10 +55,10 @@ class isystemManager(base.Manager):
|
|||
return self._update(self._path(isystem_id), patch)
|
||||
|
||||
|
||||
def _find_isystem(cc, isystem):
|
||||
def _find_isystem(cc, isystem_id):
|
||||
try:
|
||||
h = cc.isystem.get(isystem)
|
||||
h = cc.isystem.get(isystem_id)
|
||||
except exc.HTTPNotFound:
|
||||
raise exc.CommandError('system not found: %s' % isystem)
|
||||
raise exc.CommandError('system not found: %s' % isystem_id)
|
||||
else:
|
||||
return h
|
||||
|
|
|
@ -56,15 +56,15 @@ class partitionManager(base.Manager):
|
|||
return self._update(path, patch)
|
||||
|
||||
|
||||
def _find_partition(cc, ihost, partition, idisk=None):
|
||||
def _find_partition(cc, ihost, partition_id, idisk=None):
|
||||
if idisk:
|
||||
part_list = cc.partition.list(ihost.uuid, idisk.uuid)
|
||||
else:
|
||||
part_list = cc.partition.list(ihost.uuid)
|
||||
for p in part_list:
|
||||
if p.device_path == partition:
|
||||
if p.device_path == partition_id:
|
||||
return p
|
||||
if p.uuid == partition:
|
||||
if p.uuid == partition_id:
|
||||
return p
|
||||
else:
|
||||
return None
|
||||
|
|
|
@ -128,7 +128,6 @@ enable=E1603,E1609,E1610,E1602,E1606,E1608,E1607,E1605,E1604,E1601,E1611,W1652,
|
|||
# W0611: unused-import
|
||||
# W0612: unused-variable
|
||||
# W0613: unused-argument
|
||||
# W0621: redefined-outer-name
|
||||
# W0622: redefined-builtin
|
||||
# W0631: undefined-loop-variable
|
||||
# W0703: broad-except
|
||||
|
@ -136,7 +135,7 @@ enable=E1603,E1609,E1610,E1602,E1606,E1608,E1607,E1605,E1604,E1601,E1611,W1652,
|
|||
# W1618: no-absolute-import
|
||||
disable=C, R, fixme, W0105, W0108, W0110, W0120, W0123,
|
||||
W0201, W0212, W0231, W0235, W0402, W0403, W0603, W0611,
|
||||
W0612, W0613, W0621, W0622, W0631, W0703, W1401,
|
||||
W0612, W0613, W0622, W0631, W0703, W1401,
|
||||
W1618
|
||||
|
||||
[REPORTS]
|
||||
|
|
Loading…
Reference in New Issue