deltacloud-core 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +3 -9
- data/bin/deltacloudd +17 -15
- data/lib/deltacloud/drivers/ec2/ec2_driver.rb +6 -3
- data/lib/deltacloud/helpers/blob_stream.rb +36 -27
- data/lib/sinatra/respond_to.rb +10 -0
- metadata +26 -74
data/Rakefile
CHANGED
@@ -43,15 +43,9 @@ begin
|
|
43
43
|
rescue LoadError
|
44
44
|
end
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
end
|
50
|
-
|
51
|
-
@specs.values.each do |spec|
|
52
|
-
Rake::GemPackageTask.new(spec) do |pkg|
|
53
|
-
pkg.need_tar = true
|
54
|
-
end
|
46
|
+
spec = Gem::Specification.load('deltacloud-core.gemspec')
|
47
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
48
|
+
pkg.need_tar = true
|
55
49
|
end
|
56
50
|
|
57
51
|
desc "Install API"
|
data/bin/deltacloudd
CHANGED
@@ -3,6 +3,18 @@
|
|
3
3
|
require 'rubygems'
|
4
4
|
require 'optparse'
|
5
5
|
|
6
|
+
# See if we can require +name+ and return +true+ if the library is there,
|
7
|
+
# +false+ otherwise. Note that, as a side effect, the library will be
|
8
|
+
# loaded
|
9
|
+
def library_present?(name)
|
10
|
+
begin
|
11
|
+
require name
|
12
|
+
true
|
13
|
+
rescue LoadError
|
14
|
+
false
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
6
18
|
options = {
|
7
19
|
:env => 'development'
|
8
20
|
}
|
@@ -47,9 +59,11 @@ puts "Starting Deltacloud API :: #{ENV["API_DRIVER"]} :: http://#{ENV["API_HOST"
|
|
47
59
|
puts
|
48
60
|
|
49
61
|
dirname="#{File.dirname(__FILE__)}/.."
|
50
|
-
platform = RUBY_PLATFORM[/java/] || 'ruby'
|
51
62
|
|
52
|
-
|
63
|
+
have_thin = library_present?('thin')
|
64
|
+
have_rerun = library_present?('rerun')
|
65
|
+
|
66
|
+
unless have_thin
|
53
67
|
require 'rack'
|
54
68
|
|
55
69
|
# We can't chdir with webrick so add our root directory
|
@@ -78,8 +92,6 @@ if platform == 'java'
|
|
78
92
|
:Port => port,
|
79
93
|
:AccessLog => [])
|
80
94
|
else
|
81
|
-
require 'thin'
|
82
|
-
|
83
95
|
argv_opts = ARGV.clone
|
84
96
|
argv_opts << ['start'] unless Thin::Runner.commands.include?(options[0])
|
85
97
|
argv_opts << ['--address', ENV["API_HOST"] ]
|
@@ -91,17 +103,7 @@ else
|
|
91
103
|
|
92
104
|
argv_opts.flatten!
|
93
105
|
|
94
|
-
if options[:env] == "development"
|
95
|
-
use_rerun = false
|
96
|
-
begin
|
97
|
-
require "rerun"
|
98
|
-
use_rerun = true
|
99
|
-
rescue
|
100
|
-
# Do nothing
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
if use_rerun
|
106
|
+
if have_rerun && options[:env] == "development"
|
105
107
|
argv_opts.unshift "thin"
|
106
108
|
command = argv_opts.join(" ")
|
107
109
|
topdir = File::expand_path(File::join(File::dirname(__FILE__), ".."))
|
@@ -130,8 +130,11 @@ class EC2Driver < Deltacloud::BaseDriver
|
|
130
130
|
config.merge!({ :owner_id => opts[:owner_id] }) if opts and opts[:owner_id]
|
131
131
|
end
|
132
132
|
safely do
|
133
|
-
ec2.describe_images(config).imagesSet
|
134
|
-
|
133
|
+
image_set = ec2.describe_images(config).imagesSet
|
134
|
+
unless image_set.nil?
|
135
|
+
image_set.item.each do |image|
|
136
|
+
img_arr << convert_image(image)
|
137
|
+
end
|
135
138
|
end
|
136
139
|
end
|
137
140
|
img_arr = filter_on( img_arr, :architecture, opts )
|
@@ -434,7 +437,7 @@ class EC2Driver < Deltacloud::BaseDriver
|
|
434
437
|
def convert_realm(ec2_realm)
|
435
438
|
Realm.new( {
|
436
439
|
:id=>ec2_realm['zoneName'],
|
437
|
-
:name=>ec2_realm['
|
440
|
+
:name=>ec2_realm['zoneName'],
|
438
441
|
:limit=>ec2_realm['zoneState'].eql?('available') ? :unlimited : 0,
|
439
442
|
:state=>ec2_realm['zoneState'].upcase,
|
440
443
|
} )
|
@@ -15,37 +15,46 @@
|
|
15
15
|
# License for the specific language governing permissions and limitations
|
16
16
|
# under the License.
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
#--
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
18
|
+
begin
|
19
|
+
require 'eventmachine'
|
20
|
+
#--
|
21
|
+
# based on the example from http://macournoyer.com/blog/2009/06/04/pusher-and-async-with-thin/
|
22
|
+
#--
|
23
|
+
class BlobStream
|
24
|
+
AsyncResponse = [-1, {}, []].freeze
|
25
|
+
def self.call(env, credentials, params)
|
26
|
+
body = DeferrableBody.new
|
27
|
+
#Get the headers out asap. Don't specify a content-type let
|
28
|
+
#the client guess and if they can't they SHOULD default to
|
29
|
+
#'application/octet-stream' anyway as per:
|
30
|
+
#http://www.w3.org/Protocols/rfc2616/rfc2616-sec7.html#sec7.2.1
|
31
|
+
EM.next_tick { env['async.callback'].call [200, {'Content-Type' => "#{params['content_type']}", 'Content-Length' => "#{params['content_length']}"}, body] }
|
32
|
+
#call the driver from here. the driver method yields for every chunk of blob it receives. We then
|
33
|
+
#use body.call to write that chunk as received.
|
34
|
+
driver.blob_data(credentials, params[:bucket], params[:blob], params) {|chunk| body.call ["#{chunk}"]} #close blob_data block
|
35
|
+
body.succeed
|
36
|
+
AsyncResponse # Tells Thin to not close the connection and continue it's work on other request
|
37
|
+
end
|
36
38
|
end
|
37
|
-
end
|
38
39
|
|
39
|
-
class DeferrableBody
|
40
|
-
|
40
|
+
class DeferrableBody
|
41
|
+
include EventMachine::Deferrable
|
41
42
|
|
42
|
-
|
43
|
-
|
44
|
-
|
43
|
+
def call(body)
|
44
|
+
body.each do |chunk|
|
45
|
+
@body_callback.call(chunk)
|
46
|
+
end
|
45
47
|
end
|
46
|
-
end
|
47
48
|
|
48
|
-
|
49
|
-
|
49
|
+
def each(&blk)
|
50
|
+
@body_callback = blk
|
51
|
+
end
|
52
|
+
end
|
53
|
+
rescue LoadError => e
|
54
|
+
# EventMachine isn't available, disable blob streaming
|
55
|
+
class BlobStream
|
56
|
+
def self.call(env, credentials, params)
|
57
|
+
raise NotImplementedError.new("Blob streaming is only supported under Thin")
|
58
|
+
end
|
50
59
|
end
|
51
60
|
end
|
data/lib/sinatra/respond_to.rb
CHANGED
@@ -102,6 +102,8 @@ module Sinatra
|
|
102
102
|
|
103
103
|
if rack_accept.media_type.to_s.strip.eql?('Accept:')
|
104
104
|
format :xml
|
105
|
+
elsif is_chrome?
|
106
|
+
format :html
|
105
107
|
else
|
106
108
|
format lookup_format_from_mime(rack_accept.best_media_type(accept_to_array))
|
107
109
|
end
|
@@ -109,6 +111,14 @@ module Sinatra
|
|
109
111
|
end
|
110
112
|
|
111
113
|
app.class_eval do
|
114
|
+
|
115
|
+
# Simple helper to detect Chrome based browsers
|
116
|
+
# which have screwed up they Accept headers.
|
117
|
+
# Set HTML as default output format here
|
118
|
+
def is_chrome?
|
119
|
+
true if env['HTTP_USER_AGENT'] =~ /Chrome/
|
120
|
+
end
|
121
|
+
|
112
122
|
# This code was copied from respond_to plugin
|
113
123
|
# http://github.com/cehoffman/sinatra-respond_to
|
114
124
|
# MIT License
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deltacloud-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 13
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 9
|
10
|
+
version: 0.0.9
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Red Hat, Inc.
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-10-
|
18
|
+
date: 2010-10-22 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -34,26 +34,10 @@ dependencies:
|
|
34
34
|
version: 0.8.7
|
35
35
|
type: :runtime
|
36
36
|
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: eventmachine
|
39
|
-
prerelease: false
|
40
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ">="
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
hash: 59
|
46
|
-
segments:
|
47
|
-
- 0
|
48
|
-
- 12
|
49
|
-
- 10
|
50
|
-
version: 0.12.10
|
51
|
-
type: :runtime
|
52
|
-
version_requirements: *id002
|
53
37
|
- !ruby/object:Gem::Dependency
|
54
38
|
name: haml
|
55
39
|
prerelease: false
|
56
|
-
requirement: &
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
57
41
|
none: false
|
58
42
|
requirements:
|
59
43
|
- - ">="
|
@@ -65,11 +49,11 @@ dependencies:
|
|
65
49
|
- 17
|
66
50
|
version: 2.2.17
|
67
51
|
type: :runtime
|
68
|
-
version_requirements: *
|
52
|
+
version_requirements: *id002
|
69
53
|
- !ruby/object:Gem::Dependency
|
70
54
|
name: sinatra
|
71
55
|
prerelease: false
|
72
|
-
requirement: &
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
73
57
|
none: false
|
74
58
|
requirements:
|
75
59
|
- - ">="
|
@@ -81,11 +65,11 @@ dependencies:
|
|
81
65
|
- 4
|
82
66
|
version: 0.9.4
|
83
67
|
type: :runtime
|
84
|
-
version_requirements: *
|
68
|
+
version_requirements: *id003
|
85
69
|
- !ruby/object:Gem::Dependency
|
86
70
|
name: rack
|
87
71
|
prerelease: false
|
88
|
-
requirement: &
|
72
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
89
73
|
none: false
|
90
74
|
requirements:
|
91
75
|
- - ">="
|
@@ -97,11 +81,11 @@ dependencies:
|
|
97
81
|
- 0
|
98
82
|
version: 1.0.0
|
99
83
|
type: :runtime
|
100
|
-
version_requirements: *
|
84
|
+
version_requirements: *id004
|
101
85
|
- !ruby/object:Gem::Dependency
|
102
86
|
name: rack-accept
|
103
87
|
prerelease: false
|
104
|
-
requirement: &
|
88
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
105
89
|
none: false
|
106
90
|
requirements:
|
107
91
|
- - ~>
|
@@ -113,43 +97,11 @@ dependencies:
|
|
113
97
|
- 3
|
114
98
|
version: 0.4.3
|
115
99
|
type: :runtime
|
116
|
-
version_requirements: *
|
117
|
-
- !ruby/object:Gem::Dependency
|
118
|
-
name: thin
|
119
|
-
prerelease: false
|
120
|
-
requirement: &id007 !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
|
-
requirements:
|
123
|
-
- - ">="
|
124
|
-
- !ruby/object:Gem::Version
|
125
|
-
hash: 21
|
126
|
-
segments:
|
127
|
-
- 1
|
128
|
-
- 2
|
129
|
-
- 5
|
130
|
-
version: 1.2.5
|
131
|
-
type: :runtime
|
132
|
-
version_requirements: *id007
|
133
|
-
- !ruby/object:Gem::Dependency
|
134
|
-
name: rerun
|
135
|
-
prerelease: false
|
136
|
-
requirement: &id008 !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
|
-
requirements:
|
139
|
-
- - ">="
|
140
|
-
- !ruby/object:Gem::Version
|
141
|
-
hash: 15
|
142
|
-
segments:
|
143
|
-
- 0
|
144
|
-
- 5
|
145
|
-
- 2
|
146
|
-
version: 0.5.2
|
147
|
-
type: :runtime
|
148
|
-
version_requirements: *id008
|
100
|
+
version_requirements: *id005
|
149
101
|
- !ruby/object:Gem::Dependency
|
150
102
|
name: json
|
151
103
|
prerelease: false
|
152
|
-
requirement: &
|
104
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
153
105
|
none: false
|
154
106
|
requirements:
|
155
107
|
- - ">="
|
@@ -161,11 +113,11 @@ dependencies:
|
|
161
113
|
- 9
|
162
114
|
version: 1.1.9
|
163
115
|
type: :runtime
|
164
|
-
version_requirements: *
|
116
|
+
version_requirements: *id006
|
165
117
|
- !ruby/object:Gem::Dependency
|
166
118
|
name: compass
|
167
119
|
prerelease: false
|
168
|
-
requirement: &
|
120
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
169
121
|
none: false
|
170
122
|
requirements:
|
171
123
|
- - ">="
|
@@ -177,11 +129,11 @@ dependencies:
|
|
177
129
|
- 17
|
178
130
|
version: 0.8.17
|
179
131
|
type: :development
|
180
|
-
version_requirements: *
|
132
|
+
version_requirements: *id007
|
181
133
|
- !ruby/object:Gem::Dependency
|
182
134
|
name: nokogiri
|
183
135
|
prerelease: false
|
184
|
-
requirement: &
|
136
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
185
137
|
none: false
|
186
138
|
requirements:
|
187
139
|
- - ">="
|
@@ -193,11 +145,11 @@ dependencies:
|
|
193
145
|
- 1
|
194
146
|
version: 1.4.1
|
195
147
|
type: :development
|
196
|
-
version_requirements: *
|
148
|
+
version_requirements: *id008
|
197
149
|
- !ruby/object:Gem::Dependency
|
198
150
|
name: rack-test
|
199
151
|
prerelease: false
|
200
|
-
requirement: &
|
152
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
201
153
|
none: false
|
202
154
|
requirements:
|
203
155
|
- - ">="
|
@@ -209,11 +161,11 @@ dependencies:
|
|
209
161
|
- 3
|
210
162
|
version: 0.5.3
|
211
163
|
type: :development
|
212
|
-
version_requirements: *
|
164
|
+
version_requirements: *id009
|
213
165
|
- !ruby/object:Gem::Dependency
|
214
166
|
name: cucumber
|
215
167
|
prerelease: false
|
216
|
-
requirement: &
|
168
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
217
169
|
none: false
|
218
170
|
requirements:
|
219
171
|
- - ">="
|
@@ -225,11 +177,11 @@ dependencies:
|
|
225
177
|
- 3
|
226
178
|
version: 0.6.3
|
227
179
|
type: :development
|
228
|
-
version_requirements: *
|
180
|
+
version_requirements: *id010
|
229
181
|
- !ruby/object:Gem::Dependency
|
230
182
|
name: rcov
|
231
183
|
prerelease: false
|
232
|
-
requirement: &
|
184
|
+
requirement: &id011 !ruby/object:Gem::Requirement
|
233
185
|
none: false
|
234
186
|
requirements:
|
235
187
|
- - ">="
|
@@ -241,7 +193,7 @@ dependencies:
|
|
241
193
|
- 8
|
242
194
|
version: 0.9.8
|
243
195
|
type: :development
|
244
|
-
version_requirements: *
|
196
|
+
version_requirements: *id011
|
245
197
|
description: " The Deltacloud API is built as a service-based REST API.\n You do not directly link a Deltacloud library into your program to use it.\n Instead, a client speaks the Deltacloud API over HTTP to a server\n which implements the REST interface.\n"
|
246
198
|
email: deltacloud-users@lists.fedorahosted.org
|
247
199
|
executables:
|
@@ -266,7 +218,6 @@ files:
|
|
266
218
|
- lib/deltacloud/models/base_model.rb
|
267
219
|
- lib/deltacloud/models/realm.rb
|
268
220
|
- lib/deltacloud/models/instance.rb
|
269
|
-
- lib/deltacloud/models/key.rb
|
270
221
|
- lib/deltacloud/models/instance_profile.rb
|
271
222
|
- lib/deltacloud/models/storage_volume.rb
|
272
223
|
- lib/deltacloud/models/storage_snapshot.rb
|
@@ -274,6 +225,7 @@ files:
|
|
274
225
|
- lib/deltacloud/models/blob.rb
|
275
226
|
- lib/deltacloud/models/tag.rb
|
276
227
|
- lib/deltacloud/models/bucket.rb
|
228
|
+
- lib/deltacloud/models/key.rb
|
277
229
|
- lib/deltacloud/method_serializer.rb
|
278
230
|
- lib/deltacloud/helpers.rb
|
279
231
|
- lib/deltacloud/drivers/ec2/ec2_mock_driver.rb
|
@@ -299,8 +251,8 @@ files:
|
|
299
251
|
- lib/deltacloud/base_driver/mock_driver.rb
|
300
252
|
- lib/deltacloud/helpers/hardware_profiles_helper.rb
|
301
253
|
- lib/deltacloud/helpers/conversion_helper.rb
|
302
|
-
- lib/deltacloud/helpers/blob_stream.rb
|
303
254
|
- lib/deltacloud/helpers/application_helper.rb
|
255
|
+
- lib/deltacloud/helpers/blob_stream.rb
|
304
256
|
- lib/deltacloud/state_machine.rb
|
305
257
|
- lib/deltacloud/base_driver.rb
|
306
258
|
- lib/drivers.rb
|