Ejemplo n.º 1
0
    def test_device_router_zenossdeviceclass_add_device(self, responses):
        responses_callback(responses)

        dr = DeviceRouter(url, headers, True)
        dc = dr.get_device_class('Server/TEST')
        resp = dc.add_device('test2.example.com')
        assert resp == "721739ae-2b1d-4613-91e9-681f134a2c49"
Ejemplo n.º 2
0
    def test_device_router_zenossdevice_reidentify(self, responses):
        responses_callback(responses)

        dr = DeviceRouter(url, headers, True)
        dc = dr.get_device_class('Server/TEST')
        d = dc.get_device('test.example.com')
        resp = d.reidentify('test2.example.com')
Ejemplo n.º 3
0
    def test_device_router_zenossdeviceclass_add_subclass(self, responses):
        responses_callback(responses)

        dr = DeviceRouter(url, headers, True)
        dc = dr.get_device_class('Server/TEST')
        resp = dc.add_subclass('Foo')
        assert isinstance(resp, ZenossDeviceClass)
Ejemplo n.º 4
0
    def test_device_router_zenossdevice_set_bound_templates(self, responses):
        responses_callback(responses)

        dr = DeviceRouter(url, headers, True)
        dc = dr.get_device_class('Server/TEST')
        d = dc.get_device('test.example.com')
        resp = d.set_bound_templates(['Device'])
Ejemplo n.º 5
0
    def test_device_router_zenossdevice_reset_ip_address(self, responses):
        responses_callback(responses)

        dr = DeviceRouter(url, headers, True)
        dc = dr.get_device_class('Server/TEST')
        d = dc.get_device('test.example.com')
        resp = d.reset_ip_address()
        assert resp == "Reset 1 IP addresses."
Ejemplo n.º 6
0
    def test_device_router_zenossdevice_set_collector(self, responses):
        responses_callback(responses)

        dr = DeviceRouter(url, headers, True)
        dc = dr.get_device_class('Server/TEST')
        d = dc.get_device('test.example.com')
        resp = d.set_collector('localhost')
        assert resp == "bd320c54-4325-47a7-baaf-048a22c1a276"
Ejemplo n.º 7
0
    def test_device_router_zenossdevice_delete(self, responses):
        responses_callback(responses)

        dr = DeviceRouter(url, headers, True)
        dc = dr.get_device_class('Server/TEST')
        d = dc.get_device('test.example.com')
        resp = d.delete('delete')
        assert resp
Ejemplo n.º 8
0
    def test_device_router_zenossdeviceclass_get_device(self, responses):
        responses_callback(responses)

        dr = DeviceRouter(url, headers, True)
        dc = dr.get_device_class('Server/TEST')
        resp = dc.get_device('test.example.com')
        assert isinstance(resp, ZenossDevice)
        assert resp.uid == "Devices/Server/TEST/devices/test.example.com"
Ejemplo n.º 9
0
    def test_device_router_zenossdeviceclass_get_devices(self, responses):
        responses_callback(responses)

        dr = DeviceRouter(url, headers, True)
        dc = dr.get_device_class('Server/TEST')
        resp = dc.get_devices()
        assert len(resp['devices']) == 1
        assert isinstance(resp['devices'][0], ZenossDevice)
Ejemplo n.º 10
0
    def test_device_router_zenossdevice_remodel(self, responses):
        responses_callback(responses)

        dr = DeviceRouter(url, headers, True)
        dc = dr.get_device_class('Server/TEST')
        d = dc.get_device('test.example.com')
        resp = d.remodel()
        assert resp == "8735c0ba-0091-474d-8475-2ae4217aba32"
Ejemplo n.º 11
0
    def test_device_router_zenossdevice_lock_for_deletion(self, responses):
        responses_callback(responses)

        dr = DeviceRouter(url, headers, True)
        dc = dr.get_device_class('Server/TEST')
        d = dc.get_device('test.example.com')
        resp = d.lock_for_deletion()
        assert resp == "Locked 1 devices."
Ejemplo n.º 12
0
    def test_device_router_zenossdevice_list_bound_templates(self, responses):
        responses_callback(responses)

        dr = DeviceRouter(url, headers, True)
        dc = dr.get_device_class('Server/TEST')
        d = dc.get_device('test.example.com')
        resp = d.list_bound_templates()
        assert resp[0]['name'] == "Device"
