Esempio n. 1
0
    def state_info(self):
        c_deploy = utils.string_to_bool(
            self.get_property(consts.CSTATE_PREFIX + consts.FLAG_DEPLOY)
        )
        c_attach = utils.string_to_bool(
            self.get_property(consts.CSTATE_PREFIX + consts.FLAG_ATTACH)
        )
        t_deploy = utils.string_to_bool(
            self.get_property(consts.TSTATE_PREFIX + consts.FLAG_DEPLOY)
        )
        t_attach = utils.string_to_bool(
            self.get_property(consts.TSTATE_PREFIX + consts.FLAG_ATTACH)
        )

        if (not c_deploy) and (not t_deploy):
            self.add_pending_text("cleanup")
        elif c_deploy and (not t_deploy):
            self.add_pending_text("decommission")
            self.raise_level(GenericView.STATE_WARN)
        elif (not c_deploy) and t_deploy:
            self.add_pending_text("commission")
            self.raise_level(GenericView.STATE_WARN)

        if c_attach and (not t_attach) and t_deploy:
            self.add_pending_text("detach")
            self.raise_level(GenericView.STATE_WARN)
        elif (not c_attach) and t_attach and t_deploy:
            self.add_pending_text("attach")
            self.raise_level(GenericView.STATE_WARN)

        return self.get_level(), self.format_state_info()
Esempio n. 2
0
    def state_info(self):
        s_remove = utils.string_to_bool(
            self.get_property(consts.TSTATE_PREFIX + consts.FLAG_REMOVE)
        )

        prop_managed = self.get_property(consts.MANAGED)
        if prop_managed is not None:
            if not utils.string_to_bool(prop_managed):
                self.add_state_text("unmanaged")
                self.raise_level(GenericView.STATE_WARN)
        if s_remove:
            self.add_pending_text("remove")
            self.raise_level(GenericView.STATE_ALERT)

        return self.get_level(), self.format_state_info()
Esempio n. 3
0
    def state_info(self):
        c_deploy = utils.string_to_bool(
            self.get_property(consts.CSTATE_PREFIX + consts.FLAG_DEPLOY))
        t_deploy = utils.string_to_bool(
            self.get_property(consts.TSTATE_PREFIX + consts.FLAG_DEPLOY))

        if (not c_deploy) and (not t_deploy):
            self.add_pending_text("cleanup")
        elif c_deploy and (not t_deploy):
            self.add_pending_text("delete")
            self.raise_level(drbdviews.GenericView.STATE_ALERT)
        elif (not c_deploy) and t_deploy:
            self.add_pending_text("create")
            self.raise_level(drbdviews.GenericView.STATE_WARN)

        return self.get_level(), self.format_state_info()
Esempio n. 4
0
    def state_info(self):
        s_remove = utils.string_to_bool(
            self.get_property(consts.TSTATE_PREFIX + consts.FLAG_REMOVE)
        )

        if s_remove:
            self.add_pending_text("remove")
            self.raise_level(GenericView.STATE_ALERT)

        return self.get_level(), self.format_state_info()
Esempio n. 5
0
    def state_info(self):
        c_deploy = utils.string_to_bool(
            self.get_property(consts.CSTATE_PREFIX + consts.FLAG_DEPLOY))
        t_deploy = utils.string_to_bool(
            self.get_property(consts.TSTATE_PREFIX + consts.FLAG_DEPLOY))

        fail_count = 0
        try:
            fail_count_str = self.get_property(consts.FAIL_COUNT)
            if fail_count_str is not None:
                fail_count = int(fail_count_str)
        except (ValueError, TypeError):
            pass

        if (not c_deploy) and (not t_deploy):
            self.add_pending_text("cleanup")
        elif c_deploy and (not t_deploy):
            self.add_pending_text("delete")
            self.raise_level(drbdviews.GenericView.STATE_ALERT)
        elif (not c_deploy) and t_deploy and self._error_code != 0:
            # Pending create actions are hidden if the creation of the snapshot
            # failed, because it will not be retried anyway
            self.add_pending_text("create")
            self.raise_level(drbdviews.GenericView.STATE_WARN)

        # Snapshot creation either succeeds immediately, or it fails and
        # is never retried
        if self._error_code != 0:
            self.add_state_text("FAILED")
            self.raise_level(drbdviews.GenericView.STATE_ALERT)
        elif fail_count > 0:
            self.add_state_text("FAILED(" + str(fail_count) + ")")
            self.raise_level(drbdviews.GenericView.STATE_ALERT)

        state_label = self.format_state_info()

        return self.get_level(), state_label
Esempio n. 6
0
 def state_text(self, flags_texts, sepa):
     text_list = []
     for item in flags_texts:
         flag_name, text_true, text_false, text_unkn = item
         try:
             if utils.string_to_bool(self.get_property(flag_name)):
                 if text_true is not None:
                     text_list.append(text_true)
             else:
                 if text_false is not None:
                     text_list.append(text_false)
         except ValueError:
             if text_unkn is not None:
                 text_list.append(text_unkn)
     return str(sepa.join(text_list))
