コード例 #1
0
 def gethostgroup(self):
     for hgs in  self.webservice.call_clapi(
             'gethostgroup',
             self.__clapi_action,
             self.name)['result']:
         hg_obj = HostGroup(hgs)
         self.hostgroups[hg_obj.name] = hg_obj
     return self.hostgroups
コード例 #2
0
 def gethostgroup(self):
     state, hgs = self.webservice.call_clapi('gethostgroup',
                                             self.__clapi_action, self.name)
     if state:
         if len(hgs['result']) > 0:
             for h in hgs['result']:
                 hg_obj = HostGroup(h)
                 self.hostgroups[hg_obj.name] = hg_obj
             return state, self.hostgroups
         else:
             return state, None
     else:
         return state, hgs
コード例 #3
0
    def test_host_deletehostgroup(self, host_load_data):
        host = host_load_data
        with open(resource_dir / 'test_host_hostgroup.json') as hg:
            hgs = HostGroup(json.load(hg))

        data = dict()
        data['action'] = 'delhostgroup'
        data['object'] = 'HOST'
        data['values'] = ["mail-uranus-frontend", "centreon-prod"]

        with patch('requests.post') as patched_post:
            host.deletehostgroup(hgs)
            patched_post.assert_called_with(self.clapi_url,
                                            headers=self.headers,
                                            data=json.dumps(data),
                                            verify=True)