Fix pep8 failed
Change-Id: Ic7b265a480ff62a62aac230dc707534657c8cde8
This commit is contained in:
parent
1f512ce8fa
commit
37bf4fa1b6
|
@ -251,9 +251,9 @@ class _StepMapping(object):
|
|||
target = sys.modules[__name__]
|
||||
for name in dir(target):
|
||||
value = getattr(target, name)
|
||||
if (inspect.isclass(value)
|
||||
and issubclass(value, base_cls)
|
||||
and value is not base_cls):
|
||||
if (inspect.isclass(value) and
|
||||
issubclass(value, base_cls) and
|
||||
value is not base_cls):
|
||||
self.steps.append(value)
|
||||
|
||||
self.name_to_step = {}
|
||||
|
|
|
@ -59,16 +59,16 @@ def match_device(hu_disk, ks_disk):
|
|||
uspec = hu_disk['uspec']
|
||||
|
||||
# True if at least one by-id link matches ks_disk
|
||||
if ('DEVLINKS' in uspec and len(ks_disk.get('extra', [])) > 0
|
||||
and any(x.startswith('/dev/disk/by-id') for x in
|
||||
set(uspec['DEVLINKS']) &
|
||||
set(['/dev/%s' % l for l in ks_disk['extra']]))):
|
||||
if ('DEVLINKS' in uspec and len(ks_disk.get('extra', [])) > 0 and
|
||||
any(x.startswith('/dev/disk/by-id') for x in
|
||||
set(uspec['DEVLINKS']) &
|
||||
set(['/dev/%s' % l for l in ks_disk['extra']]))):
|
||||
return True
|
||||
|
||||
# True if one of DEVLINKS matches ks_disk id
|
||||
if (len(ks_disk.get('extra', [])) == 0
|
||||
and 'DEVLINKS' in uspec and 'id' in ks_disk
|
||||
and '/dev/%s' % ks_disk['id'] in uspec['DEVLINKS']):
|
||||
if (len(ks_disk.get('extra', [])) == 0 and
|
||||
'DEVLINKS' in uspec and 'id' in ks_disk and
|
||||
'/dev/%s' % ks_disk['id'] in uspec['DEVLINKS']):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
@ -349,8 +349,8 @@ class Nailgun(BaseDataDriver,
|
|||
if all((
|
||||
v["size"] <= 0
|
||||
for v in disk["volumes"]
|
||||
if v["type"] not in ("boot", 'lvm_meta_pool')
|
||||
and v.get("mount") != "/boot"
|
||||
if v["type"] not in ("boot", 'lvm_meta_pool') and
|
||||
v.get("mount") != "/boot"
|
||||
)):
|
||||
continue
|
||||
|
||||
|
@ -437,9 +437,9 @@ class Nailgun(BaseDataDriver,
|
|||
keep_data=volume.get('keep_data', False))
|
||||
LOG.debug('Partition name: %s' % prt.name)
|
||||
|
||||
elif (volume.get('mount') == '/boot'
|
||||
and not self._boot_partition_done
|
||||
and disk['name'] in
|
||||
elif (volume.get('mount') == '/boot' and
|
||||
not self._boot_partition_done and
|
||||
disk['name'] in
|
||||
[d['name'] for d in self.boot_disks]):
|
||||
LOG.debug('Adding /boot partition on disk %s: '
|
||||
'size=%s', disk['name'], volume['size'])
|
||||
|
|
|
@ -260,7 +260,7 @@ class LVMpv(BlockDevice):
|
|||
|
||||
|
||||
class LVMlv(FileSystemMixin, BlockDevice):
|
||||
def __init__(self, name, size, **fields):
|
||||
def __init__(self, name, size, **fields):
|
||||
BlockDevice.__init__(self, size, **fields)
|
||||
self.name = name
|
||||
|
||||
|
|
|
@ -155,8 +155,8 @@ class TestSizeUnit(unittest2.TestCase):
|
|||
def test_in_unit(self):
|
||||
size = block_device.SizeUnit.new_by_string('2.2 YiB')
|
||||
for unit, expect in (
|
||||
('B', 2659636803152184399101952),
|
||||
('s', 5194603131156610154496),
|
||||
('B', 2659636803152184399101952),
|
||||
('s', 5194603131156610154496),
|
||||
('KiB', 2597301565578305077248),
|
||||
('MiB', 2536427310135063552),
|
||||
('GiB', 2476979795053773),
|
||||
|
|
|
@ -430,8 +430,7 @@ LIST_BLOCK_DEVICES_SAMPLE = [
|
|||
'size': 500107862016},
|
||||
{'uspec':
|
||||
{'DEVLINKS': [
|
||||
'/dev/disk/by-id/by-id/md-fake-raid-uuid',
|
||||
],
|
||||
'/dev/disk/by-id/by-id/md-fake-raid-uuid', ],
|
||||
'ID_SERIAL_SHORT': 'fake_serial_raid',
|
||||
'ID_WWN': 'fake_wwn_raid',
|
||||
'DEVPATH': '/devices/virtual/block/md123',
|
||||
|
@ -536,8 +535,7 @@ LIST_BLOCK_DEVICES_MPATH = [
|
|||
'bspec': {
|
||||
'sz': '976773168', 'iomin': '4096', 'size64': '500107862016',
|
||||
'ss': '512', 'ioopt': '0', 'alignoff': '0', 'pbsz': '4096',
|
||||
'ra': '256', 'ro': '0', 'maxsect': '1024'
|
||||
},
|
||||
'ra': '256', 'ro': '0', 'maxsect': '1024'},
|
||||
'size': 500107862016},
|
||||
{'uspec':
|
||||
{'DEVLINKS': [
|
||||
|
@ -551,23 +549,20 @@ LIST_BLOCK_DEVICES_MPATH = [
|
|||
'ID_MODEL': 'fake_id_model',
|
||||
'DEVNAME': '/dev/sdb',
|
||||
'MAJOR': '8',
|
||||
'DEVTYPE': 'disk', 'MINOR': '0', 'ID_BUS': 'ata'
|
||||
},
|
||||
'DEVTYPE': 'disk', 'MINOR': '0', 'ID_BUS': 'ata'},
|
||||
'startsec': '0',
|
||||
'device': '/dev/sdb',
|
||||
'espec': {'state': 'running', 'timeout': '30', 'removable': '0'},
|
||||
'bspec': {
|
||||
'sz': '976773168', 'iomin': '4096', 'size64': '500107862016',
|
||||
'ss': '512', 'ioopt': '0', 'alignoff': '0', 'pbsz': '4096',
|
||||
'ra': '256', 'ro': '0', 'maxsect': '1024'
|
||||
},
|
||||
'ra': '256', 'ro': '0', 'maxsect': '1024'},
|
||||
'size': 500107862016},
|
||||
{'uspec':
|
||||
{'DEVLINKS': [
|
||||
'disk/by-id/scsi-SATA_VBOX_HARDDISK_VB69050467-b385c7cd',
|
||||
'/dev/disk/by-id/wwn-fake_wwn_1',
|
||||
'/dev/disk/by-id/dm-uuid-mpath-fake_wwn_1'
|
||||
],
|
||||
'/dev/disk/by-id/dm-uuid-mpath-fake_wwn_1'],
|
||||
'ID_SERIAL_SHORT': 'fake_serial_1',
|
||||
'ID_WWN': 'fake_wwn_1',
|
||||
'DEVPATH': '/devices/pci0000:00/0000:00:1f.2/ata1/host0/',
|
||||
|
@ -582,8 +577,7 @@ LIST_BLOCK_DEVICES_MPATH = [
|
|||
'bspec': {
|
||||
'sz': '976773168', 'iomin': '4096', 'size64': '500107862016',
|
||||
'ss': '512', 'ioopt': '0', 'alignoff': '0', 'pbsz': '4096',
|
||||
'ra': '256', 'ro': '0', 'maxsect': '1024'
|
||||
},
|
||||
'ra': '256', 'ro': '0', 'maxsect': '1024'},
|
||||
'size': 500107862016},
|
||||
{'uspec':
|
||||
{'DEVLINKS': [
|
||||
|
@ -596,16 +590,14 @@ LIST_BLOCK_DEVICES_MPATH = [
|
|||
'ID_MODEL': 'fake_id_model',
|
||||
'DEVNAME': '/dev/sdc',
|
||||
'MAJOR': '8',
|
||||
'DEVTYPE': 'disk', 'MINOR': '0', 'ID_BUS': 'ata'
|
||||
},
|
||||
'DEVTYPE': 'disk', 'MINOR': '0', 'ID_BUS': 'ata'},
|
||||
'startsec': '0',
|
||||
'device': '/dev/sdc',
|
||||
'espec': {'state': 'running', 'timeout': '30', 'removable': '0'},
|
||||
'bspec': {
|
||||
'sz': '976773168', 'iomin': '4096', 'size64': '500107862016',
|
||||
'ss': '512', 'ioopt': '0', 'alignoff': '0', 'pbsz': '4096',
|
||||
'ra': '256', 'ro': '0', 'maxsect': '1024'
|
||||
},
|
||||
'ra': '256', 'ro': '0', 'maxsect': '1024'},
|
||||
'size': 500107862016},
|
||||
]
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ class BlockDeviceMock(object):
|
|||
entry = meta[path]
|
||||
except KeyError:
|
||||
raise OSError(
|
||||
errno.ENOENT, 'FAKE: No such file or directory', path)
|
||||
errno.ENOENT, 'FAKE: No such file or directory', path)
|
||||
return entry
|
||||
|
||||
|
||||
|
|
|
@ -447,40 +447,40 @@ def match_device(uspec1, uspec2):
|
|||
"""
|
||||
|
||||
# False if ID_WWN is given and does not match each other
|
||||
if ('ID_WWN' in uspec1 and 'ID_WWN' in uspec2
|
||||
and uspec1['ID_WWN'] != uspec2['ID_WWN']):
|
||||
if ('ID_WWN' in uspec1 and 'ID_WWN' in uspec2 and
|
||||
uspec1['ID_WWN'] != uspec2['ID_WWN']):
|
||||
return False
|
||||
|
||||
# False if ID_SERIAL_SHORT is given and does not match each other
|
||||
if ('ID_SERIAL_SHORT' in uspec1 and 'ID_SERIAL_SHORT' in uspec2
|
||||
and uspec1['ID_SERIAL_SHORT'] != uspec2['ID_SERIAL_SHORT']):
|
||||
if ('ID_SERIAL_SHORT' in uspec1 and 'ID_SERIAL_SHORT' in uspec2 and
|
||||
uspec1['ID_SERIAL_SHORT'] != uspec2['ID_SERIAL_SHORT']):
|
||||
return False
|
||||
|
||||
# True if at least one by-id link is the same for both uspecs
|
||||
if ('DEVLINKS' in uspec1 and 'DEVLINKS' in uspec2
|
||||
and any(x.startswith('/dev/disk/by-id') for x in
|
||||
set(uspec1['DEVLINKS']) & set(uspec2['DEVLINKS']))):
|
||||
if ('DEVLINKS' in uspec1 and 'DEVLINKS' in uspec2 and
|
||||
any(x.startswith('/dev/disk/by-id') for x in
|
||||
set(uspec1['DEVLINKS']) & set(uspec2['DEVLINKS']))):
|
||||
return True
|
||||
|
||||
# True if ID_WWN is given and matches each other
|
||||
# and DEVTYPE is given and is 'disk'
|
||||
if (uspec1.get('ID_WWN') == uspec2.get('ID_WWN') is not None
|
||||
and uspec1.get('DEVTYPE') == uspec2.get('DEVTYPE') == 'disk'):
|
||||
if (uspec1.get('ID_WWN') == uspec2.get('ID_WWN') is not None and
|
||||
uspec1.get('DEVTYPE') == uspec2.get('DEVTYPE') == 'disk'):
|
||||
return True
|
||||
|
||||
# True if ID_WWN is given and matches each other
|
||||
# and DEVTYPE is given and is 'partition'
|
||||
# and MINOR is given and matches each other
|
||||
if (uspec1.get('ID_WWN') == uspec2.get('ID_WWN') is not None
|
||||
and uspec1.get('DEVTYPE') == uspec2.get('DEVTYPE') == 'partition'
|
||||
and uspec1.get('MINOR') == uspec2.get('MINOR') is not None):
|
||||
if (uspec1.get('ID_WWN') == uspec2.get('ID_WWN') is not None and
|
||||
uspec1.get('DEVTYPE') == uspec2.get('DEVTYPE') == 'partition' and
|
||||
uspec1.get('MINOR') == uspec2.get('MINOR') is not None):
|
||||
return True
|
||||
|
||||
# True if ID_SERIAL_SHORT is given and matches each other
|
||||
# and DEVTYPE is given and is 'disk'
|
||||
if (uspec1.get('ID_SERIAL_SHORT') == uspec2.get('ID_SERIAL_SHORT')
|
||||
is not None
|
||||
and uspec1.get('DEVTYPE') == uspec2.get('DEVTYPE') == 'disk'):
|
||||
is not None and
|
||||
uspec1.get('DEVTYPE') == uspec2.get('DEVTYPE') == 'disk'):
|
||||
return True
|
||||
|
||||
# True if DEVPATH is given and matches each other
|
||||
|
|
2
tox.ini
2
tox.ini
|
@ -50,6 +50,8 @@ commands =
|
|||
oslo-config-generator --config-file etc/oslo-config-generator/bareon.conf
|
||||
|
||||
[flake8]
|
||||
# [E731] Do not assign a lambda expression, use a def. This reduces readability in some cases.
|
||||
ignore = E731
|
||||
exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build,tools,docs
|
||||
show-pep8 = True
|
||||
show-source = True
|
||||
|
|
Loading…
Reference in New Issue