Ejemplo n.º 13
0
    def test_device_router_zenossdevice_set_production_state(self, responses):
        responses_callback(responses)

        dr = DeviceRouter(url, headers, True)
        dc = dr.get_device_class('Server/TEST')
        d = dc.get_device('test.example.com')
        resp = d.set_production_state(300)
        assert resp == "Set 1 devices to Maintenance."
Ejemplo n.º 14
0
    def test_device_router_zenossdevice_bind_or_unbind_template(
            self, responses):
        responses_callback(responses)

        dr = DeviceRouter(url, headers, True)
        dc = dr.get_device_class('Server/TEST')
        d = dc.get_device('test.example.com')
        resp = d.bind_or_unbind_template('Devices', 'DnsMonitor')
Ejemplo n.º 15
0
    def test_device_router_zenossdevice_set_priority(self, responses):
        responses_callback(responses)

        dr = DeviceRouter(url, headers, True)
        dc = dr.get_device_class('Server/TEST')
        d = dc.get_device('test.example.com')
        resp = d.set_priority(3)
        assert resp == "Set 1 devices to Normal priority."
Ejemplo n.º 16
0
    def test_device_router_zenossdevice_list_components(self, responses):
        responses_callback(responses)

        dr = DeviceRouter(url, headers, True)
        dc = dr.get_device_class('Server/TEST')
        d = dc.get_device('test.example.com')
        resp = d.list_components()
        assert resp['total'] == 1
        assert resp['components'][0] == "hw/cpus/0"
Ejemplo n.º 17
0
    def test_device_router_zenosscomponent_delete(self, responses):
        responses_callback(responses)

        dr = DeviceRouter(url, headers, True)
        dc = dr.get_device_class('Server/TEST')
        d = dc.get_device('test.example.com')
        c = d.get_component('hw/cpus/0')
        resp = c.delete()
        assert resp == "Components deleted."
Ejemplo n.º 18
0
    def test_device_router_zenossdevice_list_components_bad_filter(
            self, responses):
        responses_callback(responses)

        dr = DeviceRouter(url, headers, True)
        dc = dr.get_device_class('Server/TEST')
        d = dc.get_device('test.example.com')
        with pytest.warns(UserWarning):
            resp = d.list_components(name='foo')
Ejemplo n.º 19
0
    def test_device_router_zenosscomponent_lock_for_updates(self, responses):
        responses_callback(responses)

        dr = DeviceRouter(url, headers, True)
        dc = dr.get_device_class('Server/TEST')
        d = dc.get_device('test.example.com')
        c = d.get_component('hw/cpus/0')
        resp = c.lock_for_updates()
        assert resp == "Locked 1 components."
Ejemplo n.º 20
0
    def test_device_router_zenossdevice_list_user_commands(self, responses):
        responses_callback(responses)

        dr = DeviceRouter(url, headers, True)
        dc = dr.get_device_class('Server/TEST')
        d = dc.get_device('test.example.com')
        resp = d.list_user_commands()
        assert len(resp) == 6
        assert resp[2]['name'] == "ping"
Ejemplo n.º 21
0
    def test_device_router_zenossdevice_get_components(self, responses):
        responses_callback(responses)

        dr = DeviceRouter(url, headers, True)
        dc = dr.get_device_class('Server/TEST')
        d = dc.get_device('test.example.com')
        resp = d.get_components()
        assert len(resp) == 1
        assert isinstance(resp[0], ZenossComponent)
Ejemplo n.º 22
0
    def test_device_router_zenosscomponent_set_monitored(self, responses):
        responses_callback(responses)

        dr = DeviceRouter(url, headers, True)
        dc = dr.get_device_class('Server/TEST')
        d = dc.get_device('test.example.com')
        c = d.get_component('hw/cpus/0')
        resp = c.set_monitored(False)
        assert resp == "Set monitoring to False for 1 components."
Ejemplo n.º 23
0
    def test_device_router_zenossdeviceclass_list_devices(self, responses):
        responses_callback(responses)

        dr = DeviceRouter(url, headers, True)
        dc = dr.get_device_class('Server/TEST')
        resp = dc.list_devices()
        assert resp['total'] == 1
        assert resp['devices'][0]['name'] == "test.example.com"
        assert resp['devices'][0][
            'uid'] == "Devices/Server/TEST/devices/test.example.com"
