fog 0.0.29 → 0.0.30

Sign up to get free protection for your applications and to get access to all the features.
Files changed (181) hide show
  1. data/Rakefile +1 -0
  2. data/VERSION +1 -1
  3. data/bin/fog +18 -11
  4. data/fog.gemspec +43 -14
  5. data/lib/fog.rb +7 -1
  6. data/lib/fog/aws/ec2.rb +0 -7
  7. data/lib/fog/aws/models/ec2/address.rb +22 -26
  8. data/lib/fog/aws/models/ec2/addresses.rb +7 -22
  9. data/lib/fog/aws/models/ec2/instance.rb +2 -15
  10. data/lib/fog/aws/models/ec2/instances.rb +6 -23
  11. data/lib/fog/aws/models/ec2/key_pair.rb +2 -17
  12. data/lib/fog/aws/models/ec2/key_pairs.rb +6 -23
  13. data/lib/fog/aws/models/ec2/security_group.rb +18 -22
  14. data/lib/fog/aws/models/ec2/security_groups.rb +6 -23
  15. data/lib/fog/aws/models/ec2/snapshot.rb +2 -15
  16. data/lib/fog/aws/models/ec2/snapshots.rb +7 -20
  17. data/lib/fog/aws/models/ec2/volume.rb +23 -22
  18. data/lib/fog/aws/models/ec2/volumes.rb +8 -22
  19. data/lib/fog/aws/models/s3/bucket.rb +1 -1
  20. data/lib/fog/aws/models/s3/buckets.rb +3 -20
  21. data/lib/fog/aws/models/s3/objects.rb +11 -22
  22. data/lib/fog/aws/requests/ec2/allocate_address.rb +1 -1
  23. data/lib/fog/aws/requests/ec2/associate_address.rb +2 -2
  24. data/lib/fog/aws/requests/ec2/attach_volume.rb +2 -2
  25. data/lib/fog/aws/requests/ec2/authorize_security_group_ingress.rb +1 -1
  26. data/lib/fog/aws/requests/ec2/create_key_pair.rb +2 -2
  27. data/lib/fog/aws/requests/ec2/create_security_group.rb +2 -2
  28. data/lib/fog/aws/requests/ec2/create_snapshot.rb +2 -2
  29. data/lib/fog/aws/requests/ec2/create_volume.rb +3 -3
  30. data/lib/fog/aws/requests/ec2/delete_key_pair.rb +1 -1
  31. data/lib/fog/aws/requests/ec2/delete_security_group.rb +2 -2
  32. data/lib/fog/aws/requests/ec2/delete_snapshot.rb +2 -2
  33. data/lib/fog/aws/requests/ec2/delete_volume.rb +2 -2
  34. data/lib/fog/aws/requests/ec2/describe_addresses.rb +2 -2
  35. data/lib/fog/aws/requests/ec2/describe_availability_zones.rb +1 -1
  36. data/lib/fog/aws/requests/ec2/describe_images.rb +1 -1
  37. data/lib/fog/aws/requests/ec2/describe_instances.rb +2 -2
  38. data/lib/fog/aws/requests/ec2/describe_key_pairs.rb +2 -2
  39. data/lib/fog/aws/requests/ec2/describe_regions.rb +1 -1
  40. data/lib/fog/aws/requests/ec2/describe_security_groups.rb +2 -2
  41. data/lib/fog/aws/requests/ec2/describe_snapshots.rb +2 -2
  42. data/lib/fog/aws/requests/ec2/describe_volumes.rb +2 -2
  43. data/lib/fog/aws/requests/ec2/detach_volume.rb +2 -2
  44. data/lib/fog/aws/requests/ec2/disassociate_address.rb +2 -2
  45. data/lib/fog/aws/requests/ec2/get_console_output.rb +2 -2
  46. data/lib/fog/aws/requests/ec2/reboot_instances.rb +2 -2
  47. data/lib/fog/aws/requests/ec2/release_address.rb +2 -2
  48. data/lib/fog/aws/requests/ec2/revoke_security_group_ingress.rb +1 -1
  49. data/lib/fog/aws/requests/ec2/run_instances.rb +2 -2
  50. data/lib/fog/aws/requests/ec2/terminate_instances.rb +2 -2
  51. data/lib/fog/aws/requests/s3/copy_object.rb +2 -2
  52. data/lib/fog/aws/requests/s3/delete_bucket.rb +3 -3
  53. data/lib/fog/aws/requests/s3/delete_object.rb +2 -2
  54. data/lib/fog/aws/requests/s3/get_bucket.rb +2 -2
  55. data/lib/fog/aws/requests/s3/get_bucket_location.rb +2 -2
  56. data/lib/fog/aws/requests/s3/get_object.rb +2 -2
  57. data/lib/fog/aws/requests/s3/get_request_payment.rb +2 -2
  58. data/lib/fog/aws/requests/s3/get_service.rb +1 -1
  59. data/lib/fog/aws/requests/s3/head_object.rb +1 -1
  60. data/lib/fog/aws/requests/s3/put_bucket.rb +1 -1
  61. data/lib/fog/aws/requests/s3/put_object.rb +2 -2
  62. data/lib/fog/aws/requests/s3/put_request_payment.rb +1 -1
  63. data/lib/fog/aws/requests/simpledb/batch_put_attributes.rb +2 -2
  64. data/lib/fog/aws/requests/simpledb/create_domain.rb +1 -1
  65. data/lib/fog/aws/requests/simpledb/delete_attributes.rb +2 -2
  66. data/lib/fog/aws/requests/simpledb/delete_domain.rb +1 -1
  67. data/lib/fog/aws/requests/simpledb/domain_metadata.rb +2 -2
  68. data/lib/fog/aws/requests/simpledb/get_attributes.rb +2 -2
  69. data/lib/fog/aws/requests/simpledb/list_domains.rb +1 -1
  70. data/lib/fog/aws/requests/simpledb/put_attributes.rb +1 -1
  71. data/lib/fog/aws/requests/simpledb/select.rb +1 -1
  72. data/lib/fog/aws/s3.rb +0 -7
  73. data/lib/fog/aws/simpledb.rb +0 -4
  74. data/lib/fog/collection.rb +35 -7
  75. data/lib/fog/connection.rb +10 -130
  76. data/lib/fog/model.rb +18 -13
  77. data/lib/fog/parser.rb +0 -5
  78. data/lib/fog/rackspace.rb +35 -15
  79. data/lib/fog/rackspace/files.rb +36 -6
  80. data/lib/fog/rackspace/models/servers/server.rb +2 -16
  81. data/lib/fog/rackspace/models/servers/servers.rb +6 -21
  82. data/lib/fog/rackspace/requests/files/delete_container.rb +38 -0
  83. data/lib/fog/rackspace/requests/files/delete_object.rb +39 -0
  84. data/lib/fog/rackspace/requests/files/get_container.rb +61 -0
  85. data/lib/fog/rackspace/requests/files/get_containers.rb +5 -7
  86. data/lib/fog/rackspace/requests/files/head_container.rb +44 -0
  87. data/lib/fog/rackspace/requests/files/head_containers.rb +1 -1
  88. data/lib/fog/rackspace/requests/files/put_container.rb +38 -0
  89. data/lib/fog/rackspace/requests/files/put_object.rb +41 -0
  90. data/lib/fog/rackspace/requests/servers/create_image.rb +6 -0
  91. data/lib/fog/rackspace/requests/servers/create_server.rb +21 -2
  92. data/lib/fog/rackspace/requests/servers/delete_server.rb +18 -3
  93. data/lib/fog/rackspace/requests/servers/get_server_details.rb +17 -5
  94. data/lib/fog/rackspace/requests/servers/list_addresses.rb +52 -0
  95. data/lib/fog/rackspace/requests/servers/list_flavors.rb +2 -4
  96. data/lib/fog/rackspace/requests/servers/list_flavors_detail.rb +41 -0
  97. data/lib/fog/rackspace/requests/servers/list_images.rb +1 -1
  98. data/lib/fog/rackspace/requests/servers/list_images_detail.rb +1 -1
  99. data/lib/fog/rackspace/requests/servers/list_private_addresses.rb +50 -0
  100. data/lib/fog/rackspace/requests/servers/list_public_addresses.rb +50 -0
  101. data/lib/fog/rackspace/requests/servers/list_servers.rb +11 -2
  102. data/lib/fog/rackspace/requests/servers/list_servers_detail.rb +17 -2
  103. data/lib/fog/rackspace/requests/servers/reboot_server.rb +3 -6
  104. data/lib/fog/rackspace/requests/servers/update_server.rb +18 -5
  105. data/lib/fog/rackspace/servers.rb +20 -0
  106. data/spec/aws/models/ec2/address_spec.rb +4 -4
  107. data/spec/aws/models/ec2/instance_spec.rb +6 -6
  108. data/spec/aws/models/ec2/key_pair_spec.rb +5 -5
  109. data/spec/aws/models/ec2/security_group_spec.rb +5 -5
  110. data/spec/aws/models/ec2/snapshot_spec.rb +8 -8
  111. data/spec/aws/models/ec2/snapshots_spec.rb +6 -6
  112. data/spec/aws/models/ec2/volume_spec.rb +6 -5
  113. data/spec/aws/models/ec2/volumes_spec.rb +4 -4
  114. data/spec/aws/requests/ec2/associate_address_spec.rb +2 -2
  115. data/spec/aws/requests/ec2/attach_volume_spec.rb +2 -2
  116. data/spec/aws/requests/ec2/create_key_pair_spec.rb +1 -1
  117. data/spec/aws/requests/ec2/create_security_group_spec.rb +1 -1
  118. data/spec/aws/requests/ec2/create_snapshot_spec.rb +1 -1
  119. data/spec/aws/requests/ec2/delete_security_group_spec.rb +1 -1
  120. data/spec/aws/requests/ec2/delete_snapshot_spec.rb +1 -1
  121. data/spec/aws/requests/ec2/delete_volume_spec.rb +2 -2
  122. data/spec/aws/requests/ec2/describe_addresses_spec.rb +1 -1
  123. data/spec/aws/requests/ec2/describe_instances_spec.rb +1 -1
  124. data/spec/aws/requests/ec2/describe_key_pairs_spec.rb +1 -1
  125. data/spec/aws/requests/ec2/describe_security_groups_spec.rb +1 -1
  126. data/spec/aws/requests/ec2/describe_snapshots_spec.rb +1 -1
  127. data/spec/aws/requests/ec2/describe_volumes_spec.rb +1 -1
  128. data/spec/aws/requests/ec2/detach_volume_spec.rb +1 -1
  129. data/spec/aws/requests/ec2/disassociate_address_spec.rb +1 -1
  130. data/spec/aws/requests/ec2/get_console_output_spec.rb +1 -1
  131. data/spec/aws/requests/ec2/reboot_instances_spec.rb +1 -1
  132. data/spec/aws/requests/ec2/release_address_spec.rb +1 -1
  133. data/spec/aws/requests/ec2/terminate_instances_spec.rb +1 -1
  134. data/spec/aws/requests/s3/copy_object_spec.rb +4 -5
  135. data/spec/aws/requests/s3/delete_bucket_spec.rb +3 -4
  136. data/spec/aws/requests/s3/delete_object_spec.rb +2 -3
  137. data/spec/aws/requests/s3/get_bucket_location_spec.rb +1 -1
  138. data/spec/aws/requests/s3/get_bucket_spec.rb +4 -6
  139. data/spec/aws/requests/s3/get_object_spec.rb +6 -10
  140. data/spec/aws/requests/s3/get_request_payment_spec.rb +1 -1
  141. data/spec/aws/requests/s3/head_object_spec.rb +2 -4
  142. data/spec/aws/requests/s3/put_object_spec.rb +4 -7
  143. data/spec/aws/requests/s3/put_request_payment_spec.rb +1 -1
  144. data/spec/aws/requests/simpledb/batch_put_attributes_spec.rb +1 -1
  145. data/spec/aws/requests/simpledb/delete_attributes_spec.rb +1 -1
  146. data/spec/aws/requests/simpledb/domain_metadata_spec.rb +1 -1
  147. data/spec/aws/requests/simpledb/get_attributes_spec.rb +1 -1
  148. data/spec/aws/requests/simpledb/put_attributes_spec.rb +1 -1
  149. data/spec/rackspace/requests/files/delete_container_spec.rb +24 -0
  150. data/spec/rackspace/requests/files/delete_object_spec.rb +37 -0
  151. data/spec/rackspace/requests/files/get_container_spec.rb +33 -0
  152. data/spec/rackspace/requests/files/get_containers_spec.rb +12 -1
  153. data/spec/rackspace/requests/files/head_container_spec.rb +30 -0
  154. data/spec/rackspace/requests/files/head_containers_spec.rb +9 -1
  155. data/spec/rackspace/requests/files/put_container_spec.rb +15 -0
  156. data/spec/rackspace/requests/files/put_object_spec.rb +20 -0
  157. data/spec/rackspace/requests/servers/create_image_spec.rb +16 -2
  158. data/spec/rackspace/requests/servers/create_server_spec.rb +1 -1
  159. data/spec/rackspace/requests/servers/delete_image_spec.rb +32 -0
  160. data/spec/rackspace/requests/servers/delete_server_spec.rb +1 -1
  161. data/spec/rackspace/requests/servers/get_server_details_spec.rb +1 -1
  162. data/spec/rackspace/requests/servers/list_addresses_spec.rb +34 -0
  163. data/spec/rackspace/requests/servers/list_flavors_detail_spec.rb +17 -0
  164. data/spec/rackspace/requests/servers/list_flavors_spec.rb +6 -3
  165. data/spec/rackspace/requests/servers/list_images_detail_spec.rb +18 -0
  166. data/spec/rackspace/requests/servers/list_images_spec.rb +5 -2
  167. data/spec/rackspace/requests/servers/list_private_addresses_spec.rb +32 -0
  168. data/spec/rackspace/requests/servers/list_public_addresses_spec.rb +32 -0
  169. data/spec/rackspace/requests/servers/list_servers_detail_spec.rb +1 -1
  170. data/spec/rackspace/requests/servers/reboot_server_spec.rb +31 -0
  171. data/spec/rackspace/requests/servers/update_server_spec.rb +33 -0
  172. data/spec/spec_helper.rb +5 -1
  173. metadata +50 -14
  174. data/benchs/headers_split_vs_match.rb +0 -18
  175. data/benchs/stripping.rb +0 -26
  176. data/lib/fog/errors.rb +0 -145
  177. data/lib/fog/response.rb +0 -12
  178. data/spec/rackspace/requests/servers/delete_image.rb +0 -12
  179. data/spec/rackspace/requests/servers/list_images_detail.rb +0 -12
  180. data/spec/rackspace/requests/servers/reboot_server.rb +0 -12
  181. data/spec/rackspace/requests/servers/update_server.rb +0 -12
