Esempio n. 1
0
    def test_update_host(self):
        put_host = {
            u'host_name': u'bogus-router333',
            u'contacts': u'newcontacts',
        }
        response = self.put_json(
            "/v2/config/hosts/bogus-router333", params=put_host
        )

        mongo_host = host.Host(
            **self.mongoconnection.shinken.hosts.find_one(
                {'host_name': 'bogus-router333'}, {'_id': 0}
            )
        )

        expected = {
            'address': u'192.168.1.254',
            'check_period': u'24x7',
            'notification_interval': 30,
            'contacts': u'newcontacts',
            'notification_period': u'24x7',
            'contact_groups': u'',
            'host_name': u'bogus-router333',
            'max_check_attempts': 3,
            'use': u'test'
        }

        self.assertEqual(expected, mongo_host.as_dict())
        self.assertEqual(response.status_int, 204)
Esempio n. 2
0
    def test_delete_host(self):
        response = self.delete('/v2/config/hosts/bogus-router')

        mongo_hosts = [host.Host(**h) for h
                       in self.mongoconnection.shinken.hosts.find()]

        self.assertEqual(2, len(mongo_hosts))
        self.assertEqual(response.status_int, 204)
Esempio n. 3
0
    def test_add_host(self):
        new_host = {
            "host_name": "testpost",
            "address": "192.168.1.254",
            "max_check_attempts": 5,
            "check_period": "24x7",
            "contacts": "admin,carl",
            "contact_groups": "router-admins",
            "notification_interval": 3,
            "notification_period": "24x7"
        }
        response = self.post_json("/v2/config/hosts", params=new_host)

        hosts = [host.Host(**h).as_dict() for h
                 in self.mongoconnection.shinken.hosts.find(None, {'_id': 0})]

        self.assertTrue(new_host in hosts)
        self.assertEqual(response.status_int, 201)