Example #1
0
    def test_temmplate_router_zenosstemplate_get_data_source_not_found(self, responses):
        responses_callback(responses)

        tr = TemplateRouter(url, headers, True)
        zt = tr.get_template('Server/TEST', 'LogicalVolume')
        with pytest.raises(ZenossAPIClientError, message="Request failed: ObjectNotFoundException"):
            resp = zt.get_data_source('bad')
Example #2
0
    def test_template_router_zenossthreshold_set_min(self, responses):
        responses_callback(responses)

        tr = TemplateRouter(url, headers, True)
        zt = tr.get_template('Server/TEST', 'FileSystem')
        threshold = zt.get_threshold('90 percent used')
        threshold.set_min(1)
Example #3
0
    def test_template_router_get_templates(self, responses):
        responses_callback(responses)

        tr = TemplateRouter(url, headers, True)
        resp = tr.get_device_class_templates('Server/TEST')
        assert len(resp) == 12
        assert isinstance(resp[0], ZenossTemplate)
Example #4
0
    def test_template_router_zenosstemplate_delete_threshold(self, responses):
        responses_callback(responses)

        tr = TemplateRouter(url, headers, True)
        zt = tr.get_template('Server/TEST', 'FileSystem')
        resp = zt.delete_threshold('90 percent used')
        assert resp['success']
Example #5
0
    def test_template_router_zenosstemplate_delete_graph(self, responses):
        responses_callback(responses)

        tr = TemplateRouter(url, headers, True)
        zt = tr.get_template('Server/TEST', 'FileSystem')
        resp = zt.delete_graph('Usage')
        assert resp['success']
Example #6
0
    def test_template_router_get_template(self, responses):
        responses_callback(responses)

        tr = TemplateRouter(url, headers, True)
        resp = tr.get_template('Devices', 'Device')
        assert isinstance(resp, ZenossTemplate)
        assert resp.uid == "Devices/Server/TEST/rrdTemplates/Device"
Example #7
0
    def test_template_router_get_threshold_types(self, responses):
        responses_callback(responses)

        tr = TemplateRouter(url, headers, True)
        resp = tr.get_threshold_types()
        assert len(resp) == 4
        assert "MinMaxThreshold" in resp
Example #8
0
    def test_template_router_zenosstemplate_delete_data_source(self, responses):
        responses_callback(responses)

        tr = TemplateRouter(url, headers, True)
        zt = tr.get_template('Server/TEST', 'LogicalVolume')
        resp = zt.delete_data_source('status')
        assert resp['success']
Example #9
0
    def test_template_router_zenosstemplate_copy(self, responses):
        responses_callback(responses)

        tr = TemplateRouter(url, headers, True)
        zt = tr.get_template('Server/TEST', 'LogicalVolume')
        resp = zt.copy('Server')
        assert isinstance(resp, ZenossTemplate)
Example #10
0
    def test_template_router_get_data_source_types(self, responses):
        responses_callback(responses)

        tr = TemplateRouter(url, headers, True)
        resp = tr.get_data_source_types()
        assert len(resp) == 18
        assert "HttpMonitor" in resp
Example #11
0
    def test_template_router_add_local_template(self, responses):
        responses_callback(responses)

        tr = TemplateRouter(url, headers, True)
        resp = tr.add_local_template('Servers/TEST/devices/test.example.com', 'DnsMonitor')
        assert isinstance(resp, ZenossTemplate)
        assert resp.uid == "Devices/Server/TEST/devices/test.example.com/DnsMonitor"
Example #12
0
    def test_template_router_add_template(self, responses):
        responses_callback(responses)

        tr = TemplateRouter(url, headers, True)
        resp = tr.add_template('Servers/TEST', 'TestAdd')
        assert isinstance(resp, ZenossTemplate)
        assert resp.uid == "Devices/Server/TEST/rrdTemplates/TestAdd"
Example #13
0
    def test_template_router_list_templates(self, responses):
        responses_callback(responses)

        tr = TemplateRouter(url, headers, True)
        resp = tr.list_device_class_templates('Server/TEST')
        assert len(resp) == 12
        assert resp == template_resp.list_templates_match
Example #14
0
    def test_template_router_zenosstemplate_list_graphs(self, responses):
        responses_callback(responses)

        tr = TemplateRouter(url, headers, True)
        zt = tr.get_template('Server/TEST', 'FileSystem')
        resp = zt.list_graphs()
        assert len(resp) == 1
        assert resp[0] == "Devices/Server/TEST/rrdTemplates/FileSystem/graphDefs/Usage"
Example #15
0
    def test_template_router_zenosstemplate_list_thresholds(self, responses):
        responses_callback(responses)

        tr = TemplateRouter(url, headers, True)
        zt = tr.get_template('Server/TEST', 'FileSystem')
        resp = zt.list_thresholds()
        assert len(resp) == 2
        assert resp[0] == "Devices/Server/TEST/rrdTemplates/FileSystem/thresholds/90 percent used"
Example #16
0
    def test_template_router_zenosstemplate_get_data_points(self, responses):
        responses_callback(responses)

        tr = TemplateRouter(url, headers, True)
        zt = tr.get_template('Server/TEST', 'LogicalVolume')
        resp = zt.get_data_points()
        assert len(resp) == 2
        assert isinstance(resp[0], ZenossDataPoint)