data/Rakefile CHANGED
@@ -7,6 +7,7 @@ require "#{current_directory}/lib/fog"
7
7
  begin
8
8
  require 'jeweler'
9
9
  Jeweler::Tasks.new do |gem|
10
+ gem.add_dependency('excon')
10
11
  gem.add_dependency('mime-types')
11
12
  gem.add_dependency('nokogiri')
12
13
  gem.add_dependency('ruby-hmac')
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.29
1
+ 0.0.30
data/bin/fog CHANGED
@@ -5,11 +5,7 @@ require 'yaml'
5
5
 
6
6
  def credentials
7
7
  @credentials ||= begin
8
- if ARGV[0] && File.exists?(File.expand_path(ARGV[0]))
9
- YAML.load(File.open(File.expand_path(ARGV[0])).read)
10
- elsif File.exists?(File.expand_path('~/.fog'))
11
- YAML.load(File.open(File.expand_path('~/.fog')).read)
12
- end
8
+ YAML.load(File.open(File.expand_path('~/.fog')).read)
13
9
  end
14
10
  end
15
11
 
@@ -76,9 +72,20 @@ module Rackspace
76
72
  end
77
73
  end
78
74
 
79
- ARGV.clear # Avoid passing args to IRB
80
- IRB.setup(nil)
81
- @irb = IRB::Irb.new(nil)
82
- IRB.conf[:MAIN_CONTEXT] = @irb.context
83
- @irb.context.workspace = IRB::WorkSpace.new(binding)
84
- catch(:IRB_EXIT) { @irb.eval_input }
75
+ if ARGV[0]
76
+ result = eval(ARGV[0])
77
+ result = case result
78
+ when Fog::Collection
79
+ result.map {|model| model.attributes.reject {|key, value| key == :owner}}
80
+ when Fog::Model
81
+ result.attributes
82
+ end
83
+ print(Marshal.dump(result))
84
+ else
85
+ ARGV.clear # Avoid passing args to IRB
86
+ IRB.setup(nil)
87
+ @irb = IRB::Irb.new(nil)
88
+ IRB.conf[:MAIN_CONTEXT] = @irb.context
89
+ @irb.context.workspace = IRB::WorkSpace.new(binding)
90
+ catch(:IRB_EXIT) { @irb.eval_input }
91
+ end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{fog}
8
- s.version = "0.0.29"
8
+ s.version = "0.0.30"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["geemus (Wesley Beary)"]
12
- s.date = %q{2009-10-23}
12
+ s.date = %q{2009-11-14}
13
13
  s.default_executable = %q{fog}
