Пример #1
0
    def test_load_single_file(self):
        other_file_path = os.path.join(self.nagios_config_folder,
                                       'other_file.cfg')

        single_file_config = surveil_from_nagios.load_config(other_file_path)

        self.assertEqual(single_file_config, [('services', [{
            'host_name': ['hai']
        }])])
Пример #2
0
def upload_pack(pack_dir, client):
    # pack_name = os.path.basename(os.path.normpath(pack_dir))

    surveil_config = surveil_from_nagios.load_config(pack_dir)

    config_manager = client.config
    for object_type, objects in surveil_config:
        object_manager = getattr(config_manager, object_type)
        for object in objects:
            object_manager.create(**object)
Пример #3
0
def upload_pack(pack_dir, client):
    # pack_name = os.path.basename(os.path.normpath(pack_dir))

    surveil_config = surveil_from_nagios.load_config(pack_dir)

    config_manager = client.config
    for object_type, objects in surveil_config:
        object_manager = getattr(config_manager, object_type)
        for object in objects:
            object_manager.create(**object)
Пример #4
0
    def test_surveil_from_nagios_config_cfg(self):
        surveil_cfg = surveil_from_nagios.load_config(
            self.nagios_config_folder)

        self.assert_count_equal_backport(
            surveil_cfg,
            [('timeperiods', [{
                'alias': 'Normal Work Hours',
                'timeperiod_name': 'workhours',
                'periods': {
                    'tuesday': '09:00-17:00',
                    'friday': '09:00-17:00',
                    'thursday': '09:00-17:00',
                    'wednesday': '09:00-17:00',
                    'monday': '09:00-17:00'
                }
            }]),
             ('hosts', [
                 {
                     'name': 'generic-host',
                     'custom_fields': {}
                 },
                 {
                     'use': ['generic-host'],
                     'custom_fields': {}
                 },
                 {
                     'use': ['generic-host', 'non-existing-thing'],
                     'contact_groups': ['admins'],
                     'host_name': 'localhost',
                     'check_interval': 324,
                     'address': 'localhost',
                     'custom_fields': {
                         '_custom_yolo': 'sdfsdf'
                     }
                 },
             ]), ('services', [{
                 'host_name': ['test']
             }, {
                 'host_name': ['hai']
             }])])
Пример #5
0
    def test_surveil_from_nagios_config_cfg(self):
        surveil_cfg = surveil_from_nagios.load_config(self.nagios_config_folder)

        self.assert_count_equal_backport(
            surveil_cfg,
            [
                (
                    "timeperiods",
                    [
                        {
                            "alias": "Normal Work Hours",
                            "timeperiod_name": "workhours",
                            "periods": {
                                "tuesday": "09:00-17:00",
                                "friday": "09:00-17:00",
                                "thursday": "09:00-17:00",
                                "wednesday": "09:00-17:00",
                                "monday": "09:00-17:00",
                            },
                        }
                    ],
                ),
                (
                    "hosts",
                    [
                        {"name": "generic-host", "custom_fields": {}},
                        {"use": ["generic-host"], "custom_fields": {}},
                        {
                            "use": ["generic-host", "non-existing-thing"],
                            "contact_groups": ["admins"],
                            "host_name": "localhost",
                            "check_interval": 324,
                            "address": "localhost",
                            "custom_fields": {"_custom_yolo": "sdfsdf"},
                        },
                    ],
                ),
                ("services", [{"host_name": ["test"]}, {"host_name": ["hai"]}]),
            ],
        )
Пример #6
0
    def test_load_single_file(self):
        other_file_path = os.path.join(self.nagios_config_folder, "other_file.cfg")

        single_file_config = surveil_from_nagios.load_config(other_file_path)

        self.assertEqual(single_file_config, [("services", [{"host_name": ["hai"]}])])