fog 0.0.91 → 0.0.92

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. data/Gemfile +1 -1
  2. data/Gemfile.lock +39 -39
  3. data/fog.gemspec +17 -16
  4. data/lib/fog.rb +1 -1
  5. data/lib/fog/aws/elb.rb +4 -0
  6. data/lib/fog/aws/models/ec2/snapshot.rb +3 -0
  7. data/lib/fog/aws/parsers/ec2/create_snapshot.rb +5 -1
  8. data/lib/fog/aws/parsers/ec2/describe_snapshots.rb +5 -1
  9. data/lib/fog/aws/parsers/elb/create_load_balancer.rb +26 -0
  10. data/lib/fog/aws/parsers/elb/delete_load_balancer.rb +24 -0
  11. data/lib/fog/aws/parsers/s3/access_control_list.rb +46 -0
  12. data/lib/fog/aws/requests/ec2/create_snapshot.rb +11 -7
  13. data/lib/fog/aws/requests/ec2/describe_snapshots.rb +3 -0
  14. data/lib/fog/aws/requests/ec2/revoke_security_group_ingress.rb +0 -1
  15. data/lib/fog/aws/requests/ec2/run_instances.rb +0 -2
  16. data/lib/fog/aws/requests/ec2/terminate_instances.rb +0 -1
  17. data/lib/fog/aws/requests/elb/create_load_balancer.rb +57 -0
  18. data/lib/fog/aws/requests/elb/delete_load_balancer.rb +40 -0
  19. data/lib/fog/aws/requests/s3/copy_object.rb +0 -1
  20. data/lib/fog/aws/requests/s3/get_bucket.rb +2 -3
  21. data/lib/fog/aws/requests/s3/get_bucket_acl.rb +53 -0
  22. data/lib/fog/aws/requests/s3/get_object.rb +1 -31
  23. data/lib/fog/aws/requests/s3/get_object_acl.rb +58 -0
  24. data/lib/fog/aws/requests/s3/get_object_torrent.rb +55 -0
  25. data/lib/fog/aws/requests/s3/get_object_url.rb +54 -0
  26. data/lib/fog/aws/requests/s3/put_bucket_acl.rb +80 -0
  27. data/lib/fog/aws/s3.rb +8 -2
  28. data/lib/fog/collection.rb +1 -1
  29. data/lib/fog/connection.rb +7 -5
  30. data/lib/fog/model.rb +5 -2
  31. data/lib/fog/rackspace/files.rb +2 -2
  32. data/lib/fog/rackspace/requests/files/get_object.rb +1 -1
  33. data/lib/fog/terremark/parsers/shared/get_internet_services.rb +2 -2
  34. data/lib/fog/terremark/parsers/shared/get_node_services.rb +3 -0
  35. data/lib/fog/terremark/parsers/shared/vapp.rb +33 -3
  36. data/lib/fog/terremark/requests/shared/delete_internet_service.rb +0 -12
  37. data/lib/fog/terremark/requests/shared/delete_node_service.rb +0 -12
  38. data/lib/fog/terremark/requests/shared/delete_vapp.rb +0 -12
  39. data/lib/fog/terremark/shared.rb +0 -1
  40. data/spec/aws/models/s3/file_spec.rb +2 -2
  41. data/spec/aws/models/s3/files_spec.rb +2 -2
  42. data/spec/aws/requests/ec2/get_console_output_spec.rb +4 -4
  43. data/spec/aws/requests/s3/get_bucket_spec.rb +9 -9
  44. data/tests/aws/helper.rb +105 -0
  45. data/tests/aws/requests/ec2/address_tests.rb +88 -0
  46. data/tests/aws/requests/ec2/snapshot_tests.rb +50 -0
  47. data/tests/aws/requests/ec2/volume_tests.rb +84 -0
  48. data/tests/helper.rb +21 -6
  49. data/tests/helper_tests.rb +38 -7
  50. data/tests/rackspace/requests/servers/create_image_tests.rb +1 -1
  51. data/tests/rackspace/requests/servers/create_server_tests.rb +1 -1
  52. data/tests/rackspace/requests/servers/delete_image_tests.rb +1 -4
  53. data/tests/rackspace/requests/servers/delete_server_tests.rb +1 -4
  54. data/tests/rackspace/requests/servers/get_flavor_details_tests.rb +2 -5
  55. data/tests/rackspace/requests/servers/get_image_details_tests.rb +2 -5
  56. data/tests/rackspace/requests/servers/get_server_details_tests.rb +2 -5
  57. data/tests/rackspace/requests/servers/list_addresses_tests.rb +2 -5
  58. data/tests/rackspace/requests/servers/list_flavors_detail_tests.rb +1 -1
  59. data/tests/rackspace/requests/servers/list_flavors_tests.rb +1 -1
  60. data/tests/rackspace/requests/servers/list_images_detail_tests.rb +1 -1
  61. data/tests/rackspace/requests/servers/list_images_tests.rb +1 -1
  62. data/tests/rackspace/requests/servers/list_private_addresses_tests.rb +2 -5
  63. data/tests/rackspace/requests/servers/list_public_addresses_tests.rb +2 -5
  64. data/tests/rackspace/requests/servers/list_servers_detail_tests.rb +1 -1
  65. data/tests/rackspace/requests/servers/list_servers_tests.rb +1 -1
  66. data/tests/rackspace/requests/servers/reboot_server_tests.rb +1 -4
  67. data/tests/rackspace/requests/servers/update_server_tests.rb +2 -5
  68. data/tests/slicehost/requests/create_slice_tests.rb +1 -1
  69. data/tests/slicehost/requests/delete_slice_tests.rb +1 -4
  70. data/tests/slicehost/requests/get_backups_tests.rb +1 -2
  71. data/tests/slicehost/requests/get_flavor_tests.rb +2 -5
  72. data/tests/slicehost/requests/get_flavors_tests.rb +1 -1
  73. data/tests/slicehost/requests/get_image_tests.rb +2 -5
  74. data/tests/slicehost/requests/get_images_tests.rb +1 -1
  75. data/tests/slicehost/requests/get_slice_tests.rb +2 -5
  76. data/tests/slicehost/requests/get_slices_tests.rb +1 -1
  77. data/tests/slicehost/requests/reboot_slice_tests.rb +2 -5
  78. metadata +19 -18
  79. data/spec/aws/requests/ec2/allocate_address_spec.rb +0 -18
  80. data/spec/aws/requests/ec2/associate_address_spec.rb +0 -43
  81. data/spec/aws/requests/ec2/attach_volume_spec.rb +0 -51
  82. data/spec/aws/requests/ec2/create_snapshot_spec.rb +0 -36
  83. data/spec/aws/requests/ec2/create_volume_spec.rb +0 -23
  84. data/spec/aws/requests/ec2/delete_snapshot_spec.rb +0 -34
  85. data/spec/aws/requests/ec2/delete_volume_spec.rb +0 -26
  86. data/spec/aws/requests/ec2/describe_addresses_spec.rb +0 -38
  87. data/spec/aws/requests/ec2/describe_snapshots_spec.rb +0 -50
  88. data/spec/aws/requests/ec2/describe_volumes_spec.rb +0 -50
  89. data/spec/aws/requests/ec2/detach_volume_spec.rb +0 -41
  90. data/spec/aws/requests/ec2/disassociate_address_spec.rb +0 -36
  91. data/spec/aws/requests/ec2/release_address_spec.rb +0 -26
