Beispiel #1
0
    def action(self):
        if watolib.get_pending_changes_info():
            raise MKUserError(
                "newname",
                _("You cannot rename a host while you have pending changes."))

        newname = html.request.var("newname")
        self._check_new_host_name("newname", newname)
        c = wato_confirm(
            _("Confirm renaming of host"),
            _("Are you sure you want to rename the host <b>%s</b> into <b>%s</b>? "
              "This involves a restart of the monitoring core!") %
            (self._host.name(), newname))
        if c:
            # Creating pending entry. That makes the site dirty and that will force a sync of
            # the config to that site before the automation is being done.
            host_renaming_job = RenameHostBackgroundJob(
                self._host,
                title=_("Renaming of %s -> %s") % (self._host.name(), newname))
            renamings = [(watolib.Folder.current(), self._host.name(), newname)
                         ]
            host_renaming_job.set_function(rename_hosts_background_job,
                                           renamings)

            try:
                host_renaming_job.start()
            except background_job.BackgroundJobAlreadyRunning as e:
                raise MKGeneralException(
                    _("Another host renaming job is already running: %s") % e)

            raise HTTPRedirect(host_renaming_job.detail_url())

        if c is False:  # not yet confirmed
            return ""
Beispiel #2
0
def render_wato(mini):
    if not config.wato_enabled:
        html.write_text(_("Setup is disabled."))
        return False
    if not user.may("wato.use"):
        html.write_text(_("You are not allowed to use the setup."))
        return False

    menu = get_wato_menu_items()

    if mini:
        for topic in menu:
            for item in topic.items:
                html.icon_button(
                    url=item.url,
                    class_="show_more_mode" if item.is_show_more else None,
                    title=item.title,
                    icon=item.icon or "wato",
                    target="main",
                )
    else:
        show_topic_menu(treename="wato", menu=menu, show_item_icons=True)

    pending_info = watolib.get_pending_changes_info()
    if pending_info:
        footnotelinks([(pending_info, "wato.py?mode=changelog")])
        html.div("", class_="clear")
Beispiel #3
0
def render_wato(mini):
    if not config.wato_enabled:
        html.write_text(_("WATO is disabled."))
        return False
    elif not config.user.may("wato.use"):
        html.write_text(
            _("You are not allowed to use Check_MK's web configuration GUI."))
        return False

    if mini:
        html.icon_button("wato.py", _("Main Menu"), "home", target="main")
    else:
        iconlink(_("Main Menu"), "wato.py", "home")

    for module in wato.get_modules():
        if not module.may_see():
            continue

        url = module.get_url()
        if mini:
            html.icon_button(url, module.title, module.icon, target="main")
        else:
            iconlink(module.title, url, module.icon)

    pending_info = watolib.get_pending_changes_info()
    if pending_info:
        footnotelinks([(pending_info, "wato.py?mode=changelog")])
        html.div('', class_="clear")
Beispiel #4
0
def render_wato(mini):
    if not config.wato_enabled:
        html.write_text(_("WATO is disabled."))
        return False
    if not config.user.may("wato.use"):
        html.write_text(
            _("You are not allowed to use Check_MK's web configuration GUI."))
        return False

    menu = get_wato_menu_items()

    if mini:
        for topic in menu:
            for item in topic.items:
                html.icon_button(url=item.url,
                                 title=item.title,
                                 icon=item.icon_name or "wato",
                                 target="main")
    else:
        show_topic_menu(treename="wato", menu=menu, show_item_icons=True)

    pending_info = watolib.get_pending_changes_info()
    if pending_info:
        footnotelinks([(pending_info, "wato.py?mode=changelog")])
        html.div('', class_="clear")
Beispiel #5
0
def changelog_button():
    pending_info = watolib.get_pending_changes_info()
    if pending_info:
        hot = True
        icon = "wato_changes"
        buttontext = pending_info
    else:
        hot = False
        icon = "wato_nochanges"
        buttontext = _("No changes")
    html.context_button(buttontext, watolib.folder_preserving_link([("mode", "changelog")]), icon,
                        hot)
Beispiel #6
0
    def action(self) -> ActionResult:
        if watolib.get_pending_changes_info():
            raise MKUserError("newname",
                              _("You cannot rename a host while you have pending changes."))

        newname = request.var("newname")
        self._check_new_host_name("newname", newname)
        # Creating pending entry. That makes the site dirty and that will force a sync of
        # the config to that site before the automation is being done.
        host_renaming_job = RenameHostBackgroundJob(self._host,
                                                    title=_("Renaming of %s -> %s") %
                                                    (self._host.name(), newname))
        renamings = [(watolib.Folder.current(), self._host.name(), newname)]
        host_renaming_job.set_function(rename_hosts_background_job, renamings)

        try:
            host_renaming_job.start()
        except background_job.BackgroundJobAlreadyRunning as e:
            raise MKGeneralException(_("Another host renaming job is already running: %s") % e)

        return redirect(host_renaming_job.detail_url())