예제 #1
0
def test_load_group_information_empty(tmp_path):
    environ = dict(create_environ(), REQUEST_URI='')
    with AppContext(DummyApplication(environ, None)), \
         RequestContext(htmllib.html(Request(environ))):
        assert groups.load_contact_group_information() == {}
        assert gui_groups.load_host_group_information() == {}
        assert gui_groups.load_service_group_information() == {}
예제 #2
0
def list_groups(params):
    """Show all host groups"""
    collection = [{
        "id": k,
        "alias": v["alias"]
    } for k, v in load_host_group_information().items()]
    return constructors.serve_json(
        serialize_group_list("host_group_config", collection))
예제 #3
0
파일: groups.py 프로젝트: PLUTEX/checkmk
 def _load_groups(self) -> Dict[GroupName, GroupSpec]:
     return load_host_group_information()
예제 #4
0
 def _load_groups(self):
     return load_host_group_information()
예제 #5
0
파일: webapi.py 프로젝트: petrows/checkmk
 def _get_all_hostgroups(self, request):
     return load_host_group_information()
예제 #6
0
def test_load_group_information(tmp_path):
    with open(cmk.utils.paths.check_mk_config_dir + "/wato/groups.mk", "w") as f:
        f.write("""# encoding: utf-8

if type(define_contactgroups) != dict:
    define_contactgroups = {}
define_contactgroups.update({'all': u'Everything'})

if type(define_hostgroups) != dict:
    define_hostgroups = {}
define_hostgroups.update({'all_hosts': u'All hosts :-)'})

if type(define_servicegroups) != dict:
    define_servicegroups = {}
define_servicegroups.update({'all_services': u'All särvices'})
""")

    with open(cmk.utils.paths.default_config_dir + "/multisite.d/wato/groups.mk", "w") as f:
        f.write("""# encoding: utf-8

multisite_hostgroups = {
    "all_hosts": {
        "ding": "dong",
    },
}

multisite_servicegroups = {
    "all_services": {
        "d1ng": "dong",
    },
}

multisite_contactgroups = {
    "all": {
        "d!ng": "dong",
    },
}
""")

    environ = dict(create_environ(), REQUEST_URI='')
    with AppContext(DummyApplication(environ, None)), \
            RequestContext(htmllib.html(Request(environ))):
        assert groups.load_group_information() == {
            'contact': {
                'all': {
                    'alias': u'Everything',
                    "d!ng": "dong",
                }
            },
            'host': {
                'all_hosts': {
                    'alias': u'All hosts :-)',
                    "ding": "dong",
                }
            },
            'service': {
                'all_services': {
                    'alias': u'All s\xe4rvices',
                    "d1ng": "dong",
                }
            },
        }

        assert groups.load_contact_group_information() == {
            'all': {
                'alias': u'Everything',
                "d!ng": "dong",
            }
        }

        assert gui_groups.load_host_group_information() == {
            'all_hosts': {
                'alias': u'All hosts :-)',
                "ding": "dong",
            }
        }

        assert gui_groups.load_service_group_information() == {
            'all_services': {
                'alias': u'All s\xe4rvices',
                "d1ng": "dong",
            }
        }
예제 #7
0
def list_groups(params):
    """Show all host groups"""
    return constructors.serve_json(
        serialize_group_list('service_group_config',
                             list(load_host_group_information().values())))
예제 #8
0
def _fetch_host_group(ident):
    groups = load_host_group_information()
    group = groups[ident].copy()
    group['id'] = ident
    return group
예제 #9
0
def test_load_group_information(tmp_path, run_as_superuser):
    with open(cmk.utils.paths.check_mk_config_dir + "/wato/groups.mk",
              "w") as f:
        f.write("""# encoding: utf-8

define_contactgroups.update({'all': u'Everything'})
define_hostgroups.update({'all_hosts': u'All hosts :-)'})
define_servicegroups.update({'all_services': u'All särvices'})
""")

    with open(
            cmk.utils.paths.default_config_dir + "/multisite.d/wato/groups.mk",
            "w") as f:
        f.write("""# encoding: utf-8

multisite_hostgroups = {
    "all_hosts": {
        "ding": "dong",
    },
}

multisite_servicegroups = {
    "all_services": {
        "d1ng": "dong",
    },
}

multisite_contactgroups = {
    "all": {
        "d!ng": "dong",
    },
}
""")

    with application_and_request_context(), run_as_superuser():
        assert groups.load_group_information() == {
            "contact": {
                "all": {
                    "alias": "Everything",
                    "d!ng": "dong",
                }
            },
            "host": {
                "all_hosts": {
                    "alias": "All hosts :-)",
                    "ding": "dong",
                }
            },
            "service": {
                "all_services": {
                    "alias": "All s\xe4rvices",
                    "d1ng": "dong",
                }
            },
        }

        assert groups.load_contact_group_information() == {
            "all": {
                "alias": "Everything",
                "d!ng": "dong",
            }
        }

        assert gui_groups.load_host_group_information() == {
            "all_hosts": {
                "alias": "All hosts :-)",
                "ding": "dong",
            }
        }

        assert gui_groups.load_service_group_information() == {
            "all_services": {
                "alias": "All s\xe4rvices",
                "d1ng": "dong",
            }
        }
예제 #10
0
def test_load_group_information_empty(tmp_path, run_as_superuser):
    with application_and_request_context(), run_as_superuser():
        assert groups.load_contact_group_information() == {}
        assert gui_groups.load_host_group_information() == {}
        assert gui_groups.load_service_group_information() == {}
예제 #11
0
def test_load_group_information(tmp_path):
    with open(cmk.utils.paths.check_mk_config_dir + "/wato/groups.mk", "w") as f:
        f.write("""# encoding: utf-8

if type(define_contactgroups) != dict:
    define_contactgroups = {}
define_contactgroups.update({'all': u'Everything'})

if type(define_hostgroups) != dict:
    define_hostgroups = {}
define_hostgroups.update({'all_hosts': u'All hosts :-)'})

if type(define_servicegroups) != dict:
    define_servicegroups = {}
define_servicegroups.update({'all_services': u'All särvices'})
""")

    with open(cmk.utils.paths.default_config_dir + "/multisite.d/wato/groups.mk", "w") as f:
        f.write("""# encoding: utf-8

multisite_hostgroups = {
    "all_hosts": {
        "ding": "dong",
    },
}

multisite_servicegroups = {
    "all_services": {
        "d1ng": "dong",
    },
}

multisite_contactgroups = {
    "all": {
        "d!ng": "dong",
    },
}
""")

    with application_and_request_context():
        assert groups.load_group_information() == {
            'contact': {
                'all': {
                    'alias': u'Everything',
                    "d!ng": "dong",
                }
            },
            'host': {
                'all_hosts': {
                    'alias': u'All hosts :-)',
                    "ding": "dong",
                }
            },
            'service': {
                'all_services': {
                    'alias': u'All s\xe4rvices',
                    "d1ng": "dong",
                }
            },
        }

        assert groups.load_contact_group_information() == {
            'all': {
                'alias': u'Everything',
                "d!ng": "dong",
            }
        }

        assert gui_groups.load_host_group_information() == {
            'all_hosts': {
                'alias': u'All hosts :-)',
                "ding": "dong",
            }
        }

        assert gui_groups.load_service_group_information() == {
            'all_services': {
                'alias': u'All s\xe4rvices',
                "d1ng": "dong",
            }
        }