14
14
  s.description = %q{brings clouds to you}
15
15
  s.email = %q{me@geemus.com}
@@ -24,10 +24,8 @@ Gem::Specification.new do |s|
24
24
  "Rakefile",
25
25
  "VERSION",
26
26
  "benchs/fog_vs.rb",
27
- "benchs/headers_split_vs_match.rb",
28
27
  "benchs/params.rb",
29
28
  "benchs/parse_vs_push.rb",
30
- "benchs/stripping.rb",
31
29
  "bin/fog",
32
30
  "fog.gemspec",
33
31
  "lib/fog.rb",
@@ -133,29 +131,37 @@ Gem::Specification.new do |s|
133
131
  "lib/fog/aws/simpledb.rb",
134
132
  "lib/fog/collection.rb",
135
133
  "lib/fog/connection.rb",
136
- "lib/fog/errors.rb",
137
134
  "lib/fog/model.rb",
138
135
  "lib/fog/parser.rb",
139
136
  "lib/fog/rackspace.rb",
140
137
  "lib/fog/rackspace/files.rb",
141
138
  "lib/fog/rackspace/models/servers/server.rb",
142
139
  "lib/fog/rackspace/models/servers/servers.rb",
140
+ "lib/fog/rackspace/requests/files/delete_container.rb",
141
+ "lib/fog/rackspace/requests/files/delete_object.rb",
142
+ "lib/fog/rackspace/requests/files/get_container.rb",
143
143
  "lib/fog/rackspace/requests/files/get_containers.rb",