data/lib/fog/aws/s3.rb CHANGED
@@ -9,6 +9,7 @@ module Fog
9
9
  require 'fog/aws/models/s3/directory'
10
10
  require 'fog/aws/models/s3/files'
11
11
  require 'fog/aws/models/s3/file'
12
+ require 'fog/aws/parsers/s3/access_control_list'
12
13
  require 'fog/aws/parsers/s3/copy_object'
13
14
  require 'fog/aws/parsers/s3/get_bucket'
14
15
  require 'fog/aws/parsers/s3/get_bucket_location'
@@ -18,12 +19,17 @@ module Fog
18
19
  require 'fog/aws/requests/s3/delete_bucket'
19
20
  require 'fog/aws/requests/s3/delete_object'
20
21
  require 'fog/aws/requests/s3/get_bucket'
22
+ require 'fog/aws/requests/s3/get_bucket_acl'
21
23
  require 'fog/aws/requests/s3/get_bucket_location'
22
24
  require 'fog/aws/requests/s3/get_object'
25
+ require 'fog/aws/requests/s3/get_object_acl'
26
+ require 'fog/aws/requests/s3/get_object_torrent'
27
+ require 'fog/aws/requests/s3/get_object_url'
23
28
  require 'fog/aws/requests/s3/get_request_payment'
