Пример #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
from zenoss import Zenoss
import json

rm = Zenoss(
    'http://your.rm.instance.loc/',
    username='******',
    password='******',
    #cert='/path/to/your.cert.pem',
    ssl_verify=False)

device_list = ['10.160.32.{}'.format(i) for i in range(1, 100)]

for dev_name in device_list:

    #out = rm.remove_device(
    #    device_name=dev_name,
    #)

    out = rm.add_device(device_name=dev_name,
                        device_class='/Server/Linux',
                        model=True,
                        manageIp=dev_name)
    print(out)