コード例 #1
0
ファイル: wato.py プロジェクト: LinuxHaus/checkmk
def render_wato(mini):
    if not active_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 [],
                    title=item.title,
                    icon=item.icon or "wato",
                    target="main",
                )
    else:
        show_topic_menu(treename="wato", menu=menu, show_item_icons=True)

    pending_info = get_pending_changes_info()
    if pending_info:
        footnotelinks([(pending_info, "wato.py?mode=changelog")])
        html.div("", class_="clear")
    return None
コード例 #2
0
def rename_host(params):
    """Rename a host"""
    if activate_changes.get_pending_changes_info():
        return problem(
            status=409,
            title="Pending changes are present",
            detail=
            "Please activate all pending changes before executing a host rename process",
        )
    host_name = params['host_name']
    host: watolib.CREHost = watolib.Host.host(host_name)
    if host is None:
        return _missing_host_problem(host_name)

    new_name = params['body']["new_name"]
    _, auth_problems = perform_rename_hosts([(host.folder(), host_name,
                                              new_name)])
    if auth_problems:
        return problem(
            status=422,
            title="Rename process failed",
            detail=
            f"It was not possible to rename the host {host_name} to {new_name}",
        )
    return _serve_host(host, False)
コード例 #3
0
ファイル: html_elements.py プロジェクト: sebruant/checkmk
def _make_wato_page_state() -> PageState:
    changes_info = get_pending_changes_info()
    return PageState(
        top_line=changes_info or _("No pending changes"),
        bottom_line=html.render_a(_("View changes"), href="wato.py?mode=changelog"),
        icon_name="wato_changes" if changes_info else "wato_nochanges",
    )
コード例 #4
0
ファイル: html_elements.py プロジェクト: petrows/checkmk
def _make_wato_page_state() -> PageState:
    changes_info = get_pending_changes_info()
    changelog_url = "wato.py?mode=changelog"
    span_id = "pending_changes"
    if changes_info:
        return PageState(
            text=html.render_span(changes_info, id_=span_id),
            icon_name="pending_changes",
            url=changelog_url,
            tooltip_text=(_tooltip_changes_info(changes_info) + "\n" +
                          _("Click here to go to pending changes.")),
        )
    return PageState(text=html.render_span(_("No pending changes"), id_=span_id),
                     url=changelog_url,
                     tooltip_text=_("Click here to see the activation status per site."))
コード例 #5
0
ファイル: html_elements.py プロジェクト: troelsarvin/checkmk
def _make_wato_page_state() -> PageState:
    changes_info = get_pending_changes_info()
    tooltip = get_pending_changes_tooltip()
    changelog_url = "wato.py?mode=changelog"
    span_id = "pending_changes"
    if changes_info:
        return PageState(
            text=html.render_span(changes_info, id_=span_id),
            icon_name="pending_changes",
            url=changelog_url,
            tooltip_text=tooltip,
        )
    return PageState(
        text=html.render_span(_("No pending changes"), id_=span_id),
        icon_name="no_pending_changes",
        url=changelog_url,
        tooltip_text=tooltip,
    )
コード例 #6
0
def _make_wato_page_state() -> PageState:
    changes_info = get_pending_changes_info()
    changelog_url = "wato.py?mode=changelog"
    span_id = "pending_changes"
    if changes_info:
        return PageState(
            text=html.render_span(changes_info, id_=span_id),
            icon_name="pending_changes",
            url=changelog_url,
            tooltip_text=ungettext(singular=_("Currently there is one change to activate"),
                                   plural=_("Currently there are %s to activate." % changes_info),
                                   n=int(re.findall(r"\d+", changes_info)[0])) + \
                         "\n" + _("Click here to go to pending changes."),
        )
    return PageState(
        text=html.render_span(_("No pending changes"), id_=span_id),
        url=changelog_url,
        tooltip_text=_("Click here to see the activation status per site."))
コード例 #7
0
ファイル: host_config.py プロジェクト: m3rlinux/checkmk
def rename_host(params):
    """Rename a host"""
    user.need_permission("wato.rename_hosts")
    if activate_changes.get_pending_changes_info():
        return problem(
            status=409,
            title="Pending changes are present",
            detail="Please activate all pending changes before executing a host rename process",
        )
    host_name = params["host_name"]
    host: watolib.CREHost = watolib.Host.load_host(host_name)
    new_name = params["body"]["new_name"]
    _, auth_problems = perform_rename_hosts([(host.folder(), host_name, new_name)])
    if auth_problems:
        return problem(
            status=422,
            title="Rename process failed",
            detail=f"It was not possible to rename the host {host_name} to {new_name}",
        )
    return _serve_host(host, effective_attributes=False)