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