Bump hacking to 3.0.0
The new version enables a lot of standard flake8 checks, so a few fixes are required. W503 is disabled as it conflicts with W504 and the latter seems to be preferred nowadays. Also excluding C901 and E731 that should be fixed in different patches as they require code changes. Change-Id: I8decccc4925f86e0b979b47e2920d6a782d991d7
This commit is contained in:
parent
5bc756917d
commit
64540ba316
1
.gitignore
vendored
1
.gitignore
vendored
@ -38,6 +38,7 @@ htmlcov/
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
.testrepository/
|
||||
.stestr
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
|
@ -96,8 +96,8 @@ def allocate_disks(logical_disk, server, raid_config):
|
||||
if share_physical_disks:
|
||||
sharable_disk_wwns = []
|
||||
for sharable_logical_disk in raid_config['logical_disks']:
|
||||
if (sharable_logical_disk.get('share_physical_disks', False) and
|
||||
'root_device_hint' in sharable_logical_disk):
|
||||
if (sharable_logical_disk.get('share_physical_disks', False)
|
||||
and 'root_device_hint' in sharable_logical_disk):
|
||||
wwn = sharable_logical_disk['root_device_hint']['wwn']
|
||||
sharable_disk_wwns.append(wwn)
|
||||
|
||||
|
@ -67,8 +67,8 @@ def validate(raid_config):
|
||||
elif 'physical_disks' in logical_disk:
|
||||
no_of_disks_specified = len(logical_disk['physical_disks'])
|
||||
|
||||
if (no_of_disks_specified and
|
||||
no_of_disks_specified < min_disks_reqd):
|
||||
if (no_of_disks_specified
|
||||
and no_of_disks_specified < min_disks_reqd):
|
||||
msg = ("RAID level %(raid_level)s requires at least %(number)s "
|
||||
"disks." % {'raid_level': raid_level,
|
||||
'number': min_disks_reqd})
|
||||
@ -145,8 +145,8 @@ def create_configuration(raid_config):
|
||||
sorted((x for x in raid_config['logical_disks']
|
||||
if x['size_gb'] != "MAX"),
|
||||
reverse=True,
|
||||
key=lambda x: x['size_gb']) +
|
||||
[x for x in raid_config['logical_disks'] if x['size_gb'] == "MAX"])
|
||||
key=lambda x: x['size_gb'])
|
||||
+ [x for x in raid_config['logical_disks'] if x['size_gb'] == "MAX"])
|
||||
|
||||
if any(logical_disk['share_physical_disks']
|
||||
for logical_disk in logical_disks_sorted
|
||||
@ -235,8 +235,8 @@ def _sort_shared_logical_disks(logical_disks):
|
||||
disks.
|
||||
:returns: the logical disks sorted based the above conditions.
|
||||
"""
|
||||
is_shared = (lambda x: True if ('share_physical_disks' in x and
|
||||
x['share_physical_disks']) else False)
|
||||
is_shared = (lambda x: True if ('share_physical_disks' in x
|
||||
and x['share_physical_disks']) else False)
|
||||
num_of_disks = (lambda x: x['number_of_physical_disks']
|
||||
if 'number_of_physical_disks' in x else
|
||||
constants.RAID_LEVEL_MIN_DISKS[x['raid_level']])
|
||||
@ -291,9 +291,9 @@ def _sort_shared_logical_disks(logical_disks):
|
||||
# first, followed by shared logical disks with RAID 1, and finally by the
|
||||
# shared logical disks sorted based on number of disks and RAID 1+0
|
||||
# condition.
|
||||
logical_disks_sorted = (logical_disks_nonshared +
|
||||
logical_disks_shared_raid1 +
|
||||
logical_disks_shared)
|
||||
logical_disks_sorted = (logical_disks_nonshared
|
||||
+ logical_disks_shared_raid1
|
||||
+ logical_disks_shared)
|
||||
return logical_disks_sorted
|
||||
|
||||
|
||||
|
@ -76,7 +76,7 @@ def _get_dict(lines, start_index, indentation, deep):
|
||||
|
||||
# Check for multi-level returns
|
||||
if current_line_indentation < indentation:
|
||||
return info, i-1
|
||||
return info, i - 1
|
||||
|
||||
if current_line_indentation == indentation:
|
||||
current_item = current_line.lstrip(' ')
|
||||
@ -85,12 +85,13 @@ def _get_dict(lines, start_index, indentation, deep):
|
||||
continue
|
||||
|
||||
if i < len(lines) - 1:
|
||||
next_line_indentation = _get_indentation(lines[i+1])
|
||||
next_line_indentation = _get_indentation(lines[i + 1])
|
||||
else:
|
||||
next_line_indentation = current_line_indentation
|
||||
|
||||
if next_line_indentation > current_line_indentation:
|
||||
ret_dict, i = _get_dict(lines, i, current_line_indentation, deep+1)
|
||||
ret_dict, i = _get_dict(lines, i,
|
||||
current_line_indentation, deep + 1)
|
||||
for key in ret_dict.keys():
|
||||
if key in info[current_item]:
|
||||
info[current_item][key].update(ret_dict[key])
|
||||
@ -554,7 +555,7 @@ class RaidArray(object):
|
||||
|
||||
# TODO(rameshg87): This always returns in MB, but confirm with
|
||||
# HPSSA folks.
|
||||
match = re.search('Max: (\d+)', stdout)
|
||||
match = re.search(r"Max: (\d+)", stdout)
|
||||
if not match:
|
||||
return False
|
||||
|
||||
@ -580,9 +581,8 @@ class LogicalDrive(object):
|
||||
# TODO(rameshg87): Reduce the disk size by 1 to make sure Ironic
|
||||
# has enough space to write a config drive. Remove this when
|
||||
# Ironic doesn't need it.
|
||||
self.size_gb = int(strutils.string_to_bytes(size,
|
||||
return_int=True) /
|
||||
(1024*1024*1024)) - 1
|
||||
self.size_gb = int(strutils.string_to_bytes(
|
||||
size, return_int=True) / (1024 * 1024 * 1024)) - 1
|
||||
except KeyError:
|
||||
msg = ("Can't get 'Size' parameter from ssacli output for logical "
|
||||
"disk '%(logical_disk)s' of RAID array '%(array)s' in "
|
||||
@ -649,9 +649,8 @@ class PhysicalDrive(object):
|
||||
# It requires space to be stripped.
|
||||
try:
|
||||
size = self.properties['Size'].replace(' ', '')
|
||||
self.size_gb = int(strutils.string_to_bytes(size,
|
||||
return_int=True) /
|
||||
(1024*1024*1024))
|
||||
self.size_gb = int(strutils.string_to_bytes(
|
||||
size, return_int=True) / (1024 * 1024 * 1024))
|
||||
except KeyError:
|
||||
msg = ("Can't get 'Size' parameter from ssacli output for "
|
||||
"physical disk '%(physical_disk)s' of controller "
|
||||
|
@ -69,7 +69,7 @@ SUPPORTED_RIS_METHODS = [
|
||||
'set_vm_status',
|
||||
'update_firmware',
|
||||
'update_persistent_boot',
|
||||
]
|
||||
]
|
||||
|
||||
SUPPORTED_REDFISH_METHODS = [
|
||||
'create_raid_configuration',
|
||||
|
@ -239,14 +239,14 @@ def get_supported_boot_modes(supported_boot_mode_constant):
|
||||
"""
|
||||
boot_mode_bios = 'false'
|
||||
boot_mode_uefi = 'false'
|
||||
if (supported_boot_mode_constant ==
|
||||
constants.SUPPORTED_BOOT_MODE_LEGACY_BIOS_ONLY):
|
||||
if (supported_boot_mode_constant
|
||||
== constants.SUPPORTED_BOOT_MODE_LEGACY_BIOS_ONLY):
|
||||
boot_mode_bios = 'true'
|
||||
elif (supported_boot_mode_constant ==
|
||||
constants.SUPPORTED_BOOT_MODE_UEFI_ONLY):
|
||||
elif (supported_boot_mode_constant
|
||||
== constants.SUPPORTED_BOOT_MODE_UEFI_ONLY):
|
||||
boot_mode_uefi = 'true'
|
||||
elif (supported_boot_mode_constant ==
|
||||
constants.SUPPORTED_BOOT_MODE_LEGACY_BIOS_AND_UEFI):
|
||||
elif (supported_boot_mode_constant
|
||||
== constants.SUPPORTED_BOOT_MODE_LEGACY_BIOS_AND_UEFI):
|
||||
boot_mode_bios = 'true'
|
||||
boot_mode_uefi = 'true'
|
||||
|
||||
|
@ -135,24 +135,24 @@ class FirmwareImageUploader(FirmwareImageControllerBase):
|
||||
|
||||
firmware = open(filename, 'rb').read()
|
||||
# generate boundary
|
||||
boundary = b('------hpiLO3t' +
|
||||
str(random.randint(100000, 1000000)) + 'z')
|
||||
boundary = b('------hpiLO3t'
|
||||
+ str(random.randint(100000, 1000000)) + 'z')
|
||||
|
||||
while boundary in firmware:
|
||||
boundary = b('------hpiLO3t' +
|
||||
str(random.randint(100000, 1000000)) + 'z')
|
||||
boundary = b('------hpiLO3t'
|
||||
+ str(random.randint(100000, 1000000)) + 'z')
|
||||
# generate body parts
|
||||
parts = [
|
||||
# body1
|
||||
b("--") + boundary +
|
||||
b("""\r\nContent-Disposition: form-data; """
|
||||
"""name="fileType"\r\n\r\n"""),
|
||||
b("--") + boundary
|
||||
+ b("""\r\nContent-Disposition: form-data; """
|
||||
"""name="fileType"\r\n\r\n"""),
|
||||
# body2
|
||||
b("\r\n--") + boundary +
|
||||
b('''\r\nContent-Disposition: form-data; name="fwimgfile"; '''
|
||||
'''filename="''') +
|
||||
b(filename) +
|
||||
b('''"\r\nContent-Type: application/octet-stream\r\n\r\n'''),
|
||||
b("\r\n--") + boundary
|
||||
+ b('''\r\nContent-Disposition: form-data; name="fwimgfile"; '''
|
||||
'''filename="''')
|
||||
+ b(filename)
|
||||
+ b('''"\r\nContent-Type: application/octet-stream\r\n\r\n'''),
|
||||
# firmware image
|
||||
firmware,
|
||||
# body3
|
||||
@ -234,8 +234,8 @@ class FirmwareImageUploader(FirmwareImageControllerBase):
|
||||
return ssl.wrap_socket(sock, ssl_version=sslversion)
|
||||
except socket.sslerror:
|
||||
e = sys.exc_info()[1]
|
||||
msg = (getattr(e, 'reason', None) or
|
||||
getattr(e, 'message', None))
|
||||
msg = (getattr(e, 'reason', None)
|
||||
or getattr(e, 'message', None))
|
||||
# Some older iLO s don't support TLSv1, retry with SSLv3
|
||||
if ('wrong version number' in msg) and (
|
||||
sslversion == ssl.PROTOCOL_TLSv1):
|
||||
@ -411,8 +411,8 @@ def _get_firmware_file_in_new_path(searching_path):
|
||||
file_name, file_ext_with_dot = common.get_filename_and_extension_of(
|
||||
firmware_file_path)
|
||||
new_firmware_file_path = os.path.join(
|
||||
tempfile.gettempdir(), str(uuid.uuid4()) + '_' +
|
||||
file_name + file_ext_with_dot)
|
||||
tempfile.gettempdir(), str(uuid.uuid4())
|
||||
+ '_' + file_name + file_ext_with_dot)
|
||||
|
||||
# create a hard link to the raw firmware file
|
||||
os.link(firmware_file_path, new_firmware_file_path)
|
||||
|
@ -316,8 +316,8 @@ class RIBCLOperations(operations.IloOperations):
|
||||
"message: '%(message)s'"),
|
||||
{'message': msg})
|
||||
raise exception.IloClientInternalError(msg, status)
|
||||
if (status in exception.IloLoginFailError.statuses or
|
||||
msg in exception.IloLoginFailError.messages):
|
||||
if (status in exception.IloLoginFailError.statuses
|
||||
or msg in exception.IloLoginFailError.messages):
|
||||
LOG.debug(self._("Got invalid response with "
|
||||
"message: '%(message)s'"),
|
||||
{'message': msg})
|
||||
|
@ -113,8 +113,8 @@ class RISOperations(rest.RestConnectorBase, operations.IloOperations):
|
||||
yield 200, None, item, memberuri
|
||||
|
||||
# else walk the member links
|
||||
elif ('links' in thecollection and
|
||||
'Member' in thecollection['links']):
|
||||
elif ('links' in thecollection
|
||||
and 'Member' in thecollection['links']):
|
||||
# iterate members
|
||||
for memberuri in thecollection['links']['Member']:
|
||||
# for each member return the resource indicated by the
|
||||
@ -123,8 +123,8 @@ class RISOperations(rest.RestConnectorBase, operations.IloOperations):
|
||||
yield status, headers, member, memberuri['href']
|
||||
|
||||
# page forward if there are more pages in the collection
|
||||
if ('links' in thecollection and
|
||||
'NextPage' in thecollection['links']):
|
||||
if ('links' in thecollection
|
||||
and 'NextPage' in thecollection['links']):
|
||||
next_link_uri = (collection_uri + '?page=' + str(
|
||||
thecollection['links']['NextPage']['page']))
|
||||
status, headers, thecollection = self._rest_get(next_link_uri)
|
||||
@ -159,8 +159,8 @@ class RISOperations(rest.RestConnectorBase, operations.IloOperations):
|
||||
"""
|
||||
messages = []
|
||||
if isinstance(extended_error, dict):
|
||||
if ('Type' in extended_error and
|
||||
extended_error['Type'].startswith('ExtendedError.')):
|
||||
if ('Type' in extended_error
|
||||
and extended_error['Type'].startswith('ExtendedError.')):
|
||||
for msg in extended_error['Messages']:
|
||||
message_id = msg['MessageID']
|
||||
x = message_id.split('.')
|
||||
@ -176,12 +176,12 @@ class RISOperations(rest.RestConnectorBase, operations.IloOperations):
|
||||
msg_str = message_id + ': ' + msg_dict['Message']
|
||||
|
||||
for argn in range(0, msg_dict['NumberOfArgs']):
|
||||
subst = '%' + str(argn+1)
|
||||
subst = '%' + str(argn + 1)
|
||||
m = str(msg['MessageArgs'][argn])
|
||||
msg_str = msg_str.replace(subst, m)
|
||||
|
||||
if ('Resolution' in msg_dict and
|
||||
msg_dict['Resolution'] != 'None'):
|
||||
if ('Resolution' in msg_dict
|
||||
and msg_dict['Resolution'] != 'None'):
|
||||
msg_str += ' ' + msg_dict['Resolution']
|
||||
|
||||
messages.append(msg_str)
|
||||
@ -216,8 +216,8 @@ class RISOperations(rest.RestConnectorBase, operations.IloOperations):
|
||||
"""Check if the bios resource exists."""
|
||||
|
||||
system = self._get_host_details()
|
||||
if ('links' in system['Oem']['Hp'] and
|
||||
'BIOS' in system['Oem']['Hp']['links']):
|
||||
if ('links' in system['Oem']['Hp']
|
||||
and 'BIOS' in system['Oem']['Hp']['links']):
|
||||
# Get the BIOS URI and Settings
|
||||
bios_uri = system['Oem']['Hp']['links']['BIOS']['href']
|
||||
status, headers, bios_settings = self._rest_get(bios_uri)
|
||||
@ -251,8 +251,8 @@ class RISOperations(rest.RestConnectorBase, operations.IloOperations):
|
||||
"""
|
||||
|
||||
system = self._get_host_details()
|
||||
if ('links' in system['Oem']['Hp'] and
|
||||
'PCIDevices' in system['Oem']['Hp']['links']):
|
||||
if ('links' in system['Oem']['Hp']
|
||||
and 'PCIDevices' in system['Oem']['Hp']['links']):
|
||||
# Get the PCI URI and Settings
|
||||
pci_uri = system['Oem']['Hp']['links']['PCIDevices']['href']
|
||||
status, headers, pci_device_list = self._rest_get(pci_uri)
|
||||
@ -288,8 +288,8 @@ class RISOperations(rest.RestConnectorBase, operations.IloOperations):
|
||||
:returns the tuple of SmartStorage URI, Headers and settings.
|
||||
"""
|
||||
system = self._get_host_details()
|
||||
if ('links' in system['Oem']['Hp'] and
|
||||
'SmartStorage' in system['Oem']['Hp']['links']):
|
||||
if ('links' in system['Oem']['Hp']
|
||||
and 'SmartStorage' in system['Oem']['Hp']['links']):
|
||||
# Get the SmartStorage URI and Settings
|
||||
storage_uri = system['Oem']['Hp']['links']['SmartStorage']['href']
|
||||
status, headers, storage_settings = self._rest_get(storage_uri)
|
||||
@ -315,8 +315,8 @@ class RISOperations(rest.RestConnectorBase, operations.IloOperations):
|
||||
# Do not raise exception if there is no ArrayControllers
|
||||
# as Storage can be zero at any point and if we raise
|
||||
# exception it might fail get_server_capabilities().
|
||||
if ('links' in storage_settings and
|
||||
'ArrayControllers' in storage_settings['links']):
|
||||
if ('links' in storage_settings
|
||||
and 'ArrayControllers' in storage_settings['links']):
|
||||
# Get the ArrayCOntrollers URI and Settings
|
||||
array_uri = storage_settings['links']['ArrayControllers']['href']
|
||||
status, headers, array_settings = self._rest_get(array_uri)
|
||||
@ -338,8 +338,8 @@ class RISOperations(rest.RestConnectorBase, operations.IloOperations):
|
||||
# Do not raise exception if there is no ArrayControllers
|
||||
# as Storage can be zero at any point and if we raise
|
||||
# exception it might fail get_server_capabilities().
|
||||
if ('links' in array_settings and
|
||||
'Member' in array_settings['links']):
|
||||
if ('links' in array_settings
|
||||
and 'Member' in array_settings['links']):
|
||||
array_uri_links = array_settings['links']['Member']
|
||||
return array_uri_links
|
||||
|
||||
@ -399,13 +399,13 @@ class RISOperations(rest.RestConnectorBase, operations.IloOperations):
|
||||
_, _, member_settings = (
|
||||
self._rest_get(array_link['href']))
|
||||
|
||||
if ('links' in member_settings and
|
||||
drive_name in member_settings['links']):
|
||||
if ('links' in member_settings
|
||||
and drive_name in member_settings['links']):
|
||||
disk_uri = member_settings['links'][drive_name]['href']
|
||||
headers, disk_member_uri, disk_mem = (
|
||||
self._rest_get(disk_uri))
|
||||
if ('links' in disk_mem and
|
||||
'Member' in disk_mem['links']):
|
||||
if ('links' in disk_mem
|
||||
and 'Member' in disk_mem['links']):
|
||||
for disk_link in disk_mem['links']['Member']:
|
||||
diskdrive_uri = disk_link['href']
|
||||
_, _, disk_details = (
|
||||
@ -471,9 +471,8 @@ class RISOperations(rest.RestConnectorBase, operations.IloOperations):
|
||||
def _validate_if_patch_supported(self, headers, uri):
|
||||
"""Check if the PATCH Operation is allowed on the resource."""
|
||||
if not self._operation_allowed(headers, 'PATCH'):
|
||||
msg = ('PATCH Operation not supported on the resource '
|
||||
'"%s"' % uri)
|
||||
raise exception.IloError(msg)
|
||||
msg = ('PATCH Operation not supported on the resource "%s"' % uri)
|
||||
raise exception.IloError(msg)
|
||||
|
||||
def _get_bios_setting(self, bios_property):
|
||||
"""Retrieves bios settings of the server."""
|
||||
@ -712,8 +711,8 @@ class RISOperations(rest.RestConnectorBase, operations.IloOperations):
|
||||
"""Change secure boot settings on the server."""
|
||||
system = self._get_host_details()
|
||||
# find the BIOS URI
|
||||
if ('links' not in system['Oem']['Hp'] or
|
||||
'SecureBoot' not in system['Oem']['Hp']['links']):
|
||||
if ('links' not in system['Oem']['Hp']
|
||||
or 'SecureBoot' not in system['Oem']['Hp']['links']):
|
||||
msg = (' "SecureBoot" resource or feature is not '
|
||||
'supported on this system')
|
||||
raise exception.IloCommandNotSupportedError(msg)
|
||||
@ -735,7 +734,7 @@ class RISOperations(rest.RestConnectorBase, operations.IloOperations):
|
||||
# Change the bios setting as a workaround to enable secure boot
|
||||
# Can be removed when fixed for Gen9 snap2
|
||||
val = self._get_bios_setting('CustomPostMessage')
|
||||
val = val.rstrip() if val.endswith(" ") else val+" "
|
||||
val = val.rstrip() if val.endswith(" ") else val + " "
|
||||
self._change_bios_setting({'CustomPostMessage': val})
|
||||
|
||||
def _is_boot_mode_uefi(self):
|
||||
@ -771,8 +770,8 @@ class RISOperations(rest.RestConnectorBase, operations.IloOperations):
|
||||
"""
|
||||
system = self._get_host_details()
|
||||
|
||||
if ('links' not in system['Oem']['Hp'] or
|
||||
'SecureBoot' not in system['Oem']['Hp']['links']):
|
||||
if ('links' not in system['Oem']['Hp']
|
||||
or 'SecureBoot' not in system['Oem']['Hp']['links']):
|
||||
msg = ('"SecureBoot" resource or feature is not supported'
|
||||
' on this system')
|
||||
raise exception.IloCommandNotSupportedError(msg)
|
||||
@ -1134,8 +1133,8 @@ class RISOperations(rest.RestConnectorBase, operations.IloOperations):
|
||||
"""
|
||||
system = self._get_host_details()
|
||||
bios_uefi_class_val = 0 # value for bios_only boot mode
|
||||
if ('Bios' in system['Oem']['Hp'] and
|
||||
'UefiClass' in system['Oem']['Hp']['Bios']):
|
||||
if ('Bios' in system['Oem']['Hp']
|
||||
and 'UefiClass' in system['Oem']['Hp']['Bios']):
|
||||
bios_uefi_class_val = (system['Oem']['Hp']
|
||||
['Bios']['UefiClass'])
|
||||
return mappings.GET_SUPPORTED_BOOT_MODE_RIS_MAP.get(
|
||||
@ -1361,7 +1360,7 @@ class RISOperations(rest.RestConnectorBase, operations.IloOperations):
|
||||
msg = self._get_extended_error(response)
|
||||
raise exception.IloError(msg)
|
||||
|
||||
def _get_vm_device_status(self, device='FLOPPY'):
|
||||
def _get_vm_device_status(self, device='FLOPPY'):
|
||||
"""Returns the given virtual media device status and device URI
|
||||
|
||||
:param device: virtual media device to be queried
|
||||
@ -1375,14 +1374,14 @@ class RISOperations(rest.RestConnectorBase, operations.IloOperations):
|
||||
|
||||
# Check if the input is valid
|
||||
if device not in valid_devices:
|
||||
raise exception.IloInvalidInputError(
|
||||
"Invalid device. Valid devices: FLOPPY or CDROM.")
|
||||
raise exception.IloInvalidInputError(
|
||||
"Invalid device. Valid devices: FLOPPY or CDROM.")
|
||||
|
||||
manager, uri = self._get_ilo_details()
|
||||
try:
|
||||
vmedia_uri = manager['links']['VirtualMedia']['href']
|
||||
except KeyError:
|
||||
msg = ('"VirtualMedia" section in Manager/links does not exist')
|
||||
msg = '"VirtualMedia" section in Manager/links does not exist'
|
||||
raise exception.IloCommandNotSupportedError(msg)
|
||||
|
||||
for status, hds, vmed, memberuri in self._get_collection(vmedia_uri):
|
||||
@ -1447,8 +1446,8 @@ class RISOperations(rest.RestConnectorBase, operations.IloOperations):
|
||||
response_data['DEVICE'] = device
|
||||
|
||||
# FLOPPY cannot be a boot device
|
||||
if ((response_data['BOOT_OPTION'] == 'BOOT_ONCE') and
|
||||
(response_data['DEVICE'] == 'FLOPPY')):
|
||||
if ((response_data['BOOT_OPTION'] == 'BOOT_ONCE')
|
||||
and (response_data['DEVICE'] == 'FLOPPY')):
|
||||
response_data['BOOT_OPTION'] = 'NO_BOOT'
|
||||
|
||||
return response_data
|
||||
@ -1623,9 +1622,9 @@ class RISOperations(rest.RestConnectorBase, operations.IloOperations):
|
||||
if 'HP iLO Virtual USB CD' in boot_string:
|
||||
return 'CDROM'
|
||||
|
||||
elif ('NIC' in boot_string or
|
||||
'PXE' in boot_string or
|
||||
"iSCSI" in boot_string):
|
||||
elif ('NIC' in boot_string
|
||||
or 'PXE' in boot_string
|
||||
or "iSCSI" in boot_string):
|
||||
return 'NETWORK'
|
||||
|
||||
elif common.isDisk(boot_string):
|
||||
@ -1657,7 +1656,7 @@ class RISOperations(rest.RestConnectorBase, operations.IloOperations):
|
||||
|
||||
systems_uri = "/rest/v1/Systems/1"
|
||||
# Need to set this option first if device is 'UefiTarget'
|
||||
if new_device is 'UefiTarget':
|
||||
if new_device == 'UefiTarget':
|
||||
system = self._get_host_details()
|
||||
uefi_devices = (
|
||||
system['Boot']['UefiTargetBootSourceOverrideSupported'])
|
||||
|
@ -32,6 +32,7 @@ class MibBuilder(builder.MibBuilder):
|
||||
# cause permission problems when opening files at relative path
|
||||
defaultMiscMibs = ''
|
||||
|
||||
|
||||
cpq_mibs_path = os.path.dirname(os.path.abspath(__file__))
|
||||
cpq_mibs_path = os.path.join(cpq_mibs_path, "cpqdisk_mibs")
|
||||
mBuilder = MibBuilder()
|
||||
@ -145,12 +146,10 @@ def _parse_mibs(iLOIP, snmp_credentials):
|
||||
raise exception.IloSNMPInvalidInputFailure(msg)
|
||||
else:
|
||||
if errorStatus:
|
||||
msg = ('Parsing MIBs failed. %s at %s' % (
|
||||
errorStatus.prettyPrint(),
|
||||
errorIndex and varBinds[-1][int(errorIndex)-1]
|
||||
or '?'
|
||||
)
|
||||
)
|
||||
msg = ('Parsing MIBs failed. %s at %s'
|
||||
% (errorStatus.prettyPrint(),
|
||||
errorIndex and varBinds[-1][int(errorIndex) - 1]
|
||||
or '?'))
|
||||
LOG.error(msg)
|
||||
raise exception.IloSNMPInvalidInputFailure(msg)
|
||||
else:
|
||||
@ -224,5 +223,5 @@ def get_local_gb(iLOIP, snmp_credentials):
|
||||
for key in disk_sizes[uuid]:
|
||||
if int(disk_sizes[uuid][key]) > max_size:
|
||||
max_size = int(disk_sizes[uuid][key])
|
||||
max_size_gb = max_size/1024
|
||||
max_size_gb = max_size / 1024
|
||||
return max_size_gb
|
||||
|
@ -696,7 +696,7 @@ class RedfishOperations(operations.IloOperations):
|
||||
common_storage.has_rotational(sushy_system)),
|
||||
('has_nvme_ssd',
|
||||
common_storage.has_nvme_ssd(sushy_system))
|
||||
]
|
||||
]
|
||||
|
||||
all_key_to_value_expression_tuples += (
|
||||
[('logical_raid_level_' + x, True)
|
||||
|
@ -100,9 +100,9 @@ class VirtualMedia(virtual_media.VirtualMedia):
|
||||
"Oem": {
|
||||
"Hpe": {
|
||||
"BootOnNextServerReset": boot_on_next_reset
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
self._conn.patch(self.path, data=data)
|
||||
|
||||
|
||||
|
@ -191,8 +191,8 @@ class BIOSBootSettings(base.ResourceBase):
|
||||
preferred_boot_device = self.persistent_boot_config_order[0]
|
||||
for boot_source in self.boot_sources:
|
||||
if ((boot_source.get("StructuredBootString") is not None) and (
|
||||
preferred_boot_device ==
|
||||
boot_source.get("StructuredBootString"))):
|
||||
preferred_boot_device
|
||||
== boot_source.get("StructuredBootString"))):
|
||||
boot_string = boot_source["BootString"]
|
||||
break
|
||||
else:
|
||||
@ -221,8 +221,8 @@ class BIOSBootSettings(base.ResourceBase):
|
||||
raise exception.IloError(msg)
|
||||
|
||||
for boot_source in boot_sources:
|
||||
if (mac.upper() in boot_source['UEFIDevicePath'] and
|
||||
'iSCSI' in boot_source['UEFIDevicePath']):
|
||||
if (mac.upper() in boot_source['UEFIDevicePath']
|
||||
and 'iSCSI' in boot_source['UEFIDevicePath']):
|
||||
return boot_source['StructuredBootString']
|
||||
else:
|
||||
msg = ('MAC provided "%s" is Invalid' % mac)
|
||||
|
@ -49,10 +49,9 @@ class EthernetInterfaceCollection(base.ResourceCollectionBase):
|
||||
mac_dict = {}
|
||||
for eth in self.get_members():
|
||||
if eth.mac_address is not None:
|
||||
if (eth.status is not None and
|
||||
eth.status.health == sys_cons.HEALTH_OK
|
||||
and eth.status.state ==
|
||||
sys_cons.HEALTH_STATE_ENABLED):
|
||||
if (eth.status is not None
|
||||
and eth.status.health == sys_cons.HEALTH_OK
|
||||
and eth.status.state == sys_cons.HEALTH_STATE_ENABLED):
|
||||
mac_dict.update(
|
||||
{'Port ' + eth.identity: eth.mac_address})
|
||||
return mac_dict
|
||||
|
@ -55,8 +55,8 @@ class MemoryCollection(base.ResourceCollectionBase):
|
||||
if mem.memory_type == sys_cons.MEMORY_TYPE_NVDIMM_N:
|
||||
persistent_memory = True
|
||||
nvdimm_n = True
|
||||
if (mem.memory_device_type ==
|
||||
sys_cons.MEMORY_DEVICE_TYPE_LOGICAL):
|
||||
if (mem.memory_device_type
|
||||
== sys_cons.MEMORY_DEVICE_TYPE_LOGICAL):
|
||||
logical_nvdimm_n = True
|
||||
break
|
||||
|
||||
|
@ -96,8 +96,8 @@ class Storage(base.ResourceBase):
|
||||
def has_nvme_ssd(self):
|
||||
"""Return True if the drive is SSD and protocol is NVMe"""
|
||||
for member in self._drives_list():
|
||||
if (member.media_type == constants.MEDIA_TYPE_SSD and
|
||||
member.protocol == constants.PROTOCOL_NVMe):
|
||||
if (member.media_type == constants.MEDIA_TYPE_SSD
|
||||
and member.protocol == constants.PROTOCOL_NVMe):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
@ -315,7 +315,7 @@ class HPESystem(system.System):
|
||||
try:
|
||||
ssc_obj = self.get_smart_storage_config(config_id)
|
||||
ssc_obj.delete_raid()
|
||||
except exception.IloLogicalDriveNotFoundError as e:
|
||||
except exception.IloLogicalDriveNotFoundError:
|
||||
ld_exc_count += 1
|
||||
except sushy.exceptions.SushyError as e:
|
||||
any_exceptions.append((config_id, str(e)))
|
||||
@ -534,7 +534,7 @@ class HPESystem(system.System):
|
||||
if ssc_obj:
|
||||
result = ssc_obj.read_raid(controller=controller)
|
||||
config['logical_disks'].extend(result['logical_disks'])
|
||||
except exception.IloLogicalDriveNotFoundError as e:
|
||||
except exception.IloLogicalDriveNotFoundError:
|
||||
ld_exc_count += 1
|
||||
except sushy.exceptions.SushyError as e:
|
||||
any_exceptions.append((controller, str(e)))
|
||||
|
@ -55,7 +55,7 @@ class HPEUpdateService(base.ResourceBase):
|
||||
resource=self._path))
|
||||
return fw_update_action
|
||||
|
||||
def flash_firmware(self, redfish_inst, file_url):
|
||||
def flash_firmware(self, redfish_inst, file_url):
|
||||
"""Perform firmware flashing on a redfish system
|
||||
|
||||
:param file_url: url to firmware bits.
|
||||
|
@ -53,37 +53,34 @@ def get_subresource_path_by(resource, subresource_path):
|
||||
|
||||
if '@odata.id' not in body:
|
||||
raise exception.MissingAttributeError(
|
||||
attribute='/'.join(subresource_path)+'/@odata.id',
|
||||
attribute='/'.join(subresource_path) + '/@odata.id',
|
||||
resource=resource.path)
|
||||
|
||||
return body['@odata.id']
|
||||
|
||||
|
||||
def get_supported_boot_mode(supported_boot_mode):
|
||||
"""Return bios and uefi support.
|
||||
"""Return bios and uefi support.
|
||||
|
||||
:param supported_boot_mode: Supported boot modes
|
||||
:return: A tuple of 'true'/'false' based on bios and uefi
|
||||
support respectively.
|
||||
"""
|
||||
boot_mode_bios = 'false'
|
||||
boot_mode_uefi = 'false'
|
||||
if (supported_boot_mode ==
|
||||
sys_cons.SUPPORTED_LEGACY_BIOS_ONLY):
|
||||
boot_mode_bios = 'true'
|
||||
elif (supported_boot_mode ==
|
||||
sys_cons.SUPPORTED_UEFI_ONLY):
|
||||
boot_mode_uefi = 'true'
|
||||
elif (supported_boot_mode ==
|
||||
sys_cons.SUPPORTED_LEGACY_BIOS_AND_UEFI):
|
||||
boot_mode_bios = 'true'
|
||||
boot_mode_uefi = 'true'
|
||||
:param supported_boot_mode: Supported boot modes
|
||||
:return: A tuple of 'true'/'false' based on bios and uefi
|
||||
support respectively.
|
||||
"""
|
||||
boot_mode_bios = 'false'
|
||||
boot_mode_uefi = 'false'
|
||||
if (supported_boot_mode == sys_cons.SUPPORTED_LEGACY_BIOS_ONLY):
|
||||
boot_mode_bios = 'true'
|
||||
elif (supported_boot_mode == sys_cons.SUPPORTED_UEFI_ONLY):
|
||||
boot_mode_uefi = 'true'
|
||||
elif (supported_boot_mode == sys_cons.SUPPORTED_LEGACY_BIOS_AND_UEFI):
|
||||
boot_mode_bios = 'true'
|
||||
boot_mode_uefi = 'true'
|
||||
|
||||
return SupportedBootModes(boot_mode_bios=boot_mode_bios,
|
||||
boot_mode_uefi=boot_mode_uefi)
|
||||
return SupportedBootModes(boot_mode_bios=boot_mode_bios,
|
||||
boot_mode_uefi=boot_mode_uefi)
|
||||
|
||||
|
||||
def get_allowed_operations(resource, subresouce_path):
|
||||
def get_allowed_operations(resource, subresource_path):
|
||||
"""Helper function to get the HTTP allowed methods.
|
||||
|
||||
:param resource: ResourceBase instance from which the path is loaded.
|
||||
@ -91,7 +88,7 @@ def get_allowed_operations(resource, subresouce_path):
|
||||
Either a string, or a list of strings in case of a nested field.
|
||||
:returns: A list of allowed HTTP methods.
|
||||
"""
|
||||
uri = get_subresource_path_by(resource, subresouce_path)
|
||||
uri = get_subresource_path_by(resource, subresource_path)
|
||||
response = resource._conn.get(path=uri)
|
||||
return response.headers['Allow']
|
||||
|
||||
|
@ -48,7 +48,7 @@ EXIT_CODE_TO_STRING = {
|
||||
3: ("The smart component was not installed. Node is already "
|
||||
"up-to-date."),
|
||||
253: "The installation of the component failed."
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def _execute_sum(sum_file_path, mount_point, components=None):
|
||||
@ -129,8 +129,8 @@ def _parse_sum_ouput(exit_code):
|
||||
with open(OUTPUT_FILES[0], 'r') as f:
|
||||
output_data = f.read()
|
||||
|
||||
ret_data = output_data[(output_data.find('Deployed Components:') +
|
||||
len('Deployed Components:')):
|
||||
ret_data = output_data[(output_data.find('Deployed Components:')
|
||||
+ len('Deployed Components:')):
|
||||
output_data.find('Exit status:')]
|
||||
|
||||
failed = 0
|
||||
|
@ -50,14 +50,14 @@ class ManagerTestCases(testtools.TestCase):
|
||||
"type=logicaldrive",
|
||||
"drives=%s" % ld2_drives,
|
||||
"raid=5",
|
||||
"size=%d" % (100*1024),
|
||||
"size=%d" % (100 * 1024),
|
||||
process_input='y')
|
||||
# Verify that we created the 50GB disk the last.
|
||||
controller_exec_cmd_mock.assert_called_with("create",
|
||||
"type=logicaldrive",
|
||||
"drives=%s" % ld1_drives,
|
||||
"raid=1",
|
||||
"size=%d" % (50*1024),
|
||||
"size=%d" % (50 * 1024),
|
||||
process_input='y')
|
||||
|
||||
ld1_ret = [x for x in current_config['logical_disks']
|
||||
@ -148,14 +148,14 @@ class ManagerTestCases(testtools.TestCase):
|
||||
"type=logicaldrive",
|
||||
mock.ANY,
|
||||
"raid=5",
|
||||
"size=%d" % (100*1024),
|
||||
"size=%d" % (100 * 1024),
|
||||
process_input='y')
|
||||
# Verify that we created the 50GB disk the last.
|
||||
controller_exec_cmd_mock.assert_called_with("create",
|
||||
"type=logicaldrive",
|
||||
mock.ANY,
|
||||
"raid=1",
|
||||
"size=%d" % (50*1024),
|
||||
"size=%d" % (50 * 1024),
|
||||
process_input='y')
|
||||
|
||||
ld1_ret = [x for x in current_config['logical_disks']
|
||||
@ -551,7 +551,8 @@ class ManagerTestCases(testtools.TestCase):
|
||||
'Summary': ('Drives overwritten with zeros because '
|
||||
'sanitize erase is not supported on the '
|
||||
'controller.')
|
||||
}}
|
||||
}
|
||||
}
|
||||
|
||||
ret = manager.erase_devices()
|
||||
self.assertEqual(expt_ret, ret)
|
||||
|
@ -18,7 +18,7 @@ MODULE = "RIS"
|
||||
|
||||
HTTP_BOOT_URL = {
|
||||
"UefiShellStartupUrl": "http://10.10.1.30:8081/startup.nsh"
|
||||
}
|
||||
}
|
||||
|
||||
RESPONSE_BODY_FOR_REST_OP = """
|
||||
{
|
||||
@ -374,14 +374,12 @@ REST_GET_SECURE_BOOT = {
|
||||
"SecureBootCurrentState": False,
|
||||
"SecureBootEnable": True,
|
||||
"Type": "HpSecureBoot.0.9.5",
|
||||
"links":
|
||||
{
|
||||
"self":
|
||||
{
|
||||
"href": "/rest/v1/Systems/1/SecureBoot"
|
||||
}
|
||||
"links": {
|
||||
"self": {
|
||||
"href": "/rest/v1/Systems/1/SecureBoot"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
REST_FAILURE_OUTPUT = {
|
||||
'Type': 'ExtendedError.1.0.0',
|
||||
|
@ -44,7 +44,7 @@ class SnmpTestCase(unittest.TestCase):
|
||||
{'cpqDaPhyDrvSize': '286102'}}
|
||||
get_disk_mock.return_value = disk_snmp_data
|
||||
actual_size = snmp.get_local_gb(iLOIp, snmp_credentials)
|
||||
expected_size = (572316/1024)
|
||||
expected_size = (572316 / 1024)
|
||||
self.assertEqual(actual_size, expected_size)
|
||||
get_disk_mock.assert_called_once_with(iLOIp, snmp_credentials)
|
||||
|
||||
|
@ -135,7 +135,7 @@ class IloClientInitTestCase(testtools.TestCase):
|
||||
ribcl_obj_mock.get_product_name.return_value = 'product'
|
||||
|
||||
c = client.IloClient.cls("1.2.3.4", "admin", "Admin",
|
||||
timeout=120, port=4430,
|
||||
timeout=120, port=4430,
|
||||
bios_password='foo',
|
||||
cacert='/somewhere')
|
||||
|
||||
@ -157,7 +157,7 @@ class IloClientInitTestCase(testtools.TestCase):
|
||||
ribcl_obj_mock.get_product_name.return_value = 'product'
|
||||
|
||||
c = client.IloClient.cls("FE80::9AF2:B3FF:FEEE:F884%eth0", "admin",
|
||||
"Admin", timeout=120, port=4430,
|
||||
"Admin", timeout=120, port=4430,
|
||||
bios_password='foo',
|
||||
cacert='/somewhere')
|
||||
|
||||
@ -182,7 +182,7 @@ class IloClientInitTestCase(testtools.TestCase):
|
||||
ribcl_obj_mock.get_product_name.return_value = 'product'
|
||||
|
||||
c = client.IloClient.cls("2001:0db8:85a3::8a2e:0370:7334", "admin",
|
||||
"Admin", timeout=120, port=4430,
|
||||
"Admin", timeout=120, port=4430,
|
||||
bios_password='foo',
|
||||
cacert='/somewhere')
|
||||
|
||||
@ -208,7 +208,7 @@ class IloClientInitTestCase(testtools.TestCase):
|
||||
ribcl_obj_mock.get_product_name.return_value = 'ProLiant DL180 Gen10'
|
||||
|
||||
c = client.IloClient.cls("1.2.3.4", "admin", "Admin",
|
||||
timeout=120, port=4430,
|
||||
timeout=120, port=4430,
|
||||
bios_password='foo',
|
||||
cacert='/somewhere')
|
||||
|
||||
@ -235,7 +235,7 @@ class IloClientInitTestCase(testtools.TestCase):
|
||||
exception.IloError('RIBCL is disabled'))
|
||||
|
||||
c = client.IloClient.cls("1.2.3.4", "admin", "Admin",
|
||||
timeout=120, port=4430,
|
||||
timeout=120, port=4430,
|
||||
bios_password='foo',
|
||||
cacert='/somewhere')
|
||||
|
||||
@ -258,7 +258,7 @@ class IloClientInitTestCase(testtools.TestCase):
|
||||
self, redfish_mock, ribcl_mock):
|
||||
|
||||
c = client.IloClient.cls("1.2.3.4", "admin", "Admin",
|
||||
timeout=120, port=4430,
|
||||
timeout=120, port=4430,
|
||||
bios_password='foo', cacert='/somewhere',
|
||||
use_redfish_only=True)
|
||||
ribcl_mock.assert_called_once_with(
|
||||
@ -290,7 +290,7 @@ class IloClientInitTestCase(testtools.TestCase):
|
||||
'snmp_inspection': 'true'}
|
||||
|
||||
c = client.IloClient.cls("1.2.3.4", "admin", "Admin",
|
||||
timeout=120, port=4430,
|
||||
timeout=120, port=4430,
|
||||
bios_password='foo',
|
||||
cacert='/somewhere',
|
||||
snmp_credentials=snmp_credentials)
|
||||
@ -321,7 +321,7 @@ class IloClientInitTestCase(testtools.TestCase):
|
||||
|
||||
self.assertRaises(exception.IloInvalidInputError, client.IloClient.cls,
|
||||
"1.2.3.4", "admin", "Admin",
|
||||
timeout=120, port=4430,
|
||||
timeout=120, port=4430,
|
||||
bios_password='foo',
|
||||
cacert='/somewhere',
|
||||
snmp_credentials=snmp_credentials)
|
||||
@ -1411,8 +1411,8 @@ class IloRedfishClientTestCase(testtools.TestCase):
|
||||
if redfish_method_name not in ('unset_iscsi_boot_info',
|
||||
'set_iscsi_boot_info'):
|
||||
self.assertTrue(eval(
|
||||
'self.redfish_mock.return_value.' +
|
||||
redfish_method_name).called)
|
||||
'self.redfish_mock.return_value.'
|
||||
+ redfish_method_name).called)
|
||||
validate_method_calls.no_test_cases += 1
|
||||
except TypeError:
|
||||
missed_ops.append(redfish_method_name)
|
||||
|
@ -338,9 +338,9 @@ def setup_fixture_create_fw_file_extracts_for(format):
|
||||
fw_files_dir = temp_dir
|
||||
elif format == 'rpm':
|
||||
fw_files_dir = os.path.join(
|
||||
temp_dir +
|
||||
'/please_remove_rpm_file_extracts/usr/lib/i386-linux-gnu/' +
|
||||
'hp-firmware-iloX-xxxx'
|
||||
temp_dir
|
||||
+ '/please_remove_rpm_file_extracts/usr/lib/i386-linux-gnu/'
|
||||
+ 'hp-firmware-iloX-xxxx'
|
||||
)
|
||||
else:
|
||||
fw_files_dir = temp_dir
|
||||
|
@ -236,14 +236,14 @@ class IloRibclTestCase(unittest.TestCase):
|
||||
self.assertRaises(
|
||||
exception.IloCommandNotSupportedError,
|
||||
self.ilo.get_http_boot_url
|
||||
)
|
||||
)
|
||||
|
||||
def test_set_http_boot_url(self):
|
||||
self.assertRaises(
|
||||
exception.IloCommandNotSupportedError,
|
||||
self.ilo.set_http_boot_url,
|
||||
'http://10.10.1.30:8081/startup.nsh'
|
||||
)
|
||||
)
|
||||
|
||||
@mock.patch.object(ribcl.RIBCLOperations, '_request_ilo')
|
||||
def test_reset_server(self, request_ilo_mock):
|
||||
@ -830,7 +830,7 @@ class IloRibclTestCase(unittest.TestCase):
|
||||
|
||||
root_xml_string = constants.UPDATE_ILO_FIRMWARE_INPUT_XML % (
|
||||
self.ilo.password, self.ilo.login, 12345, 'raw_fw_file.bin')
|
||||
root_xml_string = re.sub('\n\s*', '', root_xml_string)
|
||||
root_xml_string = re.sub(r"\n\s*", '', root_xml_string)
|
||||
|
||||
((ribcl_obj, xml_elem), the_ext_header_dict) = (
|
||||
_request_ilo_mock.call_args)
|
||||
@ -864,7 +864,7 @@ class IloRibclTestCase(unittest.TestCase):
|
||||
|
||||
root_xml_string = constants.UPDATE_NONILO_FIRMWARE_INPUT_XML % (
|
||||
self.ilo.password, self.ilo.login, 12345, 'raw_fw_file.bin')
|
||||
root_xml_string = re.sub('\n\s*', '', root_xml_string)
|
||||
root_xml_string = re.sub(r"\n\s*", '', root_xml_string)
|
||||
|
||||
((ribcl_obj, xml_elem), the_ext_header_dict) = (
|
||||
_request_ilo_mock.call_args)
|
||||
@ -1091,5 +1091,6 @@ class IloRibclTestCaseBeforeRisSupport(unittest.TestCase):
|
||||
'ProLiant DL380 G7',
|
||||
self.ilo.get_bios_settings_result)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
@ -76,7 +76,7 @@ class IloRisTestCase(testtools.TestCase):
|
||||
_uefi_boot_mode_mock.assert_called_once_with()
|
||||
self.assertEqual(
|
||||
'http://10.10.1.30:8081/startup.nsh', result['UefiShellStartupUrl']
|
||||
)
|
||||
)
|
||||
|
||||
@mock.patch.object(ris.RISOperations, '_change_bios_setting')
|
||||
@mock.patch.object(ris.RISOperations, '_is_boot_mode_uefi')
|
||||
@ -87,7 +87,7 @@ class IloRisTestCase(testtools.TestCase):
|
||||
_uefi_boot_mode_mock.assert_called_once_with()
|
||||
change_bios_setting_mock.assert_called_once_with({
|
||||
"UefiShellStartupUrl": "http://10.10.1.30:8081/startup.nsh"
|
||||
})
|
||||
})
|
||||
|
||||
@mock.patch.object(ris.RISOperations, '_is_boot_mode_uefi')
|
||||
def test_get_http_boot_url_bios(self, _uefi_boot_mode_mock):
|
||||
@ -1807,7 +1807,7 @@ class TestRISOperationsPrivateMethods(testtools.TestCase):
|
||||
'12:44:6a:3b:04:11', '13:44:6a:3b:04:13']
|
||||
self.assertRaisesRegex(
|
||||
exception.InvalidInputError,
|
||||
"Given macs: \['12:44:6A:3B:04:15'\] not found in the system",
|
||||
r"Given macs: \['12:44:6A:3B:04:15'\] not found in the system",
|
||||
self.client._validate_macs, ['12:44:6A:3B:04:15'])
|
||||
|
||||
@mock.patch.object(ris.RISOperations, '_get_collection')
|
||||
@ -1883,7 +1883,7 @@ class TestRISOperationsPrivateMethods(testtools.TestCase):
|
||||
validate_macs_mock.side_effect = exception.InvalidInputError(msg)
|
||||
self.assertRaisesRegex(
|
||||
exception.InvalidInputError,
|
||||
"Given macs: \['12:44:6A:3B:04:15'\] not found in the system",
|
||||
r"Given macs: \['12:44:6A:3B:04:15'\] not found in the system",
|
||||
self.client._change_iscsi_settings, {}, ['12:44:6A:3B:04:15'])
|
||||
|
||||
@mock.patch.object(ris.RISOperations, '_check_iscsi_rest_patch_allowed')
|
||||
|
@ -1175,7 +1175,6 @@ class HPESystemTestCase(testtools.TestCase):
|
||||
'12:44:6a:3b:04:11', '13:44:6a:3b:04:13']
|
||||
self.assertRaisesRegex(
|
||||
exception.InvalidInputError,
|
||||
"Given macs: \['14:23:AD:3B:4C:78'\] "
|
||||
"not found in the system",
|
||||
r"Given macs: \['14:23:AD:3B:4C:78'\] not found in the system",
|
||||
self.sys_inst.validate_macs,
|
||||
['12:44:6a:3b:04:11', '14:23:AD:3B:4C:78'])
|
||||
|
@ -1340,7 +1340,7 @@ class RedfishOperationsTestCase(testtools.TestCase):
|
||||
exception.InvalidInputError(msg))
|
||||
self.assertRaisesRegex(
|
||||
exception.InvalidInputError,
|
||||
"Given macs: \['12:44:6A:3B:04:15'\] not found in the system",
|
||||
r"Given macs: \['12:44:6A:3B:04:15'\] not found in the system",
|
||||
self.rf_client._change_iscsi_target_settings, {},
|
||||
['12:44:6A:3B:04:15'])
|
||||
|
||||
|
@ -61,7 +61,7 @@ class SUMFirmwareUpdateTest(testtools.TestCase):
|
||||
'Summary': ("The smart component was installed successfully."
|
||||
" Status of updated components: Total: 2 Success: 2 "
|
||||
"Failed: 0.")
|
||||
}
|
||||
}
|
||||
|
||||
stdout = sum_controller._execute_sum("hpsum", "/tmp/hpsum",
|
||||
components=None)
|
||||
@ -103,7 +103,7 @@ class SUMFirmwareUpdateTest(testtools.TestCase):
|
||||
'Summary': ("The installation of the component failed. Status "
|
||||
"of updated components: Total: 2 Success: 1 "
|
||||
"Failed: 1.")
|
||||
}
|
||||
}
|
||||
value = ("hpsum_service_x64 started successfully. Sending Shutdown "
|
||||
"request to engine. Successfully shutdown the service.")
|
||||
execute_mock.side_effect = processutils.ProcessExecutionError(
|
||||
|
@ -58,7 +58,7 @@ def process_firmware_image(compact_firmware_file, ilo_object):
|
||||
# to be on a http store, and hence requires the upload to happen for the
|
||||
# firmware file.
|
||||
to_upload = False
|
||||
m = re.search('Gen(\d+)', ilo_object.model)
|
||||
m = re.search(r"Gen(\d+)", ilo_object.model)
|
||||
if int(m.group(1)) > 8:
|
||||
to_upload = True
|
||||
|
||||
@ -136,24 +136,24 @@ def verify_image_checksum(image_location, expected_checksum):
|
||||
|
||||
|
||||
def validate_href(image_href):
|
||||
"""Validate HTTP image reference.
|
||||
"""Validate HTTP image reference.
|
||||
|
||||
:param image_href: Image reference.
|
||||
:raises: exception.ImageRefValidationFailed if HEAD request failed or
|
||||
returned response code not equal to 200.
|
||||
:returns: Response to HEAD request.
|
||||
"""
|
||||
try:
|
||||
response = requests.head(image_href)
|
||||
if response.status_code != http_client.OK:
|
||||
raise exception.ImageRefValidationFailed(
|
||||
image_href=image_href,
|
||||
reason=("Got HTTP code %s instead of 200 in response to "
|
||||
"HEAD request." % response.status_code))
|
||||
except requests.RequestException as e:
|
||||
raise exception.ImageRefValidationFailed(image_href=image_href,
|
||||
reason=e)
|
||||
return response
|
||||
:param image_href: Image reference.
|
||||
:raises: exception.ImageRefValidationFailed if HEAD request failed or
|
||||
returned response code not equal to 200.
|
||||
:returns: Response to HEAD request.
|
||||
"""
|
||||
try:
|
||||
response = requests.head(image_href)
|
||||
if response.status_code != http_client.OK:
|
||||
raise exception.ImageRefValidationFailed(
|
||||
image_href=image_href,
|
||||
reason=("Got HTTP code %s instead of 200 in response to |