Esempio n. 7
0
    def state_info(self):
        s_remove = utils.string_to_bool(
            self.get_property(consts.TSTATE_PREFIX + consts.FLAG_REMOVE)
        )
        s_upd_pool = utils.string_to_bool(
            self.get_property(consts.TSTATE_PREFIX + consts.FLAG_UPD_POOL)
        )
        s_update = utils.string_to_bool(
            self.get_property(consts.TSTATE_PREFIX + consts.FLAG_UPDATE)
        )
        s_drbdctrl = utils.string_to_bool(
            self.get_property(consts.TSTATE_PREFIX + consts.FLAG_DRBDCTRL)
        )
        s_storage = utils.string_to_bool(
            self.get_property(consts.TSTATE_PREFIX + consts.FLAG_STORAGE)
        )
        s_standby = utils.string_to_bool(
            self.get_property(consts.TSTATE_PREFIX + consts.FLAG_STANDBY)
        )
        s_external = utils.string_to_bool(
            self.get_property(consts.TSTATE_PREFIX + consts.FLAG_EXTERNAL)
        )
        s_qignore = utils.string_to_bool(
            self.get_property(consts.TSTATE_PREFIX + consts.FLAG_QIGNORE)
        )
        i_offline = False
        i_offline_str = self.get_property(consts.IND_NODE_OFFLINE)
        if i_offline_str is not None:
            i_offline = utils.string_to_bool(i_offline_str)

        if s_remove:
            self.add_pending_text("remove")
            self.raise_level(GenericView.STATE_ALERT)
        else:
            if s_drbdctrl:
                # States apply only to nodes with a control volume
                if i_offline:
                    if s_qignore:
                        self.raise_level(GenericView.STATE_WARN)
                        self.add_state_text("offline/quorum vote ignored")
                    else:
                        self.raise_level(GenericView.STATE_ALERT)
                        self.add_state_text("OFFLINE")
                else:
                    # Online, but quorum vote ignored; this should be resolved
                    # automatically by the server
                    if s_qignore:
                        self.raise_level(GenericView.STATE_WARN)
                        self.add_state_text("online/quorum vote ignored")
                if s_update:
                    self.add_pending_text("adjust connections")
                    self.raise_level(GenericView.STATE_ALERT)
            if s_storage:
                # State applies only to a node with storage
                if s_upd_pool:
                    self.raise_level(GenericView.STATE_WARN)
                    self.add_pending_text("check space")
            if not s_drbdctrl:
                if s_external:
                    self.add_state_text("external node")
                else:
                    self.add_state_text("satellite node")
            if not s_storage:
                self.add_state_text("no storage")
            if s_standby:
                self.raise_level(GenericView.STATE_WARN)
                self.add_state_text("standby")

        return self.get_level(), self.format_state_info()
Esempio n. 8
0
    def state_info(self):
        c_connect = utils.string_to_bool(
            self.get_property(consts.CSTATE_PREFIX + consts.FLAG_CONNECT)
        )
        c_deploy = utils.string_to_bool(
            self.get_property(consts.CSTATE_PREFIX + consts.FLAG_DEPLOY)
        )
        t_connect = utils.string_to_bool(
            self.get_property(consts.TSTATE_PREFIX + consts.FLAG_CONNECT)
        )
        t_deploy = utils.string_to_bool(
            self.get_property(consts.TSTATE_PREFIX + consts.FLAG_DEPLOY)
        )
        t_diskless = utils.string_to_bool(
            self.get_property(consts.TSTATE_PREFIX + consts.FLAG_DISKLESS)
        )

        a_discard = utils.string_to_bool(
            self.get_property(consts.TSTATE_PREFIX + consts.FLAG_DISCARD)
        )
        a_overwrite = utils.string_to_bool(
            self.get_property(consts.TSTATE_PREFIX + consts.FLAG_OVERWRITE)
        )
        a_reconnect = utils.string_to_bool(
            self.get_property(consts.TSTATE_PREFIX + consts.FLAG_RECONNECT)
        )
        a_upd_con = utils.string_to_bool(
            self.get_property(consts.TSTATE_PREFIX + consts.FLAG_UPD_CON)
        )
        a_upd_config = utils.string_to_bool(
            self.get_property(consts.TSTATE_PREFIX + consts.FLAG_UPD_CONFIG)
        )

        fail_count = 0
        try:
            fail_count_str = self.get_property(consts.FAIL_COUNT)
            if fail_count_str is not None:
                fail_count = int(fail_count_str)
        except (ValueError, TypeError):
            pass

        if (not c_deploy) and (not t_deploy):
            self.add_pending_text("cleanup")
        elif c_deploy and (not t_deploy):
            self.add_pending_text("decommission")
            self.raise_level(GenericView.STATE_WARN)
        elif (not c_deploy) and t_deploy:
            self.add_pending_text("commission")
            self.raise_level(GenericView.STATE_WARN)

        if (not c_connect) and (not t_connect):
            self.add_state_text("disconnected")
            self.raise_level(GenericView.STATE_WARN)
        elif c_connect and (not t_connect) and t_deploy:
            self.add_pending_text("disconnect")
            self.raise_level(GenericView.STATE_WARN)
        elif (not c_connect) and t_connect and c_deploy and t_deploy:
            self.add_pending_text("connect")
            self.raise_level(GenericView.STATE_WARN)

        if t_diskless:
            self.add_state_text("client")

        if a_discard and t_deploy:
            self.add_state_text("discard data")
            self.raise_level(GenericView.STATE_ALERT)
        if a_overwrite and t_deploy:
            self.add_state_text("overwrite peers")
            self.raise_level(GenericView.STATE_ALERT)
        if a_reconnect and t_deploy:
            self.add_pending_text("cycle connections")
            self.raise_level(GenericView.STATE_WARN)
        if a_upd_con and t_deploy:
            self.add_pending_text("adjust connections")
            self.raise_level(GenericView.STATE_WARN)
        if a_upd_config and t_deploy:
            self.add_pending_text("reconfigure")
            self.raise_level(GenericView.STATE_WARN)

        if fail_count > 0:
            self.add_state_text("FAILED(" + str(fail_count) + ")")
            self.raise_level(GenericView.STATE_ALERT)

        return self.get_level(), self.format_state_info()