Exemplo n.º 1
0
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
Exemplo n.º 2
0
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
Exemplo n.º 3
0
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