Call execute from ironic-lib in hardware.py
Replace the execute wrapper from utils with execute from ironic-lib in hardware.py Adjust unit tests as needed. Change-Id: I63a3b0407b2ca2246bd0e6624bfa0f748c0d73f7
This commit is contained in:
parent
36d4a18fbc
commit
7b03fbbb36
@ -103,7 +103,7 @@ def _get_system_lshw_dict():
|
|||||||
|
|
||||||
:return: A python dict from the lshw json output
|
:return: A python dict from the lshw json output
|
||||||
"""
|
"""
|
||||||
out, _e = utils.execute('lshw', '-quiet', '-json', log_stdout=False)
|
out, _e = il_utils.execute('lshw', '-quiet', '-json', log_stdout=False)
|
||||||
out = json.loads(out)
|
out = json.loads(out)
|
||||||
# Depending on lshw version, output might be a list, starting with
|
# Depending on lshw version, output might be a list, starting with
|
||||||
# https://github.com/lyonel/lshw/commit/135a853c60582b14c5b67e5cd988a8062d9896f4 # noqa
|
# https://github.com/lyonel/lshw/commit/135a853c60582b14c5b67e5cd988a8062d9896f4 # noqa
|
||||||
@ -120,7 +120,7 @@ def _udev_settle():
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
utils.execute('udevadm', 'settle')
|
il_utils.execute('udevadm', 'settle')
|
||||||
except processutils.ProcessExecutionError as e:
|
except processutils.ProcessExecutionError as e:
|
||||||
LOG.warning('Something went wrong when waiting for udev '
|
LOG.warning('Something went wrong when waiting for udev '
|
||||||
'to settle. Error: %s', e)
|
'to settle. Error: %s', e)
|
||||||
@ -147,13 +147,13 @@ def _check_for_iscsi():
|
|||||||
- If no connection is detected we simply return.
|
- If no connection is detected we simply return.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
utils.execute('iscsistart', '-f')
|
il_utils.execute('iscsistart', '-f')
|
||||||
except (processutils.ProcessExecutionError, EnvironmentError) as e:
|
except (processutils.ProcessExecutionError, EnvironmentError) as e:
|
||||||
LOG.debug("No iscsi connection detected. Skipping iscsi. "
|
LOG.debug("No iscsi connection detected. Skipping iscsi. "
|
||||||
"Error: %s", e)
|
"Error: %s", e)
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
utils.execute('iscsistart', '-b')
|
il_utils.execute('iscsistart', '-b')
|
||||||
except processutils.ProcessExecutionError as e:
|
except processutils.ProcessExecutionError as e:
|
||||||
LOG.warning("Something went wrong executing 'iscsistart -b' "
|
LOG.warning("Something went wrong executing 'iscsistart -b' "
|
||||||
"Error: %s", e)
|
"Error: %s", e)
|
||||||
@ -166,8 +166,8 @@ def _get_md_uuid(raid_device):
|
|||||||
:returns: A string containing the UUID of an md device.
|
:returns: A string containing the UUID of an md device.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
out, _ = utils.execute('mdadm', '--detail', raid_device,
|
out, _ = il_utils.execute('mdadm', '--detail', raid_device,
|
||||||
use_standard_locale=True)
|
use_standard_locale=True)
|
||||||
except processutils.ProcessExecutionError as e:
|
except processutils.ProcessExecutionError as e:
|
||||||
LOG.warning('Could not get the details of %(dev)s: %(err)s',
|
LOG.warning('Could not get the details of %(dev)s: %(err)s',
|
||||||
{'dev': raid_device, 'err': e})
|
{'dev': raid_device, 'err': e})
|
||||||
@ -205,8 +205,8 @@ def _get_component_devices(raid_device):
|
|||||||
ignore_raid=True))
|
ignore_raid=True))
|
||||||
for bdev in block_devices:
|
for bdev in block_devices:
|
||||||
try:
|
try:
|
||||||
out, _ = utils.execute('mdadm', '--examine', bdev.name,
|
out, _ = il_utils.execute('mdadm', '--examine', bdev.name,
|
||||||
use_standard_locale=True)
|
use_standard_locale=True)
|
||||||
except processutils.ProcessExecutionError as e:
|
except processutils.ProcessExecutionError as e:
|
||||||
if "No md superblock detected" in str(e):
|
if "No md superblock detected" in str(e):
|
||||||
# actually not a component device
|
# actually not a component device
|
||||||
@ -259,8 +259,8 @@ def get_holder_disks(raid_device):
|
|||||||
return []
|
return []
|
||||||
|
|
||||||
try:
|
try:
|
||||||
out, _ = utils.execute('mdadm', '--detail', raid_device,
|
out, _ = il_utils.execute('mdadm', '--detail', raid_device,
|
||||||
use_standard_locale=True)
|
use_standard_locale=True)
|
||||||
except processutils.ProcessExecutionError as e:
|
except processutils.ProcessExecutionError as e:
|
||||||
LOG.warning('Could not get holder disks of %(dev)s: %(err)s',
|
LOG.warning('Could not get holder disks of %(dev)s: %(err)s',
|
||||||
{'dev': raid_device, 'err': e})
|
{'dev': raid_device, 'err': e})
|
||||||
@ -303,7 +303,7 @@ def is_md_device(raid_device):
|
|||||||
:returns: True if the device is an md device, False otherwise.
|
:returns: True if the device is an md device, False otherwise.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
utils.execute('mdadm', '--detail', raid_device)
|
il_utils.execute('mdadm', '--detail', raid_device)
|
||||||
LOG.debug("%s is an md device", raid_device)
|
LOG.debug("%s is an md device", raid_device)
|
||||||
return True
|
return True
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
@ -326,9 +326,9 @@ def md_restart(raid_device):
|
|||||||
try:
|
try:
|
||||||
LOG.debug('Restarting software RAID device %s', raid_device)
|
LOG.debug('Restarting software RAID device %s', raid_device)
|
||||||
component_devices = _get_component_devices(raid_device)
|
component_devices = _get_component_devices(raid_device)
|
||||||
utils.execute('mdadm', '--stop', raid_device)
|
il_utils.execute('mdadm', '--stop', raid_device)
|
||||||
utils.execute('mdadm', '--assemble', raid_device,
|
il_utils.execute('mdadm', '--assemble', raid_device,
|
||||||
*component_devices)
|
*component_devices)
|
||||||
except processutils.ProcessExecutionError as e:
|
except processutils.ProcessExecutionError as e:
|
||||||
error_msg = ('Could not restart md device %(dev)s: %(err)s' %
|
error_msg = ('Could not restart md device %(dev)s: %(err)s' %
|
||||||
{'dev': raid_device, 'err': e})
|
{'dev': raid_device, 'err': e})
|
||||||
@ -342,7 +342,7 @@ def md_get_raid_devices():
|
|||||||
:return: A python dict containing details about the discovered RAID
|
:return: A python dict containing details about the discovered RAID
|
||||||
devices
|
devices
|
||||||
"""
|
"""
|
||||||
report = utils.execute('mdadm', '--examine', '--scan')[0]
|
report = il_utils.execute('mdadm', '--examine', '--scan')[0]
|
||||||
lines = report.splitlines()
|
lines = report.splitlines()
|
||||||
result = {}
|
result = {}
|
||||||
for line in lines:
|
for line in lines:
|
||||||
@ -360,7 +360,7 @@ def _md_scan_and_assemble():
|
|||||||
This call does not fail if no md devices are present.
|
This call does not fail if no md devices are present.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
utils.execute('mdadm', '--assemble', '--scan', '--verbose')
|
il_utils.execute('mdadm', '--assemble', '--scan', '--verbose')
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
LOG.warning('mdadm has not been found, RAID devices will not be '
|
LOG.warning('mdadm has not been found, RAID devices will not be '
|
||||||
'supported')
|
'supported')
|
||||||
@ -424,8 +424,8 @@ def list_all_block_devices(block_type='disk',
|
|||||||
"Cause: %(error)s", {'path': disk_by_path_dir, 'error': e})
|
"Cause: %(error)s", {'path': disk_by_path_dir, 'error': e})
|
||||||
|
|
||||||
columns = utils.LSBLK_COLUMNS
|
columns = utils.LSBLK_COLUMNS
|
||||||
report = utils.execute('lsblk', '-Pbia',
|
report = il_utils.execute('lsblk', '-Pbia',
|
||||||
'-o{}'.format(','.join(columns)))[0]
|
'-o{}'.format(','.join(columns)))[0]
|
||||||
lines = report.splitlines()
|
lines = report.splitlines()
|
||||||
context = pyudev.Context()
|
context = pyudev.Context()
|
||||||
|
|
||||||
@ -1087,8 +1087,7 @@ class GenericHardwareManager(HardwareManager):
|
|||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
stdout, _ = utils.execute('biosdevname', '-i',
|
stdout, _ = il_utils.execute('biosdevname', '-i', interface_name)
|
||||||
interface_name)
|
|
||||||
return stdout.rstrip('\n')
|
return stdout.rstrip('\n')
|
||||||
except OSError:
|
except OSError:
|
||||||
if not WARN_BIOSDEVNAME_NOT_FOUND:
|
if not WARN_BIOSDEVNAME_NOT_FOUND:
|
||||||
@ -1150,7 +1149,7 @@ class GenericHardwareManager(HardwareManager):
|
|||||||
return network_interfaces_list
|
return network_interfaces_list
|
||||||
|
|
||||||
def get_cpus(self):
|
def get_cpus(self):
|
||||||
lines = utils.execute('lscpu')[0]
|
lines = il_utils.execute('lscpu')[0]
|
||||||
cpu_info = {k.strip().lower(): v.strip() for k, v in
|
cpu_info = {k.strip().lower(): v.strip() for k, v in
|
||||||
(line.split(':', 1)
|
(line.split(':', 1)
|
||||||
for line in lines.split('\n')
|
for line in lines.split('\n')
|
||||||
@ -1469,7 +1468,7 @@ class GenericHardwareManager(HardwareManager):
|
|||||||
args += ('--verbose', '--iterations', str(npasses), block_device.name)
|
args += ('--verbose', '--iterations', str(npasses), block_device.name)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
utils.execute(*args)
|
il_utils.execute(*args)
|
||||||
except (processutils.ProcessExecutionError, OSError) as e:
|
except (processutils.ProcessExecutionError, OSError) as e:
|
||||||
LOG.error("Erasing block device %(dev)s failed with error %(err)s",
|
LOG.error("Erasing block device %(dev)s failed with error %(err)s",
|
||||||
{'dev': block_device.name, 'err': e})
|
{'dev': block_device.name, 'err': e})
|
||||||
@ -1502,8 +1501,8 @@ class GenericHardwareManager(HardwareManager):
|
|||||||
try:
|
try:
|
||||||
# Don't use the '--nodeps' of lsblk to also catch the
|
# Don't use the '--nodeps' of lsblk to also catch the
|
||||||
# parent device of partitions which are RAID members.
|
# parent device of partitions which are RAID members.
|
||||||
out, _ = utils.execute('lsblk', '--fs', '--noheadings',
|
out, _ = il_utils.execute('lsblk', '--fs', '--noheadings',
|
||||||
block_device.name)
|
block_device.name)
|
||||||
except processutils.ProcessExecutionError as e:
|
except processutils.ProcessExecutionError as e:
|
||||||
LOG.warning("Could not determine if %(name)s is a RAID member: "
|
LOG.warning("Could not determine if %(name)s is a RAID member: "
|
||||||
"%(err)s",
|
"%(err)s",
|
||||||
@ -1544,7 +1543,7 @@ class GenericHardwareManager(HardwareManager):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def _get_ata_security_lines(self, block_device):
|
def _get_ata_security_lines(self, block_device):
|
||||||
output = utils.execute('hdparm', '-I', block_device.name)[0]
|
output = il_utils.execute('hdparm', '-I', block_device.name)[0]
|
||||||
|
|
||||||
if '\nSecurity: ' not in output:
|
if '\nSecurity: ' not in output:
|
||||||
return []
|
return []
|
||||||
@ -1577,9 +1576,9 @@ class GenericHardwareManager(HardwareManager):
|
|||||||
# instead of `scsi` or `sat` as smartctl will not be able to read
|
# instead of `scsi` or `sat` as smartctl will not be able to read
|
||||||
# a bridged device that it doesn't understand, and accordingly
|
# a bridged device that it doesn't understand, and accordingly
|
||||||
# return an error code.
|
# return an error code.
|
||||||
output = utils.execute('smartctl', '-d', 'ata', block_device.name,
|
output = il_utils.execute('smartctl', '-d', 'ata',
|
||||||
'-g', 'security',
|
block_device.name, '-g', 'security',
|
||||||
check_exit_code=[0, 127])[0]
|
check_exit_code=[0, 127])[0]
|
||||||
if 'Unavailable' in output:
|
if 'Unavailable' in output:
|
||||||
# Smartctl is reporting it is unavailable, lets return false.
|
# Smartctl is reporting it is unavailable, lets return false.
|
||||||
LOG.debug('Smartctl has reported that security is '
|
LOG.debug('Smartctl has reported that security is '
|
||||||
@ -1612,9 +1611,9 @@ class GenericHardwareManager(HardwareManager):
|
|||||||
if 'not locked' in security_lines:
|
if 'not locked' in security_lines:
|
||||||
break
|
break
|
||||||
try:
|
try:
|
||||||
utils.execute('hdparm', '--user-master', 'u',
|
il_utils.execute('hdparm', '--user-master', 'u',
|
||||||
'--security-unlock', password,
|
'--security-unlock', password,
|
||||||
block_device.name)
|
block_device.name)
|
||||||
except processutils.ProcessExecutionError as e:
|
except processutils.ProcessExecutionError as e:
|
||||||
LOG.info('Security unlock failed for device '
|
LOG.info('Security unlock failed for device '
|
||||||
'%(name)s using password "%(password)s": %(err)s',
|
'%(name)s using password "%(password)s": %(err)s',
|
||||||
@ -1660,8 +1659,9 @@ class GenericHardwareManager(HardwareManager):
|
|||||||
# SEC1. Try to transition to SEC5 by setting empty user
|
# SEC1. Try to transition to SEC5 by setting empty user
|
||||||
# password.
|
# password.
|
||||||
try:
|
try:
|
||||||
utils.execute('hdparm', '--user-master', 'u',
|
il_utils.execute('hdparm', '--user-master', 'u',
|
||||||
'--security-set-pass', 'NULL', block_device.name)
|
'--security-set-pass', 'NULL',
|
||||||
|
block_device.name)
|
||||||
except processutils.ProcessExecutionError as e:
|
except processutils.ProcessExecutionError as e:
|
||||||
error_msg = ('Security password set failed for device '
|
error_msg = ('Security password set failed for device '
|
||||||
'{name}: {err}'
|
'{name}: {err}'
|
||||||
@ -1674,8 +1674,8 @@ class GenericHardwareManager(HardwareManager):
|
|||||||
erase_option += '-enhanced'
|
erase_option += '-enhanced'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
utils.execute('hdparm', '--user-master', 'u', erase_option,
|
il_utils.execute('hdparm', '--user-master', 'u', erase_option,
|
||||||
'NULL', block_device.name)
|
'NULL', block_device.name)
|
||||||
except processutils.ProcessExecutionError as e:
|
except processutils.ProcessExecutionError as e:
|
||||||
# NOTE(TheJulia): Attempt unlock to allow fallback to shred
|
# NOTE(TheJulia): Attempt unlock to allow fallback to shred
|
||||||
# to occur, otherwise shred will fail as well, as the security
|
# to occur, otherwise shred will fail as well, as the security
|
||||||
@ -1720,8 +1720,8 @@ class GenericHardwareManager(HardwareManager):
|
|||||||
try:
|
try:
|
||||||
LOG.debug("Attempting to fetch NVMe capabilities for device %s",
|
LOG.debug("Attempting to fetch NVMe capabilities for device %s",
|
||||||
block_device.name)
|
block_device.name)
|
||||||
nvme_info, _e = utils.execute('nvme', 'id-ctrl',
|
nvme_info, _e = il_utils.execute('nvme', 'id-ctrl',
|
||||||
block_device.name, '-o', 'json')
|
block_device.name, '-o', 'json')
|
||||||
nvme_info = json.loads(nvme_info)
|
nvme_info = json.loads(nvme_info)
|
||||||
|
|
||||||
except processutils.ProcessExecutionError as e:
|
except processutils.ProcessExecutionError as e:
|
||||||
@ -1763,8 +1763,8 @@ class GenericHardwareManager(HardwareManager):
|
|||||||
try:
|
try:
|
||||||
LOG.debug("Attempting to nvme-format %s using secure format mode "
|
LOG.debug("Attempting to nvme-format %s using secure format mode "
|
||||||
"(ses) %s", block_device.name, format_mode)
|
"(ses) %s", block_device.name, format_mode)
|
||||||
utils.execute('nvme', 'format', block_device.name, '-s',
|
il_utils.execute('nvme', 'format', block_device.name, '-s',
|
||||||
format_mode, '-f')
|
format_mode, '-f')
|
||||||
LOG.info("nvme-cli format for device %s (ses= %s ) completed "
|
LOG.info("nvme-cli format for device %s (ses= %s ) completed "
|
||||||
"successfully.", block_device.name, format_mode)
|
"successfully.", block_device.name, format_mode)
|
||||||
return True
|
return True
|
||||||
@ -1785,7 +1785,7 @@ class GenericHardwareManager(HardwareManager):
|
|||||||
# different types of communication media and protocols and
|
# different types of communication media and protocols and
|
||||||
# effectively used
|
# effectively used
|
||||||
for channel in range(1, 12):
|
for channel in range(1, 12):
|
||||||
out, e = utils.execute(
|
out, e = il_utils.execute(
|
||||||
"ipmitool lan print {} | awk '/IP Address[ \\t]*:/"
|
"ipmitool lan print {} | awk '/IP Address[ \\t]*:/"
|
||||||
" {{print $4}}'".format(channel), shell=True)
|
" {{print $4}}'".format(channel), shell=True)
|
||||||
if e.startswith("Invalid channel"):
|
if e.startswith("Invalid channel"):
|
||||||
@ -1822,7 +1822,7 @@ class GenericHardwareManager(HardwareManager):
|
|||||||
# different types of communication media and protocols and
|
# different types of communication media and protocols and
|
||||||
# effectively used
|
# effectively used
|
||||||
for channel in range(1, 12):
|
for channel in range(1, 12):
|
||||||
out, e = utils.execute(
|
out, e = il_utils.execute(
|
||||||
"ipmitool lan print {} | awk '/(IP|MAC) Address[ \\t]*:/"
|
"ipmitool lan print {} | awk '/(IP|MAC) Address[ \\t]*:/"
|
||||||
" {{print $4}}'".format(channel), shell=True)
|
" {{print $4}}'".format(channel), shell=True)
|
||||||
if e.startswith("Invalid channel"):
|
if e.startswith("Invalid channel"):
|
||||||
@ -1870,7 +1870,7 @@ class GenericHardwareManager(HardwareManager):
|
|||||||
cmd = "ipmitool lan6 print {} {}_addr".format(
|
cmd = "ipmitool lan6 print {} {}_addr".format(
|
||||||
channel, 'dynamic' if dynamic else 'static')
|
channel, 'dynamic' if dynamic else 'static')
|
||||||
try:
|
try:
|
||||||
out, exc = utils.execute(cmd, shell=True)
|
out, exc = il_utils.execute(cmd, shell=True)
|
||||||
except processutils.ProcessExecutionError:
|
except processutils.ProcessExecutionError:
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -1900,7 +1900,7 @@ class GenericHardwareManager(HardwareManager):
|
|||||||
# different types of communication media and protocols and
|
# different types of communication media and protocols and
|
||||||
# effectively used
|
# effectively used
|
||||||
for channel in range(1, 12):
|
for channel in range(1, 12):
|
||||||
addr_mode, e = utils.execute(
|
addr_mode, e = il_utils.execute(
|
||||||
r"ipmitool lan6 print {} enables | "
|
r"ipmitool lan6 print {} enables | "
|
||||||
r"awk '/IPv6\/IPv4 Addressing Enables[ \t]*:/"
|
r"awk '/IPv6\/IPv4 Addressing Enables[ \t]*:/"
|
||||||
r"{{print $NF}}'".format(channel), shell=True)
|
r"{{print $NF}}'".format(channel), shell=True)
|
||||||
@ -2149,9 +2149,11 @@ class GenericHardwareManager(HardwareManager):
|
|||||||
LOG.debug("Creating partition on %(dev)s: %(str)s %(end)s",
|
LOG.debug("Creating partition on %(dev)s: %(str)s %(end)s",
|
||||||
{'dev': device, 'str': start_str,
|
{'dev': device, 'str': start_str,
|
||||||
'end': end_str})
|
'end': end_str})
|
||||||
utils.execute('parted', device, '-s', '-a',
|
|
||||||
'optimal', '--', 'mkpart', 'primary',
|
il_utils.execute('parted', device, '-s', '-a',
|
||||||
start_str, end_str)
|
'optimal', '--', 'mkpart', 'primary',
|
||||||
|
start_str, end_str)
|
||||||
|
|
||||||
except processutils.ProcessExecutionError as e:
|
except processutils.ProcessExecutionError as e:
|
||||||
msg = "Failed to create partitions on {}: {}".format(
|
msg = "Failed to create partitions on {}: {}".format(
|
||||||
device, e)
|
device, e)
|
||||||
@ -2185,8 +2187,8 @@ class GenericHardwareManager(HardwareManager):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def _scan_raids():
|
def _scan_raids():
|
||||||
utils.execute('mdadm', '--assemble', '--scan',
|
il_utils.execute('mdadm', '--assemble', '--scan',
|
||||||
check_exit_code=False)
|
check_exit_code=False)
|
||||||
raid_devices = list_all_block_devices(block_type='raid',
|
raid_devices = list_all_block_devices(block_type='raid',
|
||||||
ignore_raid=False,
|
ignore_raid=False,
|
||||||
ignore_empty=False)
|
ignore_empty=False)
|
||||||
@ -2236,12 +2238,12 @@ class GenericHardwareManager(HardwareManager):
|
|||||||
|
|
||||||
# Remove md devices.
|
# Remove md devices.
|
||||||
try:
|
try:
|
||||||
utils.execute('wipefs', '-af', raid_device.name)
|
il_utils.execute('wipefs', '-af', raid_device.name)
|
||||||
except processutils.ProcessExecutionError as e:
|
except processutils.ProcessExecutionError as e:
|
||||||
LOG.warning('Failed to wipefs %(device)s: %(err)s',
|
LOG.warning('Failed to wipefs %(device)s: %(err)s',
|
||||||
{'device': raid_device.name, 'err': e})
|
{'device': raid_device.name, 'err': e})
|
||||||
try:
|
try:
|
||||||
utils.execute('mdadm', '--stop', raid_device.name)
|
il_utils.execute('mdadm', '--stop', raid_device.name)
|
||||||
except processutils.ProcessExecutionError as e:
|
except processutils.ProcessExecutionError as e:
|
||||||
LOG.warning('Failed to stop %(device)s: %(err)s',
|
LOG.warning('Failed to stop %(device)s: %(err)s',
|
||||||
{'device': raid_device.name, 'err': e})
|
{'device': raid_device.name, 'err': e})
|
||||||
@ -2249,8 +2251,8 @@ class GenericHardwareManager(HardwareManager):
|
|||||||
# Remove md metadata from component devices.
|
# Remove md metadata from component devices.
|
||||||
for component_device in component_devices:
|
for component_device in component_devices:
|
||||||
try:
|
try:
|
||||||
utils.execute('mdadm', '--examine', component_device,
|
il_utils.execute('mdadm', '--examine', component_device,
|
||||||
use_standard_locale=True)
|
use_standard_locale=True)
|
||||||
except processutils.ProcessExecutionError as e:
|
except processutils.ProcessExecutionError as e:
|
||||||
if "No md superblock detected" in str(e):
|
if "No md superblock detected" in str(e):
|
||||||
# actually not a component device
|
# actually not a component device
|
||||||
@ -2262,8 +2264,8 @@ class GenericHardwareManager(HardwareManager):
|
|||||||
|
|
||||||
LOG.debug('Deleting md superblock on %s', component_device)
|
LOG.debug('Deleting md superblock on %s', component_device)
|
||||||
try:
|
try:
|
||||||
utils.execute('mdadm', '--zero-superblock',
|
il_utils.execute('mdadm', '--zero-superblock',
|
||||||
component_device)
|
component_device)
|
||||||
except processutils.ProcessExecutionError as e:
|
except processutils.ProcessExecutionError as e:
|
||||||
LOG.warning('Failed to remove superblock from'
|
LOG.warning('Failed to remove superblock from'
|
||||||
'%(device)s: %(err)s',
|
'%(device)s: %(err)s',
|
||||||
@ -2302,8 +2304,8 @@ class GenericHardwareManager(HardwareManager):
|
|||||||
all_blks = reversed(self.list_block_devices(include_partitions=True))
|
all_blks = reversed(self.list_block_devices(include_partitions=True))
|
||||||
for blk in all_blks:
|
for blk in all_blks:
|
||||||
try:
|
try:
|
||||||
utils.execute('mdadm', '--examine', blk.name,
|
il_utils.execute('mdadm', '--examine', blk.name,
|
||||||
use_standard_locale=True)
|
use_standard_locale=True)
|
||||||
except processutils.ProcessExecutionError as e:
|
except processutils.ProcessExecutionError as e:
|
||||||
if "No md superblock detected" in str(e):
|
if "No md superblock detected" in str(e):
|
||||||
# actually not a component device
|
# actually not a component device
|
||||||
@ -2313,7 +2315,7 @@ class GenericHardwareManager(HardwareManager):
|
|||||||
{'name': blk.name, 'err': e})
|
{'name': blk.name, 'err': e})
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
utils.execute('mdadm', '--zero-superblock', blk.name)
|
il_utils.execute('mdadm', '--zero-superblock', blk.name)
|
||||||
except processutils.ProcessExecutionError as e:
|
except processutils.ProcessExecutionError as e:
|
||||||
LOG.warning('Failed to remove superblock from'
|
LOG.warning('Failed to remove superblock from'
|
||||||
'%(device)s: %(err)s',
|
'%(device)s: %(err)s',
|
||||||
@ -2325,7 +2327,7 @@ class GenericHardwareManager(HardwareManager):
|
|||||||
for holder_disk in all_holder_disks_uniq:
|
for holder_disk in all_holder_disks_uniq:
|
||||||
LOG.info('Removing partitions on holder disk %s', holder_disk)
|
LOG.info('Removing partitions on holder disk %s', holder_disk)
|
||||||
try:
|
try:
|
||||||
utils.execute('wipefs', '-af', holder_disk)
|
il_utils.execute('wipefs', '-af', holder_disk)
|
||||||
except processutils.ProcessExecutionError as e:
|
except processutils.ProcessExecutionError as e:
|
||||||
LOG.warning('Failed to remove partitions on %s: %s',
|
LOG.warning('Failed to remove partitions on %s: %s',
|
||||||
holder_disk, e)
|
holder_disk, e)
|
||||||
|
@ -253,7 +253,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
@mock.patch('os.listdir', autospec=True)
|
@mock.patch('os.listdir', autospec=True)
|
||||||
@mock.patch('os.path.exists', autospec=True)
|
@mock.patch('os.path.exists', autospec=True)
|
||||||
@mock.patch('builtins.open', autospec=True)
|
@mock.patch('builtins.open', autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
@mock.patch.object(netutils, 'get_mac_addr', autospec=True)
|
@mock.patch.object(netutils, 'get_mac_addr', autospec=True)
|
||||||
@mock.patch.object(netutils, 'interface_has_carrier', autospec=True)
|
@mock.patch.object(netutils, 'interface_has_carrier', autospec=True)
|
||||||
def test_list_network_interfaces(self,
|
def test_list_network_interfaces(self,
|
||||||
@ -297,7 +297,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
@mock.patch('os.listdir', autospec=True)
|
@mock.patch('os.listdir', autospec=True)
|
||||||
@mock.patch('os.path.exists', autospec=True)
|
@mock.patch('os.path.exists', autospec=True)
|
||||||
@mock.patch('builtins.open', autospec=True)
|
@mock.patch('builtins.open', autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
@mock.patch.object(netutils, 'get_mac_addr', autospec=True)
|
@mock.patch.object(netutils, 'get_mac_addr', autospec=True)
|
||||||
@mock.patch.object(netutils, 'interface_has_carrier', autospec=True)
|
@mock.patch.object(netutils, 'interface_has_carrier', autospec=True)
|
||||||
def test_list_network_interfaces_with_biosdevname(self,
|
def test_list_network_interfaces_with_biosdevname(self,
|
||||||
@ -333,7 +333,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
self.assertTrue(interfaces[0].has_carrier)
|
self.assertTrue(interfaces[0].has_carrier)
|
||||||
self.assertEqual('em0', interfaces[0].biosdevname)
|
self.assertEqual('em0', interfaces[0].biosdevname)
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_get_bios_given_nic_name_ok(self, mock_execute):
|
def test_get_bios_given_nic_name_ok(self, mock_execute):
|
||||||
interface_name = 'eth0'
|
interface_name = 'eth0'
|
||||||
mock_execute.return_value = ('em0\n', '')
|
mock_execute.return_value = ('em0\n', '')
|
||||||
@ -342,7 +342,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
mock_execute.assert_called_once_with('biosdevname', '-i',
|
mock_execute.assert_called_once_with('biosdevname', '-i',
|
||||||
interface_name)
|
interface_name)
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_get_bios_given_nic_name_oserror(self, mock_execute):
|
def test_get_bios_given_nic_name_oserror(self, mock_execute):
|
||||||
interface_name = 'eth0'
|
interface_name = 'eth0'
|
||||||
mock_execute.side_effect = OSError()
|
mock_execute.side_effect = OSError()
|
||||||
@ -351,7 +351,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
mock_execute.assert_called_once_with('biosdevname', '-i',
|
mock_execute.assert_called_once_with('biosdevname', '-i',
|
||||||
interface_name)
|
interface_name)
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
@mock.patch.object(hardware, 'LOG', autospec=True)
|
@mock.patch.object(hardware, 'LOG', autospec=True)
|
||||||
def test_get_bios_given_nic_name_process_exec_err4(self, mock_log,
|
def test_get_bios_given_nic_name_process_exec_err4(self, mock_log,
|
||||||
mock_execute):
|
mock_execute):
|
||||||
@ -368,7 +368,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
mock_execute.assert_called_once_with('biosdevname', '-i',
|
mock_execute.assert_called_once_with('biosdevname', '-i',
|
||||||
interface_name)
|
interface_name)
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
@mock.patch.object(hardware, 'LOG', autospec=True)
|
@mock.patch.object(hardware, 'LOG', autospec=True)
|
||||||
def test_get_bios_given_nic_name_process_exec_err3(self, mock_log,
|
def test_get_bios_given_nic_name_process_exec_err3(self, mock_log,
|
||||||
mock_execute):
|
mock_execute):
|
||||||
@ -390,7 +390,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
@mock.patch('os.listdir', autospec=True)
|
@mock.patch('os.listdir', autospec=True)
|
||||||
@mock.patch('os.path.exists', autospec=True)
|
@mock.patch('os.path.exists', autospec=True)
|
||||||
@mock.patch('builtins.open', autospec=True)
|
@mock.patch('builtins.open', autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
@mock.patch.object(netutils, 'get_mac_addr', autospec=True)
|
@mock.patch.object(netutils, 'get_mac_addr', autospec=True)
|
||||||
@mock.patch.object(netutils, 'interface_has_carrier', autospec=True)
|
@mock.patch.object(netutils, 'interface_has_carrier', autospec=True)
|
||||||
def test_list_network_interfaces_with_lldp(self,
|
def test_list_network_interfaces_with_lldp(self,
|
||||||
@ -448,7 +448,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
@mock.patch('os.listdir', autospec=True)
|
@mock.patch('os.listdir', autospec=True)
|
||||||
@mock.patch('os.path.exists', autospec=True)
|
@mock.patch('os.path.exists', autospec=True)
|
||||||
@mock.patch('builtins.open', autospec=True)
|
@mock.patch('builtins.open', autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_list_network_interfaces_with_lldp_error(
|
def test_list_network_interfaces_with_lldp_error(
|
||||||
self, mocked_execute, mocked_open, mocked_exists, mocked_listdir,
|
self, mocked_execute, mocked_open, mocked_exists, mocked_listdir,
|
||||||
mocked_ifaddresses, mocked_lldp_info, mockedget_managers,
|
mocked_ifaddresses, mocked_lldp_info, mockedget_managers,
|
||||||
@ -484,7 +484,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
@mock.patch('os.listdir', autospec=True)
|
@mock.patch('os.listdir', autospec=True)
|
||||||
@mock.patch('os.path.exists', autospec=True)
|
@mock.patch('os.path.exists', autospec=True)
|
||||||
@mock.patch('builtins.open', autospec=True)
|
@mock.patch('builtins.open', autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
@mock.patch.object(netutils, 'get_mac_addr', autospec=True)
|
@mock.patch.object(netutils, 'get_mac_addr', autospec=True)
|
||||||
@mock.patch.object(netutils, 'interface_has_carrier', autospec=True)
|
@mock.patch.object(netutils, 'interface_has_carrier', autospec=True)
|
||||||
def test_list_network_interfaces_no_carrier(self,
|
def test_list_network_interfaces_no_carrier(self,
|
||||||
@ -526,7 +526,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
@mock.patch('os.listdir', autospec=True)
|
@mock.patch('os.listdir', autospec=True)
|
||||||
@mock.patch('os.path.exists', autospec=True)
|
@mock.patch('os.path.exists', autospec=True)
|
||||||
@mock.patch('builtins.open', autospec=True)
|
@mock.patch('builtins.open', autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
@mock.patch.object(netutils, 'get_mac_addr', autospec=True)
|
@mock.patch.object(netutils, 'get_mac_addr', autospec=True)
|
||||||
@mock.patch.object(netutils, 'interface_has_carrier', autospec=True)
|
@mock.patch.object(netutils, 'interface_has_carrier', autospec=True)
|
||||||
def test_list_network_interfaces_with_vendor_info(self,
|
def test_list_network_interfaces_with_vendor_info(self,
|
||||||
@ -569,7 +569,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
@mock.patch('os.listdir', autospec=True)
|
@mock.patch('os.listdir', autospec=True)
|
||||||
@mock.patch('os.path.exists', autospec=True)
|
@mock.patch('os.path.exists', autospec=True)
|
||||||
@mock.patch('builtins.open', autospec=True)
|
@mock.patch('builtins.open', autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
@mock.patch.object(netutils, 'get_mac_addr', autospec=True)
|
@mock.patch.object(netutils, 'get_mac_addr', autospec=True)
|
||||||
@mock.patch.object(netutils, 'interface_has_carrier', autospec=True)
|
@mock.patch.object(netutils, 'interface_has_carrier', autospec=True)
|
||||||
def test_list_network_vlan_interfaces(self,
|
def test_list_network_vlan_interfaces(self,
|
||||||
@ -613,7 +613,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
@mock.patch('os.listdir', autospec=True)
|
@mock.patch('os.listdir', autospec=True)
|
||||||
@mock.patch('os.path.exists', autospec=True)
|
@mock.patch('os.path.exists', autospec=True)
|
||||||
@mock.patch('builtins.open', autospec=True)
|
@mock.patch('builtins.open', autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
@mock.patch.object(netutils, 'get_mac_addr', autospec=True)
|
@mock.patch.object(netutils, 'get_mac_addr', autospec=True)
|
||||||
@mock.patch.object(netutils, 'interface_has_carrier', autospec=True)
|
@mock.patch.object(netutils, 'interface_has_carrier', autospec=True)
|
||||||
def test_list_network_vlan_interfaces_using_lldp(self,
|
def test_list_network_vlan_interfaces_using_lldp(self,
|
||||||
@ -666,7 +666,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
@mock.patch('os.listdir', autospec=True)
|
@mock.patch('os.listdir', autospec=True)
|
||||||
@mock.patch('os.path.exists', autospec=True)
|
@mock.patch('os.path.exists', autospec=True)
|
||||||
@mock.patch('builtins.open', autospec=True)
|
@mock.patch('builtins.open', autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
@mock.patch.object(netutils, 'get_mac_addr', autospec=True)
|
@mock.patch.object(netutils, 'get_mac_addr', autospec=True)
|
||||||
@mock.patch.object(netutils, 'interface_has_carrier', autospec=True)
|
@mock.patch.object(netutils, 'interface_has_carrier', autospec=True)
|
||||||
def test_list_network_vlan_invalid_int(self,
|
def test_list_network_vlan_invalid_int(self,
|
||||||
@ -705,7 +705,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
@mock.patch('os.listdir', autospec=True)
|
@mock.patch('os.listdir', autospec=True)
|
||||||
@mock.patch('os.path.exists', autospec=True)
|
@mock.patch('os.path.exists', autospec=True)
|
||||||
@mock.patch('builtins.open', autospec=True)
|
@mock.patch('builtins.open', autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
@mock.patch.object(netutils, 'get_mac_addr', autospec=True)
|
@mock.patch.object(netutils, 'get_mac_addr', autospec=True)
|
||||||
def test_list_network_vlan_interfaces_using_lldp_all(self,
|
def test_list_network_vlan_interfaces_using_lldp_all(self,
|
||||||
mock_get_mac,
|
mock_get_mac,
|
||||||
@ -747,7 +747,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
@mock.patch.object(os, 'readlink', autospec=True)
|
@mock.patch.object(os, 'readlink', autospec=True)
|
||||||
@mock.patch.object(os, 'listdir', autospec=True)
|
@mock.patch.object(os, 'listdir', autospec=True)
|
||||||
@mock.patch.object(hardware, 'get_cached_node', autospec=True)
|
@mock.patch.object(hardware, 'get_cached_node', autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_get_os_install_device(self, mocked_execute, mock_cached_node,
|
def test_get_os_install_device(self, mocked_execute, mock_cached_node,
|
||||||
mocked_listdir, mocked_readlink):
|
mocked_listdir, mocked_readlink):
|
||||||
mocked_readlink.return_value = '../../sda'
|
mocked_readlink.return_value = '../../sda'
|
||||||
@ -762,7 +762,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
@mock.patch.object(os, 'readlink', autospec=True)
|
@mock.patch.object(os, 'readlink', autospec=True)
|
||||||
@mock.patch.object(os, 'listdir', autospec=True)
|
@mock.patch.object(os, 'listdir', autospec=True)
|
||||||
@mock.patch.object(hardware, 'get_cached_node', autospec=True)
|
@mock.patch.object(hardware, 'get_cached_node', autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_get_os_install_device_raid(self, mocked_execute,
|
def test_get_os_install_device_raid(self, mocked_execute,
|
||||||
mock_cached_node, mocked_listdir,
|
mock_cached_node, mocked_listdir,
|
||||||
mocked_readlink):
|
mocked_readlink):
|
||||||
@ -783,7 +783,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
@mock.patch.object(os, 'readlink', autospec=True)
|
@mock.patch.object(os, 'readlink', autospec=True)
|
||||||
@mock.patch.object(os, 'listdir', autospec=True)
|
@mock.patch.object(os, 'listdir', autospec=True)
|
||||||
@mock.patch.object(hardware, 'get_cached_node', autospec=True)
|
@mock.patch.object(hardware, 'get_cached_node', autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_get_os_install_device_fails(self, mocked_execute,
|
def test_get_os_install_device_fails(self, mocked_execute,
|
||||||
mock_cached_node,
|
mock_cached_node,
|
||||||
mocked_listdir, mocked_readlink):
|
mocked_listdir, mocked_readlink):
|
||||||
@ -999,10 +999,9 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
self.assertEqual('fake-vendor', vendor)
|
self.assertEqual('fake-vendor', vendor)
|
||||||
|
|
||||||
@mock.patch.object(il_utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
def test_get_cpus(self, mocked_execute):
|
||||||
def test_get_cpus(self, mocked_execute, mte):
|
mocked_execute.side_effect = [(hws.LSCPU_OUTPUT, ''),
|
||||||
mocked_execute.return_value = (hws.LSCPU_OUTPUT, '')
|
(hws.CPUINFO_FLAGS_OUTPUT, '')]
|
||||||
mte.return_value = (hws.CPUINFO_FLAGS_OUTPUT, '')
|
|
||||||
|
|
||||||
cpus = self.hardware.get_cpus()
|
cpus = self.hardware.get_cpus()
|
||||||
self.assertEqual('Intel(R) Xeon(R) CPU E5-2609 0 @ 2.40GHz',
|
self.assertEqual('Intel(R) Xeon(R) CPU E5-2609 0 @ 2.40GHz',
|
||||||
@ -1013,10 +1012,9 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
self.assertEqual(['fpu', 'vme', 'de', 'pse'], cpus.flags)
|
self.assertEqual(['fpu', 'vme', 'de', 'pse'], cpus.flags)
|
||||||
|
|
||||||
@mock.patch.object(il_utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
def test_get_cpus2(self, mocked_execute):
|
||||||
def test_get_cpus2(self, mocked_execute, mte):
|
mocked_execute.side_effect = [(hws.LSCPU_OUTPUT_NO_MAX_MHZ, ''),
|
||||||
mocked_execute.return_value = (hws.LSCPU_OUTPUT_NO_MAX_MHZ, '')
|
(hws.CPUINFO_FLAGS_OUTPUT, '')]
|
||||||
mte.return_value = (hws.CPUINFO_FLAGS_OUTPUT, '')
|
|
||||||
|
|
||||||
cpus = self.hardware.get_cpus()
|
cpus = self.hardware.get_cpus()
|
||||||
self.assertEqual('Intel(R) Xeon(R) CPU E5-1650 v3 @ 3.50GHz',
|
self.assertEqual('Intel(R) Xeon(R) CPU E5-1650 v3 @ 3.50GHz',
|
||||||
@ -1027,10 +1025,9 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
self.assertEqual(['fpu', 'vme', 'de', 'pse'], cpus.flags)
|
self.assertEqual(['fpu', 'vme', 'de', 'pse'], cpus.flags)
|
||||||
|
|
||||||
@mock.patch.object(il_utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
def test_get_cpus_no_flags(self, mocked_execute):
|
||||||
def test_get_cpus_no_flags(self, mocked_execute, mte):
|
mocked_execute.side_effect = [(hws.LSCPU_OUTPUT, ''),
|
||||||
mocked_execute.return_value = (hws.LSCPU_OUTPUT, '')
|
processutils.ProcessExecutionError()]
|
||||||
mte.side_effect = processutils.ProcessExecutionError()
|
|
||||||
|
|
||||||
cpus = self.hardware.get_cpus()
|
cpus = self.hardware.get_cpus()
|
||||||
self.assertEqual('Intel(R) Xeon(R) CPU E5-2609 0 @ 2.40GHz',
|
self.assertEqual('Intel(R) Xeon(R) CPU E5-2609 0 @ 2.40GHz',
|
||||||
@ -1041,10 +1038,9 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
self.assertEqual([], cpus.flags)
|
self.assertEqual([], cpus.flags)
|
||||||
|
|
||||||
@mock.patch.object(il_utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
def test_get_cpus_illegal_flags(self, mocked_execute):
|
||||||
def test_get_cpus_illegal_flags(self, mocked_execute, mte):
|
mocked_execute.side_effect = [(hws.LSCPU_OUTPUT, ''),
|
||||||
mocked_execute.return_value = (hws.LSCPU_OUTPUT, '')
|
('I am not a flag', '')]
|
||||||
mte.return_value = ('I am not a flag', '')
|
|
||||||
|
|
||||||
cpus = self.hardware.get_cpus()
|
cpus = self.hardware.get_cpus()
|
||||||
self.assertEqual('Intel(R) Xeon(R) CPU E5-2609 0 @ 2.40GHz',
|
self.assertEqual('Intel(R) Xeon(R) CPU E5-2609 0 @ 2.40GHz',
|
||||||
@ -1055,7 +1051,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
self.assertEqual([], cpus.flags)
|
self.assertEqual([], cpus.flags)
|
||||||
|
|
||||||
@mock.patch('psutil.virtual_memory', autospec=True)
|
@mock.patch('psutil.virtual_memory', autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_get_memory_psutil_v1(self, mocked_execute, mocked_psutil):
|
def test_get_memory_psutil_v1(self, mocked_execute, mocked_psutil):
|
||||||
mocked_psutil.return_value.total = 3952 * 1024 * 1024
|
mocked_psutil.return_value.total = 3952 * 1024 * 1024
|
||||||
mocked_execute.return_value = hws.LSHW_JSON_OUTPUT_V1
|
mocked_execute.return_value = hws.LSHW_JSON_OUTPUT_V1
|
||||||
@ -1065,7 +1061,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
self.assertEqual(4096, mem.physical_mb)
|
self.assertEqual(4096, mem.physical_mb)
|
||||||
|
|
||||||
@mock.patch('psutil.virtual_memory', autospec=True)
|
@mock.patch('psutil.virtual_memory', autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_get_memory_psutil_v2(self, mocked_execute, mocked_psutil):
|
def test_get_memory_psutil_v2(self, mocked_execute, mocked_psutil):
|
||||||
mocked_psutil.return_value.total = 3952 * 1024 * 1024
|
mocked_psutil.return_value.total = 3952 * 1024 * 1024
|
||||||
mocked_execute.return_value = hws.LSHW_JSON_OUTPUT_V2
|
mocked_execute.return_value = hws.LSHW_JSON_OUTPUT_V2
|
||||||
@ -1075,7 +1071,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
self.assertEqual(65536, mem.physical_mb)
|
self.assertEqual(65536, mem.physical_mb)
|
||||||
|
|
||||||
@mock.patch('psutil.virtual_memory', autospec=True)
|
@mock.patch('psutil.virtual_memory', autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_get_memory_psutil_bank_size(self, mocked_execute, mocked_psutil):
|
def test_get_memory_psutil_bank_size(self, mocked_execute, mocked_psutil):
|
||||||
mocked_psutil.return_value.total = 3952 * 1024 * 1024
|
mocked_psutil.return_value.total = 3952 * 1024 * 1024
|
||||||
mocked_execute.return_value = hws.LSHW_JSON_OUTPUT_NO_MEMORY_BANK_SIZE
|
mocked_execute.return_value = hws.LSHW_JSON_OUTPUT_NO_MEMORY_BANK_SIZE
|
||||||
@ -1085,7 +1081,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
self.assertEqual(65536, mem.physical_mb)
|
self.assertEqual(65536, mem.physical_mb)
|
||||||
|
|
||||||
@mock.patch('psutil.virtual_memory', autospec=True)
|
@mock.patch('psutil.virtual_memory', autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_get_memory_psutil_exception_v1(self, mocked_execute,
|
def test_get_memory_psutil_exception_v1(self, mocked_execute,
|
||||||
mocked_psutil):
|
mocked_psutil):
|
||||||
mocked_execute.return_value = hws.LSHW_JSON_OUTPUT_V1
|
mocked_execute.return_value = hws.LSHW_JSON_OUTPUT_V1
|
||||||
@ -1096,7 +1092,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
self.assertEqual(4096, mem.physical_mb)
|
self.assertEqual(4096, mem.physical_mb)
|
||||||
|
|
||||||
@mock.patch('psutil.virtual_memory', autospec=True)
|
@mock.patch('psutil.virtual_memory', autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_get_memory_psutil_exception_v2(self, mocked_execute,
|
def test_get_memory_psutil_exception_v2(self, mocked_execute,
|
||||||
mocked_psutil):
|
mocked_psutil):
|
||||||
mocked_execute.return_value = hws.LSHW_JSON_OUTPUT_V2
|
mocked_execute.return_value = hws.LSHW_JSON_OUTPUT_V2
|
||||||
@ -1107,7 +1103,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
self.assertEqual(65536, mem.physical_mb)
|
self.assertEqual(65536, mem.physical_mb)
|
||||||
|
|
||||||
@mock.patch('psutil.virtual_memory', autospec=True)
|
@mock.patch('psutil.virtual_memory', autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_get_memory_lshw_exception(self, mocked_execute, mocked_psutil):
|
def test_get_memory_lshw_exception(self, mocked_execute, mocked_psutil):
|
||||||
mocked_execute.side_effect = OSError()
|
mocked_execute.side_effect = OSError()
|
||||||
mocked_psutil.return_value.total = 3952 * 1024 * 1024
|
mocked_psutil.return_value.total = 3952 * 1024 * 1024
|
||||||
@ -1117,7 +1113,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
self.assertIsNone(mem.physical_mb)
|
self.assertIsNone(mem.physical_mb)
|
||||||
|
|
||||||
@mock.patch('psutil.virtual_memory', autospec=True)
|
@mock.patch('psutil.virtual_memory', autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_get_memory_arm64_lshw(self, mocked_execute, mocked_psutil):
|
def test_get_memory_arm64_lshw(self, mocked_execute, mocked_psutil):
|
||||||
mocked_psutil.return_value.total = 3952 * 1024 * 1024
|
mocked_psutil.return_value.total = 3952 * 1024 * 1024
|
||||||
mocked_execute.return_value = hws.LSHW_JSON_OUTPUT_ARM64
|
mocked_execute.return_value = hws.LSHW_JSON_OUTPUT_ARM64
|
||||||
@ -1127,7 +1123,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
self.assertEqual(3952, mem.physical_mb)
|
self.assertEqual(3952, mem.physical_mb)
|
||||||
|
|
||||||
@mock.patch('psutil.virtual_memory', autospec=True)
|
@mock.patch('psutil.virtual_memory', autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_get_memory_lshw_list(self, mocked_execute, mocked_psutil):
|
def test_get_memory_lshw_list(self, mocked_execute, mocked_psutil):
|
||||||
mocked_psutil.return_value.total = 3952 * 1024 * 1024
|
mocked_psutil.return_value.total = 3952 * 1024 * 1024
|
||||||
mocked_execute.return_value = (f"[{hws.LSHW_JSON_OUTPUT_V2[0]}]", "")
|
mocked_execute.return_value = (f"[{hws.LSHW_JSON_OUTPUT_V2[0]}]", "")
|
||||||
@ -1209,7 +1205,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
@mock.patch.object(os, 'listdir', autospec=True)
|
@mock.patch.object(os, 'listdir', autospec=True)
|
||||||
@mock.patch.object(hardware, '_get_device_info', autospec=True)
|
@mock.patch.object(hardware, '_get_device_info', autospec=True)
|
||||||
@mock.patch.object(pyudev.Devices, 'from_device_file', autospec=False)
|
@mock.patch.object(pyudev.Devices, 'from_device_file', autospec=False)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_list_all_block_device(self, mocked_execute, mocked_udev,
|
def test_list_all_block_device(self, mocked_execute, mocked_udev,
|
||||||
mocked_dev_vendor, mock_listdir,
|
mocked_dev_vendor, mock_listdir,
|
||||||
mock_readlink):
|
mock_readlink):
|
||||||
@ -1278,7 +1274,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
@mock.patch.object(os, 'listdir', autospec=True)
|
@mock.patch.object(os, 'listdir', autospec=True)
|
||||||
@mock.patch.object(hardware, '_get_device_info', autospec=True)
|
@mock.patch.object(hardware, '_get_device_info', autospec=True)
|
||||||
@mock.patch.object(pyudev.Devices, 'from_device_file', autospec=False)
|
@mock.patch.object(pyudev.Devices, 'from_device_file', autospec=False)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_list_all_block_device_hctl_fail(self, mocked_execute, mocked_udev,
|
def test_list_all_block_device_hctl_fail(self, mocked_execute, mocked_udev,
|
||||||
mocked_dev_vendor,
|
mocked_dev_vendor,
|
||||||
mocked_listdir):
|
mocked_listdir):
|
||||||
@ -1298,7 +1294,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
@mock.patch.object(os, 'listdir', autospec=True)
|
@mock.patch.object(os, 'listdir', autospec=True)
|
||||||
@mock.patch.object(hardware, '_get_device_info', autospec=True)
|
@mock.patch.object(hardware, '_get_device_info', autospec=True)
|
||||||
@mock.patch.object(pyudev.Devices, 'from_device_file', autospec=False)
|
@mock.patch.object(pyudev.Devices, 'from_device_file', autospec=False)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_list_all_block_device_with_udev(self, mocked_execute, mocked_udev,
|
def test_list_all_block_device_with_udev(self, mocked_execute, mocked_udev,
|
||||||
mocked_dev_vendor, mocked_listdir,
|
mocked_dev_vendor, mocked_listdir,
|
||||||
mocked_readlink):
|
mocked_readlink):
|
||||||
@ -1452,7 +1448,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
|
|
||||||
@mock.patch.object(hardware.GenericHardwareManager,
|
@mock.patch.object(hardware.GenericHardwareManager,
|
||||||
'_is_linux_raid_member', autospec=True)
|
'_is_linux_raid_member', autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_erase_block_device_ata_success(self, mocked_execute,
|
def test_erase_block_device_ata_success(self, mocked_execute,
|
||||||
mocked_raid_member):
|
mocked_raid_member):
|
||||||
mocked_execute.side_effect = [
|
mocked_execute.side_effect = [
|
||||||
@ -1484,7 +1480,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
|
|
||||||
@mock.patch.object(hardware.GenericHardwareManager,
|
@mock.patch.object(hardware.GenericHardwareManager,
|
||||||
'_is_linux_raid_member', autospec=True)
|
'_is_linux_raid_member', autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_erase_block_device_ata_success_no_smartctl(self, mocked_execute,
|
def test_erase_block_device_ata_success_no_smartctl(self, mocked_execute,
|
||||||
mocked_raid_member):
|
mocked_raid_member):
|
||||||
mocked_execute.side_effect = [
|
mocked_execute.side_effect = [
|
||||||
@ -1516,7 +1512,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
|
|
||||||
@mock.patch.object(hardware.GenericHardwareManager,
|
@mock.patch.object(hardware.GenericHardwareManager,
|
||||||
'_is_linux_raid_member', autospec=True)
|
'_is_linux_raid_member', autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_erase_block_device_nosecurity_shred(self, mocked_execute,
|
def test_erase_block_device_nosecurity_shred(self, mocked_execute,
|
||||||
mocked_raid_member):
|
mocked_raid_member):
|
||||||
hdparm_output = hws.HDPARM_INFO_TEMPLATE.split('\nSecurity:')[0]
|
hdparm_output = hws.HDPARM_INFO_TEMPLATE.split('\nSecurity:')[0]
|
||||||
@ -1541,7 +1537,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
|
|
||||||
@mock.patch.object(hardware.GenericHardwareManager,
|
@mock.patch.object(hardware.GenericHardwareManager,
|
||||||
'_is_linux_raid_member', autospec=True)
|
'_is_linux_raid_member', autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_erase_block_device_notsupported_shred(self, mocked_execute,
|
def test_erase_block_device_notsupported_shred(self, mocked_execute,
|
||||||
mocked_raid_member):
|
mocked_raid_member):
|
||||||
hdparm_output = create_hdparm_info(
|
hdparm_output = create_hdparm_info(
|
||||||
@ -1567,7 +1563,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
|
|
||||||
@mock.patch.object(hardware.GenericHardwareManager,
|
@mock.patch.object(hardware.GenericHardwareManager,
|
||||||
'_is_linux_raid_member', autospec=True)
|
'_is_linux_raid_member', autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_erase_block_device_smartctl_unsupported_shred(self,
|
def test_erase_block_device_smartctl_unsupported_shred(self,
|
||||||
mocked_execute,
|
mocked_execute,
|
||||||
mocked_raid_member):
|
mocked_raid_member):
|
||||||
@ -1594,7 +1590,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
|
|
||||||
@mock.patch.object(hardware.GenericHardwareManager,
|
@mock.patch.object(hardware.GenericHardwareManager,
|
||||||
'_is_linux_raid_member', autospec=True)
|
'_is_linux_raid_member', autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_erase_block_device_smartctl_fails_security_fallback_to_shred(
|
def test_erase_block_device_smartctl_fails_security_fallback_to_shred(
|
||||||
self, mocked_execute, mocked_raid_member):
|
self, mocked_execute, mocked_raid_member):
|
||||||
hdparm_output = create_hdparm_info(
|
hdparm_output = create_hdparm_info(
|
||||||
@ -1620,7 +1616,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
|
|
||||||
@mock.patch.object(hardware.GenericHardwareManager,
|
@mock.patch.object(hardware.GenericHardwareManager,
|
||||||
'_is_linux_raid_member', autospec=True)
|
'_is_linux_raid_member', autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_erase_block_device_shred_uses_internal_info(self, mocked_execute,
|
def test_erase_block_device_shred_uses_internal_info(self, mocked_execute,
|
||||||
mocked_raid_member):
|
mocked_raid_member):
|
||||||
hdparm_output = create_hdparm_info(
|
hdparm_output = create_hdparm_info(
|
||||||
@ -1650,7 +1646,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
|
|
||||||
@mock.patch.object(hardware.GenericHardwareManager,
|
@mock.patch.object(hardware.GenericHardwareManager,
|
||||||
'_is_linux_raid_member', autospec=True)
|
'_is_linux_raid_member', autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_erase_block_device_shred_0_pass_no_zeroize(self, mocked_execute,
|
def test_erase_block_device_shred_0_pass_no_zeroize(self, mocked_execute,
|
||||||
mocked_raid_member):
|
mocked_raid_member):
|
||||||
hdparm_output = create_hdparm_info(
|
hdparm_output = create_hdparm_info(
|
||||||
@ -1725,7 +1721,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
mocked_exists.assert_called_once_with('/dev/disk/by-label/ir-vfd-dev')
|
mocked_exists.assert_called_once_with('/dev/disk/by-label/ir-vfd-dev')
|
||||||
self.assertFalse(mocked_link.called)
|
self.assertFalse(mocked_link.called)
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_erase_block_device_shred_fail_oserror(self, mocked_execute):
|
def test_erase_block_device_shred_fail_oserror(self, mocked_execute):
|
||||||
mocked_execute.side_effect = OSError
|
mocked_execute.side_effect = OSError
|
||||||
block_device = hardware.BlockDevice('/dev/sda', 'big', 1073741824,
|
block_device = hardware.BlockDevice('/dev/sda', 'big', 1073741824,
|
||||||
@ -1736,7 +1732,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
'shred', '--force', '--zero', '--verbose', '--iterations', '1',
|
'shred', '--force', '--zero', '--verbose', '--iterations', '1',
|
||||||
'/dev/sda')
|
'/dev/sda')
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_erase_block_device_shred_fail_processerror(self, mocked_execute):
|
def test_erase_block_device_shred_fail_processerror(self, mocked_execute):
|
||||||
mocked_execute.side_effect = processutils.ProcessExecutionError
|
mocked_execute.side_effect = processutils.ProcessExecutionError
|
||||||
block_device = hardware.BlockDevice('/dev/sda', 'big', 1073741824,
|
block_device = hardware.BlockDevice('/dev/sda', 'big', 1073741824,
|
||||||
@ -1749,7 +1745,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
|
|
||||||
@mock.patch.object(hardware.GenericHardwareManager,
|
@mock.patch.object(hardware.GenericHardwareManager,
|
||||||
'_is_linux_raid_member', autospec=True)
|
'_is_linux_raid_member', autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_erase_block_device_ata_security_unlock_fallback_pass(
|
def test_erase_block_device_ata_security_unlock_fallback_pass(
|
||||||
self, mocked_execute, mocked_raid_member):
|
self, mocked_execute, mocked_raid_member):
|
||||||
hdparm_output = create_hdparm_info(
|
hdparm_output = create_hdparm_info(
|
||||||
@ -1783,7 +1779,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
'_is_linux_raid_member', autospec=True)
|
'_is_linux_raid_member', autospec=True)
|
||||||
@mock.patch.object(hardware.GenericHardwareManager, '_shred_block_device',
|
@mock.patch.object(hardware.GenericHardwareManager, '_shred_block_device',
|
||||||
autospec=True)
|
autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_erase_block_device_ata_security_enabled(
|
def test_erase_block_device_ata_security_enabled(
|
||||||
self, mocked_execute, mock_shred, mocked_raid_member):
|
self, mocked_execute, mock_shred, mocked_raid_member):
|
||||||
# Tests that an exception is thrown if all of the recovery passwords
|
# Tests that an exception is thrown if all of the recovery passwords
|
||||||
@ -1820,7 +1816,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
'_is_linux_raid_member', autospec=True)
|
'_is_linux_raid_member', autospec=True)
|
||||||
@mock.patch.object(hardware.GenericHardwareManager, '_shred_block_device',
|
@mock.patch.object(hardware.GenericHardwareManager, '_shred_block_device',
|
||||||
autospec=True)
|
autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_erase_block_device_ata_security_enabled_unlock_attempt(
|
def test_erase_block_device_ata_security_enabled_unlock_attempt(
|
||||||
self, mocked_execute, mock_shred, mocked_raid_member):
|
self, mocked_execute, mock_shred, mocked_raid_member):
|
||||||
hdparm_output = create_hdparm_info(
|
hdparm_output = create_hdparm_info(
|
||||||
@ -1845,7 +1841,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
self.hardware.erase_block_device(self.node, block_device)
|
self.hardware.erase_block_device(self.node, block_device)
|
||||||
self.assertFalse(mock_shred.called)
|
self.assertFalse(mock_shred.called)
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test__ata_erase_security_enabled_unlock_exception(
|
def test__ata_erase_security_enabled_unlock_exception(
|
||||||
self, mocked_execute):
|
self, mocked_execute):
|
||||||
# test that an exception is thrown when security unlock fails with
|
# test that an exception is thrown when security unlock fails with
|
||||||
@ -1871,7 +1867,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
mocked_execute.assert_any_call('hdparm', '--user-master', 'u',
|
mocked_execute.assert_any_call('hdparm', '--user-master', 'u',
|
||||||
'--security-unlock', 'NULL', '/dev/sda')
|
'--security-unlock', 'NULL', '/dev/sda')
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test__ata_erase_security_enabled_set_password_exception(
|
def test__ata_erase_security_enabled_set_password_exception(
|
||||||
self, mocked_execute):
|
self, mocked_execute):
|
||||||
hdparm_output = create_hdparm_info(
|
hdparm_output = create_hdparm_info(
|
||||||
@ -1890,7 +1886,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
self.hardware._ata_erase,
|
self.hardware._ata_erase,
|
||||||
block_device)
|
block_device)
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test__ata_erase_security_erase_exec_exception(
|
def test__ata_erase_security_erase_exec_exception(
|
||||||
self, mocked_execute):
|
self, mocked_execute):
|
||||||
# Exception on security erase
|
# Exception on security erase
|
||||||
@ -1919,7 +1915,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
'_is_linux_raid_member', autospec=True)
|
'_is_linux_raid_member', autospec=True)
|
||||||
@mock.patch.object(hardware.GenericHardwareManager, '_shred_block_device',
|
@mock.patch.object(hardware.GenericHardwareManager, '_shred_block_device',
|
||||||
autospec=True)
|
autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_erase_block_device_ata_frozen(self, mocked_execute, mock_shred,
|
def test_erase_block_device_ata_frozen(self, mocked_execute, mock_shred,
|
||||||
mocked_raid_member):
|
mocked_raid_member):
|
||||||
hdparm_output = create_hdparm_info(
|
hdparm_output = create_hdparm_info(
|
||||||
@ -1944,7 +1940,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
'_is_linux_raid_member', autospec=True)
|
'_is_linux_raid_member', autospec=True)
|
||||||
@mock.patch.object(hardware.GenericHardwareManager, '_shred_block_device',
|
@mock.patch.object(hardware.GenericHardwareManager, '_shred_block_device',
|
||||||
autospec=True)
|
autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_erase_block_device_ata_failed(self, mocked_execute, mock_shred,
|
def test_erase_block_device_ata_failed(self, mocked_execute, mock_shred,
|
||||||
mocked_raid_member):
|
mocked_raid_member):
|
||||||
hdparm_output_before = create_hdparm_info(
|
hdparm_output_before = create_hdparm_info(
|
||||||
@ -1978,7 +1974,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
'_is_linux_raid_member', autospec=True)
|
'_is_linux_raid_member', autospec=True)
|
||||||
@mock.patch.object(hardware.GenericHardwareManager, '_shred_block_device',
|
@mock.patch.object(hardware.GenericHardwareManager, '_shred_block_device',
|
||||||
autospec=True)
|
autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_erase_block_device_ata_failed_continued(
|
def test_erase_block_device_ata_failed_continued(
|
||||||
self, mocked_execute, mock_shred, mocked_raid_member):
|
self, mocked_execute, mock_shred, mocked_raid_member):
|
||||||
|
|
||||||
@ -2012,7 +2008,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
'_is_linux_raid_member', autospec=True)
|
'_is_linux_raid_member', autospec=True)
|
||||||
@mock.patch.object(hardware.GenericHardwareManager, '_shred_block_device',
|
@mock.patch.object(hardware.GenericHardwareManager, '_shred_block_device',
|
||||||
autospec=True)
|
autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_erase_block_device_ata_erase_disabled(
|
def test_erase_block_device_ata_erase_disabled(
|
||||||
self, mocked_execute, mock_shred, mocked_raid_member):
|
self, mocked_execute, mock_shred, mocked_raid_member):
|
||||||
|
|
||||||
@ -2030,7 +2026,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
def test_normal_vs_enhanced_security_erase(self):
|
def test_normal_vs_enhanced_security_erase(self):
|
||||||
@mock.patch.object(hardware.GenericHardwareManager,
|
@mock.patch.object(hardware.GenericHardwareManager,
|
||||||
'_is_linux_raid_member', autospec=True)
|
'_is_linux_raid_member', autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_security_erase_option(test_case,
|
def test_security_erase_option(test_case,
|
||||||
enhanced_erase,
|
enhanced_erase,
|
||||||
expected_option,
|
expected_option,
|
||||||
@ -2099,7 +2095,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
mock.call('/sys/fs/pstore/' + arg) for arg in pstore_entries
|
mock.call('/sys/fs/pstore/' + arg) for arg in pstore_entries
|
||||||
])
|
])
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
@mock.patch.object(hardware.GenericHardwareManager,
|
@mock.patch.object(hardware.GenericHardwareManager,
|
||||||
'_is_virtual_media_device', autospec=True)
|
'_is_virtual_media_device', autospec=True)
|
||||||
@mock.patch.object(hardware.GenericHardwareManager,
|
@mock.patch.object(hardware.GenericHardwareManager,
|
||||||
@ -2186,14 +2182,14 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
mock.call(self.hardware, block_devices[0])],
|
mock.call(self.hardware, block_devices[0])],
|
||||||
mock__is_vmedia.call_args_list)
|
mock__is_vmedia.call_args_list)
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test__is_linux_raid_member(self, mocked_execute):
|
def test__is_linux_raid_member(self, mocked_execute):
|
||||||
raid_member = hardware.BlockDevice('/dev/sda1', 'small', 65535, False)
|
raid_member = hardware.BlockDevice('/dev/sda1', 'small', 65535, False)
|
||||||
mocked_execute.return_value = ('linux_raid_member host.domain:0 '
|
mocked_execute.return_value = ('linux_raid_member host.domain:0 '
|
||||||
'85fa41e4-e0ae'), ''
|
'85fa41e4-e0ae'), ''
|
||||||
self.assertTrue(self.hardware._is_linux_raid_member(raid_member))
|
self.assertTrue(self.hardware._is_linux_raid_member(raid_member))
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test__is_linux_raid_member_false(self, mocked_execute):
|
def test__is_linux_raid_member_false(self, mocked_execute):
|
||||||
raid_member = hardware.BlockDevice('/dev/md0', 'small', 65535, False)
|
raid_member = hardware.BlockDevice('/dev/md0', 'small', 65535, False)
|
||||||
mocked_execute.return_value = 'md0', ''
|
mocked_execute.return_value = 'md0', ''
|
||||||
@ -2246,34 +2242,34 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
mock_dev_file.side_effect = reads
|
mock_dev_file.side_effect = reads
|
||||||
self.assertTrue(self.hardware._is_read_only_device(device))
|
self.assertTrue(self.hardware._is_read_only_device(device))
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_get_bmc_address(self, mocked_execute):
|
def test_get_bmc_address(self, mocked_execute):
|
||||||
mocked_execute.return_value = '192.1.2.3\n', ''
|
mocked_execute.return_value = '192.1.2.3\n', ''
|
||||||
self.assertEqual('192.1.2.3', self.hardware.get_bmc_address())
|
self.assertEqual('192.1.2.3', self.hardware.get_bmc_address())
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_get_bmc_address_virt(self, mocked_execute):
|
def test_get_bmc_address_virt(self, mocked_execute):
|
||||||
mocked_execute.side_effect = processutils.ProcessExecutionError()
|
mocked_execute.side_effect = processutils.ProcessExecutionError()
|
||||||
self.assertIsNone(self.hardware.get_bmc_address())
|
self.assertIsNone(self.hardware.get_bmc_address())
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_get_bmc_address_zeroed(self, mocked_execute):
|
def test_get_bmc_address_zeroed(self, mocked_execute):
|
||||||
mocked_execute.return_value = '0.0.0.0\n', ''
|
mocked_execute.return_value = '0.0.0.0\n', ''
|
||||||
self.assertEqual('0.0.0.0', self.hardware.get_bmc_address())
|
self.assertEqual('0.0.0.0', self.hardware.get_bmc_address())
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_get_bmc_address_invalid(self, mocked_execute):
|
def test_get_bmc_address_invalid(self, mocked_execute):
|
||||||
# In case of invalid lan channel, stdout is empty and the error
|
# In case of invalid lan channel, stdout is empty and the error
|
||||||
# on stderr is "Invalid channel"
|
# on stderr is "Invalid channel"
|
||||||
mocked_execute.return_value = '\n', 'Invalid channel: 55'
|
mocked_execute.return_value = '\n', 'Invalid channel: 55'
|
||||||
self.assertEqual('0.0.0.0', self.hardware.get_bmc_address())
|
self.assertEqual('0.0.0.0', self.hardware.get_bmc_address())
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_get_bmc_address_random_error(self, mocked_execute):
|
def test_get_bmc_address_random_error(self, mocked_execute):
|
||||||
mocked_execute.return_value = '192.1.2.3\n', 'Random error message'
|
mocked_execute.return_value = '192.1.2.3\n', 'Random error message'
|
||||||
self.assertEqual('192.1.2.3', self.hardware.get_bmc_address())
|
self.assertEqual('192.1.2.3', self.hardware.get_bmc_address())
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_get_bmc_address_iterate_channels(self, mocked_execute):
|
def test_get_bmc_address_iterate_channels(self, mocked_execute):
|
||||||
# For channel 1 we simulate unconfigured IP
|
# For channel 1 we simulate unconfigured IP
|
||||||
# and for any other we return a correct IP address
|
# and for any other we return a correct IP address
|
||||||
@ -2289,34 +2285,34 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
mocked_execute.side_effect = side_effect
|
mocked_execute.side_effect = side_effect
|
||||||
self.assertEqual('192.1.2.3', self.hardware.get_bmc_address())
|
self.assertEqual('192.1.2.3', self.hardware.get_bmc_address())
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_get_bmc_address_not_available(self, mocked_execute):
|
def test_get_bmc_address_not_available(self, mocked_execute):
|
||||||
mocked_execute.return_value = '', ''
|
mocked_execute.return_value = '', ''
|
||||||
self.assertEqual('0.0.0.0', self.hardware.get_bmc_address())
|
self.assertEqual('0.0.0.0', self.hardware.get_bmc_address())
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_get_bmc_mac_not_available(self, mocked_execute):
|
def test_get_bmc_mac_not_available(self, mocked_execute):
|
||||||
mocked_execute.return_value = '', ''
|
mocked_execute.return_value = '', ''
|
||||||
self.assertRaises(errors.IncompatibleHardwareMethodError,
|
self.assertRaises(errors.IncompatibleHardwareMethodError,
|
||||||
self.hardware.get_bmc_mac)
|
self.hardware.get_bmc_mac)
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_get_bmc_mac(self, mocked_execute):
|
def test_get_bmc_mac(self, mocked_execute):
|
||||||
mocked_execute.return_value = '192.1.2.3\n01:02:03:04:05:06', ''
|
mocked_execute.return_value = '192.1.2.3\n01:02:03:04:05:06', ''
|
||||||
self.assertEqual('01:02:03:04:05:06', self.hardware.get_bmc_mac())
|
self.assertEqual('01:02:03:04:05:06', self.hardware.get_bmc_mac())
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_get_bmc_mac_virt(self, mocked_execute):
|
def test_get_bmc_mac_virt(self, mocked_execute):
|
||||||
mocked_execute.side_effect = processutils.ProcessExecutionError()
|
mocked_execute.side_effect = processutils.ProcessExecutionError()
|
||||||
self.assertIsNone(self.hardware.get_bmc_mac())
|
self.assertIsNone(self.hardware.get_bmc_mac())
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_get_bmc_mac_zeroed(self, mocked_execute):
|
def test_get_bmc_mac_zeroed(self, mocked_execute):
|
||||||
mocked_execute.return_value = '0.0.0.0\n00:00:00:00:00:00', ''
|
mocked_execute.return_value = '0.0.0.0\n00:00:00:00:00:00', ''
|
||||||
self.assertRaises(errors.IncompatibleHardwareMethodError,
|
self.assertRaises(errors.IncompatibleHardwareMethodError,
|
||||||
self.hardware.get_bmc_mac)
|
self.hardware.get_bmc_mac)
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_get_bmc_mac_invalid(self, mocked_execute):
|
def test_get_bmc_mac_invalid(self, mocked_execute):
|
||||||
# In case of invalid lan channel, stdout is empty and the error
|
# In case of invalid lan channel, stdout is empty and the error
|
||||||
# on stderr is "Invalid channel"
|
# on stderr is "Invalid channel"
|
||||||
@ -2324,13 +2320,13 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
self.assertRaises(errors.IncompatibleHardwareMethodError,
|
self.assertRaises(errors.IncompatibleHardwareMethodError,
|
||||||
self.hardware.get_bmc_mac)
|
self.hardware.get_bmc_mac)
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_get_bmc_mac_random_error(self, mocked_execute):
|
def test_get_bmc_mac_random_error(self, mocked_execute):
|
||||||
mocked_execute.return_value = ('192.1.2.3\n00:00:00:00:00:02',
|
mocked_execute.return_value = ('192.1.2.3\n00:00:00:00:00:02',
|
||||||
'Random error message')
|
'Random error message')
|
||||||
self.assertEqual('00:00:00:00:00:02', self.hardware.get_bmc_mac())
|
self.assertEqual('00:00:00:00:00:02', self.hardware.get_bmc_mac())
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_get_bmc_mac_iterate_channels(self, mocked_execute):
|
def test_get_bmc_mac_iterate_channels(self, mocked_execute):
|
||||||
# For channel 1 we simulate unconfigured IP
|
# For channel 1 we simulate unconfigured IP
|
||||||
# and for any other we return a correct IP address
|
# and for any other we return a correct IP address
|
||||||
@ -2349,12 +2345,12 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
mocked_execute.side_effect = side_effect
|
mocked_execute.side_effect = side_effect
|
||||||
self.assertEqual('01:02:03:04:05:06', self.hardware.get_bmc_mac())
|
self.assertEqual('01:02:03:04:05:06', self.hardware.get_bmc_mac())
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_get_bmc_v6address_not_enabled(self, mocked_execute):
|
def test_get_bmc_v6address_not_enabled(self, mocked_execute):
|
||||||
mocked_execute.side_effect = [('ipv4\n', '')] * 11
|
mocked_execute.side_effect = [('ipv4\n', '')] * 11
|
||||||
self.assertEqual('::/0', self.hardware.get_bmc_v6address())
|
self.assertEqual('::/0', self.hardware.get_bmc_v6address())
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_get_bmc_v6address_dynamic_address(self, mocked_execute):
|
def test_get_bmc_v6address_dynamic_address(self, mocked_execute):
|
||||||
mocked_execute.side_effect = [
|
mocked_execute.side_effect = [
|
||||||
('ipv6\n', ''),
|
('ipv6\n', ''),
|
||||||
@ -2363,7 +2359,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
self.assertEqual('2001:1234:1234:1234:1234:1234:1234:1234',
|
self.assertEqual('2001:1234:1234:1234:1234:1234:1234:1234',
|
||||||
self.hardware.get_bmc_v6address())
|
self.hardware.get_bmc_v6address())
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_get_bmc_v6address_static_address_both(self, mocked_execute):
|
def test_get_bmc_v6address_static_address_both(self, mocked_execute):
|
||||||
dynamic_disabled = \
|
dynamic_disabled = \
|
||||||
hws.IPMITOOL_LAN6_PRINT_DYNAMIC_ADDR.replace('active', 'disabled')
|
hws.IPMITOOL_LAN6_PRINT_DYNAMIC_ADDR.replace('active', 'disabled')
|
||||||
@ -2375,12 +2371,12 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
self.assertEqual('2001:5678:5678:5678:5678:5678:5678:5678',
|
self.assertEqual('2001:5678:5678:5678:5678:5678:5678:5678',
|
||||||
self.hardware.get_bmc_v6address())
|
self.hardware.get_bmc_v6address())
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_get_bmc_v6address_virt(self, mocked_execute):
|
def test_get_bmc_v6address_virt(self, mocked_execute):
|
||||||
mocked_execute.side_effect = processutils.ProcessExecutionError()
|
mocked_execute.side_effect = processutils.ProcessExecutionError()
|
||||||
self.assertIsNone(self.hardware.get_bmc_v6address())
|
self.assertIsNone(self.hardware.get_bmc_v6address())
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_get_bmc_v6address_invalid_enables(self, mocked_execute):
|
def test_get_bmc_v6address_invalid_enables(self, mocked_execute):
|
||||||
def side_effect(*args, **kwargs):
|
def side_effect(*args, **kwargs):
|
||||||
if args[0].startswith('ipmitool lan6 print'):
|
if args[0].startswith('ipmitool lan6 print'):
|
||||||
@ -2389,7 +2385,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
mocked_execute.side_effect = side_effect
|
mocked_execute.side_effect = side_effect
|
||||||
self.assertEqual('::/0', self.hardware.get_bmc_v6address())
|
self.assertEqual('::/0', self.hardware.get_bmc_v6address())
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_get_bmc_v6address_invalid_get_address(self, mocked_execute):
|
def test_get_bmc_v6address_invalid_get_address(self, mocked_execute):
|
||||||
def side_effect(*args, **kwargs):
|
def side_effect(*args, **kwargs):
|
||||||
if args[0].startswith('ipmitool lan6 print'):
|
if args[0].startswith('ipmitool lan6 print'):
|
||||||
@ -2402,7 +2398,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
self.assertEqual('::/0', self.hardware.get_bmc_v6address())
|
self.assertEqual('::/0', self.hardware.get_bmc_v6address())
|
||||||
|
|
||||||
@mock.patch.object(hardware, 'LOG', autospec=True)
|
@mock.patch.object(hardware, 'LOG', autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_get_bmc_v6address_ipmitool_invalid_stdout_format(
|
def test_get_bmc_v6address_ipmitool_invalid_stdout_format(
|
||||||
self, mocked_execute, mocked_log):
|
self, mocked_execute, mocked_log):
|
||||||
def side_effect(*args, **kwargs):
|
def side_effect(*args, **kwargs):
|
||||||
@ -2418,7 +2414,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
'command: %(e)s', mock.ANY)
|
'command: %(e)s', mock.ANY)
|
||||||
mocked_log.warning.assert_has_calls([one_call] * 14)
|
mocked_log.warning.assert_has_calls([one_call] * 14)
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_get_bmc_v6address_channel_7(self, mocked_execute):
|
def test_get_bmc_v6address_channel_7(self, mocked_execute):
|
||||||
def side_effect(*args, **kwargs):
|
def side_effect(*args, **kwargs):
|
||||||
if not args[0].startswith('ipmitool lan6 print 7'):
|
if not args[0].startswith('ipmitool lan6 print 7'):
|
||||||
@ -2437,7 +2433,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
self.assertEqual('2001:5678:5678:5678:5678:5678:5678:5678',
|
self.assertEqual('2001:5678:5678:5678:5678:5678:5678:5678',
|
||||||
self.hardware.get_bmc_v6address())
|
self.hardware.get_bmc_v6address())
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_validate_configuration_no_configuration(self, mocked_execute):
|
def test_validate_configuration_no_configuration(self, mocked_execute):
|
||||||
self.assertRaises(errors.SoftwareRAIDError,
|
self.assertRaises(errors.SoftwareRAIDError,
|
||||||
self.hardware.validate_configuration,
|
self.hardware.validate_configuration,
|
||||||
@ -2509,7 +2505,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
@mock.patch.object(raid_utils, '_get_actual_component_devices',
|
@mock.patch.object(raid_utils, '_get_actual_component_devices',
|
||||||
autospec=True)
|
autospec=True)
|
||||||
@mock.patch.object(disk_utils, 'list_partitions', autospec=True)
|
@mock.patch.object(disk_utils, 'list_partitions', autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
@mock.patch.object(os.path, 'isdir', autospec=True, return_value=False)
|
@mock.patch.object(os.path, 'isdir', autospec=True, return_value=False)
|
||||||
def test_create_configuration(self, mocked_os_path_isdir, mocked_execute,
|
def test_create_configuration(self, mocked_os_path_isdir, mocked_execute,
|
||||||
mock_list_parts, mocked_actual_comp):
|
mock_list_parts, mocked_actual_comp):
|
||||||
@ -2604,7 +2600,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
@mock.patch.object(utils, 'get_node_boot_mode', lambda node: 'bios')
|
@mock.patch.object(utils, 'get_node_boot_mode', lambda node: 'bios')
|
||||||
@mock.patch.object(disk_utils, 'list_partitions', autospec=True,
|
@mock.patch.object(disk_utils, 'list_partitions', autospec=True,
|
||||||
return_value=[])
|
return_value=[])
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_create_configuration_raid_5(self, mocked_execute,
|
def test_create_configuration_raid_5(self, mocked_execute,
|
||||||
mock_list_parts, mocked_actual_comp):
|
mock_list_parts, mocked_actual_comp):
|
||||||
node = self.node
|
node = self.node
|
||||||
@ -2703,7 +2699,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
@mock.patch.object(utils, 'get_node_boot_mode', lambda node: 'bios')
|
@mock.patch.object(utils, 'get_node_boot_mode', lambda node: 'bios')
|
||||||
@mock.patch.object(disk_utils, 'list_partitions', autospec=True,
|
@mock.patch.object(disk_utils, 'list_partitions', autospec=True,
|
||||||
return_value=[])
|
return_value=[])
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_create_configuration_raid_6(self, mocked_execute,
|
def test_create_configuration_raid_6(self, mocked_execute,
|
||||||
mock_list_parts, mocked_actual_comp):
|
mock_list_parts, mocked_actual_comp):
|
||||||
node = self.node
|
node = self.node
|
||||||
@ -2818,7 +2814,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
autospec=True)
|
autospec=True)
|
||||||
@mock.patch.object(disk_utils, 'list_partitions', autospec=True,
|
@mock.patch.object(disk_utils, 'list_partitions', autospec=True,
|
||||||
return_value=[])
|
return_value=[])
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
@mock.patch.object(os.path, 'isdir', autospec=True, return_value=True)
|
@mock.patch.object(os.path, 'isdir', autospec=True, return_value=True)
|
||||||
def test_create_configuration_efi(self, mocked_os_path_isdir,
|
def test_create_configuration_efi(self, mocked_os_path_isdir,
|
||||||
mocked_execute, mock_list_parts,
|
mocked_execute, mock_list_parts,
|
||||||
@ -2899,7 +2895,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
autospec=True)
|
autospec=True)
|
||||||
@mock.patch.object(disk_utils, 'list_partitions', autospec=True,
|
@mock.patch.object(disk_utils, 'list_partitions', autospec=True,
|
||||||
return_value=[])
|
return_value=[])
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
@mock.patch.object(os.path, 'isdir', autospec=True, return_value=False)
|
@mock.patch.object(os.path, 'isdir', autospec=True, return_value=False)
|
||||||
def test_create_configuration_force_gpt_with_disk_label(
|
def test_create_configuration_force_gpt_with_disk_label(
|
||||||
self, mocked_os_path_isdir, mocked_execute, mock_list_part,
|
self, mocked_os_path_isdir, mocked_execute, mock_list_part,
|
||||||
@ -2986,7 +2982,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
autospec=True)
|
autospec=True)
|
||||||
@mock.patch.object(disk_utils, 'list_partitions', autospec=True,
|
@mock.patch.object(disk_utils, 'list_partitions', autospec=True,
|
||||||
return_value=[])
|
return_value=[])
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
@mock.patch.object(os.path, 'isdir', autospec=True, return_value=False)
|
@mock.patch.object(os.path, 'isdir', autospec=True, return_value=False)
|
||||||
def test_create_configuration_no_max(self, _mocked_isdir, mocked_execute,
|
def test_create_configuration_no_max(self, _mocked_isdir, mocked_execute,
|
||||||
mock_list_parts, mocked_actual_comp):
|
mock_list_parts, mocked_actual_comp):
|
||||||
@ -3068,7 +3064,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
autospec=True)
|
autospec=True)
|
||||||
@mock.patch.object(disk_utils, 'list_partitions', autospec=True,
|
@mock.patch.object(disk_utils, 'list_partitions', autospec=True,
|
||||||
return_value=[])
|
return_value=[])
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
@mock.patch.object(os.path, 'isdir', autospec=True, return_value=False)
|
@mock.patch.object(os.path, 'isdir', autospec=True, return_value=False)
|
||||||
def test_create_configuration_max_is_first_logical(self, _mocked_isdir,
|
def test_create_configuration_max_is_first_logical(self, _mocked_isdir,
|
||||||
mocked_execute,
|
mocked_execute,
|
||||||
@ -3153,7 +3149,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
@mock.patch.object(utils, 'get_node_boot_mode', lambda node: 'bios')
|
@mock.patch.object(utils, 'get_node_boot_mode', lambda node: 'bios')
|
||||||
@mock.patch.object(disk_utils, 'list_partitions', autospec=True,
|
@mock.patch.object(disk_utils, 'list_partitions', autospec=True,
|
||||||
return_value=[])
|
return_value=[])
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_create_configuration_with_hints(self, mocked_execute,
|
def test_create_configuration_with_hints(self, mocked_execute,
|
||||||
mock_list_parts,
|
mock_list_parts,
|
||||||
mocked_actual_comp):
|
mocked_actual_comp):
|
||||||
@ -3246,7 +3242,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
mock.call(x) for x in ['/dev/sda', '/dev/sdb']
|
mock.call(x) for x in ['/dev/sda', '/dev/sdb']
|
||||||
])
|
])
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
@mock.patch.object(os.path, 'isdir', autospec=True, return_value=False)
|
@mock.patch.object(os.path, 'isdir', autospec=True, return_value=False)
|
||||||
def test_create_configuration_invalid_raid_config(self,
|
def test_create_configuration_invalid_raid_config(self,
|
||||||
mocked_os_path_is_dir,
|
mocked_os_path_is_dir,
|
||||||
@ -3270,7 +3266,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
self.hardware.create_configuration,
|
self.hardware.create_configuration,
|
||||||
self.node, [])
|
self.node, [])
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_create_configuration_invalid_hints(self, mocked_execute):
|
def test_create_configuration_invalid_hints(self, mocked_execute):
|
||||||
for hints in [
|
for hints in [
|
||||||
[],
|
[],
|
||||||
@ -3293,7 +3289,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
self.hardware.create_configuration,
|
self.hardware.create_configuration,
|
||||||
self.node, [])
|
self.node, [])
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_create_configuration_mismatching_hints(self, mocked_execute):
|
def test_create_configuration_mismatching_hints(self, mocked_execute):
|
||||||
device1 = hardware.BlockDevice('/dev/sda', 'sda', 107374182400, True)
|
device1 = hardware.BlockDevice('/dev/sda', 'sda', 107374182400, True)
|
||||||
device2 = hardware.BlockDevice('/dev/sdb', 'sdb', 107374182400, True)
|
device2 = hardware.BlockDevice('/dev/sdb', 'sdb', 107374182400, True)
|
||||||
@ -3325,7 +3321,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
self.node, [])
|
self.node, [])
|
||||||
|
|
||||||
@mock.patch.object(disk_utils, 'list_partitions', autospec=True)
|
@mock.patch.object(disk_utils, 'list_partitions', autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
@mock.patch.object(os.path, 'isdir', autospec=True, return_value=False)
|
@mock.patch.object(os.path, 'isdir', autospec=True, return_value=False)
|
||||||
def test_create_configuration_partitions_detected(self,
|
def test_create_configuration_partitions_detected(self,
|
||||||
mocked_os_path_is_dir,
|
mocked_os_path_is_dir,
|
||||||
@ -3364,7 +3360,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
|
|
||||||
@mock.patch.object(disk_utils, 'list_partitions', autospec=True,
|
@mock.patch.object(disk_utils, 'list_partitions', autospec=True,
|
||||||
return_value=[])
|
return_value=[])
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
@mock.patch.object(os.path, 'isdir', autospec=True, return_value=False)
|
@mock.patch.object(os.path, 'isdir', autospec=True, return_value=False)
|
||||||
def test_create_configuration_device_handling_failures(
|
def test_create_configuration_device_handling_failures(
|
||||||
self, mocked_os_path_is_dir, mocked_execute, mock_list_parts):
|
self, mocked_os_path_is_dir, mocked_execute, mock_list_parts):
|
||||||
@ -3432,7 +3428,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
|
|
||||||
@mock.patch.object(disk_utils, 'list_partitions', autospec=True,
|
@mock.patch.object(disk_utils, 'list_partitions', autospec=True,
|
||||||
return_value=[])
|
return_value=[])
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_create_configuration_device_handling_failures_raid5(
|
def test_create_configuration_device_handling_failures_raid5(
|
||||||
self, mocked_execute, mock_list_parts):
|
self, mocked_execute, mock_list_parts):
|
||||||
raid_config = {
|
raid_config = {
|
||||||
@ -3466,7 +3462,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
self.hardware.create_configuration,
|
self.hardware.create_configuration,
|
||||||
self.node, [])
|
self.node, [])
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_create_configuration_device_handling_failures_raid6(
|
def test_create_configuration_device_handling_failures_raid6(
|
||||||
self, mocked_execute):
|
self, mocked_execute):
|
||||||
raid_config = {
|
raid_config = {
|
||||||
@ -3511,7 +3507,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
autospec=True)
|
autospec=True)
|
||||||
@mock.patch.object(disk_utils, 'list_partitions', autospec=True,
|
@mock.patch.object(disk_utils, 'list_partitions', autospec=True,
|
||||||
return_value=[])
|
return_value=[])
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
@mock.patch.object(os.path, 'isdir', autospec=True, return_value=True)
|
@mock.patch.object(os.path, 'isdir', autospec=True, return_value=True)
|
||||||
def test_create_configuration_with_nvme(self, mocked_os_path_isdir,
|
def test_create_configuration_with_nvme(self, mocked_os_path_isdir,
|
||||||
mocked_execute, mock_list_parts,
|
mocked_execute, mock_list_parts,
|
||||||
@ -3590,7 +3586,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
|
|
||||||
@mock.patch.object(disk_utils, 'list_partitions', autospec=True,
|
@mock.patch.object(disk_utils, 'list_partitions', autospec=True,
|
||||||
return_value=[])
|
return_value=[])
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
@mock.patch.object(os.path, 'isdir', autospec=True, return_value=True)
|
@mock.patch.object(os.path, 'isdir', autospec=True, return_value=True)
|
||||||
def test_create_configuration_failure_with_nvme(self,
|
def test_create_configuration_failure_with_nvme(self,
|
||||||
mocked_os_path_isdir,
|
mocked_os_path_isdir,
|
||||||
@ -3655,7 +3651,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
self.hardware.create_configuration,
|
self.hardware.create_configuration,
|
||||||
self.node, [])
|
self.node, [])
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test__get_md_uuid(self, mocked_execute):
|
def test__get_md_uuid(self, mocked_execute):
|
||||||
mocked_execute.side_effect = [(hws.MDADM_DETAIL_OUTPUT, '')]
|
mocked_execute.side_effect = [(hws.MDADM_DETAIL_OUTPUT, '')]
|
||||||
md_uuid = hardware._get_md_uuid('/dev/md0')
|
md_uuid = hardware._get_md_uuid('/dev/md0')
|
||||||
@ -3663,7 +3659,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
|
|
||||||
@mock.patch.object(hardware, '_get_md_uuid', autospec=True)
|
@mock.patch.object(hardware, '_get_md_uuid', autospec=True)
|
||||||
@mock.patch.object(hardware, 'list_all_block_devices', autospec=True)
|
@mock.patch.object(hardware, 'list_all_block_devices', autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test__get_component_devices(self, mocked_execute,
|
def test__get_component_devices(self, mocked_execute,
|
||||||
mocked_list_all_block_devices,
|
mocked_list_all_block_devices,
|
||||||
mocked_md_uuid):
|
mocked_md_uuid):
|
||||||
@ -3698,13 +3694,13 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
mock.call('mdadm', '--examine', '/dev/sdz1',
|
mock.call('mdadm', '--examine', '/dev/sdz1',
|
||||||
use_standard_locale=True)])
|
use_standard_locale=True)])
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_get_holder_disks(self, mocked_execute):
|
def test_get_holder_disks(self, mocked_execute):
|
||||||
mocked_execute.side_effect = [(hws.MDADM_DETAIL_OUTPUT, '')]
|
mocked_execute.side_effect = [(hws.MDADM_DETAIL_OUTPUT, '')]
|
||||||
holder_disks = hardware.get_holder_disks('/dev/md0')
|
holder_disks = hardware.get_holder_disks('/dev/md0')
|
||||||
self.assertEqual(['/dev/vde', '/dev/vdf'], holder_disks)
|
self.assertEqual(['/dev/vde', '/dev/vdf'], holder_disks)
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
@mock.patch.object(os.path, 'exists', autospec=True)
|
@mock.patch.object(os.path, 'exists', autospec=True)
|
||||||
@mock.patch.object(os, 'stat', autospec=True)
|
@mock.patch.object(os, 'stat', autospec=True)
|
||||||
def test_get_holder_disks_with_whole_device(self, mocked_stat,
|
def test_get_holder_disks_with_whole_device(self, mocked_stat,
|
||||||
@ -3717,13 +3713,13 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
holder_disks = hardware.get_holder_disks('/dev/md0')
|
holder_disks = hardware.get_holder_disks('/dev/md0')
|
||||||
self.assertEqual(['/dev/vde', '/dev/vdf'], holder_disks)
|
self.assertEqual(['/dev/vde', '/dev/vdf'], holder_disks)
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_get_holder_disks_with_nvme(self, mocked_execute):
|
def test_get_holder_disks_with_nvme(self, mocked_execute):
|
||||||
mocked_execute.side_effect = [(hws.MDADM_DETAIL_OUTPUT_NVME, '')]
|
mocked_execute.side_effect = [(hws.MDADM_DETAIL_OUTPUT_NVME, '')]
|
||||||
holder_disks = hardware.get_holder_disks('/dev/md0')
|
holder_disks = hardware.get_holder_disks('/dev/md0')
|
||||||
self.assertEqual(['/dev/nvme0n1', '/dev/nvme1n1'], holder_disks)
|
self.assertEqual(['/dev/nvme0n1', '/dev/nvme1n1'], holder_disks)
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_get_holder_disks_unexpected_devices(self, mocked_execute):
|
def test_get_holder_disks_unexpected_devices(self, mocked_execute):
|
||||||
side_effect = hws.MDADM_DETAIL_OUTPUT_NVME.replace('nvme1n1p1',
|
side_effect = hws.MDADM_DETAIL_OUTPUT_NVME.replace('nvme1n1p1',
|
||||||
'notmatching1a')
|
'notmatching1a')
|
||||||
@ -3735,7 +3731,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
r'/dev/notmatching1a$',
|
r'/dev/notmatching1a$',
|
||||||
hardware.get_holder_disks, '/dev/md0')
|
hardware.get_holder_disks, '/dev/md0')
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_get_holder_disks_broken_raid0(self, mocked_execute):
|
def test_get_holder_disks_broken_raid0(self, mocked_execute):
|
||||||
mocked_execute.side_effect = [(hws.MDADM_DETAIL_OUTPUT_BROKEN_RAID0,
|
mocked_execute.side_effect = [(hws.MDADM_DETAIL_OUTPUT_BROKEN_RAID0,
|
||||||
'')]
|
'')]
|
||||||
@ -3745,7 +3741,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
@mock.patch.object(hardware, 'get_holder_disks', autospec=True)
|
@mock.patch.object(hardware, 'get_holder_disks', autospec=True)
|
||||||
@mock.patch.object(hardware, '_get_component_devices', autospec=True)
|
@mock.patch.object(hardware, '_get_component_devices', autospec=True)
|
||||||
@mock.patch.object(hardware, 'list_all_block_devices', autospec=True)
|
@mock.patch.object(hardware, 'list_all_block_devices', autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_delete_configuration(self, mocked_execute, mocked_list,
|
def test_delete_configuration(self, mocked_execute, mocked_list,
|
||||||
mocked_get_component, mocked_get_holder):
|
mocked_get_component, mocked_get_holder):
|
||||||
raid_device1 = hardware.BlockDevice('/dev/md0', 'RAID-1',
|
raid_device1 = hardware.BlockDevice('/dev/md0', 'RAID-1',
|
||||||
@ -3833,7 +3829,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
|
|
||||||
@mock.patch.object(hardware, '_get_component_devices', autospec=True)
|
@mock.patch.object(hardware, '_get_component_devices', autospec=True)
|
||||||
@mock.patch.object(hardware, 'list_all_block_devices', autospec=True)
|
@mock.patch.object(hardware, 'list_all_block_devices', autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_delete_configuration_partition(self, mocked_execute, mocked_list,
|
def test_delete_configuration_partition(self, mocked_execute, mocked_list,
|
||||||
mocked_get_component):
|
mocked_get_component):
|
||||||
# This test checks that if no components are returned for a given
|
# This test checks that if no components are returned for a given
|
||||||
@ -3858,7 +3854,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
|
|
||||||
@mock.patch.object(hardware, '_get_component_devices', autospec=True)
|
@mock.patch.object(hardware, '_get_component_devices', autospec=True)
|
||||||
@mock.patch.object(hardware, 'list_all_block_devices', autospec=True)
|
@mock.patch.object(hardware, 'list_all_block_devices', autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_delete_configuration_failure_blocks_remaining(
|
def test_delete_configuration_failure_blocks_remaining(
|
||||||
self, mocked_execute, mocked_list, mocked_get_component):
|
self, mocked_execute, mocked_list, mocked_get_component):
|
||||||
|
|
||||||
@ -3894,7 +3890,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
mock.call('mdadm', '--assemble', '--scan', check_exit_code=False),
|
mock.call('mdadm', '--assemble', '--scan', check_exit_code=False),
|
||||||
])
|
])
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_validate_configuration_valid_raid1(self, mocked_execute):
|
def test_validate_configuration_valid_raid1(self, mocked_execute):
|
||||||
raid_config = {
|
raid_config = {
|
||||||
"logical_disks": [
|
"logical_disks": [
|
||||||
@ -3908,7 +3904,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
self.assertIsNone(self.hardware.validate_configuration(raid_config,
|
self.assertIsNone(self.hardware.validate_configuration(raid_config,
|
||||||
self.node))
|
self.node))
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_validate_configuration_valid_raid1_raidN(self, mocked_execute):
|
def test_validate_configuration_valid_raid1_raidN(self, mocked_execute):
|
||||||
raid_config = {
|
raid_config = {
|
||||||
"logical_disks": [
|
"logical_disks": [
|
||||||
@ -3927,7 +3923,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
self.assertIsNone(self.hardware.validate_configuration(raid_config,
|
self.assertIsNone(self.hardware.validate_configuration(raid_config,
|
||||||
self.node))
|
self.node))
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_validate_configuration_invalid_MAX_MAX(self, mocked_execute):
|
def test_validate_configuration_invalid_MAX_MAX(self, mocked_execute):
|
||||||
raid_config = {
|
raid_config = {
|
||||||
"logical_disks": [
|
"logical_disks": [
|
||||||
@ -3947,7 +3943,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
self.hardware.validate_configuration,
|
self.hardware.validate_configuration,
|
||||||
raid_config, self.node)
|
raid_config, self.node)
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_validate_configuration_invalid_raid_level(self, mocked_execute):
|
def test_validate_configuration_invalid_raid_level(self, mocked_execute):
|
||||||
raid_config = {
|
raid_config = {
|
||||||
"logical_disks": [
|
"logical_disks": [
|
||||||
@ -3967,7 +3963,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
self.hardware.validate_configuration,
|
self.hardware.validate_configuration,
|
||||||
raid_config, self.node)
|
raid_config, self.node)
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_validate_configuration_invalid_no_of_raids(self, mocked_execute):
|
def test_validate_configuration_invalid_no_of_raids(self, mocked_execute):
|
||||||
raid_config = {
|
raid_config = {
|
||||||
"logical_disks": [
|
"logical_disks": [
|
||||||
@ -3992,7 +3988,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
self.hardware.validate_configuration,
|
self.hardware.validate_configuration,
|
||||||
raid_config, self.node)
|
raid_config, self.node)
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_get_system_vendor_info(self, mocked_execute):
|
def test_get_system_vendor_info(self, mocked_execute):
|
||||||
mocked_execute.return_value = hws.LSHW_JSON_OUTPUT_V1
|
mocked_execute.return_value = hws.LSHW_JSON_OUTPUT_V1
|
||||||
vendor_info = self.hardware.get_system_vendor_info()
|
vendor_info = self.hardware.get_system_vendor_info()
|
||||||
@ -4000,7 +3996,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
self.assertEqual('1234567', vendor_info.serial_number)
|
self.assertEqual('1234567', vendor_info.serial_number)
|
||||||
self.assertEqual('GENERIC', vendor_info.manufacturer)
|
self.assertEqual('GENERIC', vendor_info.manufacturer)
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_get_system_vendor_info_lshw_list(self, mocked_execute):
|
def test_get_system_vendor_info_lshw_list(self, mocked_execute):
|
||||||
mocked_execute.return_value = (f"[{hws.LSHW_JSON_OUTPUT_V2[0]}]", "")
|
mocked_execute.return_value = (f"[{hws.LSHW_JSON_OUTPUT_V2[0]}]", "")
|
||||||
vendor_info = self.hardware.get_system_vendor_info()
|
vendor_info = self.hardware.get_system_vendor_info()
|
||||||
@ -4008,7 +4004,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
self.assertEqual('1234', vendor_info.serial_number)
|
self.assertEqual('1234', vendor_info.serial_number)
|
||||||
self.assertEqual('ABCD', vendor_info.manufacturer)
|
self.assertEqual('ABCD', vendor_info.manufacturer)
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_get_system_vendor_info_failure(self, mocked_execute):
|
def test_get_system_vendor_info_failure(self, mocked_execute):
|
||||||
mocked_execute.side_effect = processutils.ProcessExecutionError()
|
mocked_execute.side_effect = processutils.ProcessExecutionError()
|
||||||
vendor_info = self.hardware.get_system_vendor_info()
|
vendor_info = self.hardware.get_system_vendor_info()
|
||||||
@ -4042,7 +4038,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
|
|
||||||
@mock.patch.object(hardware.GenericHardwareManager,
|
@mock.patch.object(hardware.GenericHardwareManager,
|
||||||
'_is_linux_raid_member', autospec=True)
|
'_is_linux_raid_member', autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_erase_block_device_nvme_crypto_success(self, mocked_execute,
|
def test_erase_block_device_nvme_crypto_success(self, mocked_execute,
|
||||||
mocked_raid_member):
|
mocked_raid_member):
|
||||||
info = self.node['driver_internal_info']
|
info = self.node['driver_internal_info']
|
||||||
@ -4066,7 +4062,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
|
|
||||||
@mock.patch.object(hardware.GenericHardwareManager,
|
@mock.patch.object(hardware.GenericHardwareManager,
|
||||||
'_is_linux_raid_member', autospec=True)
|
'_is_linux_raid_member', autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_erase_block_device_nvme_userdata_success(self, mocked_execute,
|
def test_erase_block_device_nvme_userdata_success(self, mocked_execute,
|
||||||
mocked_raid_member):
|
mocked_raid_member):
|
||||||
info = self.node['driver_internal_info']
|
info = self.node['driver_internal_info']
|
||||||
@ -4090,7 +4086,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
|
|
||||||
@mock.patch.object(hardware.GenericHardwareManager,
|
@mock.patch.object(hardware.GenericHardwareManager,
|
||||||
'_is_linux_raid_member', autospec=True)
|
'_is_linux_raid_member', autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_erase_block_device_nvme_failed(self, mocked_execute,
|
def test_erase_block_device_nvme_failed(self, mocked_execute,
|
||||||
mocked_raid_member):
|
mocked_raid_member):
|
||||||
info = self.node['driver_internal_info']
|
info = self.node['driver_internal_info']
|
||||||
@ -4108,7 +4104,7 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
|
|
||||||
@mock.patch.object(hardware.GenericHardwareManager,
|
@mock.patch.object(hardware.GenericHardwareManager,
|
||||||
'_is_linux_raid_member', autospec=True)
|
'_is_linux_raid_member', autospec=True)
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
def test_erase_block_device_nvme_format_unsupported(self, mocked_execute,
|
def test_erase_block_device_nvme_format_unsupported(self, mocked_execute,
|
||||||
mocked_raid_member):
|
mocked_raid_member):
|
||||||
info = self.node['driver_internal_info']
|
info = self.node['driver_internal_info']
|
||||||
@ -4256,7 +4252,7 @@ class TestEvaluateHardwareSupport(base.IronicAgentTest):
|
|||||||
|
|
||||||
|
|
||||||
@mock.patch.object(os, 'listdir', lambda *_: [])
|
@mock.patch.object(os, 'listdir', lambda *_: [])
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(il_utils, 'execute', autospec=True)
|
||||||
class TestModuleFunctions(base.IronicAgentTest):
|
class TestModuleFunctions(base.IronicAgentTest):
|
||||||
|
|
||||||
@mock.patch.object(os, 'readlink', autospec=True)
|
@mock.patch.object(os, 'readlink', autospec=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user