Add support to get NIC info for any version
Added more generic logic to parse the version information from the iLO version string. Change-Id: Ia3af9b69dc4b8b0199ead6398084d29cd2606c3e
This commit is contained in:
@@ -361,10 +361,11 @@ class IloClient(operations.IloOperations):
|
||||
else:
|
||||
capabilities = self.ribcl.get_server_capabilities()
|
||||
major_minor = self.ribcl.get_ilo_firmware_version_as_major_minor()
|
||||
if any(major_minor):
|
||||
nic_capacity = ipmi.get_nic_capacity(self.info, major_minor)
|
||||
else:
|
||||
nic_capacity = None
|
||||
|
||||
# NOTE(vmud213): Even if it is None, pass it on to get_nic_capacity
|
||||
# as we still want to try getting nic capacity through ipmitool
|
||||
# irrespective of what firmware we are using.
|
||||
nic_capacity = ipmi.get_nic_capacity(self.info, major_minor)
|
||||
if nic_capacity:
|
||||
capabilities.update({'nic_capacity': nic_capacity})
|
||||
if capabilities:
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
"""Common functionalities used by both RIBCL and RIS."""
|
||||
|
||||
import os
|
||||
import re
|
||||
import stat
|
||||
import time
|
||||
|
||||
@@ -24,6 +25,8 @@ from proliantutils import log
|
||||
|
||||
LOG = log.get_logger(__name__)
|
||||
|
||||
ILO_VER_STR_PATTERN = r"\d+\.\d+"
|
||||
|
||||
|
||||
def wait_for_operation_to_complete(
|
||||
has_operation_completed, retries=10, delay_bw_retries=5,
|
||||
@@ -187,3 +190,28 @@ def add_exec_permission_to(target_file):
|
||||
"""
|
||||
mode = os.stat(target_file).st_mode
|
||||
os.chmod(target_file, mode | stat.S_IXUSR)
|
||||
|
||||
|
||||
def get_major_minor(ilo_ver_str):
|
||||
"""Extract the major and minor number from the passed string
|
||||
|
||||
:param ilo_ver_str: the string that contains the version information
|
||||
:returns: String of the form "<major>.<minor>" or None
|
||||
"""
|
||||
if not ilo_ver_str:
|
||||
return None
|
||||
try:
|
||||
# Note(vmud213):This logic works for all strings
|
||||
# that contain the version info as <major>.<minor>
|
||||
# Formats of the strings:
|
||||
# Release version -> "2.50 Feb 18 2016"
|
||||
# Debug version -> "iLO 4 v2.50"
|
||||
# random version -> "XYZ ABC 2.30"
|
||||
pattern = re.search(ILO_VER_STR_PATTERN, ilo_ver_str)
|
||||
if pattern:
|
||||
matched = pattern.group(0)
|
||||
if matched:
|
||||
return matched
|
||||
return None
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
@@ -53,30 +53,24 @@ def _exec_ipmitool(driver_info, command):
|
||||
return out
|
||||
|
||||
|
||||
def get_ilo_version(ilo_fw_tup):
|
||||
def get_ilo_version(ilo_fw_str):
|
||||
"""Gets the float value of the firmware version
|
||||
|
||||
Converts a tuple with major and minor numbers to a float value.
|
||||
Converts a string with major and minor numbers to a float value.
|
||||
|
||||
:param ilo_fw_tup: Tuple containing the major and minor versions
|
||||
:param ilo_fw_tup: String containing the major and minor versions
|
||||
of the form <major>.<minor>
|
||||
:returns: float value constructed from major and minor numbers.
|
||||
"""
|
||||
|
||||
fw_rev = None
|
||||
if not any(ilo_fw_tup):
|
||||
if not ilo_fw_str:
|
||||
return None
|
||||
|
||||
try:
|
||||
(major, minor) = ilo_fw_tup
|
||||
if all(ilo_fw_tup):
|
||||
fw_rev = float('.'.join(str(m) for m in ilo_fw_tup))
|
||||
elif minor:
|
||||
fw_rev = float('.'.join(["0", str(minor)]))
|
||||
else:
|
||||
fw_rev = float('.'.join([str(major), "0"]))
|
||||
major_minor_val = float(ilo_fw_str)
|
||||
except Exception:
|
||||
return None
|
||||
return fw_rev
|
||||
return major_minor_val
|
||||
|
||||
|
||||
def get_nic_capacity(driver_info, ilo_fw):
|
||||
@@ -96,6 +90,8 @@ def get_nic_capacity(driver_info, ilo_fw):
|
||||
value = None
|
||||
ilo_fw_rev = get_ilo_version(ilo_fw) or DEFAULT_FW_REV
|
||||
|
||||
# Note(vmud213): iLO firmware versions >= 2.3 support reading the FRU
|
||||
# information in a single call instead of iterating over each FRU id.
|
||||
if ilo_fw_rev < MIN_SUGGESTED_FW_REV:
|
||||
for i in range(0xff):
|
||||
# Note(vmud213): We can discard FRU ID's between 0x6e and 0xee
|
||||
|
||||
@@ -1018,28 +1018,14 @@ class RIBCLOperations(operations.IloOperations):
|
||||
details.
|
||||
|
||||
:param data: the output returned by get_host_health_data()
|
||||
:returns: a tuple of major and minor versions of iLO firmware.
|
||||
:returns: String with the format "<major>.<minor>" or None.
|
||||
|
||||
"""
|
||||
data = self.get_host_health_data()
|
||||
firmware_details = self._get_firmware_embedded_health(data)
|
||||
if firmware_details:
|
||||
try:
|
||||
# Note(vmud213):This logic works only for released
|
||||
# versions. For debug iLO firmware versions this logic
|
||||
# may not work as the format of the string differs.
|
||||
# Formats of the strings:
|
||||
# Release version -> "2.50 Feb 18 2016"
|
||||
# Debug version -> "iLO 4 v2.50"
|
||||
# TODO(vmud213) Make changes to account for debug version.
|
||||
ilo_version_str = firmware_details['iLO']
|
||||
version_str = ilo_version_str.split()[0]
|
||||
major, minor = version_str.split('.')
|
||||
return (major, minor)
|
||||
except Exception:
|
||||
return (None, None)
|
||||
else:
|
||||
return (None, None)
|
||||
ilo_version_str = firmware_details.get('iLO', None)
|
||||
return common.get_major_minor(ilo_version_str)
|
||||
|
||||
def _get_number_of_gpu_devices_connected(self, data):
|
||||
"""Gets the number of GPU devices connected to the server
|
||||
|
||||
@@ -950,20 +950,17 @@ class RISOperations(operations.IloOperations):
|
||||
def get_ilo_firmware_version_as_major_minor(self):
|
||||
"""Gets the ilo firmware version for server capabilities
|
||||
|
||||
:returns: a tuple of major and minor versions of iLO firmware.
|
||||
:returns: String with the format "<major>.<minor>" or None.
|
||||
|
||||
"""
|
||||
try:
|
||||
manager, reset_uri = self._get_ilo_details()
|
||||
ilo_fw_maj = (
|
||||
manager['Oem']['Hp']['Firmware']['Current']['MajorVersion']
|
||||
ilo_fw_ver_str = (
|
||||
manager['Oem']['Hp']['Firmware']['Current']['VersionString']
|
||||
)
|
||||
ilo_fw_min = (
|
||||
manager['Oem']['Hp']['Firmware']['Current']['MinorVersion']
|
||||
)
|
||||
return (ilo_fw_maj, ilo_fw_min)
|
||||
return common.get_major_minor(ilo_fw_ver_str)
|
||||
except Exception:
|
||||
return (None, None)
|
||||
return None
|
||||
|
||||
def get_server_capabilities(self):
|
||||
"""Gets server properties which can be used for scheduling
|
||||
|
||||
@@ -102,6 +102,6 @@ NIC_FRU_OUT_ALL = (
|
||||
"Device not present (Command response could not be provided)")
|
||||
|
||||
|
||||
LESSER_THAN_MIN_SUGGESTED_FW_TUP = (2, 25)
|
||||
MIN_SUGGESTED_FW_TUP = (2, 30)
|
||||
GREATER_THAN_MIN_SUGGESTED_FW_TUP = (2, 35)
|
||||
LESSER_THAN_MIN_SUGGESTED_FW_STR = "2.25"
|
||||
MIN_SUGGESTED_FW_STR = "2.30"
|
||||
GREATER_THAN_MIN_SUGGESTED_FW_STR = "2.35"
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -392,9 +392,9 @@ GET_MANAGER_DETAILS = """
|
||||
"Date": "Feb 09 2015",
|
||||
"DebugBuild": false,
|
||||
"MajorVersion": 2,
|
||||
"MinorVersion": 20,
|
||||
"MinorVersion": 4,
|
||||
"Time": "",
|
||||
"VersionString": "iLO 4 v2.20"
|
||||
"VersionString": "iLO 4 v2.04"
|
||||
}
|
||||
},
|
||||
"License":
|
||||
@@ -537,6 +537,445 @@ GET_MANAGER_DETAILS = """
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
GET_MANAGER_DETAILS_EQ_SUGGESTED = """
|
||||
{
|
||||
"AvailableActions":
|
||||
[
|
||||
{
|
||||
"Action": "Reset"
|
||||
}
|
||||
],
|
||||
"CommandShell":
|
||||
{
|
||||
"ConnectTypesSupported":
|
||||
[
|
||||
"SSH",
|
||||
"Oem"
|
||||
],
|
||||
"Enabled": true,
|
||||
"MaxConcurrentSessions": 9
|
||||
},
|
||||
"Description": "Manager View",
|
||||
"Firmware":
|
||||
{
|
||||
"Current":
|
||||
{
|
||||
"VersionString": "iLO 4 v2.20"
|
||||
}
|
||||
},
|
||||
"GraphicalConsole":
|
||||
{
|
||||
"ConnectTypesSupported":
|
||||
[
|
||||
"KVMIP"
|
||||
],
|
||||
"Enabled": true,
|
||||
"MaxConcurrentSessions": 10
|
||||
},
|
||||
"ManagerType": "BMC",
|
||||
"Model": "iLO 4",
|
||||
"Name": "Manager",
|
||||
"Oem":
|
||||
{
|
||||
"Hp":
|
||||
{
|
||||
"AvailableActions":
|
||||
[
|
||||
{
|
||||
"Action": "ResetRestApiState",
|
||||
"Capabilities":
|
||||
[
|
||||
{
|
||||
"AllowableValues":
|
||||
[
|
||||
"/Oem/Hp"
|
||||
],
|
||||
"PropertyName": "Target"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"FederationConfig":
|
||||
{
|
||||
"IPv6MulticastScope": "Site",
|
||||
"MulticastAnnouncementInterval": 600,
|
||||
"MulticastDiscovery": "Enabled",
|
||||
"MulticastTimeToLive": 5,
|
||||
"iLOFederationManagement": "Enabled"
|
||||
},
|
||||
"Firmware":
|
||||
{
|
||||
"Current":
|
||||
{
|
||||
"Date": "Feb 09 2015",
|
||||
"DebugBuild": false,
|
||||
"MajorVersion": 2,
|
||||
"MinorVersion": 4,
|
||||
"Time": "",
|
||||
"VersionString": "iLO 4 v2.30"
|
||||
}
|
||||
},
|
||||
"License":
|
||||
{
|
||||
"LicenseKey": "32Q6W-PQWTB-H7XYL-39968-RR53R",
|
||||
"LicenseString": "iLO 4 Advanced",
|
||||
"LicenseType": "Perpetual"
|
||||
},
|
||||
"RequiredLoginForiLORBSU": false,
|
||||
"SerialCLISpeed": 9600,
|
||||
"SerialCLIStatus": "EnabledAuthReq",
|
||||
"Type": "HpiLO.0.13.0",
|
||||
"VSPLogDownloadEnabled": false,
|
||||
"iLOSelfTestResults":
|
||||
[
|
||||
{
|
||||
"Notes": "",
|
||||
"SelfTestName": "NVRAMData",
|
||||
"Status": "OK"
|
||||
},
|
||||
{
|
||||
"Notes": "Controller firmware revision 2.09.00 ",
|
||||
"SelfTestName": "EmbeddedFlash/SDCard",
|
||||
"Status": "OK"
|
||||
},
|
||||
{
|
||||
"Notes": "",
|
||||
"SelfTestName": "EEPROM",
|
||||
"Status": "OK"
|
||||
},
|
||||
{
|
||||
"Notes": "",
|
||||
"SelfTestName": "HostRom",
|
||||
"Status": "OK"
|
||||
},
|
||||
{
|
||||
"Notes": "",
|
||||
"SelfTestName": "SupportedHost",
|
||||
"Status": "OK"
|
||||
},
|
||||
{
|
||||
"Notes": "ProLiant BL460c Gen9 System Programmable \
|
||||
Logic Device version 0x13",
|
||||
"SelfTestName": "CPLDPAL0",
|
||||
"Status": "Informational"
|
||||
},
|
||||
{
|
||||
"Notes": "ProLiant BL460c Gen9 SAS Programmable \
|
||||
Logic Device version 0x01",
|
||||
"SelfTestName": "CPLDPAL1",
|
||||
"Status": "Informational"
|
||||
}
|
||||
],
|
||||
"links":
|
||||
{
|
||||
"ActiveHealthSystem":
|
||||
{
|
||||
"href": "/rest/v1/Managers/1/ActiveHealthSystem"
|
||||
},
|
||||
"DateTimeService":
|
||||
{
|
||||
"href": "/rest/v1/Managers/1/DateTime"
|
||||
},
|
||||
"EmbeddedMediaService":
|
||||
{
|
||||
"href": "/rest/v1/Managers/1/EmbeddedMedia"
|
||||
},
|
||||
"FederationDispatch":
|
||||
{
|
||||
"extref": "/dispatch"
|
||||
},
|
||||
"FederationGroups":
|
||||
{
|
||||
"href": "/rest/v1/Managers/1/FederationGroups"
|
||||
},
|
||||
"FederationPeers":
|
||||
{
|
||||
"href": "/rest/v1/Managers/1/FederationPeers"
|
||||
},
|
||||
"LicenseService":
|
||||
{
|
||||
"href": "/rest/v1/Managers/1/LicenseService"
|
||||
},
|
||||
"UpdateService":
|
||||
{
|
||||
"href": "/rest/v1/Managers/1/UpdateService"
|
||||
},
|
||||
"VSPLogLocation":
|
||||
{
|
||||
"extref": "/sol.log.gz"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"SerialConsole":
|
||||
{
|
||||
"ConnectTypesSupported":
|
||||
[
|
||||
"SSH",
|
||||
"IPMI",
|
||||
"Oem"
|
||||
],
|
||||
"Enabled": true,
|
||||
"MaxConcurrentSessions": 13
|
||||
},
|
||||
"Status":
|
||||
{
|
||||
"State": "Enabled"
|
||||
},
|
||||
"Type": "Manager.0.10.0",
|
||||
"UUID": "83590768-e977-575a-927a-b3de8f692d4f",
|
||||
"links":
|
||||
{
|
||||
"EthernetNICs":
|
||||
{
|
||||
"href": "/rest/v1/Managers/1/NICs"
|
||||
},
|
||||
"Logs":
|
||||
{
|
||||
"href": "/rest/v1/Managers/1/Logs"
|
||||
},
|
||||
"ManagerForServers":
|
||||
[
|
||||
{
|
||||
"href": "/rest/v1/Systems/1"
|
||||
}
|
||||
],
|
||||
"NetworkService":
|
||||
{
|
||||
"href": "/rest/v1/Managers/1/NetworkService"
|
||||
},
|
||||
"VirtualMedia":
|
||||
{
|
||||
"href": "/rest/v1/Managers/1/VirtualMedia"
|
||||
},
|
||||
"self":
|
||||
{
|
||||
"href": "/rest/v1/Managers/1"
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
GET_MANAGER_DETAILS_GT_SUGGESTED = """
|
||||
{
|
||||
"AvailableActions":
|
||||
[
|
||||
{
|
||||
"Action": "Reset"
|
||||
}
|
||||
],
|
||||
"CommandShell":
|
||||
{
|
||||
"ConnectTypesSupported":
|
||||
[
|
||||
"SSH",
|
||||
"Oem"
|
||||
],
|
||||
"Enabled": true,
|
||||
"MaxConcurrentSessions": 9
|
||||
},
|
||||
"Description": "Manager View",
|
||||
"Firmware":
|
||||
{
|
||||
"Current":
|
||||
{
|
||||
"VersionString": "iLO 4 v2.54"
|
||||
}
|
||||
},
|
||||
"GraphicalConsole":
|
||||
{
|
||||
"ConnectTypesSupported":
|
||||
[
|
||||
"KVMIP"
|
||||
],
|
||||
"Enabled": true,
|
||||
"MaxConcurrentSessions": 10
|
||||
},
|
||||
"ManagerType": "BMC",
|
||||
"Model": "iLO 4",
|
||||
"Name": "Manager",
|
||||
"Oem":
|
||||
{
|
||||
"Hp":
|
||||
{
|
||||
"AvailableActions":
|
||||
[
|
||||
{
|
||||
"Action": "ResetRestApiState",
|
||||
"Capabilities":
|
||||
[
|
||||
{
|
||||
"AllowableValues":
|
||||
[
|
||||
"/Oem/Hp"
|
||||
],
|
||||
"PropertyName": "Target"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"FederationConfig":
|
||||
{
|
||||
"IPv6MulticastScope": "Site",
|
||||
"MulticastAnnouncementInterval": 600,
|
||||
"MulticastDiscovery": "Enabled",
|
||||
"MulticastTimeToLive": 5,
|
||||
"iLOFederationManagement": "Enabled"
|
||||
},
|
||||
"Firmware":
|
||||
{
|
||||
"Current":
|
||||
{
|
||||
"Date": "Feb 09 2015",
|
||||
"DebugBuild": false,
|
||||
"MajorVersion": 2,
|
||||
"MinorVersion": 54,
|
||||
"Time": "",
|
||||
"VersionString": "iLO 4 v2.54"
|
||||
}
|
||||
},
|
||||
"License":
|
||||
{
|
||||
"LicenseKey": "32Q6W-PQWTB-H7XYL-39968-RR53R",
|
||||
"LicenseString": "iLO 4 Advanced",
|
||||
"LicenseType": "Perpetual"
|
||||
},
|
||||
"RequiredLoginForiLORBSU": false,
|
||||
"SerialCLISpeed": 9600,
|
||||
"SerialCLIStatus": "EnabledAuthReq",
|
||||
"Type": "HpiLO.0.13.0",
|
||||
"VSPLogDownloadEnabled": false,
|
||||
"iLOSelfTestResults":
|
||||
[
|
||||
{
|
||||
"Notes": "",
|
||||
"SelfTestName": "NVRAMData",
|
||||
"Status": "OK"
|
||||
},
|
||||
{
|
||||
"Notes": "Controller firmware revision 2.09.00 ",
|
||||
"SelfTestName": "EmbeddedFlash/SDCard",
|
||||
"Status": "OK"
|
||||
},
|
||||
{
|
||||
"Notes": "",
|
||||
"SelfTestName": "EEPROM",
|
||||
"Status": "OK"
|
||||
},
|
||||
{
|
||||
"Notes": "",
|
||||
"SelfTestName": "HostRom",
|
||||
"Status": "OK"
|
||||
},
|
||||
{
|
||||
"Notes": "",
|
||||
"SelfTestName": "SupportedHost",
|
||||
"Status": "OK"
|
||||
},
|
||||
{
|
||||
"Notes": "ProLiant BL460c Gen9 System Programmable \
|
||||
Logic Device version 0x13",
|
||||
"SelfTestName": "CPLDPAL0",
|
||||
"Status": "Informational"
|
||||
},
|
||||
{
|
||||
"Notes": "ProLiant BL460c Gen9 SAS Programmable \
|
||||
Logic Device version 0x01",
|
||||
"SelfTestName": "CPLDPAL1",
|
||||
"Status": "Informational"
|
||||
}
|
||||
],
|
||||
"links":
|
||||
{
|
||||
"ActiveHealthSystem":
|
||||
{
|
||||
"href": "/rest/v1/Managers/1/ActiveHealthSystem"
|
||||
},
|
||||
"DateTimeService":
|
||||
{
|
||||
"href": "/rest/v1/Managers/1/DateTime"
|
||||
},
|
||||
"EmbeddedMediaService":
|
||||
{
|
||||
"href": "/rest/v1/Managers/1/EmbeddedMedia"
|
||||
},
|
||||
"FederationDispatch":
|
||||
{
|
||||
"extref": "/dispatch"
|
||||
},
|
||||
"FederationGroups":
|
||||
{
|
||||
"href": "/rest/v1/Managers/1/FederationGroups"
|
||||
},
|
||||
"FederationPeers":
|
||||
{
|
||||
"href": "/rest/v1/Managers/1/FederationPeers"
|
||||
},
|
||||
"LicenseService":
|
||||
{
|
||||
"href": "/rest/v1/Managers/1/LicenseService"
|
||||
},
|
||||
"UpdateService":
|
||||
{
|
||||
"href": "/rest/v1/Managers/1/UpdateService"
|
||||
},
|
||||
"VSPLogLocation":
|
||||
{
|
||||
"extref": "/sol.log.gz"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"SerialConsole":
|
||||
{
|
||||
"ConnectTypesSupported":
|
||||
[
|
||||
"SSH",
|
||||
"IPMI",
|
||||
"Oem"
|
||||
],
|
||||
"Enabled": true,
|
||||
"MaxConcurrentSessions": 13
|
||||
},
|
||||
"Status":
|
||||
{
|
||||
"State": "Enabled"
|
||||
},
|
||||
"Type": "Manager.0.10.0",
|
||||
"UUID": "83590768-e977-575a-927a-b3de8f692d4f",
|
||||
"links":
|
||||
{
|
||||
"EthernetNICs":
|
||||
{
|
||||
"href": "/rest/v1/Managers/1/NICs"
|
||||
},
|
||||
"Logs":
|
||||
{
|
||||
"href": "/rest/v1/Managers/1/Logs"
|
||||
},
|
||||
"ManagerForServers":
|
||||
[
|
||||
{
|
||||
"href": "/rest/v1/Systems/1"
|
||||
}
|
||||
],
|
||||
"NetworkService":
|
||||
{
|
||||
"href": "/rest/v1/Managers/1/NetworkService"
|
||||
},
|
||||
"VirtualMedia":
|
||||
{
|
||||
"href": "/rest/v1/Managers/1/VirtualMedia"
|
||||
},
|
||||
"self":
|
||||
{
|
||||
"href": "/rest/v1/Managers/1"
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
GET_MANAGER_DETAILS_NO_FIRMWARE = """
|
||||
{
|
||||
"AvailableActions":
|
||||
@@ -611,7 +1050,7 @@ GET_MANAGER_DETAILS_NO_FIRMWARE = """
|
||||
"DebugBuild": false,
|
||||
"MinorVersion": 20,
|
||||
"Time": "",
|
||||
"VersionString": "iLO 4 v2.20"
|
||||
"VersionString": "iLO 4 v"
|
||||
}
|
||||
},
|
||||
"License":
|
||||
|
||||
@@ -270,7 +270,7 @@ class IloClientTestCase(testtools.TestCase):
|
||||
@mock.patch.object(ribcl.RIBCLOperations, 'get_server_capabilities')
|
||||
def test_get_server_capabilities(self, cap_mock, maj_min_mock, nic_mock):
|
||||
info = {'address': "1.2.3.4", 'username': "admin", 'password': "Admin"}
|
||||
tup_val = maj_min_mock.return_value = (u'2', u'10',)
|
||||
str_val = maj_min_mock.return_value = "2.10"
|
||||
nic_mock.return_value = '10Gb'
|
||||
cap_mock.return_value = {'ilo_firmware_version': '2.10',
|
||||
'rom_firmware_version': 'x',
|
||||
@@ -283,7 +283,7 @@ class IloClientTestCase(testtools.TestCase):
|
||||
'pci_gpu_devices': '2',
|
||||
'nic_capacity': '10Gb'}
|
||||
cap_mock.assert_called_once_with()
|
||||
nic_mock.assert_called_once_with(self.client.info, tup_val)
|
||||
nic_mock.assert_called_once_with(self.client.info, str_val)
|
||||
self.assertEqual(expected_capabilities, capabilities)
|
||||
self.assertEqual(info, self.client.info)
|
||||
|
||||
@@ -294,7 +294,7 @@ class IloClientTestCase(testtools.TestCase):
|
||||
def test_get_server_capabilities_no_nic(self, cap_mock, maj_min_mock,
|
||||
nic_mock):
|
||||
info = {'address': "1.2.3.4", 'username': "admin", 'password': "Admin"}
|
||||
tup_val = maj_min_mock.return_value = (u'2', u'10',)
|
||||
str_val = maj_min_mock.return_value = '2.10'
|
||||
nic_mock.return_value = None
|
||||
cap_mock.return_value = {'ilo_firmware_version': '2.10',
|
||||
'rom_firmware_version': 'x',
|
||||
@@ -306,7 +306,7 @@ class IloClientTestCase(testtools.TestCase):
|
||||
'server_model': 'Gen8',
|
||||
'pci_gpu_devices': '2'}
|
||||
cap_mock.assert_called_once_with()
|
||||
nic_mock.assert_called_once_with(self.client.info, tup_val)
|
||||
nic_mock.assert_called_once_with(self.client.info, str_val)
|
||||
self.assertEqual(expected_capabilities, capabilities)
|
||||
self.assertEqual(info, self.client.info)
|
||||
|
||||
@@ -316,7 +316,7 @@ class IloClientTestCase(testtools.TestCase):
|
||||
@mock.patch.object(ribcl.RIBCLOperations, 'get_server_capabilities')
|
||||
def test_get_server_capabilities_no_firmware(self, cap_mock,
|
||||
maj_min_mock, nic_mock):
|
||||
maj_min_mock.return_value = (None, None,)
|
||||
maj_min_mock.return_value = None
|
||||
nic_mock.return_value = None
|
||||
cap_mock.return_value = {'rom_firmware_version': 'x',
|
||||
'server_model': 'Gen8',
|
||||
@@ -326,7 +326,7 @@ class IloClientTestCase(testtools.TestCase):
|
||||
'pci_gpu_devices': '2'}
|
||||
capabilities = self.client.get_server_capabilities()
|
||||
self.assertEqual(expected_capabilities, capabilities)
|
||||
nic_mock.assert_not_called()
|
||||
nic_mock.assert_called_once_with(self.client.info, None)
|
||||
|
||||
@mock.patch.object(ris.RISOperations,
|
||||
'get_ilo_firmware_version_as_major_minor')
|
||||
@@ -341,7 +341,7 @@ class IloClientTestCase(testtools.TestCase):
|
||||
data = constants.GET_EMBEDDED_HEALTH_OUTPUT
|
||||
json_data = json.loads(data)
|
||||
host_mock.return_value = json_data
|
||||
tup_val = mm_mock.return_value = (u'2', u'10',)
|
||||
str_val = mm_mock.return_value = '2.10'
|
||||
self.client.model = 'Gen9'
|
||||
nic_mock.return_value = None
|
||||
gpu_mock.return_value = {'pci_gpu_devices': 2}
|
||||
@@ -351,7 +351,7 @@ class IloClientTestCase(testtools.TestCase):
|
||||
'secure_boot': 'true'}
|
||||
capabilities = self.client.get_server_capabilities()
|
||||
cap_mock.assert_called_once_with()
|
||||
nic_mock.assert_called_once_with(self.client.info, tup_val)
|
||||
nic_mock.assert_called_once_with(self.client.info, str_val)
|
||||
expected_capabilities = {'ilo_firmware_version': '2.10',
|
||||
'rom_firmware_version': 'x',
|
||||
'server_model': 'Gen9',
|
||||
@@ -373,7 +373,7 @@ class IloClientTestCase(testtools.TestCase):
|
||||
data = constants.GET_EMBEDDED_HEALTH_OUTPUT
|
||||
json_data = json.loads(data)
|
||||
host_mock.return_value = json_data
|
||||
tup_val = mm_mock.return_value = (u'2', u'10',)
|
||||
str_val = mm_mock.return_value = '2.10'
|
||||
self.client.model = 'Gen9'
|
||||
gpu_mock.return_value = {'pci_gpu_devices': 2}
|
||||
nic_mock.return_value = '10Gb'
|
||||
@@ -383,7 +383,7 @@ class IloClientTestCase(testtools.TestCase):
|
||||
'secure_boot': 'true'}
|
||||
capabilities = self.client.get_server_capabilities()
|
||||
cap_mock.assert_called_once_with()
|
||||
nic_mock.assert_called_once_with(self.client.info, tup_val)
|
||||
nic_mock.assert_called_once_with(self.client.info, str_val)
|
||||
expected_capabilities = {'ilo_firmware_version': '2.10',
|
||||
'rom_firmware_version': 'x',
|
||||
'server_model': 'Gen9',
|
||||
|
||||
@@ -191,3 +191,27 @@ class IloCommonModuleTestCase(unittest.TestCase):
|
||||
os_mock.stat.assert_called_once_with(any_file)
|
||||
os_mock.chmod.assert_called_once_with(
|
||||
any_file, os_mock.stat().st_mode | stat_mock.S_IXUSR)
|
||||
|
||||
def test_get_major_minor_lt_suggested_min(self):
|
||||
ver_str = "iLO 4 v2.05"
|
||||
actual = "2.05"
|
||||
expected = common.get_major_minor(ver_str)
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
def test_get_major_minor_eq_suggested_min(self):
|
||||
ver_str = "iLO 4 v2.30"
|
||||
actual = "2.30"
|
||||
expected = common.get_major_minor(ver_str)
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
def test_get_major_minor_gt_suggested_min(self):
|
||||
ver_str = "iLO 4 v2.5"
|
||||
actual = "2.5"
|
||||
expected = common.get_major_minor(ver_str)
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
def test_get_major_minor_unexpected(self):
|
||||
ver_str = "iLO 4 v"
|
||||
actual = None
|
||||
expected = common.get_major_minor(ver_str)
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
@@ -32,40 +32,40 @@ class IloIpmiTestCase(unittest.TestCase):
|
||||
'username': "admin",
|
||||
'password': "Admin"}
|
||||
|
||||
def test_get_ilo_version_valid(self):
|
||||
in_vals = (u'2', u'30',)
|
||||
def test_get_ilo_version_valid_1(self):
|
||||
in_vals = '2.03'
|
||||
expected = 2.03
|
||||
actual = ipmi.get_ilo_version(in_vals)
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
def test_get_ilo_version_valid_2(self):
|
||||
in_vals = '2.3'
|
||||
expected = 2.30
|
||||
actual = ipmi.get_ilo_version(in_vals)
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
def test_get_ilo_version_no_minor(self):
|
||||
in_vals = (u'2', None,)
|
||||
expected = 2.0
|
||||
actual = ipmi.get_ilo_version(in_vals)
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
def test_get_ilo_version_no_major(self):
|
||||
in_vals = (None, u'2',)
|
||||
expected = 0.2
|
||||
actual = ipmi.get_ilo_version(in_vals)
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
def test_get_ilo_version_no_major_no_minor(self):
|
||||
in_vals = (None, None,)
|
||||
def test_get_ilo_version_invalid(self):
|
||||
in_vals = 'x.y'
|
||||
expected = None
|
||||
actual = ipmi.get_ilo_version(in_vals)
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
def test_get_ilo_version_exception(self):
|
||||
in_vals = ("text", 2,)
|
||||
def test_get_ilo_version_appended_spaces(self):
|
||||
in_vals = ' 2.50 '
|
||||
expected = 2.5
|
||||
actual = ipmi.get_ilo_version(in_vals)
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
def test_get_ilo_version_none(self):
|
||||
in_vals = None
|
||||
expected = None
|
||||
actual = ipmi.get_ilo_version(in_vals)
|
||||
self.assertEqual(expected, actual)
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
@mock.patch.object(ipmi, '_parse_ipmi_nic_capacity')
|
||||
@mock.patch.object(ipmi, '_exec_ipmitool')
|
||||
def test_get_nic_capacity_fw_lt_suggested(self, ipmi_mock, parse_mock):
|
||||
fw_rev = constants.LESSER_THAN_MIN_SUGGESTED_FW_TUP
|
||||
fw_rev = constants.LESSER_THAN_MIN_SUGGESTED_FW_STR
|
||||
ipmi_mock.return_value = constants.NIC_FRU_OUT
|
||||
parse_mock.return_value = "1Gb"
|
||||
expected_out = "1Gb"
|
||||
@@ -78,7 +78,7 @@ class IloIpmiTestCase(unittest.TestCase):
|
||||
def test_get_nic_capacity_fw_lt_suggested_none(self,
|
||||
ipmi_mock,
|
||||
parse_mock):
|
||||
fw_rev = constants.LESSER_THAN_MIN_SUGGESTED_FW_TUP
|
||||
fw_rev = constants.LESSER_THAN_MIN_SUGGESTED_FW_STR
|
||||
ipmi_mock.return_value = constants.NIC_FRU_OUT
|
||||
parse_mock.return_value = None
|
||||
actual_out = ipmi.get_nic_capacity(self.info, fw_rev)
|
||||
@@ -89,7 +89,7 @@ class IloIpmiTestCase(unittest.TestCase):
|
||||
@mock.patch.object(ipmi, '_exec_ipmitool')
|
||||
def test_get_nic_capacity_fw_lt_suggested_out_of_range_check(
|
||||
self, ipmi_mock, parse_mock):
|
||||
fw_rev = constants.LESSER_THAN_MIN_SUGGESTED_FW_TUP
|
||||
fw_rev = constants.LESSER_THAN_MIN_SUGGESTED_FW_STR
|
||||
actual_out = ipmi.get_nic_capacity(self.info, fw_rev)
|
||||
format_call_args = map(lambda x: x[0][1],
|
||||
ipmi_mock.call_args_list)
|
||||
@@ -100,7 +100,7 @@ class IloIpmiTestCase(unittest.TestCase):
|
||||
@mock.patch.object(ipmi, '_exec_ipmitool')
|
||||
def test_get_nic_capacity_fw_lt_suggested_in_range_check(
|
||||
self, ipmi_mock, parse_mock):
|
||||
fw_rev = constants.LESSER_THAN_MIN_SUGGESTED_FW_TUP
|
||||
fw_rev = constants.LESSER_THAN_MIN_SUGGESTED_FW_STR
|
||||
actual_out = ipmi.get_nic_capacity(self.info, fw_rev)
|
||||
format_call_args = map(lambda x: x[0][1],
|
||||
ipmi_mock.call_args_list)
|
||||
@@ -110,7 +110,7 @@ class IloIpmiTestCase(unittest.TestCase):
|
||||
@mock.patch.object(ipmi, '_parse_ipmi_nic_capacity')
|
||||
@mock.patch.object(ipmi, '_exec_ipmitool')
|
||||
def test_get_nic_capacity_fw_suggested(self, ipmi_mock, parse_mock):
|
||||
fw_rev = constants.MIN_SUGGESTED_FW_TUP
|
||||
fw_rev = constants.MIN_SUGGESTED_FW_STR
|
||||
ipmi_mock.return_value = constants.NIC_FRU_OUT_ALL
|
||||
parse_mock.return_value = "1Gb"
|
||||
expected_out = "1Gb"
|
||||
@@ -122,7 +122,7 @@ class IloIpmiTestCase(unittest.TestCase):
|
||||
@mock.patch.object(ipmi, '_parse_ipmi_nic_capacity')
|
||||
@mock.patch.object(ipmi, '_exec_ipmitool')
|
||||
def test_get_nic_capacity_fw_suggested_none(self, ipmi_mock, parse_mock):
|
||||
fw_rev = constants.MIN_SUGGESTED_FW_TUP
|
||||
fw_rev = constants.MIN_SUGGESTED_FW_STR
|
||||
ipmi_mock.return_value = constants.NIC_FRU_OUT_ALL
|
||||
parse_mock.return_value = None
|
||||
actual_out = ipmi.get_nic_capacity(self.info, fw_rev)
|
||||
@@ -132,7 +132,7 @@ class IloIpmiTestCase(unittest.TestCase):
|
||||
@mock.patch.object(ipmi, '_parse_ipmi_nic_capacity')
|
||||
@mock.patch.object(ipmi, '_exec_ipmitool')
|
||||
def test_get_nic_capacity_fw_gt_suggested(self, ipmi_mock, parse_mock):
|
||||
fw_rev = constants.GREATER_THAN_MIN_SUGGESTED_FW_TUP
|
||||
fw_rev = constants.GREATER_THAN_MIN_SUGGESTED_FW_STR
|
||||
ipmi_mock.return_value = constants.NIC_FRU_OUT_ALL
|
||||
parse_mock.return_value = "1Gb"
|
||||
expected_out = "1Gb"
|
||||
@@ -145,7 +145,7 @@ class IloIpmiTestCase(unittest.TestCase):
|
||||
def test_get_nic_capacity_fw_lt_suggested_loop_N_times(self,
|
||||
ipmi_mock,
|
||||
parse_mock):
|
||||
fw_rev = constants.LESSER_THAN_MIN_SUGGESTED_FW_TUP
|
||||
fw_rev = constants.LESSER_THAN_MIN_SUGGESTED_FW_STR
|
||||
ipmi_mock.side_effect = ["Device not present", "Device not present",
|
||||
"Device not present", "Device not present",
|
||||
"Device not present", "Device not present",
|
||||
|
||||
@@ -601,9 +601,26 @@ class IloRibclTestCase(unittest.TestCase):
|
||||
def test_get_ilo_firmware_version_as_major_minor(self, mock_health_data):
|
||||
data = constants.GET_EMBEDDED_HEALTH_OUTPUT
|
||||
mock_health_data.return_value = json.loads(data)
|
||||
expected_ilo = (u'2', u'02',)
|
||||
expected_ilo = '2.02'
|
||||
ilo_firmware = self.ilo.get_ilo_firmware_version_as_major_minor()
|
||||
self.assertEqual(expected_ilo, ilo_firmware)
|
||||
|
||||
@mock.patch.object(ribcl.RIBCLOperations, 'get_host_health_data')
|
||||
def test_get_ilo_firmware_version_as_major_minor_eq_suggested(
|
||||
self, mock_health_data):
|
||||
data = constants.GET_EMBEDDED_HEALTH_OUTPUT_EQ_SUGGESTED
|
||||
mock_health_data.return_value = json.loads(data)
|
||||
expected_ilo = '2.30'
|
||||
ilo_firmware = self.ilo.get_ilo_firmware_version_as_major_minor()
|
||||
self.assertEqual(expected_ilo, ilo_firmware)
|
||||
|
||||
@mock.patch.object(ribcl.RIBCLOperations, 'get_host_health_data')
|
||||
def test_get_ilo_firmware_version_as_major_minor_gt_suggested(
|
||||
self, mock_health_data):
|
||||
data = constants.GET_EMBEDDED_HEALTH_OUTPUT_GT_SUGGESTED
|
||||
mock_health_data.return_value = json.loads(data)
|
||||
expected_ilo = '2.54'
|
||||
ilo_firmware = self.ilo.get_ilo_firmware_version_as_major_minor()
|
||||
self.assertIsInstance(ilo_firmware, tuple)
|
||||
self.assertEqual(expected_ilo, ilo_firmware)
|
||||
|
||||
@mock.patch.object(ribcl.RIBCLOperations, 'get_host_health_data')
|
||||
@@ -611,19 +628,17 @@ class IloRibclTestCase(unittest.TestCase):
|
||||
self, mock_health_data):
|
||||
data = constants.GET_EMBEDDED_HEALTH_OUTPUT_UNEXPECTED_FORMAT
|
||||
mock_health_data.return_value = json.loads(data)
|
||||
expected_ilo = (None, None,)
|
||||
expected_ilo = None
|
||||
ilo_firmware = self.ilo.get_ilo_firmware_version_as_major_minor()
|
||||
self.assertIsInstance(ilo_firmware, tuple)
|
||||
self.assertEqual(expected_ilo, ilo_firmware)
|
||||
|
||||
@mock.patch.object(ribcl.RIBCLOperations, 'get_host_health_data')
|
||||
def test_get_ilo_firmware_version_as_major_minor_no_firmware(
|
||||
self, mock_health_data):
|
||||
data = constants.GET_EMBEDDED_HEALTH_OUTPUT_UNEXPECTED_FORMAT
|
||||
data = constants.GET_EMBEDDED_HEALTH_OUTPUT_NO_FIRMWARE
|
||||
mock_health_data.return_value = json.loads(data)
|
||||
expected_ilo = (None, None,)
|
||||
expected_ilo = None
|
||||
ilo_firmware = self.ilo.get_ilo_firmware_version_as_major_minor()
|
||||
self.assertIsInstance(ilo_firmware, tuple)
|
||||
self.assertEqual(expected_ilo, ilo_firmware)
|
||||
|
||||
def test__get_number_of_gpu_devices_connected(self):
|
||||
|
||||
@@ -409,19 +409,37 @@ class IloRisTestCase(testtools.TestCase):
|
||||
uri = '/rest/v1/Managers/1'
|
||||
get_ilo_details_mock.return_value = (ilo_details, uri)
|
||||
ilo_firm = self.client.get_ilo_firmware_version_as_major_minor()
|
||||
expected_ilo_firm = (2, 20)
|
||||
self.assertIsInstance(ilo_firm, tuple)
|
||||
expected_ilo_firm = "2.04"
|
||||
self.assertEqual(expected_ilo_firm, ilo_firm)
|
||||
|
||||
@mock.patch.object(ris.RISOperations, '_get_ilo_details')
|
||||
def test_get_ilo_firmware_version_as_major_minor_no_data(
|
||||
def test_get_ilo_firmware_version_as_major_minor_suggested_min(
|
||||
self, get_ilo_details_mock):
|
||||
ilo_details = json.loads(ris_outputs.GET_MANAGER_DETAILS_EQ_SUGGESTED)
|
||||
uri = '/rest/v1/Managers/1'
|
||||
get_ilo_details_mock.return_value = (ilo_details, uri)
|
||||
ilo_firm = self.client.get_ilo_firmware_version_as_major_minor()
|
||||
expected_ilo_firm = "2.30"
|
||||
self.assertEqual(expected_ilo_firm, ilo_firm)
|
||||
|
||||
@mock.patch.object(ris.RISOperations, '_get_ilo_details')
|
||||
def test_get_ilo_firmware_version_as_major_minor_gt_suggested_min(
|
||||
self, get_ilo_details_mock):
|
||||
ilo_details = json.loads(ris_outputs.GET_MANAGER_DETAILS_GT_SUGGESTED)
|
||||
uri = '/rest/v1/Managers/1'
|
||||
get_ilo_details_mock.return_value = (ilo_details, uri)
|
||||
ilo_firm = self.client.get_ilo_firmware_version_as_major_minor()
|
||||
expected_ilo_firm = "2.54"
|
||||
self.assertEqual(expected_ilo_firm, ilo_firm)
|
||||
|
||||
@mock.patch.object(ris.RISOperations, '_get_ilo_details')
|
||||
def test_get_ilo_firmware_version_as_major_minor_no_firmware(
|
||||
self, get_ilo_details_mock):
|
||||
ilo_details = json.loads(ris_outputs.GET_MANAGER_DETAILS_NO_FIRMWARE)
|
||||
uri = '/rest/v1/Managers/1'
|
||||
get_ilo_details_mock.return_value = (ilo_details, uri)
|
||||
ilo_firm = self.client.get_ilo_firmware_version_as_major_minor()
|
||||
expected_ilo_firm = (None, None)
|
||||
self.assertIsInstance(ilo_firm, tuple)
|
||||
expected_ilo_firm = None
|
||||
self.assertEqual(expected_ilo_firm, ilo_firm)
|
||||
|
||||
@mock.patch.object(ris.RISOperations, '_get_ilo_details')
|
||||
|
||||
Reference in New Issue
Block a user