Пример #1
0
def render_wato_foldertree():
    if not wato.is_wato_slave_site():
        if not config.wato_enabled:
            html.write(_("WATO is disabled."))
            return False

    user_folders = compute_foldertree()

    #
    # Render link target selection
    #
    selected_topic, selected_target = config.load_user_file(
        "foldertree", (_('Hosts'), 'allhosts'))

    views.load_views()
    dashboard.load_dashboards()
    topic_views = visuals_by_topic(views.permitted_views().items() +
                                   dashboard.permitted_dashboards().items())
    topics = [(t, t) for t, s in topic_views]
    html.select("topic",
                topics,
                selected_topic,
                onchange='wato_tree_topic_changed(this)')
    html.write('<span class=left>%s</span>' % _('Topic:'))

    for topic, view_list in topic_views:
        targets = []
        for t, title, name, is_view in view_list:
            if config.visible_views and name not in config.visible_views:
                continue
            if config.hidden_views and name in config.hidden_views:
                continue
            if t == topic:
                if not is_view:
                    name = 'dashboard|' + name
                targets.append((name, title))

        attrs = {}
        if topic != selected_topic:
            attrs['style'] = 'display:none'
            default = ''
        else:
            default = selected_target

        html.select("target_%s" % topic,
                    targets,
                    default,
                    attrs=attrs,
                    onchange='wato_tree_target_changed(this)')

    html.write('<span class=left>%s</span>' % _('View:'))

    # Now render the whole tree
    if user_folders:
        render_tree_folder("wato-hosts",
                           user_folders.values()[0], 'wato_tree_click')
Пример #2
0
def userdb_sync_job_enabled():
    cfg = transform_userdb_automatic_sync(config.userdb_automatic_sync)
    if cfg == None:
        return False  # not enabled at all

    import wato  # FIXME: Cleanup!
    if cfg == "master" and wato.is_wato_slave_site():
        return False

    return True
Пример #3
0
def render_wato_foldertree():
    if not wato.is_wato_slave_site():
        if not config.wato_enabled:
            html.write(_("WATO is disabled."))
            return False

    user_folders = compute_foldertree()

    #
    # Render link target selection
    #
    selected_topic, selected_target = config.user.load_file("foldertree", (_('Hosts'), 'allhosts'))

    views.load_views()
    dashboard.load_dashboards()
    topic_views  = visuals_by_topic(views.permitted_views().items() + dashboard.permitted_dashboards().items())
    topics = [ (t, t) for t, s in topic_views ]
    html.select("topic", topics, selected_topic, onchange = 'wato_tree_topic_changed(this)')
    html.write('<span class=left>%s</span>' % _('Topic:'))

    for topic, view_list in topic_views:
        targets = []
        for t, title, name, is_view in view_list:
            if config.visible_views and name not in config.visible_views:
                continue
            if config.hidden_views and name in config.hidden_views:
                continue
            if t == topic:
                if not is_view:
                    name = 'dashboard|' + name
                targets.append((name, title))

        attrs = {}
        if topic != selected_topic:
            attrs['style'] = 'display:none'
            default = ''
        else:
            default = selected_target

        html.select("target_%s" % topic, targets, default, attrs = attrs, onchange = 'wato_tree_target_changed(this)')

    html.write('<span class=left>%s</span>' % _('View:'))

    # Now render the whole tree
    if user_folders:
        render_tree_folder("wato-hosts", user_folders.values()[0], 'wato_tree_click')
Пример #4
0
 def available(self):
     # This filter is also available on slave sites with disabled WATO
     # To determine if this site is a slave we check the existance of the distributed_wato.mk
     # file and the absence of any site configuration
     return (config.wato_enabled or wato.is_wato_slave_site())