fog 0.0.77 → 0.0.78
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +2 -2
- data/fog.gemspec +59 -48
- data/lib/fog.rb +2 -1
- data/lib/fog/aws/models/ec2/snapshot.rb +3 -1
- data/lib/fog/aws/models/ec2/volume.rb +4 -2
- data/lib/fog/aws/s3.rb +1 -1
- data/lib/fog/deprecation.rb +14 -0
- data/lib/fog/terremark.rb +7 -220
- data/lib/fog/terremark/bin.rb +24 -14
- data/lib/fog/terremark/ecloud.rb +51 -0
- data/lib/fog/terremark/models/shared/address.rb +29 -0
- data/lib/fog/terremark/models/shared/addresses.rb +49 -0
- data/lib/fog/terremark/models/shared/network.rb +30 -0
- data/lib/fog/terremark/models/shared/networks.rb +52 -0
- data/lib/fog/terremark/models/shared/server.rb +57 -0
- data/lib/fog/terremark/models/shared/servers.rb +55 -0
- data/lib/fog/terremark/models/shared/task.rb +43 -0
- data/lib/fog/terremark/models/shared/tasks.rb +58 -0
- data/lib/fog/terremark/parser.rb +18 -0
- data/lib/fog/terremark/parsers/shared/get_catalog.rb +46 -0
- data/lib/fog/terremark/parsers/shared/get_catalog_item.rb +46 -0
- data/lib/fog/terremark/parsers/shared/get_internet_services.rb +60 -0
- data/lib/fog/terremark/parsers/{get_node_services.rb → shared/get_node_services.rb} +10 -11
- data/lib/fog/terremark/parsers/shared/get_organization.rb +47 -0
- data/lib/fog/terremark/parsers/shared/get_organizations.rb +27 -0
- data/lib/fog/terremark/parsers/shared/get_public_ips.rb +30 -0
- data/lib/fog/terremark/parsers/shared/get_tasks_list.rb +52 -0
- data/lib/fog/terremark/parsers/shared/get_vapp_template.rb +46 -0
- data/lib/fog/terremark/parsers/shared/get_vdc.rb +108 -0
- data/lib/fog/terremark/parsers/shared/instantiate_vapp_template.rb +41 -0
- data/lib/fog/terremark/parsers/shared/internet_service.rb +65 -0
- data/lib/fog/terremark/parsers/shared/network.rb +51 -0
- data/lib/fog/terremark/parsers/shared/node_service.rb +32 -0
- data/lib/fog/terremark/parsers/shared/public_ip.rb +26 -0
- data/lib/fog/terremark/parsers/shared/task.rb +40 -0
- data/lib/fog/terremark/parsers/shared/vapp.rb +47 -0
- data/lib/fog/terremark/requests/shared/add_internet_service.rb +63 -0
- data/lib/fog/terremark/requests/shared/add_node_service.rb +63 -0
- data/lib/fog/terremark/requests/shared/create_internet_service.rb +63 -0
- data/lib/fog/terremark/requests/shared/delete_internet_service.rb +42 -0
- data/lib/fog/terremark/requests/shared/delete_node_service.rb +42 -0
- data/lib/fog/terremark/requests/shared/delete_public_ip.rb +30 -0
- data/lib/fog/terremark/requests/shared/delete_vapp.rb +42 -0
- data/lib/fog/terremark/requests/shared/deploy_vapp.rb +43 -0
- data/lib/fog/terremark/requests/shared/get_catalog.rb +40 -0
- data/lib/fog/terremark/requests/shared/get_catalog_item.rb +43 -0
- data/lib/fog/terremark/requests/shared/get_internet_services.rb +43 -0
- data/lib/fog/terremark/requests/shared/get_network.rb +37 -0
- data/lib/fog/terremark/requests/shared/get_node_services.rb +38 -0
- data/lib/fog/terremark/requests/shared/get_organization.rb +42 -0
- data/lib/fog/terremark/requests/shared/get_organizations.rb +39 -0
- data/lib/fog/terremark/requests/shared/get_public_ip.rb +41 -0
- data/lib/fog/terremark/requests/shared/get_public_ips.rb +41 -0
- data/lib/fog/terremark/requests/shared/get_task.rb +47 -0
- data/lib/fog/terremark/requests/shared/get_tasks_list.rb +40 -0
- data/lib/fog/terremark/requests/shared/get_vapp.rb +50 -0
- data/lib/fog/terremark/requests/shared/get_vapp_template.rb +43 -0
- data/lib/fog/terremark/requests/shared/get_vdc.rb +43 -0
- data/lib/fog/terremark/requests/shared/instantiate_vapp_template.rb +79 -0
- data/lib/fog/terremark/requests/shared/power_off.rb +43 -0
- data/lib/fog/terremark/requests/shared/power_on.rb +43 -0
- data/lib/fog/terremark/requests/shared/reset.rb +43 -0
- data/lib/fog/terremark/requests/shared/shutdown.rb +43 -0
- data/lib/fog/terremark/shared.rb +139 -0
- data/lib/fog/terremark/vcloud.rb +98 -0
- metadata +60 -49
- data/lib/fog/terremark/models/server.rb +0 -56
- data/lib/fog/terremark/models/servers.rb +0 -53
- data/lib/fog/terremark/models/task.rb +0 -41
- data/lib/fog/terremark/models/tasks.rb +0 -56
- data/lib/fog/terremark/parsers/get_catalog.rb +0 -44
- data/lib/fog/terremark/parsers/get_catalog_item.rb +0 -44
- data/lib/fog/terremark/parsers/get_internet_services.rb +0 -58
- data/lib/fog/terremark/parsers/get_organization.rb +0 -45
- data/lib/fog/terremark/parsers/get_organizations.rb +0 -26
- data/lib/fog/terremark/parsers/get_public_ips.rb +0 -28
- data/lib/fog/terremark/parsers/get_tasks_list.rb +0 -50
- data/lib/fog/terremark/parsers/get_vapp_template.rb +0 -44
- data/lib/fog/terremark/parsers/get_vdc.rb +0 -106
- data/lib/fog/terremark/parsers/instantiate_vapp_template.rb +0 -39
- data/lib/fog/terremark/parsers/internet_service.rb +0 -63
- data/lib/fog/terremark/parsers/node_service.rb +0 -30
- data/lib/fog/terremark/parsers/public_ip.rb +0 -24
- data/lib/fog/terremark/parsers/task.rb +0 -38
- data/lib/fog/terremark/parsers/vapp.rb +0 -45
- data/lib/fog/terremark/requests/add_internet_service.rb +0 -61
- data/lib/fog/terremark/requests/add_node_service.rb +0 -61
- data/lib/fog/terremark/requests/create_internet_service.rb +0 -61
- data/lib/fog/terremark/requests/delete_internet_service.rb +0 -40
- data/lib/fog/terremark/requests/delete_node_service.rb +0 -40
- data/lib/fog/terremark/requests/delete_public_ip.rb +0 -28
- data/lib/fog/terremark/requests/delete_vapp.rb +0 -40
- data/lib/fog/terremark/requests/deploy_vapp.rb +0 -41
- data/lib/fog/terremark/requests/get_catalog.rb +0 -38
- data/lib/fog/terremark/requests/get_catalog_item.rb +0 -41
- data/lib/fog/terremark/requests/get_internet_services.rb +0 -41
- data/lib/fog/terremark/requests/get_node_services.rb +0 -36
- data/lib/fog/terremark/requests/get_organization.rb +0 -40
- data/lib/fog/terremark/requests/get_organizations.rb +0 -37
- data/lib/fog/terremark/requests/get_public_ip.rb +0 -35
- data/lib/fog/terremark/requests/get_public_ips.rb +0 -35
- data/lib/fog/terremark/requests/get_task.rb +0 -45
- data/lib/fog/terremark/requests/get_tasks_list.rb +0 -38
- data/lib/fog/terremark/requests/get_vapp.rb +0 -48
- data/lib/fog/terremark/requests/get_vapp_template.rb +0 -41
- data/lib/fog/terremark/requests/get_vdc.rb +0 -41
- data/lib/fog/terremark/requests/instantiate_vapp_template.rb +0 -77
- data/lib/fog/terremark/requests/power_off.rb +0 -41
- data/lib/fog/terremark/requests/power_on.rb +0 -41
- data/lib/fog/terremark/requests/reset.rb +0 -41
- data/lib/fog/terremark/requests/shutdown.rb +0 -41
data/Gemfile.lock
CHANGED
data/fog.gemspec
CHANGED
@@ -7,8 +7,8 @@ Gem::Specification.new do |s|
|
|
7
7
|
## If your rubyforge_project name is different, then edit it and comment out
|
8
8
|
## the sub! line in the Rakefile
|
9
9
|
s.name = 'fog'
|
10
|
-
s.version = '0.0.
|
11
|
-
s.date = '2010-04-
|
10
|
+
s.version = '0.0.78'
|
11
|
+
s.date = '2010-04-25'
|
12
12
|
s.rubyforge_project = 'fog'
|
13
13
|
|
14
14
|
## Make sure your summary is short. The description may be as long
|
@@ -180,6 +180,7 @@ Gem::Specification.new do |s|
|
|
180
180
|
lib/fog/collection.rb
|
181
181
|
lib/fog/connection.rb
|
182
182
|
lib/fog/credentials.rb
|
183
|
+
lib/fog/deprecation.rb
|
183
184
|
lib/fog/model.rb
|
184
185
|
lib/fog/parser.rb
|
185
186
|
lib/fog/rackspace.rb
|
@@ -253,52 +254,62 @@ Gem::Specification.new do |s|
|
|
253
254
|
lib/fog/ssh.rb
|
254
255
|
lib/fog/terremark.rb
|
255
256
|
lib/fog/terremark/bin.rb
|
256
|
-
lib/fog/terremark/
|
257
|
-
lib/fog/terremark/models/
|
258
|
-
lib/fog/terremark/models/
|
259
|
-
lib/fog/terremark/models/
|
260
|
-
lib/fog/terremark/
|
261
|
-
lib/fog/terremark/
|
262
|
-
lib/fog/terremark/
|
263
|
-
lib/fog/terremark/
|
264
|
-
lib/fog/terremark/
|
265
|
-
lib/fog/terremark/
|
266
|
-
lib/fog/terremark/parsers/
|
267
|
-
lib/fog/terremark/parsers/
|
268
|
-
lib/fog/terremark/parsers/
|
269
|
-
lib/fog/terremark/parsers/
|
270
|
-
lib/fog/terremark/parsers/
|
271
|
-
lib/fog/terremark/parsers/
|
272
|
-
lib/fog/terremark/parsers/
|
273
|
-
lib/fog/terremark/parsers/
|
274
|
-
lib/fog/terremark/parsers/
|
275
|
-
lib/fog/terremark/parsers/
|
276
|
-
lib/fog/terremark/
|
277
|
-
lib/fog/terremark/
|
278
|
-
lib/fog/terremark/
|
279
|
-
lib/fog/terremark/
|
280
|
-
lib/fog/terremark/
|
281
|
-
lib/fog/terremark/
|
282
|
-
lib/fog/terremark/
|
283
|
-
lib/fog/terremark/requests/
|
284
|
-
lib/fog/terremark/requests/
|
285
|
-
lib/fog/terremark/requests/
|
286
|
-
lib/fog/terremark/requests/
|
287
|
-
lib/fog/terremark/requests/
|
288
|
-
lib/fog/terremark/requests/
|
289
|
-
lib/fog/terremark/requests/
|
290
|
-
lib/fog/terremark/requests/
|
291
|
-
lib/fog/terremark/requests/
|
292
|
-
lib/fog/terremark/requests/
|
293
|
-
lib/fog/terremark/requests/
|
294
|
-
lib/fog/terremark/requests/
|
295
|
-
lib/fog/terremark/requests/
|
296
|
-
lib/fog/terremark/requests/
|
297
|
-
lib/fog/terremark/requests/
|
298
|
-
lib/fog/terremark/requests/
|
299
|
-
lib/fog/terremark/requests/
|
300
|
-
lib/fog/terremark/requests/
|
301
|
-
lib/fog/terremark/requests/
|
257
|
+
lib/fog/terremark/ecloud.rb
|
258
|
+
lib/fog/terremark/models/shared/address.rb
|
259
|
+
lib/fog/terremark/models/shared/addresses.rb
|
260
|
+
lib/fog/terremark/models/shared/network.rb
|
261
|
+
lib/fog/terremark/models/shared/networks.rb
|
262
|
+
lib/fog/terremark/models/shared/server.rb
|
263
|
+
lib/fog/terremark/models/shared/servers.rb
|
264
|
+
lib/fog/terremark/models/shared/task.rb
|
265
|
+
lib/fog/terremark/models/shared/tasks.rb
|
266
|
+
lib/fog/terremark/parser.rb
|
267
|
+
lib/fog/terremark/parsers/shared/get_catalog.rb
|
268
|
+
lib/fog/terremark/parsers/shared/get_catalog_item.rb
|
269
|
+
lib/fog/terremark/parsers/shared/get_internet_services.rb
|
270
|
+
lib/fog/terremark/parsers/shared/get_node_services.rb
|
271
|
+
lib/fog/terremark/parsers/shared/get_organization.rb
|
272
|
+
lib/fog/terremark/parsers/shared/get_organizations.rb
|
273
|
+
lib/fog/terremark/parsers/shared/get_public_ips.rb
|
274
|
+
lib/fog/terremark/parsers/shared/get_tasks_list.rb
|
275
|
+
lib/fog/terremark/parsers/shared/get_vapp_template.rb
|
276
|
+
lib/fog/terremark/parsers/shared/get_vdc.rb
|
277
|
+
lib/fog/terremark/parsers/shared/instantiate_vapp_template.rb
|
278
|
+
lib/fog/terremark/parsers/shared/internet_service.rb
|
279
|
+
lib/fog/terremark/parsers/shared/network.rb
|
280
|
+
lib/fog/terremark/parsers/shared/node_service.rb
|
281
|
+
lib/fog/terremark/parsers/shared/public_ip.rb
|
282
|
+
lib/fog/terremark/parsers/shared/task.rb
|
283
|
+
lib/fog/terremark/parsers/shared/vapp.rb
|
284
|
+
lib/fog/terremark/requests/shared/add_internet_service.rb
|
285
|
+
lib/fog/terremark/requests/shared/add_node_service.rb
|
286
|
+
lib/fog/terremark/requests/shared/create_internet_service.rb
|
287
|
+
lib/fog/terremark/requests/shared/delete_internet_service.rb
|
288
|
+
lib/fog/terremark/requests/shared/delete_node_service.rb
|
289
|
+
lib/fog/terremark/requests/shared/delete_public_ip.rb
|
290
|
+
lib/fog/terremark/requests/shared/delete_vapp.rb
|
291
|
+
lib/fog/terremark/requests/shared/deploy_vapp.rb
|
292
|
+
lib/fog/terremark/requests/shared/get_catalog.rb
|
293
|
+
lib/fog/terremark/requests/shared/get_catalog_item.rb
|
294
|
+
lib/fog/terremark/requests/shared/get_internet_services.rb
|
295
|
+
lib/fog/terremark/requests/shared/get_network.rb
|
296
|
+
lib/fog/terremark/requests/shared/get_node_services.rb
|
297
|
+
lib/fog/terremark/requests/shared/get_organization.rb
|
298
|
+
lib/fog/terremark/requests/shared/get_organizations.rb
|
299
|
+
lib/fog/terremark/requests/shared/get_public_ip.rb
|
300
|
+
lib/fog/terremark/requests/shared/get_public_ips.rb
|
301
|
+
lib/fog/terremark/requests/shared/get_task.rb
|
302
|
+
lib/fog/terremark/requests/shared/get_tasks_list.rb
|
303
|
+
lib/fog/terremark/requests/shared/get_vapp.rb
|
304
|
+
lib/fog/terremark/requests/shared/get_vapp_template.rb
|
305
|
+
lib/fog/terremark/requests/shared/get_vdc.rb
|
306
|
+
lib/fog/terremark/requests/shared/instantiate_vapp_template.rb
|
307
|
+
lib/fog/terremark/requests/shared/power_off.rb
|
308
|
+
lib/fog/terremark/requests/shared/power_on.rb
|
309
|
+
lib/fog/terremark/requests/shared/reset.rb
|
310
|
+
lib/fog/terremark/requests/shared/shutdown.rb
|
311
|
+
lib/fog/terremark/shared.rb
|
312
|
+
lib/fog/terremark/vcloud.rb
|
302
313
|
spec/aws/models/ec2/address_spec.rb
|
303
314
|
spec/aws/models/ec2/addresses_spec.rb
|
304
315
|
spec/aws/models/ec2/flavors_spec.rb
|
data/lib/fog.rb
CHANGED
@@ -20,6 +20,7 @@ $LOAD_PATH.unshift __DIR__ unless
|
|
20
20
|
|
21
21
|
require 'fog/collection'
|
22
22
|
require 'fog/connection'
|
23
|
+
require 'fog/deprecation'
|
23
24
|
require 'fog/model'
|
24
25
|
require 'fog/parser'
|
25
26
|
require 'fog/ssh'
|
@@ -30,7 +31,7 @@ require 'fog/terremark'
|
|
30
31
|
|
31
32
|
module Fog
|
32
33
|
|
33
|
-
VERSION = '0.0.
|
34
|
+
VERSION = '0.0.78'
|
34
35
|
|
35
36
|
module Mock
|
36
37
|
@delay = 1
|
@@ -5,12 +5,14 @@ module Fog
|
|
5
5
|
module EC2
|
6
6
|
|
7
7
|
class Snapshot < Fog::Model
|
8
|
+
extend Fog::Deprecation
|
9
|
+
deprecate(:status, :state)
|
8
10
|
|
9
11
|
identity :id, 'snapshotId'
|
10
12
|
|
11
13
|
attribute :progress
|
12
14
|
attribute :created_at, 'startTime'
|
13
|
-
attribute :status
|
15
|
+
attribute :state, 'status'
|
14
16
|
attribute :volume_id, 'volumeId'
|
15
17
|
|
16
18
|
def destroy
|
@@ -5,6 +5,8 @@ module Fog
|
|
5
5
|
module EC2
|
6
6
|
|
7
7
|
class Volume < Fog::Model
|
8
|
+
extend Fog::Deprecation
|
9
|
+
deprecate(:status, :state)
|
8
10
|
|
9
11
|
identity :id, 'volumeId'
|
10
12
|
|
@@ -15,8 +17,8 @@ module Fog
|
|
15
17
|
attribute :server_id, 'instanceId'
|
16
18
|
attribute :size
|
17
19
|
attribute :snapshot_id, 'snapshotId'
|
18
|
-
attribute :status
|
19
|
-
|
20
|
+
attribute :state, 'status'
|
21
|
+
|
20
22
|
def initialize(attributes = {})
|
21
23
|
if attributes['attachmentSet']
|
22
24
|
attributes.merge!(attributes.delete('attachmentSet').first || {})
|
data/lib/fog/aws/s3.rb
CHANGED
@@ -167,7 +167,7 @@ DATA
|
|
167
167
|
|
168
168
|
subdomain = params[:host].split(".#{@host}").first
|
169
169
|
unless subdomain =~ /^(?:[a-z]|\d(?!\d{0,2}(?:\.\d{1,3}){3}$))(?:[a-z0-9]|\.(?![\.\-])|\-(?![\.])){1,61}[a-z0-9]$/
|
170
|
-
|
170
|
+
Formatador.display_line("[yellow][WARN] fog: the specified s3 bucket name(#{subdomain}) is not a valid dns name. See: http://docs.amazonwebservices.com/AmazonS3/latest/dev/index.html?Introduction.html[/]")
|
171
171
|
params[:host] = params[:host].split("#{subdomain}.")[-1]
|
172
172
|
if params[:path]
|
173
173
|
params[:path] = "#{subdomain}/#{params[:path]}"
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Fog
|
2
|
+
module Deprecation
|
3
|
+
|
4
|
+
def deprecate(older, newer)
|
5
|
+
class_eval <<-EOS, __FILE__, __LINE__
|
6
|
+
def #{older}(*args)
|
7
|
+
Formatador.display_line("[yellow][WARN] #{self} => ##{older} is deprecated, use ##{newer} instead[/]")
|
8
|
+
#{newer}(*args)
|
9
|
+
end
|
10
|
+
EOS
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
data/lib/fog/terremark.rb
CHANGED
@@ -1,224 +1,11 @@
|
|
1
|
+
require 'fog/terremark/shared'
|
2
|
+
require 'fog/terremark/parser'
|
3
|
+
require 'fog/terremark/ecloud'
|
4
|
+
require 'fog/terremark/vcloud'
|
5
|
+
|
1
6
|
module Fog
|
2
7
|
module Terremark
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
def parse(data)
|
7
|
-
case data['type']
|
8
|
-
when 'application/vnd.vmware.vcloud.vApp+xml'
|
9
|
-
servers.new(data.merge!(:connection => self))
|
10
|
-
else
|
11
|
-
data
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.new(options={})
|
18
|
-
|
19
|
-
unless @required
|
20
|
-
require 'fog/terremark/models/server'
|
21
|
-
require 'fog/terremark/models/servers'
|
22
|
-
require 'fog/terremark/models/task'
|
23
|
-
require 'fog/terremark/models/tasks'
|
24
|
-
require 'fog/terremark/parsers/get_catalog'
|
25
|
-
require 'fog/terremark/parsers/get_catalog_item'
|
26
|
-
require 'fog/terremark/parsers/get_internet_services'
|
27
|
-
require 'fog/terremark/parsers/get_node_services'
|
28
|
-
require 'fog/terremark/parsers/get_organization'
|
29
|
-
require 'fog/terremark/parsers/get_organizations'
|
30
|
-
require 'fog/terremark/parsers/get_public_ips'
|
31
|
-
require 'fog/terremark/parsers/get_tasks_list'
|
32
|
-
require 'fog/terremark/parsers/get_vapp_template'
|
33
|
-
require 'fog/terremark/parsers/get_vdc'
|
34
|
-
require 'fog/terremark/parsers/instantiate_vapp_template'
|
35
|
-
require 'fog/terremark/parsers/internet_service'
|
36
|
-
require 'fog/terremark/parsers/node_service'
|
37
|
-
require 'fog/terremark/parsers/public_ip'
|
38
|
-
require 'fog/terremark/parsers/task'
|
39
|
-
require 'fog/terremark/parsers/vapp'
|
40
|
-
require 'fog/terremark/requests/add_internet_service'
|
41
|
-
require 'fog/terremark/requests/add_node_service'
|
42
|
-
require 'fog/terremark/requests/create_internet_service'
|
43
|
-
require 'fog/terremark/requests/delete_internet_service'
|
44
|
-
require 'fog/terremark/requests/delete_node_service'
|
45
|
-
require 'fog/terremark/requests/delete_public_ip'
|
46
|
-
require 'fog/terremark/requests/delete_vapp'
|
47
|
-
require 'fog/terremark/requests/deploy_vapp'
|
48
|
-
require 'fog/terremark/requests/get_catalog'
|
49
|
-
require 'fog/terremark/requests/get_catalog_item'
|
50
|
-
require 'fog/terremark/requests/get_internet_services'
|
51
|
-
require 'fog/terremark/requests/get_node_services'
|
52
|
-
require 'fog/terremark/requests/get_organization'
|
53
|
-
require 'fog/terremark/requests/get_organizations'
|
54
|
-
require 'fog/terremark/requests/get_public_ip'
|
55
|
-
require 'fog/terremark/requests/get_public_ips'
|
56
|
-
require 'fog/terremark/requests/get_task'
|
57
|
-
require 'fog/terremark/requests/get_tasks_list'
|
58
|
-
require 'fog/terremark/requests/get_vapp'
|
59
|
-
require 'fog/terremark/requests/get_vapp_template'
|
60
|
-
require 'fog/terremark/requests/get_vdc'
|
61
|
-
require 'fog/terremark/requests/instantiate_vapp_template'
|
62
|
-
require 'fog/terremark/requests/reset'
|
63
|
-
require 'fog/terremark/requests/power_off'
|
64
|
-
require 'fog/terremark/requests/power_on'
|
65
|
-
require 'fog/terremark/requests/shutdown'
|
66
|
-
@required = true
|
67
|
-
end
|
68
|
-
|
69
|
-
unless options[:terremark_password]
|
70
|
-
raise ArgumentError.new('terremark_password is required to access terremark')
|
71
|
-
end
|
72
|
-
unless options[:terremark_username]
|
73
|
-
raise ArgumentError.new('terremark_username is required to access terremark')
|
74
|
-
end
|
75
|
-
if Fog.mocking?
|
76
|
-
Fog::Terremark::Mock.new(options)
|
77
|
-
else
|
78
|
-
Fog::Terremark::Real.new(options)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
class Mock
|
83
|
-
include Fog::Terremark::Parser
|
84
|
-
|
85
|
-
def self.data
|
86
|
-
@data ||= Hash.new do |hash, key|
|
87
|
-
hash[key] = {}
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
def self.reset_data(keys=data.keys)
|
92
|
-
for key in [*keys]
|
93
|
-
data.delete(key)
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
def initialize(options={})
|
98
|
-
@terremark_username = options[:terremark_username]
|
99
|
-
@data = self.class.data[@terremark_username]
|
100
|
-
end
|
101
|
-
|
102
|
-
end
|
103
|
-
|
104
|
-
class Real
|
105
|
-
include Fog::Terremark::Parser
|
106
|
-
|
107
|
-
def initialize(options={})
|
108
|
-
@terremark_password = options[:terremark_password]
|
109
|
-
@terremark_username = options[:terremark_username]
|
110
|
-
@terremark_service = options[:terremark_service] || :vcloud
|
111
|
-
case options[:terremark_service]
|
112
|
-
when :ecloud
|
113
|
-
@host = options[:host] || "services.enterprisecloud.terremark.com"
|
114
|
-
@path = options[:path] || "/api/v0.8a-ext2.0"
|
115
|
-
when :vcloud
|
116
|
-
@host = options[:host] || "services.vcloudexpress.terremark.com"
|
117
|
-
@path = options[:path] || "/api/v0.8"
|
118
|
-
else
|
119
|
-
raise "Unsupported Terremark Service"
|
120
|
-
end
|
121
|
-
@port = options[:port] || 443
|
122
|
-
@scheme = options[:scheme] || 'https'
|
123
|
-
@cookie = get_organizations.headers['Set-Cookie']
|
124
|
-
end
|
125
|
-
|
126
|
-
# TODO: bust cache on organization creation?
|
127
|
-
def default_organization_id
|
128
|
-
@default_organization_id ||= begin
|
129
|
-
org_list = get_organizations.body['OrgList']
|
130
|
-
if org_list.length == 1
|
131
|
-
org_list.first['href'].split('/').last.to_i
|
132
|
-
else
|
133
|
-
nil
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
def default_vdc_id
|
139
|
-
if default_organization_id
|
140
|
-
@default_vdc_id ||= begin
|
141
|
-
vdcs = get_organization(default_organization_id).body['Links'].select {|link|
|
142
|
-
link['type'] == 'application/vnd.vmware.vcloud.vdc+xml'
|
143
|
-
}
|
144
|
-
if vdcs.length == 1
|
145
|
-
vdcs.first['href'].split('/').last.to_i
|
146
|
-
else
|
147
|
-
nil
|
148
|
-
end
|
149
|
-
end
|
150
|
-
else
|
151
|
-
nil
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
def default_network_id
|
156
|
-
if default_vdc_id
|
157
|
-
@default_network_id ||= begin
|
158
|
-
networks = get_vdc(default_vdc_id).body['AvailableNetworks']
|
159
|
-
if networks.length == 1
|
160
|
-
networks.first['href'].split('/').last.to_i
|
161
|
-
else
|
162
|
-
nil
|
163
|
-
end
|
164
|
-
end
|
165
|
-
else
|
166
|
-
nil
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
def default_public_ip_id
|
171
|
-
if default_vdc_id
|
172
|
-
@default_public_ip_id ||= begin
|
173
|
-
ips = get_public_ips(default_vdc_id).body['PublicIpAddresses']
|
174
|
-
if ips.length == 1
|
175
|
-
ips.first['Href'].split('/').last.to_i
|
176
|
-
else
|
177
|
-
nil
|
178
|
-
end
|
179
|
-
end
|
180
|
-
else
|
181
|
-
nil
|
182
|
-
end
|
183
|
-
end
|
184
|
-
|
185
|
-
def default_tasks_list_id
|
186
|
-
if default_organization_id
|
187
|
-
@default_tasks_list_id ||= begin
|
188
|
-
task_lists = get_organization(default_organization_id).body['Links'].select {|link|
|
189
|
-
link['type'] == 'application/vnd.vmware.vcloud.tasksList+xml'
|
190
|
-
}
|
191
|
-
if task_lists.length == 1
|
192
|
-
task_lists.first['href'].split('/').last.to_i
|
193
|
-
else
|
194
|
-
nil
|
195
|
-
end
|
196
|
-
end
|
197
|
-
else
|
198
|
-
nil
|
199
|
-
end
|
200
|
-
end
|
201
|
-
|
202
|
-
private
|
203
|
-
|
204
|
-
def request(params)
|
205
|
-
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}")
|
206
|
-
headers = {}
|
207
|
-
if @cookie
|
208
|
-
headers.merge!('Cookie' => @cookie)
|
209
|
-
end
|
210
|
-
response = @connection.request({
|
211
|
-
:body => params[:body],
|
212
|
-
:expects => params[:expects],
|
213
|
-
:headers => headers.merge!(params[:headers] || {}),
|
214
|
-
:host => @host,
|
215
|
-
:method => params[:method],
|
216
|
-
:parser => params[:parser],
|
217
|
-
:path => "#{@path}/#{params[:path]}"
|
218
|
-
})
|
219
|
-
end
|
220
|
-
|
221
|
-
end
|
222
|
-
|
8
|
+
ECLOUD_OPTIONS = [:terremark_ecloud_username, :terremark_ecloud_password]
|
9
|
+
VCLOUD_OPTIONS = [:terremark_vcloud_username, :terremark_vcloud_password]
|
223
10
|
end
|
224
11
|
end
|