iteh-zabbixapi 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/zabbixapi/template.rb +4 -1
- data/lib/zabbixapi/version.rb +1 -1
- data/spec/zabbixapi_spec.rb +7 -6
- metadata +4 -4
data/lib/zabbixapi/template.rb
CHANGED
@@ -89,7 +89,10 @@ module Zabbix
|
|
89
89
|
}
|
90
90
|
|
91
91
|
response = send_request(message)
|
92
|
-
|
92
|
+
result = nil
|
93
|
+
result = response.first["templateid"] if (response.is_a?(Array) && response.first.is_a?(Hash)) # API > 1.8.3
|
94
|
+
result = response[response.keys.first]["templateid"] if (response.is_a?(Hash) && response[response.keys.first].is_a?(Hash)) # API <= 1.8.3
|
95
|
+
result
|
93
96
|
end
|
94
97
|
|
95
98
|
def link_templates_with_hosts(templates_id, hosts_id)
|
data/lib/zabbixapi/version.rb
CHANGED
data/spec/zabbixapi_spec.rb
CHANGED
@@ -38,8 +38,8 @@ describe Zabbix::ZabbixApi do
|
|
38
38
|
RecordHttp.perform_save = false
|
39
39
|
FakeWeb.allow_net_connect = false
|
40
40
|
|
41
|
-
|
42
|
-
zbx = Zabbix::ZabbixApi.new(
|
41
|
+
api_url = "http://192.168.1.29/login_success_user.authenticate.txt"
|
42
|
+
zbx = Zabbix::ZabbixApi.new(api_url, @api_login, @api_password)
|
43
43
|
zbx.auth.should_not be_nil
|
44
44
|
end
|
45
45
|
|
@@ -48,9 +48,9 @@ describe Zabbix::ZabbixApi do
|
|
48
48
|
RecordHttp.perform_save = false
|
49
49
|
FakeWeb.allow_net_connect = false
|
50
50
|
|
51
|
-
|
52
|
-
|
53
|
-
zbx = Zabbix::ZabbixApi.new(
|
51
|
+
api_url = "http://192.168.1.29/failed_auth_wrong_password_user.authenticate.txt"
|
52
|
+
api_login = "wrong_user"
|
53
|
+
zbx = Zabbix::ZabbixApi.new(api_url, api_login, @api_password)
|
54
54
|
lambda { zbx.auth}.should raise_error(Zabbix::AuthError)
|
55
55
|
end
|
56
56
|
|
@@ -102,7 +102,7 @@ describe Zabbix::ZabbixApi do
|
|
102
102
|
"useip" => 1,
|
103
103
|
"dns" => "myhost.com",
|
104
104
|
"groups" => [2],
|
105
|
-
"templates" => [10001]
|
105
|
+
"templates" => [10001,10049]
|
106
106
|
}
|
107
107
|
zbx = Zabbix::ZabbixApi.new(@api_url, @api_login, @api_password)
|
108
108
|
|
@@ -118,6 +118,7 @@ describe Zabbix::ZabbixApi do
|
|
118
118
|
context 'get template' do
|
119
119
|
it "should get a template" do
|
120
120
|
FakeWeb.allow_net_connect = true
|
121
|
+
@api_url = "http://192.168.1.29/zabbix/api_jsonrpc.php"
|
121
122
|
|
122
123
|
zbx = Zabbix::ZabbixApi.new(@api_url, @api_login, @api_password)
|
123
124
|
template_id = zbx.get_template_id("Template_Linux")
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iteh-zabbixapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 4
|
10
|
+
version: 0.2.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Eduard Snesarev
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-06-
|
19
|
+
date: 2011-06-28 00:00:00 +02:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|