Exemplo n.º 1
0
    def action_detail(self, name):
        """[EXTERNAL]"""
        zbx_name = ZabbixActionContainer.action_name_factory(
            self.dc.name, name)
        zac = ZabbixActionContainer.from_zabbix_name(self.ezx.zapi, zbx_name)

        return zac.as_mgmt_data
Exemplo n.º 2
0
    def action_delete(self, name):
        """[EXTERNAL]"""
        zbx_name = ZabbixActionContainer.action_name_factory(
            self.dc.name, name)
        zac = ZabbixActionContainer.from_zabbix_name(self.ezx.zapi, zbx_name)
        zac.delete()

        return None
Exemplo n.º 3
0
    def _create_new_action(self, action_name, action_data, nonexistent_usergroups=False):
        self.assertListEqual(self.ezx_zapi.action.get({
            'filter': {'name': ZabbixActionContainer.action_name_factory(self.dc.name, action_name)}}
        ), [], 'action should not exist in zabbix')

        if nonexistent_usergroups:
            self.assertRaises(RelatedRemoteObjectDoesNotExist, self.zabbix.action_create, action_name, action_data)
            return

        action_info = self.zabbix.action_create(action_name, action_data)
        zabbix_action_ = self.ezx_zapi.action.get({
            'filter': {'name': ZabbixActionContainer.action_name_factory(self.dc.name, action_name)}}
        )
        self.assertEqual(len(zabbix_action_), 1, 'action should exist in zabbix')
        self.assertEqual(action_info['name'], action_name)

        return action_info
Exemplo n.º 4
0
    def action_create(self, name, data):
        """[EXTERNAL]"""
        data['name'] = name  # Action name must be also in data
        zbx_name = ZabbixActionContainer.action_name_factory(
            self.dc.name, name)
        zac = ZabbixActionContainer.from_mgmt_data(self.ezx.zapi, zbx_name)
        zac.create(self.dc.name, data)

        return zac.as_mgmt_data
Exemplo n.º 5
0
    def _get_existing_action(self, action_name):
        zabbix_action_ = self.ezx_zapi.action.get({
            'filter': {'name': ZabbixActionContainer.action_name_factory(self.dc.name, action_name)}}
        )
        self.assertEqual(len(zabbix_action_), 1, 'action should exist in zabbix')
        action_info = self.zabbix.action_detail(action_name)
        self.assertEqual(action_info['name'], action_name)

        return action_info
Exemplo n.º 6
0
    def action_update(self, name, data):
        """[EXTERNAL]"""
        data.pop('name', None)  # Action name cannot be changed
        zbx_name = ZabbixActionContainer.action_name_factory(
            self.dc.name, name)
        zac = ZabbixActionContainer.from_zabbix_name(
            self.ezx.zapi,
            zbx_name,
            # we don't need to fetch hostgroups when we are replacing them
            resolve_hostgroups='hostgroups' not in data,
            # we don't need to fetch usergroups when we are replacing them
            resolve_usergroups='usergroups' not in data)
        zac.update(self.dc.name, data)

        return zac.as_mgmt_data
Exemplo n.º 7
0
 def _delete_new_action(self, action_name):
     self.assertListEqual(self.ezx_zapi.action.get({
         'filter': {'name': ZabbixActionContainer.action_name_factory(self.dc.name, action_name)}}
     ), [], 'action should not exist in zabbix anymore')
     self.assertRaises(RemoteObjectDoesNotExist, self.zabbix.action_delete, action_name)
Exemplo n.º 8
0
 def _delete_existing_action(self, action_name):
     self.zabbix.action_delete(action_name)
     self.assertListEqual(self.ezx_zapi.action.get({
         'filter': {'name': ZabbixActionContainer.action_name_factory(self.dc.name, action_name)}}
     ), [], 'action should not exist in zabbix anymore')
Exemplo n.º 9
0
 def _create_existing_action(self, action_name, action_data):
     zabbix_action_ = self.ezx_zapi.action.get({
         'filter': {'name': ZabbixActionContainer.action_name_factory(self.dc.name, action_name)}}
     )
     self.assertEqual(len(zabbix_action_), 1, 'action should exist in zabbix')
     self.assertRaises(RemoteObjectAlreadyExists, self.zabbix.action_create, action_name, action_data)