Пример #1
0
def _stonith_warnings(cib: Element, is_sbd_running: bool) -> List[str]:
    warning_list = []

    is_stonith_enabled = stonith.is_stonith_enabled(get_crm_config(cib))
    stonith_all, stonith_with_action, stonith_with_method_cycle = (
        stonith.get_misconfigured_resources(get_resources(cib)))

    if is_stonith_enabled and not stonith_all and not is_sbd_running:
        warning_list.append(
            "No stonith devices and stonith-enabled is not false")

    if stonith_with_action:
        warning_list.append(
            ("Following stonith devices have the 'action' option set, "
             "it is recommended to set {0} instead: {1}").format(
                 format_list(STONITH_ACTION_REPLACED_BY),
                 format_list([x.get("id", "") for x in stonith_with_action]),
             ))

    if stonith_with_method_cycle:
        warning_list.append(
            "Following stonith devices have the 'method' option set "
            "to 'cycle' which is potentially dangerous, please consider using "
            "'onoff': {0}".format(
                format_list(
                    [x.get("id", "") for x in stonith_with_method_cycle]), ))

    return warning_list
Пример #2
0
 def ensure_not_incompatible(self, checked, incompatible):
     if not checked in self._defined_options:
         return
     disallowed = self._defined_options & set(incompatible)
     if disallowed:
         raise CmdLineInputError("'{}' cannot be used with {}".format(
             checked, format_list(sorted(disallowed))))
Пример #3
0
def booth_config_accepted_by_node(info):
    desc = ""
    if info["name_list"] and info["name_list"] not in [["booth"]]:
        desc = "{_s} {_list}".format(
            _s=("s" if len(info["name_list"]) > 1 else ""),
            _list=format_list(info["name_list"])
        )
    return "{_node_info}Booth config{_desc} saved".format(
        _node_info=format_optional(info["node"], "{0}: "),
        _desc=desc,
    )
Пример #4
0
 def ensure_only_supported(self,
                           *supported_options,
                           hint_syntax_changed=False):
     unsupported_options = (
         # --debug is supported in all commands
         self._defined_options - set(supported_options) - set(["--debug"]))
     if unsupported_options:
         pluralize = lambda word: format_plural(unsupported_options, word)
         raise CmdLineInputError(
             "Specified {option} {option_list} {_is} not supported in this "
             "command".format(
                 option=pluralize("option"),
                 option_list=format_list(sorted(unsupported_options)),
                 _is=pluralize("is"),
             ),
             # Print error messages which point users to the changes section
             # in pcs manpage.
             # To be removed in the next significant version.
             hint=(HINT_SYNTAX_CHANGE if hint_syntax_changed else None))
Пример #5
0
 def ensure_not_mutually_exclusive(self, *mutually_exclusive):
     options_to_report = self._defined_options & set(mutually_exclusive)
     if len(options_to_report) > 1:
         raise CmdLineInputError("Only one of {} can be used".format(
             format_list(sorted(options_to_report))))