144
+ "lib/fog/rackspace/requests/files/head_container.rb",
144
145
  "lib/fog/rackspace/requests/files/head_containers.rb",
146
+ "lib/fog/rackspace/requests/files/put_container.rb",
147
+ "lib/fog/rackspace/requests/files/put_object.rb",
145
148
  "lib/fog/rackspace/requests/servers/create_image.rb",
146
149
  "lib/fog/rackspace/requests/servers/create_server.rb",
147
150
  "lib/fog/rackspace/requests/servers/delete_image.rb",
148
151
  "lib/fog/rackspace/requests/servers/delete_server.rb",
149
152
  "lib/fog/rackspace/requests/servers/get_server_details.rb",
153
+ "lib/fog/rackspace/requests/servers/list_addresses.rb",
150
154
  "lib/fog/rackspace/requests/servers/list_flavors.rb",
155
+ "lib/fog/rackspace/requests/servers/list_flavors_detail.rb",
151
156
  "lib/fog/rackspace/requests/servers/list_images.rb",
152
157
  "lib/fog/rackspace/requests/servers/list_images_detail.rb",
158
+ "lib/fog/rackspace/requests/servers/list_private_addresses.rb",
159
+ "lib/fog/rackspace/requests/servers/list_public_addresses.rb",
153
160
  "lib/fog/rackspace/requests/servers/list_servers.rb",
