예제 #1
0
    def _get_virtual_drives(self, controller_num):
        """Retrieve virtual drive data"""

        drives = []

        with self._graph_ref.get_session() as session:

            vd_details = GraphReference.get_virtual_drive_details(
                session, self._server_key, controller_num
            )
            cv_info = GraphReference.get_cachevault(
                session, self._server_key, controller_num
            )

            # iterate over virtual drives
            for i, v_drive in enumerate(vd_details):
                vd_state = copy.deepcopy(
                    self._storcli_details["stateConfig"]["virtualDrive"]["Optl"]
                )

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

                if cv_info["replacement"] == "Yes" and cv_info["writeThrough"]:
                    v_drive["Cache"] = "RWTD"

                # Add physical drive output (do some formatting plus check pd states)
                self._format_pd_for_output(v_drive["pd"])
                self._check_vd_state(vd_state, v_drive["pd"])

                v_drive["State"] = self._get_state_from_config(
                    "virtualDrive", vd_state, "Optl"
                )

                drives.append(
                    {
                        "physical_drives": self._format_as_table(
                            StorCLIEmulator.pd_header, v_drive["pd"]
                        ),
                        "virtual_drives": self._format_as_table(
                            StorCLIEmulator.vd_header, [v_drive]
                        ),
                        "virtual_drives_num": i,
                    }
                )

            return drives
예제 #2
0
    def _strcli_ctrl_cachevault(self, controller_num):
        """Cachevault output for storcli"""

        cv_f = os.path.join(self._storcli_dir, "cachevault_data")
        with open(
            os.path.join(self._storcli_dir, cv_f)
        ) as templ_h, self._graph_ref.get_session() as session:

            cv_info = GraphReference.get_cachevault(
                session, self._server_key, controller_num
            )
            cv_info["mfgDate"] = "/".join(
                reversed(cv_info["mfgDate"].split("/"))
            )  # dumb storcli (change date format)
            options = {**{"header": self._strcli_header(controller_num)}, **cv_info}

            template = Template(templ_h.read())
            return template.substitute(options)
예제 #3
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]),
            })