class OpTestFlashBase(unittest.TestCase): def setUp(self): conf = OpTestConfiguration.conf self.cv_SYSTEM = conf.system() self.cv_BMC = conf.bmc() self.cv_HOST = conf.host() self.cv_IPMI = conf.ipmi() self.platform = conf.platform() self.util = OpTestUtil() self.bmc_type = conf.args.bmc_type self.bmc_ip = conf.args.bmc_ip self.bmc_username = conf.args.bmc_username self.bmc_password = conf.args.bmc_password def validate_side_activated(self): l_bmc_side, l_pnor_side = self.cv_IPMI.ipmi_get_side_activated() self.assertIn(BMC_CONST.PRIMARY_SIDE, l_bmc_side, "BMC: Primary side is not active") # TODO force setting of primary side to BIOS Golden side sensor self.assertIn(BMC_CONST.PRIMARY_SIDE, l_pnor_side, "PNOR: Primary side is not active") def get_pnor_level(self): rc = self.cv_IPMI.ipmi_get_PNOR_level() print rc def bmc_down_check(self): cmd = "ping -c 1 " + self.cv_BMC.host_name + " 1> /dev/null; echo $?" count = 0 while count < 500: output = commands.getstatusoutput(cmd) if output[1] != '0': print "FSP/BMC Comes down" break count = count + 1 time.sleep(2) else: self.assertTrue(False, "FSP/BMC keeps on pinging up") return True def scp_file(self, src_file_path, dst_file_path): self.util.copyFilesToDest(src_file_path, self.bmc_username, self.bmc_ip, dst_file_path, self.bmc_password, "2", BMC_CONST.SCP_TO_REMOTE)
class OpTestFWTS(): ## Initialize this object # @param i_bmcIP The IP address of the BMC # @param i_bmcUser The userid to log into the BMC with # @param i_bmcPasswd The password of the userid to log into the BMC with # @param i_bmcUserIpmi The userid to issue the BMC IPMI commands with # @param i_bmcPasswdIpmi The password of BMC IPMI userid # @param i_ffdcDir Optional param to indicate where to write FFDC # # "Only required for inband tests" else Default = None # @param i_hostIP The IP address of the HOST # @param i_hostuser The userid to log into the HOST # @param i_hostPasswd The password of the userid to log into the HOST with # def __init__(self, i_bmcIP, i_bmcUser, i_bmcPasswd, i_bmcUserIpmi, i_bmcPasswdIpmi, i_ffdcDir=None, i_hostip=None, i_hostuser=None, i_hostPasswd=None): self.cv_BMC = OpTestBMC(i_bmcIP, i_bmcUser, i_bmcPasswd, i_ffdcDir) self.cv_IPMI = OpTestIPMI(i_bmcIP, i_bmcUserIpmi, i_bmcPasswdIpmi, i_ffdcDir, i_hostip, i_hostuser, i_hostPasswd) self.cv_HOST = OpTestHost(i_hostip, i_hostuser, i_hostPasswd, i_bmcIP, i_ffdcDir) self.cv_SYSTEM = OpTestSystem(i_bmcIP, i_bmcUser, i_bmcPasswd, i_bmcUserIpmi, i_bmcPasswdIpmi, i_ffdcDir, i_hostip, i_hostuser, i_hostPasswd) self.util = OpTestUtil() self.user = i_hostuser self.ip = i_hostip self.passwd = i_hostPasswd ## # @brief This function just brings the system to host OS. # # @return BMC_CONST.FW_SUCCESS or raise OpTestError # def test_system_reboot(self): print "Testing FWTS: Booting system to OS" print "Performing a IPMI Power OFF Operation" # Perform a IPMI Power OFF Operation(Immediate Shutdown) self.cv_IPMI.ipmi_power_off() if int(self.cv_SYSTEM.sys_wait_for_standby_state(BMC_CONST.SYSTEM_STANDBY_STATE_DELAY)) == BMC_CONST.FW_SUCCESS: print "System is in standby/Soft-off state" else: l_msg = "System failed to reach standby/Soft-off state" raise OpTestError(l_msg) self.cv_IPMI.ipmi_power_on() self.cv_SYSTEM.sys_check_host_status() self.util.PingFunc(self.cv_HOST.ip, BMC_CONST.PING_RETRY_POWERCYCLE) self.cv_IPMI.clear_ssh_keys(self.cv_HOST.ip) print "Gathering the OPAL msg logs" self.cv_HOST.host_gather_opal_msg_log() return BMC_CONST.FW_SUCCESS ## # @brief This function just executes the fwts_execution.sh on host OS # # @return BMC_CONST.FW_SUCCESS or raise OpTestError # def test_fwts(self): l_oslevel = self.cv_HOST.host_get_OS_Level() if not "Ubuntu" in l_oslevel: return # Copy the fwts execution file to the tmp folder in the host base_path = (os.path.dirname(os.path.abspath(__file__))).split('testcases')[0] fwts_script = base_path + "/testcases/fwts_execution.sh" try: self.util.copyFilesToDest(fwts_script, self.user, self.ip, "/tmp/", self.passwd) except: l_msg = "Copying fwts file to host failed" print l_msg raise OpTestError(l_msg) l_res = self.cv_HOST.host_run_command("/tmp/fwts_execution.sh") print l_res
class OpTestMtdPnorDriver(): ## Initialize this object and also getting the host login credentials to use by scp utility # @param i_bmcIP The IP address of the BMC # @param i_bmcUser The userid to log into the BMC with # @param i_bmcPasswd The password of the userid to log into the BMC with # @param i_bmcUserIpmi The userid to issue the BMC IPMI commands with # @param i_bmcPasswdIpmi The password of BMC IPMI userid # @param i_ffdcDir Optional param to indicate where to write FFDC # # "Only required for inband tests" else Default = None # @param i_hostIP The IP address of the HOST # @param i_hostuser The userid to log into the HOST # @param i_hostPasswd The password of the userid to log into the HOST with # def __init__(self, i_bmcIP, i_bmcUser, i_bmcPasswd, i_bmcUserIpmi, i_bmcPasswdIpmi, i_ffdcDir=None, i_hostip=None, i_hostuser=None, i_hostPasswd=None): self.cv_BMC = OpTestBMC(i_bmcIP, i_bmcUser, i_bmcPasswd, i_ffdcDir) self.cv_IPMI = OpTestIPMI(i_bmcIP, i_bmcUserIpmi, i_bmcPasswdIpmi, i_ffdcDir) self.cv_HOST = OpTestHost(i_hostip, i_hostuser, i_hostPasswd, i_bmcIP) self.cv_SYSTEM = OpTestSystem(i_bmcIP, i_bmcUser, i_bmcPasswd, i_bmcUserIpmi, i_bmcPasswdIpmi, i_ffdcDir, i_hostip, i_hostuser, i_hostPasswd) self.util = OpTestUtil() self.host_user = i_hostuser self.host_ip = i_hostip self.host_Passwd = i_hostPasswd ## # @brief This function has following test steps # 1. Get host information(OS and Kernel information) # 2. Load the mtd module based on config value # 3. Check /dev/mtd0 character device file existence on host # 4. Copying the contents of the flash in a file /tmp/pnor # 5. Getting the /tmp/pnor file into local x86 machine using scp utility # 6. Remove existing /tmp/ffs directory and # Clone latest ffs git repository in local x86 working machine # 7. Compile ffs repository to get fcp utility # 8. Check existence of fcp utility in ffs repository, after compiling # 9. Get the PNOR flash contents on an x86 machine using fcp utility # # @return BMC_CONST.FW_SUCCESS-success or raise OpTestError-fail # def testMtdPnorDriver(self): self.cv_SYSTEM.sys_bmc_power_on_validate_host() # Get OS level l_oslevel = self.cv_HOST.host_get_OS_Level() # Get Kernel Version l_kernel = self.cv_HOST.host_get_kernel_version() # loading mtd module based on config option l_config = "CONFIG_MTD_POWERNV_FLASH" l_module = "mtd" self.cv_HOST.host_load_module_based_on_config(l_kernel, l_config, l_module) # Check /dev/mtd0 file existence on host l_cmd = "ls -l /dev/mtd0; echo $?" l_res = self.cv_HOST.host_run_command(l_cmd) l_res = l_res.splitlines() if int(l_res[-1]) == 0: print "/dev/mtd0 character device file exists on host" else: l_msg = "/dev/mtd0 character device file doesn't exist on host" print l_msg raise OpTestError(l_msg) # Copying the contents of the PNOR flash in a file /tmp/pnor l_file = "/tmp/pnor" l_cmd = "cat /dev/mtd0 > %s; echo $?" % l_file l_res = self.cv_HOST.host_run_command(l_cmd) l_res = l_res.splitlines() if int(l_res[-1]) == 0: print "Fetched PNOR data from /dev/mtd0 into temp file /tmp/pnor" else: l_msg = "Fetching PNOR data is failed from /dev/mtd0 into temp file /tmp/pnor" print l_msg raise OpTestError(l_msg) # Getting the /tmp/pnor file into local x86 machine l_path = "/tmp/" self.util.copyFilesToDest(l_path, self.host_user, self.host_ip, l_file, self.host_Passwd, "2", BMC_CONST.SCP_TO_LOCAL) l_list = commands.getstatusoutput("ls -l %s; echo $?" % l_path) print l_list l_workdir = "/tmp/ffs" # Remove existing /tmp/ffs directory l_res = commands.getstatusoutput("rm -rf %s" % l_workdir) print l_res # Clone latest ffs git repository in local x86 working machine l_cmd = "git clone https://github.com/open-power/ffs/ %s" % l_workdir l_res = commands.getstatusoutput(l_cmd) print l_res if int(l_res[0]) == 0: print "Cloning of ffs repository is successfull" else: l_msg = "Cloning ffs repository is failed" print l_msg raise OpTestError(l_msg) # Compile ffs repository to get fcp utility l_cmd = "cd %s/; make" % l_workdir l_res = commands.getstatusoutput(l_cmd) print l_res if int(l_res[0]) == 0: print "Compiling fcp utility is successfull" else: l_msg = "Compiling fcp utility is failed" print l_msg raise OpTestError(l_msg) # Check existence of fcp utility in ffs repository, after compiling. l_cmd = "test -f %s/fcp/x86/fcp" % l_workdir l_res = commands.getstatusoutput(l_cmd) print l_res if int(l_res[0]) == 0: print "Compiling fcp utility is successfull" else: l_msg = "Compiling fcp utility is failed" print l_msg raise OpTestError(l_msg) # Check the PNOR flash contents on an x86 machine using fcp utility l_cmd = "%s/fcp/x86/fcp -o 0x0 -L %s" % (l_workdir, l_file) l_res = commands.getstatusoutput(l_cmd) print l_res[1] if int(l_res[0]) == 0: print "Getting PNOR data successfull using fcp utility" return BMC_CONST.FW_SUCCESS else: l_msg = "Getting the PNOR data using fcp utility failed" print l_msg raise OpTestError(l_msg)
class OpTestFlashBase(unittest.TestCase): def setUp(self): conf = OpTestConfiguration.conf self.cv_SYSTEM = conf.system() self.cv_BMC = conf.bmc() self.cv_REST = self.cv_BMC.get_rest_api() self.cv_HOST = conf.host() self.cv_IPMI = conf.ipmi() self.platform = conf.platform() self.util = OpTestUtil() self.bmc_type = conf.args.bmc_type self.bmc_ip = conf.args.bmc_ip self.bmc_username = conf.args.bmc_username self.bmc_password = conf.args.bmc_password self.pupdate_binary = conf.args.pupdate self.pflash = conf.args.pflash def validate_side_activated(self): l_bmc_side, l_pnor_side = self.cv_IPMI.ipmi_get_side_activated() self.assertIn(BMC_CONST.PRIMARY_SIDE, l_bmc_side, "BMC: Primary side is not active") if (l_pnor_side == BMC_CONST.GOLDEN_SIDE): print "PNOR: Primary side is not active" bios_sensor = self.cv_IPMI.ipmi_get_golden_side_sensor_id() self.assertNotEqual( bios_sensor, None, "Failed to get the BIOS Golden side sensor id") boot_count_sensor = self.cv_IPMI.ipmi_get_boot_count_sensor_id() self.assertNotEqual(boot_count_sensor, None, "Failed to get the Boot Count sensor id") self.cv_IPMI.ipmi_set_pnor_primary_side(bios_sensor, boot_count_sensor) l_bmc_side, l_pnor_side = self.cv_IPMI.ipmi_get_side_activated() self.assertIn(BMC_CONST.PRIMARY_SIDE, l_pnor_side, "PNOR: Primary side is not active") def get_pnor_level(self): rc = self.cv_IPMI.ipmi_get_PNOR_level() print rc def bmc_down_check(self): self.assertTrue(self.util.ping_fail_check(self.cv_BMC.host_name), "FSP/BMC keeps on pinging up") def scp_file(self, src_file_path, dst_file_path): self.util.copyFilesToDest(src_file_path, self.bmc_username, self.bmc_ip, dst_file_path, self.bmc_password, "2", BMC_CONST.SCP_TO_REMOTE) def get_version_tar(self, file_path): tar = tarfile.open(file_path) for member in tar.getmembers(): fd = tar.extractfile(member) content = fd.read() if "version=" in content: content = content.split("\n") content = [x for x in content if "version=" in x] version = content[0].split("=")[-1] break tar.close() print version return version def get_image_version(self, path): output = self.cv_BMC.run_command("cat %s | grep \"version=\"" % path) return output[0].split("=")[-1] def delete_images_dir(self): try: self.cv_BMC.run_command("rm -rf /tmp/images/*") except CommandFailed: pass def get_image_path(self, image_version): retry = 0 while (retry < 20): image_list = [] try: image_list = self.cv_BMC.run_command( "ls -1 -d /tmp/images/*/ --color=never") except CommandFailed as cf: pass for i in range(0, len(image_list)): version = self.get_image_version(image_list[i] + "MANIFEST") if (version == image_version): return image_list[i] time.sleep(5) retry += 1 def get_image_id(self, version): img_path = self.get_image_path(version) img_id = img_path.split("/")[-2] print "Image id for Host image is : %s" % img_id return img_id def wait_for_bmc_runtime(self): self.util.PingFunc(self.bmc_ip, BMC_CONST.PING_RETRY_FOR_STABILITY) if "SMC" in self.bmc_type: self.cv_IPMI.ipmi_wait_for_bmc_runtime() elif "OpenBMC" in self.bmc_type: self.cv_REST.wait_for_bmc_runtime() return
class OpTestFlashBase(unittest.TestCase): def setUp(self): conf = OpTestConfiguration.conf self.cv_SYSTEM = conf.system() self.cv_BMC = conf.bmc() self.cv_REST = self.cv_BMC.get_rest_api() self.cv_HOST = conf.host() self.cv_IPMI = conf.ipmi() self.platform = conf.platform() self.util = OpTestUtil() self.bmc_type = conf.args.bmc_type self.bmc_ip = conf.args.bmc_ip self.bmc_username = conf.args.bmc_username self.bmc_password = conf.args.bmc_password self.pupdate_binary = conf.args.pupdate self.pflash = conf.args.pflash def validate_side_activated(self): l_bmc_side, l_pnor_side = self.cv_IPMI.ipmi_get_side_activated() self.assertIn(BMC_CONST.PRIMARY_SIDE, l_bmc_side, "BMC: Primary side is not active") # TODO force setting of primary side to BIOS Golden side sensor self.assertIn(BMC_CONST.PRIMARY_SIDE, l_pnor_side, "PNOR: Primary side is not active") def get_pnor_level(self): rc = self.cv_IPMI.ipmi_get_PNOR_level() print rc def bmc_down_check(self): self.assertTrue(self.util.ping_fail_check(self.cv_BMC.host_name), "FSP/BMC keeps on pinging up") def scp_file(self, src_file_path, dst_file_path): self.util.copyFilesToDest(src_file_path, self.bmc_username, self.bmc_ip, dst_file_path, self.bmc_password, "2", BMC_CONST.SCP_TO_REMOTE) def get_version_tar(self, file_path): tar = tarfile.open(file_path) for member in tar.getmembers(): fd = tar.extractfile(member) content = fd.read() if "version=" in content: content = content.split("\n") content = [x for x in content if "version=" in x] version = content[0].split("=")[-1] break tar.close() print version return version def get_image_version(self, path): output = self.cv_BMC.run_command("cat %s | grep \"version=\"" % path) return output[0].split("=")[-1] def delete_images_dir(self): try: self.cv_BMC.run_command("rm -rf /tmp/images/*") except CommandFailed: pass def get_image_path(self, image_version): retry = 0 while (retry < 20): image_list = [] try: image_list = self.cv_BMC.run_command("ls -1 -d /tmp/images/*/ --color=never") except CommandFailed as cf: pass for i in range(0, len(image_list)): version = self.get_image_version(image_list[i] + "MANIFEST") if (version == image_version): return image_list[i] time.sleep(5) retry += 1 def get_image_id(self, version): img_path = self.get_image_path(version) img_id = img_path.split("/")[-2] print "Image id for Host image is : %s" % img_id return img_id def wait_for_bmc_runtime(self): self.util.PingFunc(self.bmc_ip, BMC_CONST.PING_RETRY_FOR_STABILITY) if "SMC" in self.bmc_type: self.cv_IPMI.ipmi_wait_for_bmc_runtime() elif "OpenBMC" in self.bmc_type: self.cv_REST.wait_for_bmc_runtime() return
class OpTestFWTS(): ## Initialize this object # @param i_bmcIP The IP address of the BMC # @param i_bmcUser The userid to log into the BMC with # @param i_bmcPasswd The password of the userid to log into the BMC with # @param i_bmcUserIpmi The userid to issue the BMC IPMI commands with # @param i_bmcPasswdIpmi The password of BMC IPMI userid # @param i_ffdcDir Optional param to indicate where to write FFDC # # "Only required for inband tests" else Default = None # @param i_hostIP The IP address of the HOST # @param i_hostuser The userid to log into the HOST # @param i_hostPasswd The password of the userid to log into the HOST with # def __init__(self, i_bmcIP, i_bmcUser, i_bmcPasswd, i_bmcUserIpmi, i_bmcPasswdIpmi, i_ffdcDir=None, i_hostip=None, i_hostuser=None, i_hostPasswd=None): self.cv_BMC = OpTestBMC(i_bmcIP, i_bmcUser, i_bmcPasswd, i_ffdcDir) self.cv_IPMI = OpTestIPMI(i_bmcIP, i_bmcUserIpmi, i_bmcPasswdIpmi, i_ffdcDir, i_hostip, i_hostuser, i_hostPasswd) self.cv_HOST = OpTestHost(i_hostip, i_hostuser, i_hostPasswd, i_bmcIP, i_ffdcDir) self.cv_SYSTEM = OpTestSystem(i_bmcIP, i_bmcUser, i_bmcPasswd, i_bmcUserIpmi, i_bmcPasswdIpmi, i_ffdcDir, i_hostip, i_hostuser, i_hostPasswd) self.util = OpTestUtil() self.user = i_hostuser self.ip = i_hostip self.passwd = i_hostPasswd ## # @brief This function just brings the system to host OS. # # @return BMC_CONST.FW_SUCCESS or raise OpTestError # def test_system_reboot(self): print "Testing FWTS: Booting system to OS" print "Performing a IPMI Power OFF Operation" # Perform a IPMI Power OFF Operation(Immediate Shutdown) self.cv_IPMI.ipmi_power_off() if int( self.cv_SYSTEM.sys_wait_for_standby_state( BMC_CONST.SYSTEM_STANDBY_STATE_DELAY) ) == BMC_CONST.FW_SUCCESS: print "System is in standby/Soft-off state" else: l_msg = "System failed to reach standby/Soft-off state" raise OpTestError(l_msg) self.cv_IPMI.ipmi_power_on() self.cv_SYSTEM.sys_check_host_status() self.util.PingFunc(self.cv_HOST.ip, BMC_CONST.PING_RETRY_POWERCYCLE) self.cv_IPMI.clear_ssh_keys(self.cv_HOST.ip) print "Gathering the OPAL msg logs" self.cv_HOST.host_gather_opal_msg_log() return BMC_CONST.FW_SUCCESS ## # @brief This function just executes the fwts_execution.sh on host OS # # @return BMC_CONST.FW_SUCCESS or raise OpTestError # def test_fwts(self): l_oslevel = self.cv_HOST.host_get_OS_Level() if not "Ubuntu" in l_oslevel: return # Copy the fwts execution file to the tmp folder in the host base_path = (os.path.dirname( os.path.abspath(__file__))).split('testcases')[0] fwts_script = base_path + "/testcases/fwts_execution.sh" try: self.util.copyFilesToDest(fwts_script, self.user, self.ip, "/tmp/", self.passwd) except: l_msg = "Copying fwts file to host failed" print l_msg raise OpTestError(l_msg) l_res = self.cv_HOST.host_run_command("/tmp/fwts_execution.sh") print l_res
class OpTestFlashBase(unittest.TestCase): def setUp(self): conf = OpTestConfiguration.conf self.cv_SYSTEM = conf.system() self.cv_BMC = conf.bmc() self.cv_REST = self.cv_BMC.get_rest_api() self.cv_HOST = conf.host() self.cv_IPMI = conf.ipmi() self.platform = conf.platform() self.util = OpTestUtil() self.bmc_type = conf.args.bmc_type self.bmc_ip = conf.args.bmc_ip self.bmc_username = conf.args.bmc_username self.bmc_password = conf.args.bmc_password self.pupdate_binary = conf.args.pupdate self.pflash = conf.args.pflash def validate_side_activated(self): l_bmc_side, l_pnor_side = self.cv_IPMI.ipmi_get_side_activated() self.assertIn(BMC_CONST.PRIMARY_SIDE, l_bmc_side, "BMC: Primary side is not active") # TODO force setting of primary side to BIOS Golden side sensor self.assertIn(BMC_CONST.PRIMARY_SIDE, l_pnor_side, "PNOR: Primary side is not active") def get_pnor_level(self): rc = self.cv_IPMI.ipmi_get_PNOR_level() print rc def bmc_down_check(self): self.assertTrue(self.util.ping_fail_check(self.cv_BMC.host_name), "FSP/BMC keeps on pinging up") def scp_file(self, src_file_path, dst_file_path): self.util.copyFilesToDest(src_file_path, self.bmc_username, self.bmc_ip, dst_file_path, self.bmc_password, "2", BMC_CONST.SCP_TO_REMOTE) def get_version_tar(self, file_path): tar = tarfile.open(file_path) for member in tar.getmembers(): fd = tar.extractfile(member) content = fd.read() if "version=" in content: content = content.split("\n") content = [x for x in content if "version=" in x] version = content[0].split("=")[-1] break tar.close() print version return version def get_image_version(self, path): output = self.cv_BMC.run_command("cat %s | grep \"version=\"" % path) return output[0].split("=")[-1] def wait_for_bmc_runtime(self): self.util.PingFunc(self.bmc_ip, BMC_CONST.PING_RETRY_FOR_STABILITY) if "SMC" in self.bmc_type: self.cv_IPMI.ipmi_wait_for_bmc_runtime() elif "OpenBMC" in self.bmc_type: self.cv_REST.wait_for_bmc_runtime() return
class OpTestMtdPnorDriver(): ## Initialize this object and also getting the lpar login credentials to use by scp utility # @param i_bmcIP The IP address of the BMC # @param i_bmcUser The userid to log into the BMC with # @param i_bmcPasswd The password of the userid to log into the BMC with # @param i_bmcUserIpmi The userid to issue the BMC IPMI commands with # @param i_bmcPasswdIpmi The password of BMC IPMI userid # @param i_ffdcDir Optional param to indicate where to write FFDC # # "Only required for inband tests" else Default = None # @param i_lparIP The IP address of the LPAR # @param i_lparuser The userid to log into the LPAR # @param i_lparPasswd The password of the userid to log into the LPAR with # def __init__(self, i_bmcIP, i_bmcUser, i_bmcPasswd, i_bmcUserIpmi, i_bmcPasswdIpmi, i_ffdcDir=None, i_lparip=None, i_lparuser=None, i_lparPasswd=None): self.cv_BMC = OpTestBMC(i_bmcIP, i_bmcUser, i_bmcPasswd, i_ffdcDir) self.cv_IPMI = OpTestIPMI(i_bmcIP, i_bmcUserIpmi, i_bmcPasswdIpmi, i_ffdcDir) self.cv_LPAR = OpTestLpar(i_lparip, i_lparuser, i_lparPasswd, i_bmcIP) self.util = OpTestUtil() self.lpar_user = i_lparuser self.lpar_ip = i_lparip self.lpar_Passwd = i_lparPasswd ## # @brief This function has following test steps # 1. Get lpar information(OS and Kernel information) # 2. Load the mtd module based on config value # 3. Check /dev/mtd0 character device file existence on lpar # 4. Copying the contents of the flash in a file /tmp/pnor # 5. Getting the /tmp/pnor file into local x86 machine using scp utility # 6. Remove existing /tmp/ffs directory and # Clone latest ffs git repository in local x86 working machine # 7. Compile ffs repository to get fcp utility # 8. Check existence of fcp utility in ffs repository, after compiling # 9. Get the PNOR flash contents on an x86 machine using fcp utility # # @return BMC_CONST.FW_SUCCESS-success or raise OpTestError-fail # def testMtdPnorDriver(self): # Get OS level l_oslevel = self.cv_LPAR.lpar_get_OS_Level() # Get Kernel Version l_kernel = self.cv_LPAR.lpar_get_kernel_version() # loading mtd module based on config option l_config = "CONFIG_MTD_POWERNV_FLASH" l_module = "mtd" self.cv_LPAR.lpar_load_module_based_on_config(l_kernel, l_config, l_module) # Check /dev/mtd0 file existence on lpar l_cmd = "ls -l /dev/mtd0; echo $?" l_res = self.cv_LPAR.lpar_run_command(l_cmd) l_res = l_res.splitlines() if int(l_res[-1]) == 0: print "/dev/mtd0 character device file exists on lpar" else: l_msg = "/dev/mtd0 character device file doesn't exist on lpar" print l_msg raise OpTestError(l_msg) # Copying the contents of the PNOR flash in a file /tmp/pnor l_file = "/tmp/pnor" l_cmd = "cat /dev/mtd0 > %s; echo $?" % l_file l_res = self.cv_LPAR.lpar_run_command(l_cmd) l_res = l_res.splitlines() if int(l_res[-1]) == 0: print "Fetched PNOR data from /dev/mtd0 into temp file /tmp/pnor" else: l_msg = "Fetching PNOR data is failed from /dev/mtd0 into temp file /tmp/pnor" print l_msg raise OpTestError(l_msg) # Getting the /tmp/pnor file into local x86 machine l_path = "/tmp/" self.util.copyFilesToDest(l_path, self.lpar_user, self.lpar_ip, l_file, self.lpar_Passwd, "2", BMC_CONST.SCP_TO_LOCAL) l_list = commands.getstatusoutput("ls -l %s; echo $?" % l_path) print l_list l_workdir = "/tmp/ffs" # Remove existing /tmp/ffs directory l_res = commands.getstatusoutput("rm -rf %s" % l_workdir) print l_res # Clone latest ffs git repository in local x86 working machine l_cmd = "git clone https://github.com/open-power/ffs/ %s" % l_workdir l_res = commands.getstatusoutput(l_cmd) print l_res if int(l_res[0]) == 0: print "Cloning of ffs repository is successfull" else: l_msg = "Cloning ffs repository is failed" print l_msg raise OpTestError(l_msg) # Compile ffs repository to get fcp utility l_cmd = "cd %s/; make" % l_workdir l_res = commands.getstatusoutput(l_cmd) print l_res if int(l_res[0]) == 0: print "Compiling fcp utility is successfull" else: l_msg = "Compiling fcp utility is failed" print l_msg raise OpTestError(l_msg) # Check existence of fcp utility in ffs repository, after compiling. l_cmd = "test -f %s/fcp/x86/fcp" % l_workdir l_res = commands.getstatusoutput(l_cmd) print l_res if int(l_res[0]) == 0: print "Compiling fcp utility is successfull" else: l_msg = "Compiling fcp utility is failed" print l_msg raise OpTestError(l_msg) # Check the PNOR flash contents on an x86 machine using fcp utility l_cmd = "%s/fcp/x86/fcp -o 0x0 -L %s" % (l_workdir, l_file) l_res = commands.getstatusoutput(l_cmd) print l_res[1] if int(l_res[0]) == 0: print "Getting PNOR data successfull using fcp utility" return BMC_CONST.FW_SUCCESS else: l_msg = "Getting the PNOR data using fcp utility failed" print l_msg raise OpTestError(l_msg)
class OpTestFlashBase(unittest.TestCase): def setUp(self): conf = OpTestConfiguration.conf self.cv_SYSTEM = conf.system() self.cv_BMC = conf.bmc() self.cv_REST = self.cv_BMC.get_rest_api() self.cv_HOST = conf.host() self.cv_IPMI = conf.ipmi() self.platform = conf.platform() self.util = OpTestUtil() self.bmc_type = conf.args.bmc_type self.bmc_ip = conf.args.bmc_ip self.bmc_username = conf.args.bmc_username self.bmc_password = conf.args.bmc_password def validate_side_activated(self): l_bmc_side, l_pnor_side = self.cv_IPMI.ipmi_get_side_activated() self.assertIn(BMC_CONST.PRIMARY_SIDE, l_bmc_side, "BMC: Primary side is not active") # TODO force setting of primary side to BIOS Golden side sensor self.assertIn(BMC_CONST.PRIMARY_SIDE, l_pnor_side, "PNOR: Primary side is not active") def get_pnor_level(self): rc = self.cv_IPMI.ipmi_get_PNOR_level() print rc def bmc_down_check(self): cmd = "ping -c 1 " + self.cv_BMC.host_name + " 1> /dev/null; echo $?" count = 0 while count < 500: output = commands.getstatusoutput(cmd) if output[1] != '0': print "FSP/BMC Comes down" break count = count + 1 time.sleep(2) else: self.assertTrue(False, "FSP/BMC keeps on pinging up") return True def scp_file(self, src_file_path, dst_file_path): self.util.copyFilesToDest(src_file_path, self.bmc_username, self.bmc_ip, dst_file_path, self.bmc_password, "2", BMC_CONST.SCP_TO_REMOTE) def get_version_tar(self, file_path): tar = tarfile.open(file_path) for member in tar.getmembers(): fd = tar.extractfile(member) content = fd.read() if "version=" in content: content = content.split("\n") content = [x for x in content if "version=" in x] version = content[0].split("=")[-1] break tar.close() print version return version def get_image_version(self, path): output = self.cv_BMC.run_command("cat %s | grep \"version=\"" % path) return output[0].split("=")[-1]