steamcannon-deltacloud-client 0.1.0.5 → 0.1.1.1
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/lib/deltacloud.rb +31 -9
- data/specs/data/images/img1.yml +4 -0
- data/specs/data/images/img2.yml +4 -0
- data/specs/data/images/img3.yml +4 -0
- data/specs/data/instances/inst0.yml +16 -0
- data/specs/data/instances/inst1.yml +9 -0
- data/specs/data/instances/inst2.yml +9 -0
- data/specs/data/storage_snapshots/snap1.yml +4 -0
- data/specs/data/storage_snapshots/snap2.yml +4 -0
- data/specs/data/storage_snapshots/snap3.yml +4 -0
- data/specs/data/storage_volumes/vol1.yml +6 -0
- data/specs/data/storage_volumes/vol2.yml +6 -0
- data/specs/data/storage_volumes/vol3.yml +6 -0
- data/specs/instances_spec.rb +2 -2
- metadata +150 -122
data/lib/deltacloud.rb
CHANGED
@@ -34,8 +34,9 @@ module DeltaCloud
|
|
34
34
|
# @param [String, password] API password
|
35
35
|
# @param [String, user_name] API URL (eg. http://localhost:3001/api)
|
36
36
|
# @return [DeltaCloud::API]
|
37
|
-
def self.new(user_name, password, api_url, &block)
|
38
|
-
|
37
|
+
def self.new(user_name, password, api_url, opts={}, &block)
|
38
|
+
opts ||= {}
|
39
|
+
API.new(user_name, password, api_url, opts, &block)
|
39
40
|
end
|
40
41
|
|
41
42
|
# Check given credentials if their are valid against
|
@@ -45,8 +46,8 @@ module DeltaCloud
|
|
45
46
|
# @param [String, password] API password
|
46
47
|
# @param [String, user_name] API URL (eg. http://localhost:3001/api)
|
47
48
|
# @return [true|false]
|
48
|
-
def self.valid_credentials?(user_name, password, api_url)
|
49
|
-
api=API.new(user_name, password, api_url)
|
49
|
+
def self.valid_credentials?(user_name, password, api_url, opts={})
|
50
|
+
api=API.new(user_name, password, api_url, opts)
|
50
51
|
result = false
|
51
52
|
api.request(:get, '', :force_auth => '1') do |response|
|
52
53
|
result = true if response.code.eql?(200)
|
@@ -62,11 +63,13 @@ module DeltaCloud
|
|
62
63
|
end
|
63
64
|
|
64
65
|
class API
|
65
|
-
attr_reader
|
66
|
+
attr_reader :api_uri, :driver_name, :api_version, :features, :entry_points
|
67
|
+
attr_reader :api_driver, :api_provider
|
66
68
|
|
67
69
|
def initialize(user_name, password, api_url, opts={}, &block)
|
68
70
|
opts[:version] = true
|
69
|
-
@
|
71
|
+
@api_driver, @api_provider = opts[:driver], opts[:provider]
|
72
|
+
@username, @password = opts[:username] || user_name, opts[:password] || password
|
70
73
|
@api_uri = URI.parse(api_url)
|
71
74
|
@features, @entry_points = {}, {}
|
72
75
|
@verbose = opts[:verbose] || false
|
@@ -159,7 +162,7 @@ module DeltaCloud
|
|
159
162
|
end
|
160
163
|
end
|
161
164
|
|
162
|
-
# If there are actions, add
|
165
|
+
# If there are actions, add they to ActionObject/StateFullObject
|
163
166
|
if attribute.name == 'actions'
|
164
167
|
(attribute/'link').each do |link|
|
165
168
|
obj.add_action_link!(item['id'], link)
|
@@ -241,6 +244,25 @@ module DeltaCloud
|
|
241
244
|
raise NoMethodError
|
242
245
|
end
|
243
246
|
|
247
|
+
def use_driver(driver, opts={})
|
248
|
+
if driver
|
249
|
+
@api_driver = driver
|
250
|
+
@driver_name = driver
|
251
|
+
discover_entry_points
|
252
|
+
end
|
253
|
+
@username = opts[:username] if opts[:username]
|
254
|
+
@password = opts[:password] if opts[:password]
|
255
|
+
@api_provider = opts[:provider] if opts[:provider]
|
256
|
+
return self
|
257
|
+
end
|
258
|
+
|
259
|
+
def extended_headers
|
260
|
+
headers = {}
|
261
|
+
headers["X-Deltacloud-Driver"] = @api_driver.to_s if @api_driver
|
262
|
+
headers["X-Deltacloud-Provider"] = @api_provider.to_s if @api_provider
|
263
|
+
headers
|
264
|
+
end
|
265
|
+
|
244
266
|
# Basic request method
|
245
267
|
#
|
246
268
|
def request(*args, &block)
|
@@ -255,7 +277,7 @@ module DeltaCloud
|
|
255
277
|
end
|
256
278
|
|
257
279
|
if conf[:method].eql?(:post)
|
258
|
-
RestClient.send(:post, conf[:path], conf[:form_data], default_headers) do |response, request, block|
|
280
|
+
RestClient.send(:post, conf[:path], conf[:form_data], default_headers.merge(extended_headers)) do |response, request, block|
|
259
281
|
handle_backend_error(response) if response.code.eql?(500)
|
260
282
|
if response.respond_to?('body')
|
261
283
|
yield response.body if block_given?
|
@@ -264,7 +286,7 @@ module DeltaCloud
|
|
264
286
|
end
|
265
287
|
end
|
266
288
|
else
|
267
|
-
RestClient.send(conf[:method], conf[:path], default_headers) do |response, request, block|
|
289
|
+
RestClient.send(conf[:method], conf[:path], default_headers.merge(extended_headers)) do |response, request, block|
|
268
290
|
handle_backend_error(response) if response.code.eql?(500)
|
269
291
|
if conf[:method].eql?(:get) and [301, 302, 307].include? response.code
|
270
292
|
response.follow_redirection(request) do |response, request, block|
|
@@ -0,0 +1,16 @@
|
|
1
|
+
---
|
2
|
+
:realm_id: us
|
3
|
+
:public_addresses:
|
4
|
+
- img1.inst0.public.com
|
5
|
+
:state: RUNNING
|
6
|
+
:name: "Mock Instance With Profile Change"
|
7
|
+
:private_addresses:
|
8
|
+
- img1.inst0.private.com
|
9
|
+
:image_id: img1
|
10
|
+
:instance_profile: !ruby/object:InstanceProfile
|
11
|
+
id: m1-large
|
12
|
+
memory: "12288"
|
13
|
+
:owner_id: mockuser
|
14
|
+
:actions:
|
15
|
+
- :reboot
|
16
|
+
- :stop
|
data/specs/instances_spec.rb
CHANGED
@@ -34,9 +34,9 @@ describe "instances" do
|
|
34
34
|
instance.owner_id.should_not be_nil
|
35
35
|
instance.owner_id.should be_a( String )
|
36
36
|
instance.image.should_not be_nil
|
37
|
-
instance.image.should be_a( DeltaCloud::API::Image )
|
37
|
+
instance.image.should be_a( DeltaCloud::API::Base::Image )
|
38
38
|
instance.hardware_profile.should_not be_nil
|
39
|
-
instance.hardware_profile.should be_a( DeltaCloud::API::HardwareProfile )
|
39
|
+
instance.hardware_profile.should be_a( DeltaCloud::API::Base::HardwareProfile )
|
40
40
|
instance.state.should_not be_nil
|
41
41
|
instance.state.should be_a( String )
|
42
42
|
instance.public_addresses.should_not be_nil
|
metadata
CHANGED
@@ -1,112 +1,126 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: steamcannon-deltacloud-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 65
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
version: 0.1.
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 1
|
10
|
+
- 1
|
11
|
+
version: 0.1.1.1
|
11
12
|
platform: ruby
|
12
13
|
authors:
|
13
|
-
|
14
|
+
- Red Hat, Inc.
|
14
15
|
autorequire:
|
15
16
|
bindir: bin
|
16
17
|
cert_chain: []
|
17
18
|
|
18
|
-
date: 2010-12-
|
19
|
+
date: 2010-12-23 00:00:00 -05:00
|
19
20
|
default_executable: deltacloudc
|
20
21
|
dependencies:
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
22
|
+
- !ruby/object:Gem::Dependency
|
23
|
+
name: rest-client
|
24
|
+
prerelease: false
|
25
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ">="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
hash: 13
|
31
|
+
segments:
|
32
|
+
- 1
|
33
|
+
- 6
|
34
|
+
- 1
|
35
|
+
version: 1.6.1
|
36
|
+
type: :runtime
|
37
|
+
version_requirements: *id001
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: nokogiri
|
40
|
+
prerelease: false
|
41
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
hash: 1
|
47
|
+
segments:
|
48
|
+
- 1
|
49
|
+
- 4
|
50
|
+
- 3
|
51
|
+
version: 1.4.3
|
52
|
+
type: :runtime
|
53
|
+
version_requirements: *id002
|
54
|
+
- !ruby/object:Gem::Dependency
|
55
|
+
name: rspec
|
56
|
+
prerelease: false
|
57
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
hash: 27
|
63
|
+
segments:
|
64
|
+
- 1
|
65
|
+
- 3
|
66
|
+
- 0
|
67
|
+
version: 1.3.0
|
68
|
+
type: :development
|
69
|
+
version_requirements: *id003
|
68
70
|
description: Deltacloud REST Client for API
|
69
71
|
email: deltacloud-users@lists.fedorahosted.org
|
70
72
|
executables:
|
71
|
-
|
73
|
+
- deltacloudc
|
72
74
|
extensions: []
|
73
75
|
|
74
76
|
extra_rdoc_files:
|
75
|
-
|
77
|
+
- COPYING
|
76
78
|
files:
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
79
|
+
- Rakefile
|
80
|
+
- lib/plain_formatter.rb
|
81
|
+
- lib/string.rb
|
82
|
+
- lib/deltacloud.rb
|
83
|
+
- lib/base_object.rb
|
84
|
+
- lib/hwp_properties.rb
|
85
|
+
- lib/instance_state.rb
|
86
|
+
- lib/documentation.rb
|
87
|
+
- init.rb
|
88
|
+
- bin/deltacloudc
|
89
|
+
- specs/data/storage_volumes/vol3.yml
|
90
|
+
- specs/data/storage_volumes/vol1.yml
|
91
|
+
- specs/data/storage_volumes/vol2.yml
|
92
|
+
- specs/data/images/img2.yml
|
93
|
+
- specs/data/images/img3.yml
|
94
|
+
- specs/data/images/img1.yml
|
95
|
+
- specs/data/instances/inst2.yml
|
96
|
+
- specs/data/instances/inst1.yml
|
97
|
+
- specs/data/instances/inst0.yml
|
98
|
+
- specs/data/storage_snapshots/snap3.yml
|
99
|
+
- specs/data/storage_snapshots/snap1.yml
|
100
|
+
- specs/data/storage_snapshots/snap2.yml
|
101
|
+
- specs/fixtures/storage_volumes/vol3.yml
|
102
|
+
- specs/fixtures/storage_volumes/vol1.yml
|
103
|
+
- specs/fixtures/storage_volumes/vol2.yml
|
104
|
+
- specs/fixtures/images/img2.yml
|
105
|
+
- specs/fixtures/images/img3.yml
|
106
|
+
- specs/fixtures/images/img1.yml
|
107
|
+
- specs/fixtures/instances/inst2.yml
|
108
|
+
- specs/fixtures/instances/inst1.yml
|
109
|
+
- specs/fixtures/instances/inst0.yml
|
110
|
+
- specs/fixtures/storage_snapshots/snap3.yml
|
111
|
+
- specs/fixtures/storage_snapshots/snap1.yml
|
112
|
+
- specs/fixtures/storage_snapshots/snap2.yml
|
113
|
+
- specs/storage_snapshot_spec.rb
|
114
|
+
- specs/hardware_profiles_spec.rb
|
115
|
+
- specs/images_spec.rb
|
116
|
+
- specs/realms_spec.rb
|
117
|
+
- specs/instances_spec.rb
|
118
|
+
- specs/storage_volume_spec.rb
|
119
|
+
- specs/spec_helper.rb
|
120
|
+
- specs/instance_states_spec.rb
|
121
|
+
- specs/shared/resources.rb
|
122
|
+
- specs/initialization_spec.rb
|
123
|
+
- COPYING
|
110
124
|
has_rdoc: true
|
111
125
|
homepage: http://www.deltacloud.org
|
112
126
|
licenses: []
|
@@ -115,23 +129,25 @@ post_install_message:
|
|
115
129
|
rdoc_options: []
|
116
130
|
|
117
131
|
require_paths:
|
118
|
-
|
132
|
+
- lib
|
119
133
|
required_ruby_version: !ruby/object:Gem::Requirement
|
120
134
|
none: false
|
121
135
|
requirements:
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
hash: 3
|
139
|
+
segments:
|
140
|
+
- 0
|
141
|
+
version: "0"
|
127
142
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
143
|
none: false
|
129
144
|
requirements:
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
145
|
+
- - ">="
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
hash: 3
|
148
|
+
segments:
|
149
|
+
- 0
|
150
|
+
version: "0"
|
135
151
|
requirements: []
|
136
152
|
|
137
153
|
rubyforge_project:
|
@@ -140,25 +156,37 @@ signing_key:
|
|
140
156
|
specification_version: 3
|
141
157
|
summary: Deltacloud REST Client
|
142
158
|
test_files:
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
159
|
+
- specs/data/storage_volumes/vol3.yml
|
160
|
+
- specs/data/storage_volumes/vol1.yml
|
161
|
+
- specs/data/storage_volumes/vol2.yml
|
162
|
+
- specs/data/images/img2.yml
|
163
|
+
- specs/data/images/img3.yml
|
164
|
+
- specs/data/images/img1.yml
|
165
|
+
- specs/data/instances/inst2.yml
|
166
|
+
- specs/data/instances/inst1.yml
|
167
|
+
- specs/data/instances/inst0.yml
|
168
|
+
- specs/data/storage_snapshots/snap3.yml
|
169
|
+
- specs/data/storage_snapshots/snap1.yml
|
170
|
+
- specs/data/storage_snapshots/snap2.yml
|
171
|
+
- specs/fixtures/storage_volumes/vol3.yml
|
172
|
+
- specs/fixtures/storage_volumes/vol1.yml
|
173
|
+
- specs/fixtures/storage_volumes/vol2.yml
|
174
|
+
- specs/fixtures/images/img2.yml
|
175
|
+
- specs/fixtures/images/img3.yml
|
176
|
+
- specs/fixtures/images/img1.yml
|
177
|
+
- specs/fixtures/instances/inst2.yml
|
178
|
+
- specs/fixtures/instances/inst1.yml
|
179
|
+
- specs/fixtures/instances/inst0.yml
|
180
|
+
- specs/fixtures/storage_snapshots/snap3.yml
|
181
|
+
- specs/fixtures/storage_snapshots/snap1.yml
|
182
|
+
- specs/fixtures/storage_snapshots/snap2.yml
|
183
|
+
- specs/storage_snapshot_spec.rb
|
184
|
+
- specs/hardware_profiles_spec.rb
|
185
|
+
- specs/images_spec.rb
|
186
|
+
- specs/realms_spec.rb
|
187
|
+
- specs/instances_spec.rb
|
188
|
+
- specs/storage_volume_spec.rb
|
189
|
+
- specs/spec_helper.rb
|
190
|
+
- specs/instance_states_spec.rb
|
191
|
+
- specs/shared/resources.rb
|
192
|
+
- specs/initialization_spec.rb
|