Example #1
0
    def hostgroup_detail(self, name, dc_bound=True):
        """[EXTERNAL]"""
        if dc_bound:
            dc_name = self.dc.name
        else:
            dc_name = None

        zbx_name = ZabbixHostGroupContainer.hostgroup_name_factory(
            dc_name, name)
        zgc = ZabbixHostGroupContainer.from_zabbix_name(self.ezx.zapi,
                                                        zbx_name,
                                                        dc_bound=dc_bound)

        return zgc.as_mgmt_data
Example #2
0
    def _create_new_hostgroup(self, hostgroup_name, dc_bound=True):
        if dc_bound:
            dc_name = self.dc.name
        else:
            dc_name = None

        self.assertListEqual(self.ezx_zapi.hostgroup.get({
            'filter': {'name': ZabbixHostGroupContainer.hostgroup_name_factory(dc_name, hostgroup_name)}}
        ), [], 'hostgroup should not exist in zabbix')
        hostgroup_info = self.zabbix.hostgroup_create(hostgroup_name, dc_bound=dc_bound)
        zabbix_hostgroup_ = self.ezx_zapi.hostgroup.get({
            'filter': {'name': ZabbixHostGroupContainer.hostgroup_name_factory(dc_name, hostgroup_name)}}
        )
        self.assertEqual(len(zabbix_hostgroup_), 1, 'hostgroup should exist in zabbix')
        self.assertEqual(hostgroup_info['name'], hostgroup_name)

        return hostgroup_info
Example #3
0
    def _delete_new_hostgroup(self, hostgroup_name, dc_bound=True):
        if dc_bound:
            dc_name = self.dc.name
        else:
            dc_name = None

        self.assertListEqual(self.ezx_zapi.hostgroup.get({
            'filter': {'name': ZabbixHostGroupContainer.hostgroup_name_factory(dc_name, hostgroup_name)}}
        ), [], 'hostgroup should not exist in zabbix anymore')
        self.assertRaises(RemoteObjectDoesNotExist, self.zabbix.hostgroup_delete, hostgroup_name, dc_bound=dc_bound)
Example #4
0
    def _create_existing_hostgroup(self, hostgroup_name, dc_bound=True):
        if dc_bound:
            dc_name = self.dc.name
        else:
            dc_name = None

        zabbix_hostgroup_ = self.ezx_zapi.hostgroup.get({
            'filter': {'name': ZabbixHostGroupContainer.hostgroup_name_factory(dc_name, hostgroup_name)}}
        )
        self.assertEqual(len(zabbix_hostgroup_), 1, 'hostgroup should exist in zabbix')
        self.assertRaises(RemoteObjectAlreadyExists, self.zabbix.hostgroup_create, hostgroup_name, dc_bound=dc_bound)
Example #5
0
    def _get_existing_hostgroup(self, hostgroup_name, dc_bound=True):
        if dc_bound:
            dc_name = self.dc.name
        else:
            dc_name = None

        zabbix_hostgroup_ = self.ezx_zapi.hostgroup.get({
            'filter': {'name': ZabbixHostGroupContainer.hostgroup_name_factory(dc_name, hostgroup_name)}}
        )
        self.assertEqual(len(zabbix_hostgroup_), 1, 'hostgroup should exist in zabbix')
        hostgroup_info = self.zabbix.hostgroup_detail(hostgroup_name, dc_bound=dc_bound)
        self.assertEqual(hostgroup_info['name'], hostgroup_name)
Example #6
0
    def hostgroup_list(self, dc_bound=True, full=False, extended=False):
        """[EXTERNAL] Return list of available hostgroups"""
        if full or extended:
            display_attr = 'as_mgmt_data'
        else:
            display_attr = 'name_without_dc_prefix'

        return [
            getattr(zgc, display_attr)
            for zgc in ZabbixHostGroupContainer.all(self.ezx.zapi,
                                                    self.dc.name,
                                                    include_global=True,
                                                    count_hosts=True,
                                                    dc_bound=dc_bound)
        ]