24
29
  require 'fog/aws/requests/s3/get_service'
25
30
  require 'fog/aws/requests/s3/head_object'
26
31
  require 'fog/aws/requests/s3/put_bucket'
32
+ require 'fog/aws/requests/s3/put_bucket_acl'
27
33
  require 'fog/aws/requests/s3/put_object'
28
34
  require 'fog/aws/requests/s3/put_request_payment'
29
35
  @required = true
@@ -141,12 +147,12 @@ module Fog
141
147
 
142
148
  private
143
149
 
144
- def request(params)
150
+ def request(params, &block)
145
151
  @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}")
146
152
  params[:headers]['Date'] = Time.now.utc.strftime("%a, %d %b %Y %H:%M:%S +0000")
147
153
  params[:headers]['Authorization'] = "AWS #{@aws_access_key_id}:#{signature(params)}"
148
154
 
149
- response = @connection.request(params)
155
+ response = @connection.request(params, &block)
150
156
 
151
157
  response
152
158
  end
@@ -130,7 +130,7 @@ module Fog
130
130
 
131
131
  def new(attributes = {})
132
132
  model.new(
133
- attributes.merge!(
133
+ attributes.merge(
134
134
  :collection => self,
135
135
  :connection => connection
136
136
  )
@@ -5,13 +5,15 @@ module Fog
5
5
  @excon = Excon.new(url)
6
6
  end
7
7
 
8
- def request(params)
9
- if parser = params.delete(:parser)
10
- body = Nokogiri::XML::SAX::PushParser.new(parser)
11
- params[:block] = lambda { |chunk| body << chunk }
8
+ def request(params, &block)
9
+ unless block_given?
10
+ if (parser = params.delete(:parser))
11
+ body = Nokogiri::XML::SAX::PushParser.new(parser)
12
+ block = lambda { |chunk| body << chunk }
13
+ end
12
14
  end
13
15
 
14
- response = @excon.request(params)
16
+ response = @excon.request(params, &block)
15
17
 
16
18
  if parser
17
19
  body.finish
data/lib/fog/model.rb CHANGED
@@ -91,8 +91,8 @@ module Fog
91
91
  if data = collection.get(identity)
92
92
  new_attributes = data.attributes
93
93
  merge_attributes(new_attributes)
94
+ self
94
95
  end
95
- self
96
96
  end
97
97
 
98
98
  def requires(*args)
@@ -115,7 +115,10 @@ module Fog
115
115
 
116
116
  def wait_for(timeout = 600, &block)
117
117
  reload
118
- Fog.wait_for(timeout) { reload && instance_eval(&block) }
118
+ Fog.wait_for(timeout) do
119
+ reload or raise StandardError.new("Reload failed, #{self.class} #{self.identity} went away.")
120
+ instance_eval(&block)
121
+ end
119
122
  end
120
123
 
121
124
  private
@@ -112,7 +112,7 @@ module Fog
112
112
  response
113
113
  end
114
114
 
115
- def storage_request(params, parse_json = true)
115
+ def storage_request(params, parse_json = true, &block)
116
116
  @storage_connection = Fog::Connection.new("#{@storage_scheme}://#{@storage_host}:#{@storage_port}")
117
117
  response = @storage_connection.request({
118
118
  :body => params[:body],
@@ -125,7 +125,7 @@ module Fog
125
125
  :method => params[:method],
126
126
  :path => "#{@storage_path}/#{params[:path]}",
127
127
  :query => params[:query]
128
- })
128
+ }, &block)
129
129
  if !response.body.empty? && parse_json
