Пример #1
0
class TestZenoss(unittest.TestCase):
    def setUp(self):
        self.api = Zenoss('http://zenoss:8080', 'admin', 'password')

    def test_get_devices(self):
        with HTTMock(response_content):
            result = self.api.get_devices()
            self.assertTrue(result['success'])

    def test_get_events(self):
        with HTTMock(response_content):
            result = self.api.get_events()
            self.assertTrue(type(result is list))
            self.assertTrue('count' in result[0])

    def test_add_device(self):
        with HTTMock(response_content):
            result = self.api.add_device(TEST_SERVERNAME,
                                         '/Devices/Server/Linux')
            self.assertTrue(result['success'])

    def test_remove_device(self):
        with HTTMock(response_content):
            result = self.api.remove_device(TEST_SERVERNAME)
            self.assertTrue(result['success'])

    def test_create_event_on_device(self):
        with HTTMock(response_content):
            self.api.create_event_on_device(TEST_SERVERNAME, 'Error',
                                            'This is just an error')

    def test_ack_event(self):
        with HTTMock(response_content):
            events = self.api.get_events()
            if len(events) > 0:
                self.assertTrue(
                    self.api.ack_event(events[0]['evid'])['success'])

    def test_close_event(self):
        with HTTMock(response_content):
            events = self.api.get_events()
            if len(events) > 0:
                self.assertTrue(
                    self.api.close_event(events[0]['evid'])['success'])
Пример #2
0
class TestZenoss(unittest.TestCase):
    def setUp(self):
        self.api = Zenoss('http://zenoss:8080', 'admin', 'password')

    def test_get_devices(self):
        with HTTMock(response_content):
            result = self.api.get_devices()
            self.assertTrue(result['success'])

    def test_get_events(self):
        with HTTMock(response_content):
            result = self.api.get_events()
            self.assertTrue(type(result is list))
            self.assertTrue('count' in result[0])

    def test_add_device(self):
        with HTTMock(response_content):
            result = self.api.add_device(TEST_SERVERNAME, '/Devices/Server/Linux')
            self.assertTrue(result['success'])

    def test_remove_device(self):
        with HTTMock(response_content):
            result = self.api.remove_device(TEST_SERVERNAME)
            self.assertTrue(result['success'])

    def test_create_event_on_device(self):
        with HTTMock(response_content):
            self.api.create_event_on_device(TEST_SERVERNAME, 'Error', 'This is just an error')

    def test_ack_event(self):
        with HTTMock(response_content):
            events = self.api.get_events()
            if len(events) > 0:
                self.assertTrue(self.api.ack_event(events[0]['evid'])['success'])

    def test_close_event(self):
        with HTTMock(response_content):
            events = self.api.get_events()
            if len(events) > 0:
                self.assertTrue(self.api.close_event(events[0]['evid'])['success'])
Пример #3
0

if __name__ == "__main__":
    import datetime
    start_time = datetime.datetime.now()

    load_properties()
    if not connect_params['enabled']:
        sys.exit(0)

    logger.info('------------------- starting -------------------------')
    try:
        test_mode = connect_params['test_mode']
        zenoss_src = connection_setup(host=connect_params['src_host'])
        src_devices = build_device_data_structure(
            Zenoss.get_devices(zenoss_src))

        zenoss_dest = connection_setup(host=connect_params['dest_host'])
        dest_devices = build_device_data_structure(
            Zenoss.get_devices(zenoss_dest))

        src_unique_devices, dest_unique_devices = find_unique_devices(
            src_devices, dest_devices)

        # now remove systems to be ignore
        remove_ignored_devices(src_unique_devices, devices_to_ignore)
        remove_ignored_devices(dest_unique_devices, devices_to_ignore)

        src_collector_totals = find_collector_device_totals(src_devices)
        dest_collector_totals = find_collector_device_totals(dest_devices)
#!/usr/bin/env python

from zenoss import Zenoss

zenoss = Zenoss('http://zenoss:8080/', 'admin', 'password')

for device in zenoss.get_devices()['devices']:
    print(device['name'])