Пример #1
0
    def _get_rate_prop(self, controller_num, rate_type):
        """Get controller rate property
        (rate type matches rate template file and the rate template value)"""

        rate_file = os.path.join(self._storcli_dir, rate_type)
        with open(rate_file) as templ_h, self._graph_ref.get_session(
        ) as session:

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

            options = {}
            options["header"] = self._strcli_header(controller_num)
            options[rate_type] = ctrl_info[to_camelcase(rate_type)]

            template = Template(templ_h.read())
            return template.substitute(options)
Пример #2
0
    def _strcli_ctrl_alarm_state(self, controller_num):
        """Get controller alarm state"""

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

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

            options = {
                "header": self._strcli_header(controller_num),
                "alarm_state": ctrl_info["alarmState"],
            }

            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]),
            })