Example #17
0
    def test_template_router_zenosstemplate_add_data_source(self, responses):
        responses_callback(responses)

        tr = TemplateRouter(url, headers, True)
        zt = tr.get_template('Server/TEST', 'LogicalVolume')
        resp = zt.add_data_source('status', 'COMMAND')
        assert isinstance(resp, ZenossDataSource)
        assert resp.uid == "Devices/Server/TEST/rrdTemplates/LogicalVolume/datasources/status"
Example #18
0
    def test_template_router_zenosstemplate_get_graphs(self, responses):
        responses_callback(responses)

        tr = TemplateRouter(url, headers, True)
        zt = tr.get_template('Server/TEST', 'FileSystem')
        resp = zt.get_graphs()
        assert len(resp) == 1
        assert isinstance(resp[0], ZenossGraph)
Example #19
0
    def test_template_router_zenosstemplate_add_graph(self, responses):
        responses_callback(responses)

        tr = TemplateRouter(url, headers, True)
        zt = tr.get_template('Server/TEST', 'FileSystem')
        resp = zt.add_graph('Usage')
        assert isinstance(resp, ZenossGraph)
        assert resp.uid == "Devices/Server/TEST/rrdTemplates/FileSystem/graphDefs/Usage"
Example #20
0
    def tet_template_router_zenossdatapoint_make_gauge(self, responses):
        responses_callback(responses)

        tr = TemplateRouter(url, headers, True)
        zt = tr.get_template('Server/TEST', 'FileSystem')
        ds = zt.get_data_source('disk')
        dp = ds.get_data_point('disk_percentUsed')
        dp.make_gauge()
Example #21
0
    def test_template_router_zenosstemplate_list_data_points(self, responses):
        responses_callback(responses)

        tr = TemplateRouter(url, headers, True)
        zt = tr.get_template('Server/TEST', 'LogicalVolume')
        resp = zt.list_data_points()
        assert len(resp) == 2
        assert resp[0] == "Devices/Server/TEST/rrdTemplates/LogicalVolume/datasources/status/datapoints/state"
Example #22
0
    def test_template_router_get_object_templates(self, responses):
        responses_callback(responses)

        tr = TemplateRouter(url, headers, True)
        resp = tr.get_object_templates('Server/TEST/test.example.com')
        assert len(resp) == 2
        assert isinstance(resp[0], ZenossTemplate)
        assert isinstance(resp[1], ZenossTemplate)
Example #23
0
    def test_template_router_zenossgraph_add_graph_threshold(self, responses):
        responses_callback(responses)

        tr = TemplateRouter(url, headers, True)
        zt = tr.get_template('Server/TEST', 'FileSystem')
        graph = zt.get_graph('Usage')
        resp = graph.add_graph_threshold('Devices/Server/TEST/rrdTemplates/FileSystem/thresholds/90 percent used')
        assert resp['success']
Example #24
0
    def test_template_router_zenossgraph_set_point_sequence(self, responses):
        responses_callback(responses)

        tr = TemplateRouter(url, headers, True)
        zt = tr.get_template('Server/TEST', 'FileSystem')
        graph = zt.get_graph('Usage')
        resp = graph.set_point_sequence(['Used'])
        assert resp['success']
Example #25
0
    def test_template_router_zenosstemplate_add_threshold(self, responses):
        responses_callback(responses)

        tr = TemplateRouter(url, headers, True)
        zt = tr.get_template('Server/TEST', 'FileSystem')
        resp = zt.add_threshold('90 percent used', 'MinMaxThreshold', ['dp'])
        assert isinstance(resp, ZenossThreshold)
        assert resp.uid == "Devices/Server/TEST/rrdTemplates/FileSystem/thresholds/90 percent used"
Example #26
0
    def test_template_router_zenossgraph_set_graph_properties(self, responses):
        responses_callback(responses)

        tr = TemplateRouter(url, headers, True)
        zt = tr.get_template('Server/TEST', 'FileSystem')
        graph = zt.get_graph('Usage')
        resp = graph.set_graph_properties(dict(foo='bar'))
        assert resp['success']
Example #27
0
    def test_template_router_zenossgraph_add_point(self, responses):
        responses_callback(responses)

        tr = TemplateRouter(url, headers, True)
        zt = tr.get_template('Server/TEST', 'FileSystem')
        graph = zt.get_graph('Usage')
        resp = graph.add_point('disk', 'usedBlocks')
        assert resp['success']
Example #28
0
    def test_template_router_zenossgraph_get_points(self, responses):
        responses_callback(responses)

        tr = TemplateRouter(url, headers, True)
        zt = tr.get_template('Server/TEST', 'FileSystem')
        graph = zt.get_graph('Usage')
        resp = graph.get_points()
        assert len(resp) == 1
        assert isinstance(resp[0], ZenossDataPoint)
Example #29
0
    def test_template_router_zenossdatasource_add_data_point(self, responses):
        responses_callback(responses)

        tr = TemplateRouter(url, headers, True)
        zt = tr.get_template('Server/TEST', 'LogicalVolume')
        ds = zt.get_data_source('status')
        resp = ds.get_data_point('state')
        assert isinstance(resp, ZenossDataPoint)
        assert resp.uid == "Devices/Server/TEST/rrdTemplates/LogicalVolume/datasources/status/datapoints/state"
Example #30
0
    def test_template_router_zenossdatapoint_delete(self, responses):
        responses_callback(responses)

        tr = TemplateRouter(url, headers, True)
        zt = tr.get_template('Server/TEST', 'FileSystem')
        ds = zt.get_data_source('disk')
        dp = ds.get_data_point('disk_percentUsed')
        resp = dp.delete()
        assert resp['success']