zenoss_client 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/zenoss/jsonapi/device_router.rb +11 -0
- data/lib/zenoss/model/devices/device.rb +5 -0
- data/test/fixtures/vcr_cassettes/6_2_1_initial_connection.yml +18 -61
- data/test/fixtures/vcr_cassettes/6_2_1_test_0010_sets_info_for_a_device.yml +100 -0
- data/test/fixtures/vcr_cassettes/6_2_1_test_0011_sets_info_for_a_device_on_a_device_object.yml +100 -0
- data/test/zenoss_client_test.rb +22 -1
- data/test/zenoss_model_device_test.rb +25 -0
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c50bb43ef8360b1861920b2db604b4620f67379d
|
4
|
+
data.tar.gz: d788721031d0bb940b2f4546b3c988ff599b7a91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8cbf8ca1804409707f13efc42daf0c09514274ea54b56b964203f902309c3244b915518fbb37ec73c75bbad6751700413464f767600bb99178e621365a90b40
|
7
|
+
data.tar.gz: 9489a2223bbbdee4f4202b66cd9f026388ea197953ca3b6bf84494715f7d7602470a1794269d178ce3875417f8c8c0b2b1f31b598eebce5ea3fcc644c3d90d80
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.9.
|
1
|
+
0.9.1
|
@@ -61,6 +61,17 @@ module Zenoss
|
|
61
61
|
json_request('DeviceRouter', 'getInfo', [data])
|
62
62
|
end
|
63
63
|
|
64
|
+
# @param [Hash] opts arguments to pass to setInfo
|
65
|
+
# @option opts [String] :uid required; device id in Zenoss
|
66
|
+
def set_info(opts = {})
|
67
|
+
if @zenoss_version && @zenoss_version > '6'
|
68
|
+
json_request('DeviceRouter', 'setInfo', [opts])
|
69
|
+
else
|
70
|
+
raise ZenossError, 'setInfo method on DeviceRouter is only allowed '\
|
71
|
+
'for version 6 and above'
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
64
75
|
# =============== Non-API Helper methods ===============
|
65
76
|
|
66
77
|
# This method will allow you to search for devices by name. If you put a partial name
|
@@ -50,6 +50,11 @@ module Zenoss
|
|
50
50
|
@zenoss.get_info(self.uid, keys)
|
51
51
|
end
|
52
52
|
|
53
|
+
def set_info(opts = {})
|
54
|
+
opts[:uid] = self.uid
|
55
|
+
@zenoss.set_info(opts)
|
56
|
+
end
|
57
|
+
|
53
58
|
# ------------------ Legacy REST Calls ------------------ #
|
54
59
|
|
55
60
|
# Move this Device to the given DeviceClass.
|
@@ -5,14 +5,14 @@ http_interactions:
|
|
5
5
|
uri: http://localhost:8080/zport/dmd/zport/acl_users/cookieAuthHelper/login
|
6
6
|
body:
|
7
7
|
encoding: UTF-8
|
8
|
-
string: __ac_name=admin&__ac_password=zenoss&submitted=true&came_from=
|
8
|
+
string: __ac_name=admin&__ac_password=zenoss&submitted=true&came_from=http://localhost:8080/zport/dmd
|
9
9
|
headers:
|
10
10
|
User-Agent:
|
11
11
|
- HTTPClient/1.0 (2.8.3, ruby 2.3.3 (2016-11-21))
|
12
12
|
Accept:
|
13
13
|
- "*/*"
|
14
14
|
Date:
|
15
|
-
-
|
15
|
+
- Mon, 25 Feb 2019 23:20:05 GMT
|
16
16
|
Content-Type:
|
17
17
|
- application/x-www-form-urlencoded
|
18
18
|
Cookie: ''
|
@@ -26,7 +26,7 @@ http_interactions:
|
|
26
26
|
Content-Type:
|
27
27
|
- text/plain; charset=utf-8
|
28
28
|
Date:
|
29
|
-
-
|
29
|
+
- Mon, 25 Feb 2019 23:20:06 GMT
|
30
30
|
Location:
|
31
31
|
- "/zport/dmd?submitted=true"
|
32
32
|
Server: ''
|
@@ -41,20 +41,20 @@ http_interactions:
|
|
41
41
|
encoding: UTF-8
|
42
42
|
string: "/zport/dmd?submitted=true"
|
43
43
|
http_version:
|
44
|
-
recorded_at:
|
44
|
+
recorded_at: Mon, 25 Feb 2019 23:20:06 GMT
|
45
45
|
- request:
|
46
46
|
method: post
|
47
47
|
uri: http://localhost:8080/zport/dmd//zport/dmd?submitted=true
|
48
48
|
body:
|
49
49
|
encoding: UTF-8
|
50
|
-
string: __ac_name=admin&__ac_password=zenoss&submitted=true&came_from=
|
50
|
+
string: __ac_name=admin&__ac_password=zenoss&submitted=true&came_from=http://localhost:8080/zport/dmd
|
51
51
|
headers:
|
52
52
|
User-Agent:
|
53
53
|
- HTTPClient/1.0 (2.8.3, ruby 2.3.3 (2016-11-21))
|
54
54
|
Accept:
|
55
55
|
- "*/*"
|
56
56
|
Date:
|
57
|
-
-
|
57
|
+
- Mon, 25 Feb 2019 23:20:06 GMT
|
58
58
|
Content-Type:
|
59
59
|
- application/x-www-form-urlencoded
|
60
60
|
Cookie: ''
|
@@ -68,7 +68,7 @@ http_interactions:
|
|
68
68
|
Content-Type:
|
69
69
|
- text/html; charset=utf-8
|
70
70
|
Date:
|
71
|
-
-
|
71
|
+
- Mon, 25 Feb 2019 23:20:07 GMT
|
72
72
|
Server: ''
|
73
73
|
Set-Cookie: ''
|
74
74
|
Strict-Transport-Security:
|
@@ -87,52 +87,7 @@ http_interactions:
|
|
87
87
|
encoding: UTF-8
|
88
88
|
string: "\\n\\n <!DOCTYPE html>\\n<html>\\n"
|
89
89
|
http_version:
|
90
|
-
recorded_at:
|
91
|
-
- request:
|
92
|
-
method: post
|
93
|
-
uri: http://localhost:8080/zport/dmd/zport/dmd/device_router
|
94
|
-
body:
|
95
|
-
encoding: UTF-8
|
96
|
-
string: __ac_name=admin&__ac_password=zenoss&submitted=true&came_from=https%3A%2F%2Fhttp:://localhost:8080/zport/dmd%2Fzport%2Fdmd
|
97
|
-
headers:
|
98
|
-
User-Agent:
|
99
|
-
- HTTPClient/1.0 (2.8.3, ruby 2.3.3 (2016-11-21))
|
100
|
-
Accept:
|
101
|
-
- "*/*"
|
102
|
-
Date:
|
103
|
-
- Tue, 19 Feb 2019 22:36:48 GMT
|
104
|
-
Content-Type:
|
105
|
-
- application/json; charset=utf-8
|
106
|
-
Cookie: ''
|
107
|
-
response:
|
108
|
-
status:
|
109
|
-
code: 200
|
110
|
-
message: OK
|
111
|
-
headers:
|
112
|
-
Content-Type:
|
113
|
-
- application/json
|
114
|
-
Date:
|
115
|
-
- Tue, 19 Feb 2019 22:36:49 GMT
|
116
|
-
Server: ''
|
117
|
-
Strict-Transport-Security:
|
118
|
-
- max-age=31536000
|
119
|
-
Vary:
|
120
|
-
- Accept-Encoding
|
121
|
-
X-Frame-Options:
|
122
|
-
- SAMEORIGIN
|
123
|
-
X-Xss-Protection:
|
124
|
-
- 1; mode=block
|
125
|
-
Content-Length:
|
126
|
-
- '309'
|
127
|
-
Set-Cookie: ''
|
128
|
-
body:
|
129
|
-
encoding: UTF-8
|
130
|
-
string: '{"uuid": "02f12150-4aa5-4616-a35d-fd4b942421a4", "action": "DeviceRouter",
|
131
|
-
"result": {"new_jobs": [{"uuid": "3bbee1ec-4f40-44ce-ada1-cc064eb40505", "description":
|
132
|
-
"Create UnitTestDevice under /Devices/Server", "uid": "/zport/dmd/JobManager"}],
|
133
|
-
"success": true}, "tid": 1, "type": "rpc", "method": "addDevice"}'
|
134
|
-
http_version:
|
135
|
-
recorded_at: Tue, 19 Feb 2019 22:36:49 GMT
|
90
|
+
recorded_at: Mon, 25 Feb 2019 23:20:07 GMT
|
136
91
|
- request:
|
137
92
|
method: post
|
138
93
|
uri: http://localhost:8080/zport/dmd/zport/dmd/device_router
|
@@ -145,7 +100,7 @@ http_interactions:
|
|
145
100
|
Accept:
|
146
101
|
- "*/*"
|
147
102
|
Date:
|
148
|
-
-
|
103
|
+
- Mon, 25 Feb 2019 23:20:07 GMT
|
149
104
|
Content-Type:
|
150
105
|
- application/json; charset=utf-8
|
151
106
|
Cookie: ''
|
@@ -157,7 +112,7 @@ http_interactions:
|
|
157
112
|
Content-Type:
|
158
113
|
- application/json
|
159
114
|
Date:
|
160
|
-
-
|
115
|
+
- Mon, 25 Feb 2019 23:20:07 GMT
|
161
116
|
Server: ''
|
162
117
|
Strict-Transport-Security:
|
163
118
|
- max-age=31536000
|
@@ -168,21 +123,23 @@ http_interactions:
|
|
168
123
|
X-Xss-Protection:
|
169
124
|
- 1; mode=block
|
170
125
|
Content-Length:
|
171
|
-
- '
|
126
|
+
- '1063'
|
172
127
|
Set-Cookie: ''
|
173
128
|
body:
|
174
129
|
encoding: UTF-8
|
175
|
-
string: '{"uuid": "
|
130
|
+
string: '{"uuid": "05f56525-8c70-487e-90ad-0b4480e3a9e5", "action": "DeviceRouter",
|
176
131
|
"result": {"totalCount": 1, "hash": "1", "success": true, "devices": [{"ipAddressString":
|
177
132
|
null, "serialNumber": "", "pythonClass": "Products.ZenModel.Device", "hwManufacturer":
|
178
|
-
null, "collector": "
|
179
|
-
[], "priority": 3, "hwModel": null, "tagNumber": "", "osManufacturer":
|
180
|
-
"location": null, "groups": [
|
133
|
+
null, "collector": "zencollector01", "osModel": null, "productionState": -1,
|
134
|
+
"systems": [], "priority": 3, "hwModel": null, "tagNumber": "", "osManufacturer":
|
135
|
+
null, "location": null, "groups": [{"uid": "/zport/dmd/Groups/BackboneDevices",
|
136
|
+
"path": "/Groups/BackboneDevices", "uuid": "65142f38-df6e-482e-a74d-ec825af8e058",
|
137
|
+
"name": "/BackboneDevices"}], "uid": "/zport/dmd/Devices/Server/devices/UnitTestDevice",
|
181
138
|
"ipAddress": null, "events": {"info": {"count": 0, "acknowledged_count": 0},
|
182
139
|
"clear": {"count": 0, "acknowledged_count": 0}, "warning": {"count": 0, "acknowledged_count":
|
183
140
|
0}, "critical": {"count": 0, "acknowledged_count": 0}, "error": {"count":
|
184
141
|
0, "acknowledged_count": 0}, "debug": {"count": 0, "acknowledged_count": 0}},
|
185
142
|
"name": "UnitTestDevice"}]}, "tid": 2, "type": "rpc", "method": "getDevices"}'
|
186
143
|
http_version:
|
187
|
-
recorded_at:
|
144
|
+
recorded_at: Mon, 25 Feb 2019 23:20:07 GMT
|
188
145
|
recorded_with: VCR 4.0.0
|
@@ -0,0 +1,100 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://localhost:8080/zport/dmd/zport/dmd/device_router
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: '[{"action":"DeviceRouter","method":"getDevices","data":[{"uid":"/zport/dmd/Devices","params":{"name":"UnitTestDevice"}}],"type":"rpc","tid":15}]'
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- HTTPClient/1.0 (2.8.3, ruby 2.3.3 (2016-11-21))
|
12
|
+
Accept:
|
13
|
+
- "*/*"
|
14
|
+
Date:
|
15
|
+
- Mon, 25 Feb 2019 23:20:07 GMT
|
16
|
+
Content-Type:
|
17
|
+
- application/json; charset=utf-8
|
18
|
+
Cookie: ''
|
19
|
+
response:
|
20
|
+
status:
|
21
|
+
code: 200
|
22
|
+
message: OK
|
23
|
+
headers:
|
24
|
+
Content-Type:
|
25
|
+
- application/json
|
26
|
+
Date:
|
27
|
+
- Mon, 25 Feb 2019 23:20:08 GMT
|
28
|
+
Server: ''
|
29
|
+
Strict-Transport-Security:
|
30
|
+
- max-age=31536000
|
31
|
+
Vary:
|
32
|
+
- Accept-Encoding
|
33
|
+
X-Frame-Options:
|
34
|
+
- SAMEORIGIN
|
35
|
+
X-Xss-Protection:
|
36
|
+
- 1; mode=block
|
37
|
+
Content-Length:
|
38
|
+
- '1064'
|
39
|
+
Set-Cookie: ''
|
40
|
+
body:
|
41
|
+
encoding: UTF-8
|
42
|
+
string: '{"uuid": "6245a13a-8add-4ee0-a04d-8e6206b8d8c8", "action": "DeviceRouter",
|
43
|
+
"result": {"totalCount": 1, "hash": "1", "success": true, "devices": [{"ipAddressString":
|
44
|
+
null, "serialNumber": "", "pythonClass": "Products.ZenModel.Device", "hwManufacturer":
|
45
|
+
null, "collector": "zencollector01", "osModel": null, "productionState": -1,
|
46
|
+
"systems": [], "priority": 3, "hwModel": null, "tagNumber": "", "osManufacturer":
|
47
|
+
null, "location": null, "groups": [{"uid": "/zport/dmd/Groups/BackboneDevices",
|
48
|
+
"path": "/Groups/BackboneDevices", "uuid": "65142f38-df6e-482e-a74d-ec825af8e058",
|
49
|
+
"name": "/BackboneDevices"}], "uid": "/zport/dmd/Devices/Server/devices/UnitTestDevice",
|
50
|
+
"ipAddress": null, "events": {"info": {"count": 0, "acknowledged_count": 0},
|
51
|
+
"clear": {"count": 0, "acknowledged_count": 0}, "warning": {"count": 0, "acknowledged_count":
|
52
|
+
0}, "critical": {"count": 0, "acknowledged_count": 0}, "error": {"count":
|
53
|
+
0, "acknowledged_count": 0}, "debug": {"count": 0, "acknowledged_count": 0}},
|
54
|
+
"name": "UnitTestDevice"}]}, "tid": 15, "type": "rpc", "method": "getDevices"}'
|
55
|
+
http_version:
|
56
|
+
recorded_at: Mon, 25 Feb 2019 23:20:08 GMT
|
57
|
+
- request:
|
58
|
+
method: post
|
59
|
+
uri: http://localhost:8080/zport/dmd/zport/dmd/device_router
|
60
|
+
body:
|
61
|
+
encoding: UTF-8
|
62
|
+
string: '[{"action":"DeviceRouter","method":"setInfo","data":[{"uid":"/zport/dmd/Devices/Server/devices/UnitTestDevice","productionState":-1}],"type":"rpc","tid":16}]'
|
63
|
+
headers:
|
64
|
+
User-Agent:
|
65
|
+
- HTTPClient/1.0 (2.8.3, ruby 2.3.3 (2016-11-21))
|
66
|
+
Accept:
|
67
|
+
- "*/*"
|
68
|
+
Date:
|
69
|
+
- Mon, 25 Feb 2019 23:20:08 GMT
|
70
|
+
Content-Type:
|
71
|
+
- application/json; charset=utf-8
|
72
|
+
Cookie: ''
|
73
|
+
response:
|
74
|
+
status:
|
75
|
+
code: 200
|
76
|
+
message: OK
|
77
|
+
headers:
|
78
|
+
Content-Type:
|
79
|
+
- application/json
|
80
|
+
Date:
|
81
|
+
- Mon, 25 Feb 2019 23:20:08 GMT
|
82
|
+
Server: ''
|
83
|
+
Strict-Transport-Security:
|
84
|
+
- max-age=31536000
|
85
|
+
Vary:
|
86
|
+
- Accept-Encoding
|
87
|
+
X-Frame-Options:
|
88
|
+
- SAMEORIGIN
|
89
|
+
X-Xss-Protection:
|
90
|
+
- 1; mode=block
|
91
|
+
Content-Length:
|
92
|
+
- '150'
|
93
|
+
Set-Cookie: ''
|
94
|
+
body:
|
95
|
+
encoding: UTF-8
|
96
|
+
string: '{"uuid": "7e7ea36e-b80b-4fa6-bb1f-3ba6ab104996", "action": "DeviceRouter",
|
97
|
+
"result": {"success": true}, "tid": 16, "type": "rpc", "method": "setInfo"}'
|
98
|
+
http_version:
|
99
|
+
recorded_at: Mon, 25 Feb 2019 23:20:08 GMT
|
100
|
+
recorded_with: VCR 4.0.0
|
data/test/fixtures/vcr_cassettes/6_2_1_test_0011_sets_info_for_a_device_on_a_device_object.yml
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://localhost:8080/zport/dmd/zport/dmd/device_router
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: '[{"action":"DeviceRouter","method":"getDevices","data":[{"uid":"/zport/dmd/Devices","params":{"name":"UnitTestDevice"}}],"type":"rpc","tid":21}]'
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- HTTPClient/1.0 (2.8.3, ruby 2.3.3 (2016-11-21))
|
12
|
+
Accept:
|
13
|
+
- "*/*"
|
14
|
+
Date:
|
15
|
+
- Mon, 25 Feb 2019 23:20:08 GMT
|
16
|
+
Content-Type:
|
17
|
+
- application/json; charset=utf-8
|
18
|
+
Cookie: ''
|
19
|
+
response:
|
20
|
+
status:
|
21
|
+
code: 200
|
22
|
+
message: OK
|
23
|
+
headers:
|
24
|
+
Content-Type:
|
25
|
+
- application/json
|
26
|
+
Date:
|
27
|
+
- Mon, 25 Feb 2019 23:20:08 GMT
|
28
|
+
Server: ''
|
29
|
+
Strict-Transport-Security:
|
30
|
+
- max-age=31536000
|
31
|
+
Vary:
|
32
|
+
- Accept-Encoding
|
33
|
+
X-Frame-Options:
|
34
|
+
- SAMEORIGIN
|
35
|
+
X-Xss-Protection:
|
36
|
+
- 1; mode=block
|
37
|
+
Content-Length:
|
38
|
+
- '1064'
|
39
|
+
Set-Cookie: ''
|
40
|
+
body:
|
41
|
+
encoding: UTF-8
|
42
|
+
string: '{"uuid": "9e2f968f-be4a-4cc2-836a-9e5687d3c86c", "action": "DeviceRouter",
|
43
|
+
"result": {"totalCount": 1, "hash": "1", "success": true, "devices": [{"ipAddressString":
|
44
|
+
null, "serialNumber": "", "pythonClass": "Products.ZenModel.Device", "hwManufacturer":
|
45
|
+
null, "collector": "zencollector01", "osModel": null, "productionState": -1,
|
46
|
+
"systems": [], "priority": 3, "hwModel": null, "tagNumber": "", "osManufacturer":
|
47
|
+
null, "location": null, "groups": [{"uid": "/zport/dmd/Groups/BackboneDevices",
|
48
|
+
"path": "/Groups/BackboneDevices", "uuid": "65142f38-df6e-482e-a74d-ec825af8e058",
|
49
|
+
"name": "/BackboneDevices"}], "uid": "/zport/dmd/Devices/Server/devices/UnitTestDevice",
|
50
|
+
"ipAddress": null, "events": {"info": {"count": 0, "acknowledged_count": 0},
|
51
|
+
"clear": {"count": 0, "acknowledged_count": 0}, "warning": {"count": 0, "acknowledged_count":
|
52
|
+
0}, "critical": {"count": 0, "acknowledged_count": 0}, "error": {"count":
|
53
|
+
0, "acknowledged_count": 0}, "debug": {"count": 0, "acknowledged_count": 0}},
|
54
|
+
"name": "UnitTestDevice"}]}, "tid": 21, "type": "rpc", "method": "getDevices"}'
|
55
|
+
http_version:
|
56
|
+
recorded_at: Mon, 25 Feb 2019 23:20:08 GMT
|
57
|
+
- request:
|
58
|
+
method: post
|
59
|
+
uri: http://localhost:8080/zport/dmd/zport/dmd/device_router
|
60
|
+
body:
|
61
|
+
encoding: UTF-8
|
62
|
+
string: '[{"action":"DeviceRouter","method":"setInfo","data":[{"uid":"/zport/dmd/Devices/Server/devices/UnitTestDevice","productionState":-1}],"type":"rpc","tid":22}]'
|
63
|
+
headers:
|
64
|
+
User-Agent:
|
65
|
+
- HTTPClient/1.0 (2.8.3, ruby 2.3.3 (2016-11-21))
|
66
|
+
Accept:
|
67
|
+
- "*/*"
|
68
|
+
Date:
|
69
|
+
- Mon, 25 Feb 2019 23:20:08 GMT
|
70
|
+
Content-Type:
|
71
|
+
- application/json; charset=utf-8
|
72
|
+
Cookie: ''
|
73
|
+
response:
|
74
|
+
status:
|
75
|
+
code: 200
|
76
|
+
message: OK
|
77
|
+
headers:
|
78
|
+
Content-Type:
|
79
|
+
- application/json
|
80
|
+
Date:
|
81
|
+
- Mon, 25 Feb 2019 23:20:09 GMT
|
82
|
+
Server: ''
|
83
|
+
Strict-Transport-Security:
|
84
|
+
- max-age=31536000
|
85
|
+
Vary:
|
86
|
+
- Accept-Encoding
|
87
|
+
X-Frame-Options:
|
88
|
+
- SAMEORIGIN
|
89
|
+
X-Xss-Protection:
|
90
|
+
- 1; mode=block
|
91
|
+
Content-Length:
|
92
|
+
- '150'
|
93
|
+
Set-Cookie: ''
|
94
|
+
body:
|
95
|
+
encoding: UTF-8
|
96
|
+
string: '{"uuid": "25ba2f17-7cdd-4229-9a5f-7c4e1d0c240b", "action": "DeviceRouter",
|
97
|
+
"result": {"success": true}, "tid": 22, "type": "rpc", "method": "setInfo"}'
|
98
|
+
http_version:
|
99
|
+
recorded_at: Mon, 25 Feb 2019 23:20:09 GMT
|
100
|
+
recorded_with: VCR 4.0.0
|
data/test/zenoss_client_test.rb
CHANGED
@@ -70,7 +70,7 @@ describe Zenoss do
|
|
70
70
|
end
|
71
71
|
|
72
72
|
before do
|
73
|
-
VCR.insert_cassette gen_cassette_name, :match_requests_on => [:method, :path, :query]
|
73
|
+
VCR.insert_cassette gen_cassette_name, :match_requests_on => [:method, :path, :query], :allow_playback_repeats => true
|
74
74
|
@zen = self.class.zen
|
75
75
|
@dev = @zen.find_devices_by_name(TEST_DEVICE_NAME).first
|
76
76
|
end
|
@@ -138,6 +138,27 @@ describe Zenoss do
|
|
138
138
|
renamed_device.rename_device(TEST_DEVICE_NAME)
|
139
139
|
end
|
140
140
|
end
|
141
|
+
|
142
|
+
if ZENOSS_VERSION > '6'
|
143
|
+
it 'sets info for a device' do
|
144
|
+
opts = {}
|
145
|
+
opts[:uid] = @dev.uid
|
146
|
+
opts[:productionState] = -1
|
147
|
+
set_info = @zen.set_info(opts)
|
148
|
+
set_info.must_be_kind_of Hash
|
149
|
+
set_info.wont_be_empty
|
150
|
+
set_info['success'].must_equal true
|
151
|
+
end
|
152
|
+
|
153
|
+
it 'sets info for a device on a device object' do
|
154
|
+
opts = {}
|
155
|
+
opts[:productionState] = -1
|
156
|
+
set_info = @dev.set_info(opts)
|
157
|
+
set_info.must_be_kind_of Hash
|
158
|
+
set_info.wont_be_empty
|
159
|
+
set_info['success'].must_equal true
|
160
|
+
end
|
161
|
+
end
|
141
162
|
end
|
142
163
|
|
143
164
|
describe Zenoss::Events::Event do
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require_relative './test_helper'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
|
4
|
+
describe Zenoss::Model::Device do
|
5
|
+
it 'raises error on #set_info when version is less than 6' do
|
6
|
+
opts = {}
|
7
|
+
opts[:version] = '4.2.5'
|
8
|
+
opts[:no_sign_in] = true
|
9
|
+
connection = Zenoss::Connection.new('http://localhost', 'admin', 'zenoss', opts)
|
10
|
+
zhash = {
|
11
|
+
productionState: 400,
|
12
|
+
priority: 3,
|
13
|
+
uid: '/zport/dmd/Devices/Server/devices/UnitTestDevice',
|
14
|
+
name: 'UnitTestDevice'
|
15
|
+
}
|
16
|
+
|
17
|
+
dev = Zenoss::Model::Device.new(connection, zhash)
|
18
|
+
options = {}
|
19
|
+
options[:productionState] = -1
|
20
|
+
exception = assert_raises Zenoss::ZenossError do
|
21
|
+
dev.set_info(options)
|
22
|
+
end
|
23
|
+
assert_equal('setInfo method on DeviceRouter is only allowed for version 6 and above', exception.message)
|
24
|
+
end
|
25
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zenoss_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Wanek
|
@@ -205,8 +205,11 @@ files:
|
|
205
205
|
- test/fixtures/vcr_cassettes/6_2_1_test_0007_fetches_the_report_tree.yml
|
206
206
|
- test/fixtures/vcr_cassettes/6_2_1_test_0008_fetches_available_report_types_and_returns_a_Hash.yml
|
207
207
|
- test/fixtures/vcr_cassettes/6_2_1_test_0009_renames_the_device.yml
|
208
|
+
- test/fixtures/vcr_cassettes/6_2_1_test_0010_sets_info_for_a_device.yml
|
209
|
+
- test/fixtures/vcr_cassettes/6_2_1_test_0011_sets_info_for_a_device_on_a_device_object.yml
|
208
210
|
- test/test_helper.rb
|
209
211
|
- test/zenoss_client_test.rb
|
212
|
+
- test/zenoss_model_device_test.rb
|
210
213
|
- tools/callZenossMethod.py
|
211
214
|
- zenoss_client.gemspec
|
212
215
|
homepage: http://github.com/RubyOpenSource/zenoss_client
|