154
161
  "lib/fog/rackspace/requests/servers/list_servers_detail.rb",
155
162
  "lib/fog/rackspace/requests/servers/reboot_server.rb",
156
163
  "lib/fog/rackspace/requests/servers/update_server.rb",
157
164
  "lib/fog/rackspace/servers.rb",
158
- "lib/fog/response.rb",
159
165
  "spec/aws/models/ec2/address_spec.rb",
160
166
  "spec/aws/models/ec2/addresses_spec.rb",
161
167
  "spec/aws/models/ec2/instance_spec.rb",
@@ -224,20 +230,30 @@ Gem::Specification.new do |s|
224
230
  "spec/aws/requests/simpledb/put_attributes_spec.rb",
225
231
  "spec/aws/requests/simpledb/select_spec.rb",
226
232
  "spec/lorem.txt",
233
+ "spec/rackspace/requests/files/delete_container_spec.rb",
234
+ "spec/rackspace/requests/files/delete_object_spec.rb",
235
+ "spec/rackspace/requests/files/get_container_spec.rb",
227
236
  "spec/rackspace/requests/files/get_containers_spec.rb",
237
+ "spec/rackspace/requests/files/head_container_spec.rb",
228
238
  "spec/rackspace/requests/files/head_containers_spec.rb",
239
+ "spec/rackspace/requests/files/put_container_spec.rb",
240
+ "spec/rackspace/requests/files/put_object_spec.rb",
229
241
  "spec/rackspace/requests/servers/create_image_spec.rb",
230
242
  "spec/rackspace/requests/servers/create_server_spec.rb",
231
- "spec/rackspace/requests/servers/delete_image.rb",
243
+ "spec/rackspace/requests/servers/delete_image_spec.rb",
232
244
  "spec/rackspace/requests/servers/delete_server_spec.rb",
233
245
  "spec/rackspace/requests/servers/get_server_details_spec.rb",
246
+ "spec/rackspace/requests/servers/list_addresses_spec.rb",
247
+ "spec/rackspace/requests/servers/list_flavors_detail_spec.rb",
234
248
  "spec/rackspace/requests/servers/list_flavors_spec.rb",