130
130
  response.body = JSON.parse(response.body)
131
131
  end
@@ -15,7 +15,7 @@ module Fog
15
15
  :expects => 200,
16
16
  :method => 'GET',
17
17
  :path => "#{CGI.escape(container)}/#{CGI.escape(object)}"
18
- }, false)
18
+ }, false, &block)
19
19
  response
20
20
  end
21
21
 
@@ -14,7 +14,7 @@ module Fog
14
14
  def start_element(name, attributes)
15
15
  super
16
16
  case name
17
- when 'PublicIPAddress'
17
+ when 'PublicIpAddress'
18
18
  @in_public_ip_address = true
19
19
  end
20
20
  end
@@ -48,7 +48,7 @@ module Fog
48
48
  @internet_service = {}
49
49
  when 'Port', 'Timeout'
50
50
  @internet_service[name] = @value.to_i
51
- when 'PublicIPAddress'
51
+ when 'PublicIpAddress'
52
52
  @in_public_ip_address = false
53
53
  end
54
54
  end
@@ -22,6 +22,9 @@ module Fog
22
22
  end
23
23
  when 'Id', 'Port'
24
24
  @node_service[name] = @value.to_i
25
+ when 'NodeService'
26
+ @response['NodeServices'] << @node_service
27
+ @node_service = {}
25
28
  end
26
29
  end
27
30
 
@@ -6,7 +6,9 @@ module Fog
6
6
  class Vapp < Fog::Parsers::Base
7
7
 
8
8
  def reset
9
- @response = { 'Links' => [] }
9
+ @response = { 'Links' => [], 'VirtualHardware' => {}, 'OperatingSystem' => {} }
10
+ @in_operating_system = false
11
+ @resource_type = nil
10
12
  end
11
13
 
12
14
  def start_element(name, attributes)
@@ -18,7 +20,9 @@ module Fog
18
20
  link[attributes.shift] = attributes.shift
19
21
  end
20
22
  @response['Links'] << link
21
- when 'VApp'
23
+ when 'OperatingSystemSection'
24
+ @in_operating_system = true
25
+ when 'VApp'
22
26
  vapp = {}
23
27
  until attributes.empty?
24
28
  if attributes.first.is_a?(Array)
@@ -29,13 +33,38 @@ module Fog
29
33
  end
30
34
  end
31
35
  @response.merge!(vapp.reject {|key,value| !['href', 'name', 'size', 'status', 'type'].include?(key)})
32
- end
36
+ end
33
37
  end
34
38
 
35
39
  def end_element(name)
36
40
  case name
37
41
  when 'IpAddress'
38
42
  @response['IpAddress'] = @value
43
+ when 'Description'
44
+ if @in_operating_system
45
+ @response['OperatingSystem'][name] = @value
46
+ @in_operating_system = false
47
+ end
48
+ when 'ResourceType'
49
+ @resource_type = @value
50
+ case @value
51
+ when '3'
52
+ @get_cpu = true # cpu
53
+ when '4' # memory
54
+ @get_ram = true
55
+ when '17' # disks
56
+ @get_disks = true
57
+ end
58
+ when 'VirtualQuantity'
59
+ case @resource_type
60
+ when '3'
61
+ @response['VirtualHardware']['cpu'] = @value
62
+ when '4'
63
+ @response['VirtualHardware']['ram'] = @value
64
+ when '17'
65
+ @response['VirtualHardware']['disks'] ||= []
66
+ @response['VirtualHardware']['disks'] << @value
67
+ end
39
68
  end
40
69
  end
41
70
 
@@ -45,3 +74,4 @@ module Fog
45
74
  end
46
75
  end
47
76
  end
77
+
@@ -8,18 +8,6 @@ module Fog
8
8
  # ==== Parameters