Ejemplo n.º 24
0
    def test_device_router_zenossdevice_get_component(self, responses):
        responses_callback(responses)

        dr = DeviceRouter(url, headers, True)
        dc = dr.get_device_class('Server/TEST')
        d = dc.get_device('test.example.com')
        resp = d.get_component('hw/cpus/0')
        assert resp.uid == "Devices/Server/TEST/devices/test.example.com/hw/cpus/0"
        assert resp.meta_type == "CPU"
        assert resp.name == "0"
Ejemplo n.º 25
0
    def test_device_router_zenossdeviceclass_delete_property(self, responses):
        responses.add_callback(
            responses.POST,
            '{0}/properties_router'.format(url),
            callback=request_callback,
            content_type='application/json',
        )
        responses.add_callback(
            responses.POST,
            '{0}/device_router'.format(url),
            callback=request_callback,
            content_type='application/json',
        )

        dr = DeviceRouter(url, headers, True)
        dc = dr.get_device_class('Server/TEST')
        assert dc.delete_property('zWinTrustedRealm')
Ejemplo n.º 26
0
    def test_device_router_zenossdevice_set_property(self, responses):
        responses.add_callback(
            responses.POST,
            '{0}/properties_router'.format(url),
            callback=request_callback,
            content_type='application/json',
        )
        responses.add_callback(
            responses.POST,
            '{0}/device_router'.format(url),
            callback=request_callback,
            content_type='application/json',
        )

        dr = DeviceRouter(url, headers, True)
        dc = dr.get_device_class('Server/TEST')
        d = dc.get_device('test.example.com')
        prop = d.set_property('zWinTrustedRealm', value='Westeros')
        assert prop['value'] == "Westeros"
Ejemplo n.º 27
0
    def test_device_router_zenossdeviceclass_list_properties(self, responses):
        responses.add_callback(
            responses.POST,
            '{0}/properties_router'.format(url),
            callback=request_callback,
            content_type='application/json',
        )
        responses.add_callback(
            responses.POST,
            '{0}/device_router'.format(url),
            callback=request_callback,
            content_type='application/json',
        )

        dr = DeviceRouter(url, headers, True)
        dc = dr.get_device_class('Server/TEST')
        props = dc.list_properties()
        assert props['total'] == 4
        assert len(props['properties']) == 4
        assert props['properties'][0]['id'] == "zAggregatorCollectionInterval"
Ejemplo n.º 28
0
 def test_device_router_zenossdevice_get_bound_templates(self, responses):
     responses.assert_all_requests_are_fired = False
     responses.add_callback(
         responses.POST,
         '{0}/template_router'.format(url),
         callback=request_callback,
         content_type='application/json',
     )
     responses.add_callback(
         responses.POST,
         '{0}/device_router'.format(url),
         callback=request_callback,
         content_type='application/json',
     )
     dr = DeviceRouter(url, headers, True)
     dc = dr.get_device_class('Server/TEST')
     d = dc.get_device('test.example.com')
     resp = d.get_bound_templates()
     assert len(resp) == 2
     assert isinstance(resp[0], ZenossTemplate)
Ejemplo n.º 29
0
    def test_device_router_zenossdevice_get_custom_property(self, responses):
        responses.add_callback(
            responses.POST,
            '{0}/properties_router'.format(url),
            callback=request_callback,
            content_type='application/json',
        )
        responses.add_callback(
            responses.POST,
            '{0}/device_router'.format(url),
            callback=request_callback,
            content_type='application/json',
        )

        dr = DeviceRouter(url, headers, True)
        dc = dr.get_device_class('Server/TEST')
        d = dc.get_device('test.example.com')
        prop = d.get_custom_property('zWinTrustedRealm')
        assert isinstance(prop, ZenossCustomProperty)
        assert prop.id == "cDateTest"
        assert prop.path == "Devices/"
Ejemplo n.º 30
0
    def test_device_router_zenossdevice_list_local_properties(self, responses):
        responses.add_callback(
            responses.POST,
            '{0}/properties_router'.format(url),
            callback=request_callback,
            content_type='application/json',
        )
        responses.add_callback(
            responses.POST,
            '{0}/device_router'.format(url),
            callback=request_callback,
            content_type='application/json',
        )

        dr = DeviceRouter(url, headers, True)
        dc = dr.get_device_class('Server/TEST')
        d = dc.get_device('test.example.com')
        props = d.list_local_properties()
        assert props['total'] == 2
        assert len(props['properties']) == 2
        assert props['properties'][0]['id'] == "zMySQLConnectionString"