235
- "spec/rackspace/requests/servers/list_images_detail.rb",
249
+ "spec/rackspace/requests/servers/list_images_detail_spec.rb",
236
250
  "spec/rackspace/requests/servers/list_images_spec.rb",
251
+ "spec/rackspace/requests/servers/list_private_addresses_spec.rb",
252
+ "spec/rackspace/requests/servers/list_public_addresses_spec.rb",
237
253
  "spec/rackspace/requests/servers/list_servers_detail_spec.rb",
238
254
  "spec/rackspace/requests/servers/list_servers_spec.rb",
239
- "spec/rackspace/requests/servers/reboot_server.rb",
240
- "spec/rackspace/requests/servers/update_server.rb",
255
+ "spec/rackspace/requests/servers/reboot_server_spec.rb",
256
+ "spec/rackspace/requests/servers/update_server_spec.rb",
241
257
  "spec/spec.opts",
242
258
  "spec/spec_helper.rb"
243
259
  ]
@@ -315,20 +331,30 @@ Gem::Specification.new do |s|
315
331
  "spec/aws/requests/simpledb/list_domains_spec.rb",
316
332
  "spec/aws/requests/simpledb/put_attributes_spec.rb",
317
333
  "spec/aws/requests/simpledb/select_spec.rb",
334
+ "spec/rackspace/requests/files/delete_container_spec.rb",
335
+ "spec/rackspace/requests/files/delete_object_spec.rb",
336
+ "spec/rackspace/requests/files/get_container_spec.rb",
318
337
  "spec/rackspace/requests/files/get_containers_spec.rb",
338
+ "spec/rackspace/requests/files/head_container_spec.rb",
319
339
  "spec/rackspace/requests/files/head_containers_spec.rb",
340
+ "spec/rackspace/requests/files/put_container_spec.rb",
341
+ "spec/rackspace/requests/files/put_object_spec.rb",
320
342
  "spec/rackspace/requests/servers/create_image_spec.rb",
321
343
  "spec/rackspace/requests/servers/create_server_spec.rb",
322
- "spec/rackspace/requests/servers/delete_image.rb",
344
+ "spec/rackspace/requests/servers/delete_image_spec.rb",
323
345
  "spec/rackspace/requests/servers/delete_server_spec.rb",
324
346
  "spec/rackspace/requests/servers/get_server_details_spec.rb",
347
+ "spec/rackspace/requests/servers/list_addresses_spec.rb",
348
+ "spec/rackspace/requests/servers/list_flavors_detail_spec.rb",
325
349
  "spec/rackspace/requests/servers/list_flavors_spec.rb",
326
- "spec/rackspace/requests/servers/list_images_detail.rb",
350
+ "spec/rackspace/requests/servers/list_images_detail_spec.rb",
327
351
  "spec/rackspace/requests/servers/list_images_spec.rb",
352
+ "spec/rackspace/requests/servers/list_private_addresses_spec.rb",
353
+ "spec/rackspace/requests/servers/list_public_addresses_spec.rb",
328
354
  "spec/rackspace/requests/servers/list_servers_detail_spec.rb",
329
355
  "spec/rackspace/requests/servers/list_servers_spec.rb",
330
- "spec/rackspace/requests/servers/reboot_server.rb",
331
- "spec/rackspace/requests/servers/update_server.rb",
356
+ "spec/rackspace/requests/servers/reboot_server_spec.rb",
357
+ "spec/rackspace/requests/servers/update_server_spec.rb",
332
358
  "spec/spec_helper.rb"
333
359
  ]
334
360
 
@@ -337,15 +363,18 @@ Gem::Specification.new do |s|
337
363
  s.specification_version = 3
338
364
 
339
365
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
366
+ s.add_runtime_dependency(%q<excon>, [">= 0"])
340
367
  s.add_runtime_dependency(%q<mime-types>, [">= 0"])
341
368
  s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
342
369
  s.add_runtime_dependency(%q<ruby-hmac>, [">= 0"])
343
370
  else
371
+ s.add_dependency(%q<excon>, [">= 0"])
344
372
  s.add_dependency(%q<mime-types>, [">= 0"])
345
373
  s.add_dependency(%q<nokogiri>, [">= 0"])
346
374
  s.add_dependency(%q<ruby-hmac>, [">= 0"])
347
375
  end
348
376
  else
377
+ s.add_dependency(%q<excon>, [">= 0"])
349
378
  s.add_dependency(%q<mime-types>, [">= 0"])
350
379
  s.add_dependency(%q<nokogiri>, [">= 0"])
