From a28eb287750f0289595507f3f0c07cd32dfcadca Mon Sep 17 00:00:00 2001 From: vanou Date: Fri, 7 Jan 2022 21:01:55 +0900 Subject: [PATCH] Add function to determine virtual FD support iRMC dropped support of virtual floppy disk at specific iRMC firmware version. iRMC S4 supports virtual FD till version 9.21F and deprecates it from version 9.62F iRMC S5 supports virtual FD till version 1.25P and deprecates it from version 1.60P This commit adds functions which determine whether iRMC supports virtual floppy disk based on iRMC firmware version. Change-Id: I024b6fb09ebe3c3ffe7ccfff5cf8b2e5b844be94 --- scciclient/irmc/scci.py | 64 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/scciclient/irmc/scci.py b/scciclient/irmc/scci.py index 187e4fb..ba1cb5b 100755 --- a/scciclient/irmc/scci.py +++ b/scciclient/irmc/scci.py @@ -17,6 +17,7 @@ SCCI functionalities shared between different iRMC modules. """ import functools +import re import time import defusedxml.ElementTree as ET @@ -28,6 +29,14 @@ from scciclient.irmc import snmp DEBUG = False +S4_PATTERN = re.compile(r"^iRMC\s*S4$") +S5_PATTERN = re.compile(r"^iRMC\s*S5$") +FW_VERSION_HEAD_PATTERN = re.compile(r"^\d[\d.]*") +FW_VERSION_TAIL_PATTERN = re.compile(r"[a-zA-Z]*$") + +S4_FD_SUPPORT_UPPER = 9.21 +S5_FD_SUPPORT_UPPER = 1.25 + class SCCIError(Exception): """SCCI Error @@ -90,6 +99,14 @@ OpCode SCCI Command String Description 0x0203 ResetFirmware Perform a BMC Reset 0x0251 ConnectRemoteFdImage Connect or Disconnect a Floppy Disk image on a Remote Image Mount (NFS or CIFS Share ) + + This command was deprecated at following + version: + iRMC S4: 9.62F + (9.21F still supports virtual FD) + iRMC S5: 1.60P + (1.25P still supports virtual FD) + 0x0252 ConnectRemoteCdImage Connect or Disconnect a CD/DVD .iso image on a Remote Image Mount (NFS or CIFS Share ) 0x0253 ConnectRemoteHdImage Connect or Disconnect a Hard Disk image on a @@ -627,6 +644,53 @@ def get_irmc_version(report): return version +def get_irmc_version_str(report): + """extract iRMC OS and iRMC firmware version from SCCI report + + This function returns iRMC OS name and iRMC firmware version + :param report: SCCI report element + :returns: a tuple of string (iRMC OS name, iRMC FW version) + """ + + version = get_irmc_version(report) + return version.get('Name'), version.find('Firmware').text + + +def support_virtual_fd_str(irmc_os, fw_version): + """determine iRMC supports virtual floppy disk + + This function determines whether iRMC supports virtual floppy disk + based on provided iRMC OS & iRMC firmware version + :param irmc_os: string representing iRMC OS + :param fw_version: string representing iRMC firmware version + :returns: boolean + """ + + version_head = FW_VERSION_HEAD_PATTERN.match(fw_version) + + if S4_PATTERN.match(irmc_os): + if version_head and float(version_head.group()) <= S4_FD_SUPPORT_UPPER: + return True + elif S5_PATTERN.match(irmc_os): + if version_head and float(version_head.group()) <= S5_FD_SUPPORT_UPPER: + return True + + return False + + +def support_virtual_fd(report): + """determine iRMC supports virtual floppy disk + + This function determines whether iRMC supports virtual floppy disk + based on SCCI report + :param report: SCCI report element + :returns: boolean + """ + + irmc_os, fwv = get_irmc_version_str(report) + return support_virtual_fd_str(irmc_os, fwv) + + def get_essential_properties(report, prop_keys): """get essential properties