Beispiel #1
0
    def _strcli_ctrl_phys_disks(self, controller_num):
        """Storcli physical drive details"""

        pd_info_f = os.path.join(self._storcli_dir, "physical_disk_data")
        pd_entry_f = os.path.join(self._storcli_dir, "physical_disk_entry")
        pd_output = []

        info_options = {
            "header": self._strcli_header(controller_num),
            "physical_drives": "",
        }

        with open(pd_info_f) as info_h, open(
                pd_entry_f) as entry_h, self._graph_ref.get_session(
                ) as session:
            drives = GraphReference.get_all_drives(session, self._server_key,
                                                   controller_num)
            pd_template = entry_h.read()

            pd_drives = sorted(drives["pd"], key=lambda k: k["slotNum"])
            self._format_pd_for_output(pd_drives)

            pd_drive_table = map(
                lambda pd: {
                    "drive_path":
                    "/c{}/e{}/s{}".format(controller_num, pd["EID"], pd[
                        "slotNum"]),
                    "drive_table":
                    self._format_as_table(StorCLIEmulator.pd_header, [pd]),
                    "media_error_count":
                    pd["mediaErrorCount"],
                    "other_error_count":
                    pd["otherErrorCount"],
                    "predictive_failure_count":
                    pd["predictiveErrorCount"],
                    "drive_temp_c":
                    pd["temperature"],
                    "drive_temp_f": (pd["temperature"] * 9 / 5) + 32,
                    "drive_model":
                    pd["Model"],
                    "drive_size":
                    pd["Size"],
                    "drive_group":
                    pd["DG"],
                    "serial_number":
                    pd["serialNumber"],
                    "manufacturer_id":
                    pd["manufacturerId"],
                },
                pd_drives,
            )

            pd_output = map(Template(pd_template).substitute, pd_drive_table)

            info_options["physical_drives"] = "\n".join(pd_output)
            return Template(info_h.read()).substitute(info_options)
Beispiel #2
0
    def _strcli_ctrl_info(self, controller_num):
        """Return aggregated information for a particular controller (show all)"""

        ctrl_info_f = os.path.join(self._storcli_dir, "controller_info")
        ctrl_entry_f = os.path.join(self._storcli_dir, "controller_entry")

        with open(ctrl_info_f) as info_h, open(
                ctrl_entry_f) as entry_h, self._graph_ref.get_session(
                ) as session:

            ctrl_info = GraphReference.get_controller_details(
                session, self._server_key, controller_num)

            topology_defaults = {
                "DG": 0,
                "Arr": "-",
                "Row": "-",
                "EID:Slot": "-",
                "DID": "-",
                "BT": "N",
                "PDC": "dsbl",
                "PI": "N",
                "SED": "N",
                "DS3": "none",
                "FSpace": "N",
                "TR": "N",
            }

            # templated keys
            ctrl_info_templ_keys = [
                "serial_number",
                "model",
                "serial_number",
                "mfg_date",
                "SAS_address",
                "PCI_address",
                "rework_date",
                "memory_correctable_errors",
                "memory_uncorrectable_errors",
                "rebuild_rate",
                "pr_rate",
                "bgi_rate",
                "cc_rate",
            ]

            entry_options = {
                "controller_num": controller_num,
                "drive_groups_num": ctrl_info["numDriveGroups"],
                "controller_date": "",
                "system_date": "",
                "status": "Optimal",
            }

            # copy over controller details
            for key in ctrl_info_templ_keys:
                entry_options[key] = ctrl_info[to_camelcase(key)]

            # keep track of the issues associated with the controller
            ctrl_state = copy.deepcopy(
                self._storcli_details["stateConfig"]["controller"]["Optimal"])
            ctrl_state["memoryCorrectableErrors"] = ctrl_info[
                "memoryCorrectableErrors"]
            ctrl_state["memoryUncorrectableErrors"] = ctrl_info[
                "memoryUncorrectableErrors"]

            drives = GraphReference.get_all_drives(session, self._server_key,
                                                   controller_num)

            # Add physical drive output (do some formatting plus check pd states)
            drives["pd"].sort(key=lambda k: k["slotNum"])
            topology = []

            # analyze and format virtual drive output
            for i, v_drive in enumerate(drives["vd"]):

                vd_state = copy.deepcopy(self._storcli_details["stateConfig"]
                                         ["virtualDrive"]["Optl"])

                # Add Virtual Drive output
                v_drive["DG/VD"] = str(v_drive["DG"]) + "/" + str(i)
                v_drive["Size"] = str(v_drive["Size"]) + " GB"

                # check pd states & determine virtual drive health status
                self._check_vd_state(vd_state, drives["pd"])
                v_drive["State"] = self._get_state_from_config(
                    "virtualDrive", vd_state, "Optl")

                if v_drive["State"] != "Optl":
                    ctrl_state["vdDgd"] += 1

                topology.extend([
                    {
                        **topology_defaults,
                        **{
                            "DG": v_drive["DG"],
                            "Type": v_drive["TYPE"],
                            "State": v_drive["State"],
                            "Size": v_drive["Size"],
                        },
                    },
                    {
                        **topology_defaults,
                        **{
                            "Arr": 0,
                            "DG": v_drive["DG"],
                            "Type": v_drive["TYPE"],
                            "State": v_drive["State"],
                            "Size": v_drive["Size"],
                        },
                    },
                ])

                self._format_pd_for_output(v_drive["pd"])
                for pdid, pd in enumerate(v_drive["pd"]):
                    topology.append({
                        **topology_defaults,
                        **{
                            "Arr": 0,
                            "DG": v_drive["DG"],
                            "Row": pdid,
                            "EID:Slot": pd["EID:Slt"],
                            "DID": pd["DID"],
                            "Type": "DRIVE",
                            "State": pd["State"],
                            "Size": pd["Size"],
                            "FSpace": "-",
                        },
                    })

            self._format_pd_for_output(drives["pd"])

            # determine overall controller status
            entry_options["status"] = self._get_state_from_config(
                "controller", ctrl_state, "Optimal")

            # get cachevault details:
            cv_info = GraphReference.get_cachevault(session, self._server_key,
                                                    controller_num)
            cv_table = {
                "Model": cv_info["model"],
                "State": cv_info["state"],
                "Temp": str(cv_info["temperature"]) + "C",
                "Mode": "-",
                "MfgDate": cv_info["mfgDate"],
            }

            return Template(info_h.read()).substitute({
                "header":
                self._strcli_header(controller_num),
                "controller_entry":
                Template(entry_h.read()).substitute(entry_options),
                "num_virt_drives":
                len(drives["vd"]),
                "num_phys_drives":
                len(drives["pd"]),
                "topology":
                self._format_as_table(StorCLIEmulator.topology_header,
                                      topology),
                "virtual_drives":
                self._format_as_table(StorCLIEmulator.vd_header, drives["vd"]),
                "physical_drives":
                self._format_as_table(StorCLIEmulator.pd_header, drives["pd"]),
                "cachevault":
                self._format_as_table(cv_table.keys(), [cv_table]),
            })
Beispiel #3
0
 def get_server_drives(self, controller_num):
     """Get all the drives that are in the server"""
     with self._graph_ref.get_session() as session:
         return GraphReference.get_all_drives(session, self.key, controller_num)