351
380
  s.add_dependency(%q<ruby-hmac>, [">= 0"])
data/lib/fog.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  require 'rubygems'
2
- require 'rubygems'
3
2
  require 'base64'
4
3
  require 'cgi'
5
4
  require 'digest/md5'
@@ -7,6 +6,8 @@ require 'hmac-sha1'
7
6
  require 'hmac-sha2'
8
7
  require 'json'
9
8
  require 'mime/types'
9
+ require 'nokogiri'
10
+ require 'time'
10
11
 
11
12
  __DIR__ = File.dirname(__FILE__)
12
13
 
@@ -26,6 +27,11 @@ module Fog
26
27
  end
27
28
 
28
29
  def self.reload
30
+ load "fog/collection.rb"
31
+ load "fog/connection.rb"
32
+ load "fog/model.rb"
33
+ load "fog/parser.rb"
34
+
29
35
  load "fog/aws.rb"
30
36
  load "fog/rackspace.rb"
31
37
  end
@@ -20,12 +20,6 @@ module Fog
20
20
  end
21
21
 
22
22
  def self.reload
23
- load "fog/collection.rb"
24
- load "fog/connection.rb"
25
- load "fog/model.rb"
26
- load "fog/parser.rb"
27
- load "fog/response.rb"
28
-
29
23
  load "fog/aws/models/ec2/address.rb"
30
24
  load "fog/aws/models/ec2/addresses.rb"
31
25
  load "fog/aws/models/ec2/instance.rb"
