rackspace-monitoring 0.2.3 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/rackspace-monitoring.rb +54 -28
- metadata +20 -20
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.4
|
data/lib/rackspace-monitoring.rb
CHANGED
@@ -9,7 +9,7 @@ module Fog
|
|
9
9
|
ENDPOINT = 'https://monitoring.api.rackspacecloud.com/v1.0'
|
10
10
|
|
11
11
|
requires :rackspace_api_key, :rackspace_username
|
12
|
-
recognizes :rackspace_auth_url, :persistent
|
12
|
+
recognizes :rackspace_auth_url, :persistent, :raise_errors
|
13
13
|
recognizes :rackspace_auth_token, :rackspace_service_url, :rackspace_account_id
|
14
14
|
|
15
15
|
model_path 'rackspace-monitoring/monitoring/models'
|
@@ -66,8 +66,16 @@ module Fog
|
|
66
66
|
@rackspace_service_url = options[:rackspace_service_url] || ENDPOINT
|
67
67
|
@rackspace_must_reauthenticate = false
|
68
68
|
@connection_options = options[:connection_options] || {}
|
69
|
+
|
70
|
+
if options.has_key("raise_errors")
|
71
|
+
@raise_errors = options[:raise_errors]
|
72
|
+
else
|
73
|
+
@raise_errors = true
|
74
|
+
end
|
75
|
+
|
69
76
|
authenticate
|
70
77
|
@persistent = options[:persistent] || false
|
78
|
+
|
71
79
|
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
|
72
80
|
end
|
73
81
|
|
@@ -75,37 +83,48 @@ module Fog
|
|
75
83
|
@connection.reset
|
76
84
|
end
|
77
85
|
|
86
|
+
def raise_error(error)
|
87
|
+
if @raise_errors
|
88
|
+
raise error
|
89
|
+
else
|
90
|
+
print "Error occurred: " + error.message
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
78
94
|
def request(params)
|
79
|
-
print params
|
80
95
|
begin
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
+
begin
|
97
|
+
response = @connection.request(params.merge({
|
98
|
+
:headers => {
|
99
|
+
'Content-Type' => 'application/json',
|
100
|
+
'X-Auth-Token' => @auth_token
|
101
|
+
}.merge!(params[:headers] || {}),
|
102
|
+
:host => @host,
|
103
|
+
:path => "#{@path}/#{params[:path]}"
|
104
|
+
}))
|
105
|
+
rescue Excon::Errors::Unauthorized => error
|
106
|
+
if error.response.body != 'Bad username or password' # token expiration
|
107
|
+
@rackspace_must_reauthenticate = true
|
108
|
+
authenticate
|
109
|
+
retry
|
110
|
+
else # bad credentials
|
111
|
+
raise error
|
112
|
+
end
|
113
|
+
rescue Excon::Errors::HTTPStatusError => error
|
114
|
+
raise case error
|
115
|
+
when Excon::Errors::NotFound
|
116
|
+
Fog::Monitoring::Rackspace::NotFound.slurp(error)
|
117
|
+
else
|
118
|
+
error
|
119
|
+
end
|
96
120
|
end
|
97
|
-
|
98
|
-
|
99
|
-
when Excon::Errors::NotFound
|
100
|
-
Fog::Monitoring::Rackspace::NotFound.slurp(error)
|
101
|
-
else
|
102
|
-
error
|
121
|
+
unless response.body.empty?
|
122
|
+
response.body = JSON.parse(response.body)
|
103
123
|
end
|
124
|
+
response
|
125
|
+
rescue Exception => error
|
126
|
+
raise_error(error)
|
104
127
|
end
|
105
|
-
unless response.body.empty?
|
106
|
-
response.body = JSON.parse(response.body)
|
107
|
-
end
|
108
|
-
response
|
109
128
|
end
|
110
129
|
|
111
130
|
private
|
@@ -117,7 +136,14 @@ module Fog
|
|
117
136
|
:rackspace_username => @rackspace_username,
|
118
137
|
:rackspace_auth_url => @rackspace_auth_url
|
119
138
|
}
|
120
|
-
|
139
|
+
|
140
|
+
begin
|
141
|
+
credentials = Fog::Rackspace.authenticate(options)
|
142
|
+
rescue Exception => error
|
143
|
+
raise_error(error)
|
144
|
+
return
|
145
|
+
end
|
146
|
+
|
121
147
|
@auth_token = credentials['X-Auth-Token']
|
122
148
|
@account_id = credentials['X-Server-Management-Url'].match(/.*\/([\d]+)$/)[1]
|
123
149
|
else
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rackspace-monitoring
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
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
|
- Dan Di Spaltro
|
@@ -15,10 +15,11 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-07-09 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
|
-
|
21
|
+
type: :runtime
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
22
23
|
none: false
|
23
24
|
requirements:
|
24
25
|
- - "="
|
@@ -29,12 +30,12 @@ dependencies:
|
|
29
30
|
- 7
|
30
31
|
- 0
|
31
32
|
version: 0.7.0
|
33
|
+
version_requirements: *id001
|
32
34
|
name: fog
|
33
35
|
prerelease: false
|
34
|
-
type: :runtime
|
35
|
-
requirement: *id001
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
|
-
|
37
|
+
type: :development
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
39
|
none: false
|
39
40
|
requirements:
|
40
41
|
- - ">="
|
@@ -43,12 +44,12 @@ dependencies:
|
|
43
44
|
segments:
|
44
45
|
- 0
|
45
46
|
version: "0"
|
47
|
+
version_requirements: *id002
|
46
48
|
name: shoulda
|
47
49
|
prerelease: false
|
48
|
-
type: :development
|
49
|
-
requirement: *id002
|
50
50
|
- !ruby/object:Gem::Dependency
|
51
|
-
|
51
|
+
type: :development
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
52
53
|
none: false
|
53
54
|
requirements:
|
54
55
|
- - ~>
|
@@ -58,12 +59,12 @@ dependencies:
|
|
58
59
|
- 3
|
59
60
|
- 12
|
60
61
|
version: "3.12"
|
62
|
+
version_requirements: *id003
|
61
63
|
name: rdoc
|
62
64
|
prerelease: false
|
63
|
-
type: :development
|
64
|
-
requirement: *id003
|
65
65
|
- !ruby/object:Gem::Dependency
|
66
|
-
|
66
|
+
type: :development
|
67
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
67
68
|
none: false
|
68
69
|
requirements:
|
69
70
|
- - ">="
|
@@ -74,12 +75,12 @@ dependencies:
|
|
74
75
|
- 0
|
75
76
|
- 0
|
76
77
|
version: 1.0.0
|
78
|
+
version_requirements: *id004
|
77
79
|
name: bundler
|
78
80
|
prerelease: false
|
79
|
-
type: :development
|
80
|
-
requirement: *id004
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
|
-
|
82
|
+
type: :development
|
83
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
83
84
|
none: false
|
84
85
|
requirements:
|
85
86
|
- - ~>
|
@@ -90,10 +91,9 @@ dependencies:
|
|
90
91
|
- 8
|
91
92
|
- 3
|
92
93
|
version: 1.8.3
|
94
|
+
version_requirements: *id005
|
93
95
|
name: jeweler
|
94
96
|
prerelease: false
|
95
|
-
type: :development
|
96
|
-
requirement: *id005
|
97
97
|
description: Rackspace Cloud Monitoring Ruby Bindings, built on top of fog.
|
98
98
|
email: dan.dispaltro@gmail.com
|
99
99
|
executables: []
|
@@ -173,7 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
173
173
|
requirements: []
|
174
174
|
|
175
175
|
rubyforge_project:
|
176
|
-
rubygems_version: 1.8.
|
176
|
+
rubygems_version: 1.8.13
|
177
177
|
signing_key:
|
178
178
|
specification_version: 3
|
179
179
|
summary: Rackspace Cloud Monitoring Ruby Bindings
|