9
9
  # * internet_service_id<~Integer> - Id of service to destroy
10
10
  #
11
- # ==== Returns
12
- # * response<~Excon::Response>:
13
- # * body<~Hash>:
14
-
15
- # FIXME
16
-
17
- # * 'CatalogItems'<~Array>
18
- # * 'href'<~String> - linke to item
19
- # * 'name'<~String> - name of item
20
- # * 'type'<~String> - type of item
21
- # * 'description'<~String> - Description of catalog
22
- # * 'name'<~String> - Name of catalog
23
11
  def delete_internet_service(internet_service_id)
24
12
  request(
25
13
  :expects => 200,
@@ -8,18 +8,6 @@ module Fog
8
8
  # ==== Parameters
9
9
  # * node_service_id<~Integer> - Id of node to destroy
10
10
  #
11
- # ==== Returns
12
- # * response<~Excon::Response>:
13
- # * body<~Hash>:
14
-
15
- # FIXME
16
-
17
- # * 'CatalogItems'<~Array>
18
- # * 'href'<~String> - linke to item
19
- # * 'name'<~String> - name of item
20
- # * 'type'<~String> - type of item
21
- # * 'description'<~String> - Description of catalog
22
- # * 'name'<~String> - Name of catalog
23
11
  def delete_node_service(node_service_id)
24
12
  request(
25
13
  :expects => 200,
@@ -8,18 +8,6 @@ module Fog
8
8
  # ==== Parameters
9
9
  # * vapp_id<~Integer> - Id of vapp to destroy
10
10
  #
11
- # ==== Returns
12
- # * response<~Excon::Response>:
13
- # * body<~Hash>:
14
-
15
- # FIXME
16
-
17
- # * 'CatalogItems'<~Array>
18
- # * 'href'<~String> - linke to item
19
- # * 'name'<~String> - name of item
20
- # * 'type'<~String> - type of item
21
- # * 'description'<~String> - Description of catalog
22
- # * 'name'<~String> - Name of catalog
23
11
  def delete_vapp(vapp_id)
24
12
  request(
25
13
  :expects => 202,
@@ -5,7 +5,6 @@ module Fog
5
5
  # Commond methods shared by Real and Mock
6
6
  module Common
7
7
 
8
- # TODO: bust cache on organization creation?
9
8
  def default_organization_id
10
9
  @default_organization_id ||= begin
11
10
  org_list = get_organizations.body['OrgList']
@@ -3,7 +3,7 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
3
3
  describe 'Fog::AWS::S3::File' do
4
4
 
5
5
  before(:each) do
6
- @directory = AWS[:s3].directories.create(:name => 'fogdirectoryname')
6
+ @directory = AWS[:s3].directories.create(:key => 'fogdirectoryname')
7
7
  end
8
8
 
9
9
  after(:each) do
@@ -53,7 +53,7 @@ describe 'Fog::AWS::S3::File' do
53
53
  describe "#copy" do
54
54
 
55
55
  it "should return a Fog::AWS::S3::File with matching attributes" do
56
- other_directory = AWS[:s3].directories.create(:name => 'fogotherdirectoryname')
56
+ other_directory = AWS[:s3].directories.create(:key => 'fogotherdirectoryname')
57
57
  data = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
58
58
  file = @directory.files.create(:key => 'fogfilename', :body => data)
59
59
  other_file = file.copy('fogotherdirectoryname', 'fogotherfilename')
@@ -3,7 +3,7 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
3
3
  describe 'Fog::AWS::S3::Files' do
4
4
 
5
5
  before(:each) do
6
- @directory = AWS[:s3].directories.create(:name => 'fogdirectoryname')
6
+ @directory = AWS[:s3].directories.create(:key => 'fogdirectoryname')
7
7
  end
8
8
 
9
9
  after(:each) do
@@ -30,7 +30,7 @@ describe 'Fog::AWS::S3::Files' do
30
30
  describe "#all" do
31
31
 
32
32
  it "should return nil if the directory does not exist" do
33
- directory = AWS[:s3].directories.new(:name => 'notadirectory')
33
+ directory = AWS[:s3].directories.new(:key => 'notadirectory')
34
34
  directory.files.all.should be_nil
35
35
  end
36
36
 
@@ -4,16 +4,16 @@ describe 'EC2.get_console_output' do
4
4
  describe 'success' do
5
5
 
6
6
  before(:each) do
7
- @instance_id = AWS[:ec2].run_instances(GENTOO_AMI, 1, 1).body['instancesSet'].first['instanceId']
8
- AWS[:ec2].servers.get(@instance_id).wait_for { ready? }
7
+ @instance = AWS[:ec2].servers.create(:image_id => GENTOO_AMI)
8
+ @instance.wait_for { ready? }
9
9
  end
10
10
 
11
11
  after(:each) do
12
- AWS[:ec2].terminate_instances([@instance_id])
12
+ @instance.destroy
13
13
  end
14
14
 
15
15
  it "should return proper attributes" do
16
- actual = AWS[:ec2].get_console_output(@instance_id).body
16
+ actual = AWS[:ec2].get_console_output(@instance.id).body
17
17
  actual['instanceId'].should be_a(String)
18
18
  if actual['output']
19
19
  actual['output'].should be_a(String)
@@ -3,13 +3,13 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
3
3
  describe 'S3.get_bucket' do
4
4
  describe 'success' do
5
5
 
6
- before(:each) do
6
+ before(:all) do
7
7
  AWS[:s3].put_bucket('foggetbucket')
8
8
  AWS[:s3].put_object('foggetbucket', 'fog_object', lorem_file)
9
9
  AWS[:s3].put_object('foggetbucket', 'fog_other_object', lorem_file)
10
10
  end
11
11
 
12
- after(:each) do
12
+ after(:all) do
13
13
  AWS[:s3].delete_object('foggetbucket', 'fog_object')
14
14
  AWS[:s3].delete_object('foggetbucket', 'fog_other_object')
15
15
  AWS[:s3].delete_bucket('foggetbucket')
@@ -18,10 +18,10 @@ describe 'S3.get_bucket' do
18
18
  it 'should return proper attributes' do
19
19
  actual = AWS[:s3].get_bucket('foggetbucket')
20
20
  actual.body['IsTruncated'].should == false
21
- actual.body['Marker'].should be_a(String)
21
+ actual.body['Marker'].should be_nil
22
22
  actual.body['MaxKeys'].should be_an(Integer)
23
23
  actual.body['Name'].should be_a(String)
24
- actual.body['Prefix'].should be_a(String)
24
+ actual.body['Prefix'].should be_nil
25
25
  actual.body['Contents'].should be_an(Array)
26
26
  actual.body['Contents'].length.should == 2
27
27
  object = actual.body['Contents'].first
@@ -41,7 +41,7 @@ describe 'S3.get_bucket' do
41
41
  actual.body['Marker'].should be_a(String)
42
42
  actual.body['MaxKeys'].should be_an(Integer)
43
43
  actual.body['Name'].should be_a(String)
44
- actual.body['Prefix'].should be_a(String)
44
+ actual.body['Prefix'].should be_nil
45
45
  actual.body['Contents'].should be_an(Array)
46
46
  actual.body['Contents'].length.should == 1
47
47
  object = actual.body['Contents'].first
@@ -55,13 +55,13 @@ describe 'S3.get_bucket' do
55
55
  object['StorageClass'].should be_a(String)
56
56
  end
57
57
 
58
- it 'should respect max-keys option' do
58
+ it 'should accept max-keys option' do
59
59
  actual = AWS[:s3].get_bucket('foggetbucket', 'max-keys' => 1)
60
60
  actual.body['IsTruncated'].should == true
61
- actual.body['Marker'].should be_a(String)
61
+ actual.body['Marker'].should be_nil
62
62
  actual.body['MaxKeys'].should be_an(Integer)
63
63
  actual.body['Name'].should be_a(String)
64
- actual.body['Prefix'].should be_a(String)
64
+ actual.body['Prefix'].should be_nil
65
65
  actual.body['Contents'].should be_an(Array)
66
66
  actual.body['Contents'].length.should == 1
67
67
  object = actual.body['Contents'].first
@@ -78,7 +78,7 @@ describe 'S3.get_bucket' do
78
78
  it 'should accept prefix option' do
79
79
  actual = AWS[:s3].get_bucket('foggetbucket', 'prefix' => 'fog_ob')
80
80
  actual.body['IsTruncated'].should == false
81
- actual.body['Marker'].should be_a(String)
81
+ actual.body['Marker'].should be_nil
82
82
  actual.body['MaxKeys'].should be_an(Integer)
83
83
  actual.body['Name'].should be_a(String)
84
84
  actual.body['Prefix'].should be_a(String)
@@ -0,0 +1,105 @@
1
+ # Boolean hax
2
+ module Fog
3
+ module Boolean
4
+ end
5
+ end
6
+ FalseClass.send(:include, Fog::Boolean)
7
+ TrueClass.send(:include, Fog::Boolean)
8
+
9
+ module AWS
10
+
11
+ class << self
12
+ def [](service)
13
+ @@connections ||= Hash.new do |hash, key|
14
+ credentials = Fog.credentials.reject do |k, v|
15
+ ![:aws_access_key_id, :aws_secret_access_key].include?(k)
16
+ end
17
+ hash[key] = case key
18
+ when :ec2
19
+ Fog::AWS::EC2.new(credentials)
20
+ when :eu_s3
21
+ Fog::AWS::S3.new(credentials.merge!(:host => 's3-external-3.amazonaws.com'))
22
+ when :sdb
23
+ Fog::AWS::SimpleDB.new(credentials)
24
+ when :s3
25
+ Fog::AWS::S3.new(credentials)
26
+ end
27
+ end
28
+ @@connections[service]
29
+ end
30
+ end
31
+
32
+ module EC2
33
+
34
+ module Formats
35
+
36
+ ADDRESSES = {
37
+ 'addressesSet' => [{
38
+ 'instanceId' => NilClass,
39
+ 'publicIp' => String
40
+ }],
41
+ 'requestId' => String
42
+ }
43
+
44
+ BASIC = {
45
+ 'requestId' => String,
46
+ 'return' => ::Fog::Boolean
47
+ }
48
+
49
+ SNAPSHOT = {
50
+ 'description' => NilClass,
51
+ 'ownerId' => String,
52
+ 'progress' => String,
53
+ 'snapshotId' => String,
54
+ 'startTime' => Time,
55
+ 'status' => String,
56
+ 'volumeId' => String,
57
+ 'volumeSize' => Integer
58
+ }
59
+
60
+ SNAPSHOTS = {
61
+ 'requestId' => String,
62
+ 'snapshotSet' => [SNAPSHOT]
63
+ }
64
+
65
+ VOLUME = {
66
+ 'availabilityZone' => String,
67
+ 'createTime' => Time,
68
+ 'requestId' => String,
69
+ 'size' => Integer,
70
+ 'snapshotId' => NilClass,
71
+ 'status' => String,
72
+ 'volumeId' => String
73
+ }
74
+
75
+ VOLUME_ATTACHMENT = {
76
+ 'attachTime' => Time,
77
+ 'device' => String,
78
+ 'instanceId' => String,
79
+ 'requestId' => String,
80
+ 'status' => String,
81
+ 'volumeId' => String
82
+ }
83
+
84
+ VOLUMES = {
85
+ 'volumeSet' => [{
86
+ 'availabilityZone' => String,
87
+ 'attachmentSet' => [],
88
+ 'createTime' => Time,
89
+ 'size' => Integer,
90
+ 'snapshotId' => NilClass,
91
+ 'status' => String,
92
+ 'volumeId' => String
93
+ }],
94
+ 'requestId' => String
95
+ }
96
+
97
+ end
98
+
99
+ end
100
+
101
+ end
102
+
103
+ unless defined?(GENTOO_AMI)
104
+ GENTOO_AMI = 'ami-5ee70037'
105
+ end