@@ -172,7 +166,6 @@ module Fog
172
166
  response = @connection.request({
173
167
  :body => body,
174
168
  :expects => 200,
175
- :error_parser => Fog::Errors::Parser.new,
176
169
  :headers => { 'Content-Type' => 'application/x-www-form-urlencoded' },
177
170
  :host => @host,
178
171
  :method => 'POST',
@@ -4,19 +4,9 @@ module Fog
4
4
 
5
5
  class Address < Fog::Model
6
6
 
7
- attribute :instance_id, 'instanceId'
8
- attribute :public_ip, 'publicIp'
9
-
10
- def addresses
11
- @addresses
12
- end
7
+ identity :public_ip, 'publicIp'
13
8
 
14
- def initialize(new_attributes = {})
15
- new_attributes = {
16
- :instance_id => ''
17
- }.merge!(new_attributes)
18
- super(new_attributes)
19
- end
9
+ attribute :instance_id, 'instanceId'
20
10
 
21
11
  def destroy
22
12
  connection.release_address(@public_ip)
@@ -24,18 +14,10 @@ module Fog
24
14
  end
25
15
 
26
16
  def instance=(new_instance)
27
- if !@public_ip
28
- @instance = new_instance
29
- elsif new_instance
30
- @instance = nil
31
- @instance_id = new_instance.instance_id
32
- connection.associate_address(@instance_id, @public_ip)
33
- end
34
- end
35
-
36
- def reload
37
- if new_address = addresses.get(@public_ip)
38
- merge_attributes(new_address.attributes)
17
+ if new_instance
18
+ associate(new_instance)
19
+ else
20
+ disassociate
39
21
  end
40
22
  end
41
23
 
@@ -50,8 +32,22 @@ module Fog
50
32
 
51
33
  private
52
34
 
53
- def addresses=(new_addresses)
54
- @addresses = new_addresses
35
+ def associate(new_instance)
36
+ if new_record?
37
+ @instance = new_instance
38
+ else
39
+ @instance = nil
40
+ @instance_id = new_instance.instance_id
41
+ connection.associate_address(@instance_id, @public_ip)
42
+ end
43
+ end
44
+
45
+ def disassociate
46
+ @instance = nil
47
+ @instance_id = nil
48
+ unless new_record?
49
+ connection.disassociate_address(@public_ip)
50
+ end
55
51
  end
56
52
 
57
53
  end
@@ -13,22 +13,21 @@ module Fog
13
13
  attribute :public_ip
14
14
  attribute :instance
15
15
 
16
+ model Fog::AWS::EC2::Address
17
+
16
18
  def initialize(attributes)
17
19
  @public_ip ||= []
18
20
  super
19
21
  end
20
22
 
21
- def all(public_ip = [])
23
+ def all(public_ip = @public_ip)
22
24
  data = connection.describe_addresses(public_ip).body
23
25
  addresses = Fog::AWS::EC2::Addresses.new({
24
26
  :connection => connection,
25
27
  :public_ip => public_ip
26
28
  }.merge!(attributes))
27
29
  data['addressesSet'].each do |address|
28
- addresses << Fog::AWS::EC2::Address.new({
29
- :addresses => addresses,
30
- :connection => connection
31
- }.merge!(address))
30
+ addresses << new(address.reject {|key, value| value.nil? || value.empty? })
32
31
  end
33
32
  if instance
34
33
  addresses = addresses.select {|address| address.instance_id == instance.id}
@@ -36,30 +35,16 @@ module Fog
36
35
  addresses
37
36
  end
38
37
 
39
- def create
40
- address = new
41
- address.save
42
- address
43
- end
44
-
45
38
  def get(public_ip)
46
39
  if public_ip
47
40
  all(public_ip).first
48
41
  end
49
- rescue Fog::Errors::BadRequest
42
+ rescue Excon::Errors::BadRequest
50
43
  nil
51
44
  end
52
45
 
53
- def new
54
- Fog::AWS::EC2::Address.new(
55
- :addresses => self,
56
- :connection => connection,
57
- :instance => instance
58
- )
59
- end
60
-
61
- def reload
62
- all(public_ip)
46
+ def new(attributes = {})
47
+ super({ :instance => instance }.merge!(attributes))
63
48
  end
64
49
 
65
50
  end
@@ -4,12 +4,13 @@ module Fog
4
4
 
5
5
  class Instance < Fog::Model
6
6
 
7
+ identity :instance_id, 'instanceId'
8
+
7
9
  attribute :ami_launch_index, 'amiLaunchIndex'
8
10
  attribute :availability_zone, 'availabilityZone'
9
11
  attribute :dns_name, 'dnsName'
10
12
  attribute :group_id, 'groupId'
11
13
  attribute :image_id, 'imageId'
12
- attribute :instance_id, 'instanceId'
13
14
  attribute :instance_state, 'instanceState'
14
15
  attribute :instance_type, 'instanceType'
15
16
  attribute :kernel_id, 'kernelId'
@@ -47,10 +48,6 @@ module Fog
47
48
  @key_name = new_keypair.name
48
49
  end
49
50
 
50
- def instances
51
- @instances
52
- end
53
-
54
51
  def monitoring=(new_monitoring)
55
52
  if new_monitoring.is_a?(Hash)
56
53
  @monitoring = new_monitoring['state']
@@ -67,12 +64,6 @@ module Fog
67
64
  end
68
65
  end
69
66
 
70
- def reload
71
- if new_instance = instances.get(@instance_id)
72
- merge_attributes(new_instance.attributes)
73
- end
74
- end
75
-
76
67
  def save
77
68
  options = {}
78
69
  if @availability_zone
@@ -118,10 +109,6 @@ module Fog
118
109
  end
119
110
  end
120
111
 
121
- def instances=(new_instances)
122
- @instances = new_instances
123
- end
124
-
125
112
  end
126
113
 
127
114
  end
@@ -10,12 +10,14 @@ module Fog
10
10
 
11
11
  attribute :instance_id
12
12
 
13
+ model Fog::AWS::EC2::Instance
14
+
13
15
  def initialize(attributes)
14
16
  @instance_id ||= []
15
17
  super
16
18
  end
17
19
 
18
- def all(instance_id = [])
20
+ def all(instance_id = @instance_id)
19
21
  data = connection.describe_instances(instance_id).body
20
22
  instances = Fog::AWS::EC2::Instances.new({
21
23
  :connection => connection,
@@ -24,41 +26,22 @@ module Fog
24
26
  data['reservationSet'].each do |reservation|
25
27
  reservation['instancesSet'].each do |instance|
26
28
  instances << Fog::AWS::EC2::Instance.new({
27
- :connection => connection,
28
- :instances => self
29
+ :collection => instances,
30
+ :connection => connection
29
31
  }.merge!(instance))
30
32
  end
31
33
  end
32
34
  instances
33
35
  end
34
36
 
35
- def create(attributes = {})
36
- instance = new(attributes)
37
- instance.save
38
- instance
39
- end
40
-
41
37
  def get(instance_id)
42
38
  if instance_id
43
39
  all(instance_id).first
44
40
  end
45
- rescue Fog::Errors::BadRequest
41
+ rescue Excon::Errors::BadRequest
46
42
  nil
47
43
  end
48
44
 
49
- def new(attributes = {})
50
- Fog::AWS::EC2::Instance.new(
51
- attributes.merge!(
52
- :connection => connection,
53
- :instances => self
54
- )
55
- )
56
- end
57
-
58
- def reload
59
- all(instance_id)
60
- end
61
-
62
45
  end
63
46
 
64
47
  end