fog 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (211) hide show
  1. data/Rakefile +106 -17
  2. data/bin/fog +1 -1
  3. data/changelog.txt +17 -0
  4. data/docs/_layouts/default.html +2 -1
  5. data/docs/about/contributing.markdown +1 -1
  6. data/docs/compute/index.markdown +104 -0
  7. data/docs/index.markdown +1 -0
  8. data/docs/storage/index.markdown +17 -0
  9. data/fog.gemspec +3 -2
  10. data/lib/fog.rb +1 -1
  11. data/lib/fog/aws/elb.rb +1 -0
  12. data/lib/fog/aws/iam.rb +1 -0
  13. data/lib/fog/aws/rds.rb +1 -0
  14. data/lib/fog/aws/requests/simpledb/batch_put_attributes.rb +5 -5
  15. data/lib/fog/aws/requests/simpledb/create_domain.rb +1 -1
  16. data/lib/fog/aws/requests/simpledb/delete_attributes.rb +3 -3
  17. data/lib/fog/aws/requests/simpledb/delete_domain.rb +1 -1
  18. data/lib/fog/aws/requests/simpledb/domain_metadata.rb +1 -1
  19. data/lib/fog/aws/requests/simpledb/get_attributes.rb +5 -5
  20. data/lib/fog/aws/requests/simpledb/list_domains.rb +2 -2
  21. data/lib/fog/aws/requests/simpledb/put_attributes.rb +6 -6
  22. data/lib/fog/aws/ses.rb +1 -0
  23. data/lib/fog/aws/simpledb.rb +8 -2
  24. data/lib/fog/bin.rb +2 -2
  25. data/lib/fog/cdn/aws.rb +8 -2
  26. data/lib/fog/cdn/rackspace.rb +8 -2
  27. data/lib/fog/compute/aws.rb +12 -3
  28. data/lib/fog/compute/bluebox.rb +8 -2
  29. data/lib/fog/compute/ecloud.rb +9 -4
  30. data/lib/fog/compute/go_grid.rb +8 -2
  31. data/lib/fog/compute/linode.rb +38 -6
  32. data/lib/fog/compute/models/aws/volumes.rb +4 -4
  33. data/lib/fog/compute/models/bluebox/server.rb +3 -3
  34. data/lib/fog/compute/models/brightbox/server.rb +9 -9
  35. data/lib/fog/compute/models/linode/data_center.rb +12 -0
  36. data/lib/fog/compute/models/linode/data_centers.rb +26 -0
  37. data/lib/fog/compute/models/linode/disk.rb +62 -0
  38. data/lib/fog/compute/models/linode/disks.rb +40 -0
  39. data/lib/fog/compute/models/linode/flavor.rb +23 -0
  40. data/lib/fog/compute/models/linode/flavors.rb +32 -0
  41. data/lib/fog/compute/models/linode/image.rb +14 -0
  42. data/lib/fog/compute/models/linode/images.rb +33 -0
  43. data/lib/fog/compute/models/linode/ip.rb +30 -0
  44. data/lib/fog/compute/models/linode/ips.rb +40 -0
  45. data/lib/fog/compute/models/linode/kernel.rb +12 -0
  46. data/lib/fog/compute/models/linode/kernels.rb +32 -0
  47. data/lib/fog/compute/models/linode/server.rb +88 -0
  48. data/lib/fog/compute/models/linode/servers.rb +32 -0
  49. data/lib/fog/compute/models/linode/stack_script.rb +13 -0
  50. data/lib/fog/compute/models/linode/stack_scripts.rb +32 -0
  51. data/lib/fog/compute/models/rackspace/server.rb +2 -2
  52. data/lib/fog/compute/models/slicehost/server.rb +2 -2
  53. data/lib/fog/compute/models/voxel/server.rb +3 -3
  54. data/lib/fog/compute/new_servers.rb +8 -2
  55. data/lib/fog/compute/rackspace.rb +8 -2
  56. data/lib/fog/compute/requests/aws/allocate_address.rb +4 -2
  57. data/lib/fog/compute/requests/aws/associate_address.rb +4 -2
  58. data/lib/fog/compute/requests/aws/attach_volume.rb +4 -2
  59. data/lib/fog/compute/requests/aws/authorize_security_group_ingress.rb +5 -3
  60. data/lib/fog/compute/requests/aws/create_image.rb +2 -1
  61. data/lib/fog/compute/requests/aws/create_key_pair.rb +4 -2
  62. data/lib/fog/compute/requests/aws/create_security_group.rb +5 -3
  63. data/lib/fog/compute/requests/aws/create_snapshot.rb +6 -4
  64. data/lib/fog/compute/requests/aws/create_tags.rb +7 -5
  65. data/lib/fog/compute/requests/aws/create_volume.rb +4 -2
  66. data/lib/fog/compute/requests/aws/delete_key_pair.rb +3 -1
  67. data/lib/fog/compute/requests/aws/delete_security_group.rb +4 -2
  68. data/lib/fog/compute/requests/aws/delete_snapshot.rb +3 -1
  69. data/lib/fog/compute/requests/aws/delete_tags.rb +5 -3
  70. data/lib/fog/compute/requests/aws/delete_volume.rb +4 -2
  71. data/lib/fog/compute/requests/aws/deregister_image.rb +2 -0
  72. data/lib/fog/compute/requests/aws/describe_addresses.rb +3 -1
  73. data/lib/fog/compute/requests/aws/describe_availability_zones.rb +2 -0
  74. data/lib/fog/compute/requests/aws/describe_images.rb +3 -1
  75. data/lib/fog/compute/requests/aws/describe_instances.rb +12 -10
  76. data/lib/fog/compute/requests/aws/describe_key_pairs.rb +3 -1
  77. data/lib/fog/compute/requests/aws/describe_regions.rb +2 -0
  78. data/lib/fog/compute/requests/aws/describe_reserved_instances.rb +2 -0
  79. data/lib/fog/compute/requests/aws/describe_reserved_instances_offerings.rb +2 -0
  80. data/lib/fog/compute/requests/aws/describe_security_groups.rb +3 -1
  81. data/lib/fog/compute/requests/aws/describe_snapshots.rb +5 -3
  82. data/lib/fog/compute/requests/aws/describe_tags.rb +2 -0
  83. data/lib/fog/compute/requests/aws/describe_volumes.rb +9 -7
  84. data/lib/fog/compute/requests/aws/detach_volume.rb +3 -1
  85. data/lib/fog/compute/requests/aws/disassociate_address.rb +4 -2
  86. data/lib/fog/compute/requests/aws/get_console_output.rb +3 -1
  87. data/lib/fog/compute/requests/aws/get_password_data.rb +15 -1
  88. data/lib/fog/compute/requests/aws/import_key_pair.rb +4 -2
  89. data/lib/fog/compute/requests/aws/modify_image_attributes.rb +4 -0
  90. data/lib/fog/compute/requests/aws/modify_snapshot_attribute.rb +4 -0
  91. data/lib/fog/compute/requests/aws/monitor_instances.rb +3 -1
  92. data/lib/fog/compute/requests/aws/reboot_instances.rb +4 -2
  93. data/lib/fog/compute/requests/aws/register_image.rb +4 -0
  94. data/lib/fog/compute/requests/aws/release_address.rb +3 -1
  95. data/lib/fog/compute/requests/aws/revoke_security_group_ingress.rb +3 -1
  96. data/lib/fog/compute/requests/aws/run_instances.rb +12 -6
  97. data/lib/fog/compute/requests/aws/start_instances.rb +2 -0
  98. data/lib/fog/compute/requests/aws/stop_instances.rb +2 -0
  99. data/lib/fog/compute/requests/aws/terminate_instances.rb +5 -3
  100. data/lib/fog/compute/requests/aws/unmonitor_instances.rb +3 -1
  101. data/lib/fog/compute/requests/go_grid/grid_image_get.rb +1 -1
  102. data/lib/fog/compute/requests/go_grid/grid_image_list.rb +1 -1
  103. data/lib/fog/compute/requests/linode/avail_datacenters.rb +1 -2
  104. data/lib/fog/compute/requests/linode/avail_distributions.rb +1 -2
  105. data/lib/fog/compute/requests/linode/avail_kernels.rb +6 -5
  106. data/lib/fog/compute/requests/linode/avail_linodeplans.rb +9 -3
  107. data/lib/fog/compute/requests/linode/avail_stackscripts.rb +3 -15
  108. data/lib/fog/compute/requests/linode/linode_boot.rb +15 -0
  109. data/lib/fog/compute/requests/linode/linode_config_create.rb +21 -0
  110. data/lib/fog/compute/requests/linode/linode_config_list.rb +18 -0
  111. data/lib/fog/compute/requests/linode/linode_create.rb +3 -4
  112. data/lib/fog/compute/requests/linode/linode_delete.rb +0 -1
  113. data/lib/fog/compute/requests/linode/linode_disk_create.rb +21 -0
  114. data/lib/fog/compute/requests/linode/linode_disk_createfromdistribution.rb +22 -0
  115. data/lib/fog/compute/requests/linode/linode_disk_createfromstackscript.rb +24 -0
  116. data/lib/fog/compute/requests/linode/linode_disk_delete.rb +19 -0
  117. data/lib/fog/compute/requests/linode/linode_disk_list.rb +19 -0
  118. data/lib/fog/compute/requests/linode/linode_ip_addprivate.rb +15 -0
  119. data/lib/fog/compute/requests/linode/linode_ip_list.rb +19 -0
  120. data/lib/fog/compute/requests/linode/linode_list.rb +0 -1
  121. data/lib/fog/compute/requests/linode/linode_reboot.rb +1 -2
  122. data/lib/fog/compute/requests/linode/linode_shutdown.rb +15 -0
  123. data/lib/fog/compute/requests/linode/linode_update.rb +15 -0
  124. data/lib/fog/compute/requests/linode/stackscript_list.rb +31 -0
  125. data/lib/fog/compute/requests/rackspace/confirm_resized_server.rb +3 -3
  126. data/lib/fog/compute/requests/rackspace/create_image.rb +2 -2
  127. data/lib/fog/compute/requests/rackspace/create_server.rb +2 -2
  128. data/lib/fog/compute/requests/rackspace/delete_image.rb +2 -2
  129. data/lib/fog/compute/requests/rackspace/delete_server.rb +2 -2
  130. data/lib/fog/compute/requests/rackspace/list_images_detail.rb +2 -2
  131. data/lib/fog/compute/requests/rackspace/list_servers_detail.rb +2 -2
  132. data/lib/fog/compute/requests/rackspace/resize_server.rb +4 -4
  133. data/lib/fog/compute/requests/rackspace/revert_resized_server.rb +4 -4
  134. data/lib/fog/compute/slicehost.rb +8 -2
  135. data/lib/fog/compute/storm_on_demand.rb +12 -1
  136. data/lib/fog/compute/voxel.rb +8 -2
  137. data/lib/fog/core/mock.rb +14 -1
  138. data/lib/fog/dns/aws.rb +8 -2
  139. data/lib/fog/dns/bluebox.rb +8 -2
  140. data/lib/fog/dns/dnsimple.rb +15 -3
  141. data/lib/fog/dns/linode.rb +8 -2
  142. data/lib/fog/dns/slicehost.rb +8 -2
  143. data/lib/fog/dns/zerigo.rb +8 -2
  144. data/lib/fog/providers/aws.rb +5 -10
  145. data/lib/fog/providers/linode.rb +0 -3
  146. data/lib/fog/storage.rb +6 -4
  147. data/lib/fog/storage/aws.rb +8 -2
  148. data/lib/fog/storage/google.rb +8 -2
  149. data/lib/fog/storage/local.rb +8 -2
  150. data/lib/fog/storage/models/aws/file.rb +0 -1
  151. data/lib/fog/storage/models/google/file.rb +1 -5
  152. data/lib/fog/storage/models/local/file.rb +1 -1
  153. data/lib/fog/storage/models/rackspace/file.rb +1 -5
  154. data/lib/fog/storage/rackspace.rb +8 -2
  155. data/lib/fog/storage/requests/aws/copy_object.rb +2 -2
  156. data/lib/fog/storage/requests/aws/delete_bucket.rb +3 -3
  157. data/lib/fog/storage/requests/aws/delete_object.rb +1 -1
  158. data/lib/fog/storage/requests/aws/get_bucket.rb +1 -1
  159. data/lib/fog/storage/requests/aws/get_bucket_acl.rb +1 -1
  160. data/lib/fog/storage/requests/aws/get_bucket_location.rb +1 -1
  161. data/lib/fog/storage/requests/aws/get_object.rb +1 -1
  162. data/lib/fog/storage/requests/aws/get_object_acl.rb +1 -1
  163. data/lib/fog/storage/requests/aws/get_request_payment.rb +1 -1
  164. data/lib/fog/storage/requests/aws/get_service.rb +1 -1
  165. data/lib/fog/storage/requests/aws/put_bucket.rb +3 -3
  166. data/lib/fog/storage/requests/aws/put_object.rb +3 -3
  167. data/lib/fog/storage/requests/aws/put_request_payment.rb +1 -1
  168. data/lib/fog/storage/requests/google/copy_object.rb +2 -2
  169. data/lib/fog/storage/requests/google/delete_bucket.rb +3 -3
  170. data/lib/fog/storage/requests/google/delete_object.rb +1 -1
  171. data/lib/fog/storage/requests/google/get_bucket.rb +1 -1
  172. data/lib/fog/storage/requests/google/get_bucket_acl.rb +1 -1
  173. data/lib/fog/storage/requests/google/get_object.rb +1 -1
  174. data/lib/fog/storage/requests/google/get_object_acl.rb +1 -1
  175. data/lib/fog/storage/requests/google/get_service.rb +2 -2
  176. data/lib/fog/storage/requests/google/put_bucket.rb +3 -3
  177. data/lib/fog/storage/requests/google/put_object.rb +3 -3
  178. data/lib/fog/terremark/requests/shared/get_network.rb +1 -1
  179. data/lib/fog/terremark/requests/shared/get_organization.rb +1 -1
  180. data/lib/fog/terremark/requests/shared/get_organizations.rb +1 -1
  181. data/lib/fog/terremark/requests/shared/get_public_ips.rb +1 -1
  182. data/lib/fog/terremark/requests/shared/get_vdc.rb +1 -1
  183. data/lib/fog/terremark/shared.rb +4 -0
  184. data/lib/fog/terremark/vcloud.rb +11 -1
  185. data/spec/ecloud/bin_spec.rb +8 -2
  186. data/spec/ecloud/spec_helper.rb +3 -3
  187. data/tests/compute/helper.rb +1 -3
  188. data/tests/compute/models/aws/server_tests.rb +3 -2
  189. data/tests/compute/requests/aws/instance_tests.rb +12 -9
  190. data/tests/compute/requests/aws/key_pair_tests.rb +1 -1
  191. data/tests/compute/requests/aws/volume_tests.rb +2 -2
  192. data/tests/compute/requests/brightbox/helper.rb +3 -0
  193. data/tests/compute/requests/linode/kernel_tests.rb +27 -0
  194. data/tests/compute/requests/linode/linode_tests.rb +62 -4
  195. data/tests/compute/requests/linode/stackscripts_tests.rb +35 -0
  196. data/tests/compute/requests/rackspace/resize_tests.rb +2 -2
  197. data/tests/compute/requests/voxel/server_tests.rb +1 -0
  198. data/tests/core/credential_tests.rb +7 -2
  199. data/tests/core/parser_tests.rb +1 -1
  200. data/tests/helper.rb +1 -1
  201. data/tests/helpers/compute/server_helper.rb +6 -0
  202. data/tests/helpers/formats_helper.rb +2 -0
  203. data/tests/helpers/mock_helper.rb +8 -1
  204. data/tests/helpers/model_helper.rb +1 -3
  205. data/tests/helpers/responds_to_helper.rb +2 -2
  206. data/tests/storage/helper.rb +1 -1
  207. data/tests/storage/models/directories_tests.rb +8 -4
  208. data/tests/storage/models/directory_test.rb +15 -11
  209. data/tests/storage/models/file_tests.rb +6 -6
  210. data/tests/storage/models/files_tests.rb +5 -5
  211. metadata +105 -55
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'rubygems'
2
2
  require 'bundler/setup'
3
3
  require 'date'
4
- require 'fog'
4
+ require 'lib/fog'
5
5
 
6
6
  #############################################################################
7
7
  #
@@ -52,11 +52,40 @@ task :examples do
52
52
  # sh("export FOG_MOCK=true && bundle exec shindont examples")
53
53
  end
54
54
 
55
- task :test => :examples do
56
- sh("export FOG_MOCK=true && bundle exec spec spec") &&
57
- sh("export FOG_MOCK=true && bundle exec shindont tests") &&
58
- sh("export FOG_MOCK=false && bundle exec spec spec") &&
59
- sh("export FOG_MOCK=false && bundle exec shindont tests")
55
+ task :test do # => :examples do
56
+ Rake::Task[:mock_tests].invoke
57
+ Rake::Task[:real_tests].invoke
58
+ end
59
+
60
+ def tests(mocked)
61
+ Formatador.display_line
62
+ sh("export FOG_MOCK=#{mocked} && bundle exec spec spec")
63
+ Formatador.display_line
64
+ start = Time.now.to_i
65
+ threads = []
66
+ Thread.main[:results] = []
67
+ Fog.providers.each do |provider|
68
+ threads << Thread.new do
69
+ Thread.main[:results] << {
70
+ :provider => provider,
71
+ :success => sh("export FOG_MOCK=#{mocked} && bundle exec shindont +#{provider.downcase}")
72
+ }
73
+ end
74
+ end
75
+ threads.each do |thread|
76
+ thread.join
77
+ end
78
+ Formatador.display_table(Thread.main[:results].sort {|x,y| x[:provider] <=> y[:provider]})
79
+ Formatador.display_line("[bold]FOG_MOCK=#{mocked}[/] tests completed in [bold]#{Time.now.to_i - start}[/] seconds")
80
+ Formatador.display_line
81
+ end
82
+
83
+ task :mock_tests do
84
+ tests(true)
85
+ end
86
+
87
+ task :real_tests do
88
+ tests(false)
60
89
  end
61
90
 
62
91
  desc "Generate RCov test coverage and open in your browser"
@@ -67,8 +96,8 @@ task :coverage do
67
96
  sh "open coverage/index.html"
68
97
  end
69
98
 
70
- require 'rake/rdoctask'
71
- Rake::RDocTask.new do |rdoc|
99
+ require 'rdoc/task'
100
+ RDoc::Task.new do |rdoc|
72
101
  rdoc.rdoc_dir = 'rdoc'
73
102
  rdoc.title = "#{name} #{version}"
74
103
  rdoc.rdoc_files.include('README*')
@@ -98,6 +127,7 @@ task :release => :build do
98
127
  sh "git push origin v#{version}"
99
128
  sh "gem push pkg/#{name}-#{version}.gem"
100
129
  Rake::Task[:docs].invoke
130
+ Rake::Task[:changelog].invoke
101
131
  end
102
132
 
103
133
  task :build => :gemspec do
@@ -143,11 +173,13 @@ task :changelog do
143
173
  last_sha = `cat changelog.txt | head -1`.split(' ').last
144
174
  shortlog = `git shortlog #{last_sha}..HEAD`
145
175
  changes = {}
176
+ committers = {}
146
177
  for line in shortlog.split("\n")
147
178
  if line =~ /^\S/
148
179
  committer = line.split(' (', 2).first
149
- elsif line =~ /^\s*(Merge.*)?$/
150
- # skip empty lines and Merge commits
180
+ committers[committer] = 0
181
+ elsif line =~ /^\s*((Merge.*)|(Release.*))?$/
182
+ # skip empty lines, Merge and Release commits
151
183
  else
152
184
  unless line[-1..-1] == '.'
153
185
  line << '.'
@@ -156,7 +188,17 @@ task :changelog do
156
188
  tag = $1 || 'misc'
157
189
  changes[tag] ||= []
158
190
  changes[tag] << (line << ' thanks ' << committer)
191
+ committers[committer] += 1
192
+ end
193
+ end
194
+
195
+ for committer, commits in committers.to_a.sort {|x,y| y[1] <=> x[1]}
196
+ if ['Aaron Suggs', 'geemus', 'Wesley Beary'].include?(committer)
197
+ next
159
198
  end
199
+ changelog << "MVP! #{committer}"
200
+ changelog << ''
201
+ break
160
202
  end
161
203
 
162
204
  for tag in changes.keys.sort
@@ -167,31 +209,39 @@ task :changelog do
167
209
  changelog << ''
168
210
  end
169
211
 
170
- for line in changelog
171
- print(line << "\n")
172
- end
212
+ `echo "#{changelog.join("\n")}" | pbcopy`
213
+ p 'changelog copied to clipboard'
173
214
  end
174
215
 
175
216
  task :docs do
176
217
  # build the docs locally
177
218
  sh "jekyll docs docs/_site"
178
219
 
179
- # connect to storage provider and write files to versioned 'folder'
220
+ # connect to storage provider
180
221
  Fog.credential = :geemus
181
222
  storage = Fog::Storage.new(:provider => 'AWS')
182
223
  directory = storage.directories.new(:key => 'fog.io')
224
+
225
+ # write web page files to versioned 'folder'
183
226
  for file_path in Dir.glob('docs/_site/**/*')
184
227
  next if File.directory?(file_path)
185
228
  file_name = file_path.gsub('docs/_site/', '')
186
229
  key = '' << version << '/' << file_name
187
- Formatador.redisplay(' ' * 80) # clear last line
188
- Formatador.redisplay('Uploading ' << key)
230
+ Formatador.redisplay(' ' * 128)
231
+ Formatador.redisplay("Uploading [bold]#{key}[/]")
189
232
  if File.extname(file_name) == '.html'
190
233
  # rewrite links with version
191
234
  body = File.read(file_path)
235
+ body.gsub!(/vX.Y.Z/, 'v' << version)
192
236
  body.gsub!(/='\//, %{='/} << version << '/')
193
237
  body.gsub!(/="\//, %{="/} << version << '/')
194
238
  content_type = 'text/html'
239
+ directory.files.create(
240
+ :body => redirecter(key),
241
+ :content_type => 'text/html',
242
+ :key => 'latest/' << file_name,
243
+ :public => true
244
+ )
195
245
  else
196
246
  body = File.open(file_path)
197
247
  content_type = nil # leave it up to mime-types
@@ -203,10 +253,35 @@ task :docs do
203
253
  :public => true
204
254
  )
205
255
  end
256
+ Formatador.redisplay(' ' * 128)
257
+ Formatador.redisplay('Uploaded docs/_site')
258
+
259
+ # write rdoc files to versioned 'folder'
260
+ Rake::Task[:rdoc].invoke
261
+ for file_path in Dir.glob('rdoc/**/*')
262
+ next if File.directory?(file_path)
263
+ file_name = file_path.gsub('rdoc/', '')
264
+ key = '' << version << '/rdoc/' << file_name
265
+ Formatador.redisplay(' ' * 128)
266
+ Formatador.redisplay("Uploading [bold]#{key}[/]")
267
+ directory.files.create(
268
+ :body => File.open(file_path),
269
+ :key => key,
270
+ :public => true
271
+ )
272
+ end
273
+ Formatador.redisplay(' ' * 128)
274
+ directory.files.create(
275
+ :body => redirecter("#{version}/rdoc/index.html"),
276
+ :content_type => 'text/html',
277
+ :key => 'latest/rdoc/index.html',
278
+ :public => true
279
+ )
280
+ Formatador.redisplay('Uploaded rdoc')
206
281
 
207
282
  # write base index with redirect to new version
208
283
  directory.files.create(
209
- :body => '<!doctype html><head><script>window.location = "http://fog.io/' << version << '"</script></head></html>',
284
+ :body => redirecter(version),
210
285
  :content_type => 'text/html',
211
286
  :key => 'index.html',
212
287
  :public => true
@@ -214,3 +289,17 @@ task :docs do
214
289
 
215
290
  Formatador.display_line
216
291
  end
292
+
293
+ def redirecter(path)
294
+ redirecter = <<-HTML
295
+ <!doctype html>
296
+ <head>
297
+ <title>fog</title>
298
+ <meta http-equiv="REFRESH" content="0;url=http://fog.io/#{path}">
299
+ </head>
300
+ <body>
301
+ <a href="http://fog.io/#{path}">redirecting to lastest (#{path})</a>
302
+ </body>
303
+ </html>
304
+ HTML
305
+ end
data/bin/fog CHANGED
@@ -10,7 +10,7 @@ end
10
10
 
11
11
  require 'fog/bin'
12
12
 
13
- providers = Fog.providers
13
+ providers = Fog.available_providers
14
14
  providers = if providers.length > 1
15
15
  providers[0...-1].join(', ') << ' and ' << providers[-1]
16
16
  else
@@ -1,3 +1,20 @@
1
+ 0.8.1 05/13/2011 3a452347a396f0ad1fea7f5475fb3c349b10f527
2
+ =========================================================
3
+
4
+ [aws|compute]
5
+ less confusing explanation comment. thanks geemus
6
+
7
+ [compute|aws]
8
+ Fix describe_instances filtering. thanks ktheory
9
+ Add get_password_data request. thanks ktheory
10
+
11
+ [core]
12
+ Add test for Fog::Parsers::Base. thanks ktheory
13
+ handle busted ENV['HOME']. thanks pfalcone closes #301. thanks geemus
14
+ update fog.io in release task. thanks geemus
15
+ add hash to changelog. thanks geemus
16
+ work toward automating changelog. thanks geemus
17
+
1
18
  0.8.0 05/12/2011 27bf76d1f881bec0f900cd11d5c2a10dce4856ca
2
19
  =========================================================
3
20
 
@@ -33,7 +33,7 @@
33
33
  <a href="/"><img src="/public/images/fog.png" title="fog" /></a>
34
34
  <h1>{{ page.title }}</h1>
35
35
  <dl>
36
- <dt>version</dt><dd>v0.7.2</dd>
36
+ <dt>version</dt><dd>vX.Y.Z</dd>
37
37
  <dt>install</dt><dd><code>gem install fog</code></dd>
38
38
  <dt>source</dt><dd><a href="http://github.com/geemus/fog">geemus/fog</a></dd>
39
39
  </dl>
@@ -46,6 +46,7 @@
46
46
  <h2>Services</h2>
47
47
  <ul>
48
48
  <li><a href="/cdn">CDN</a></li>
49
+ <li><a href="/compute">Compute</a></li>
49
50
  <li><a href="/dns">DNS</a></li>
50
51
  <li><a href="/storage">Storage</a></li>
51
52
  {% for post in site.posts %}
@@ -201,7 +201,7 @@ For instance:
201
201
  class Mock
202
202
 
203
203
  def destroy_server(server_identity)
204
- if data = @data[:servers].delete(server_identity)
204
+ if data = self.data[:servers].delete(server_identity)
205
205
  response = Excon::Response.new
206
206
  response.status = 202
207
207
  response.body = data
@@ -0,0 +1,104 @@
1
+ ---
2
+ layout: default
3
+ title: Compute
4
+ ---
5
+
6
+ Compute is the lifeblood of the cloud, but with great power comes great complication. Compute opens up huge swaths of potential, but it varies greatly in both capabilities and usage from provider to provider. Thankfully fog helps to abstract these idiosyncrasies to provide a more seamless experience.
7
+
8
+ ## Installing fog
9
+
10
+ fog is distributed as a RubyGem:
11
+
12
+ gem install fog
13
+
14
+ Or for bundler users, you can add it in your Gemfile:
15
+
16
+ gem "fog"
17
+
18
+ ## Using Amazon EC2 and fog
19
+
20
+ Sign up for an account <a href="http://aws-portal.amazon.com/gp/aws/developer/subscription/index.html?productCode=AmazonEC2">here</a> and copy down your secret access key and access key id from <a href="http://aws-portal.amazon.com/gp/aws/developer/account/index.html?action=access-key">here</a>. We are about to get into the code samples, so be sure to fill in anything in ALL_CAPS with your own values!
21
+
22
+ First, create a connection with your new account:
23
+
24
+ require 'rubygems'
25
+ require 'fog'
26
+
27
+ # create a connection
28
+ connection = Fog::Compute.new(
29
+ :provider => 'AWS',
30
+ :aws_secret_access_key => YOUR_SECRET_ACCESS_KEY,
31
+ :aws_access_key_id => YOUR_SECRET_ACCESS_KEY_ID
32
+ )
33
+
34
+ With that in hand we are ready to start making EC2 calls!
35
+
36
+ ## Servers the EC2 way
37
+
38
+ Creating a server on EC2 is very easy if you are willing to accept the defaults (the smallest server size, using Ubuntu 10.04 LTS).
39
+
40
+ server = connection.servers.create
41
+
42
+ You can then list your servers to see that it now appears:
43
+
44
+ connection.servers
45
+
46
+ Rather than worrying about the whole list, we can also just get the latest data for just our server:
47
+
48
+ server.reload
49
+
50
+ That can get tedious quickly however, especially when servers can take several minutes to boot. Fog has `wait_for` for cases like this and `ready?` for checking to see when a server has completed its start up.
51
+
52
+ server.wait_for { ready? }
53
+
54
+ Once we are done with that we can shut it down.
55
+
56
+ server.destroy
57
+
58
+ ## Bootstrap: Servers the fog Way
59
+
60
+ Cycling servers is great, but in order to actually ssh in we need to setup ssh keys and open ports. But rather than worrying about the nitty gritty, we will utilize `bootstrap`. NOTE: normally we could leave out username and use the default (root), but the default Ubuntu from Canonical uses the ubuntu username instead.
61
+
62
+ server = connection.servers.bootstrap(:private_key_path => '~/.ssh/id_rsa', :public_key_path => '~/.ssh/id_rsa.pub', :username => 'ubuntu')
63
+
64
+ Bootstrap will create the server, but it will also make sure that port 22 is open for traffic and has ssh keys setup. In order to hook everything up it will need the server to be running, so by the time it finishes it will be ready. You can then make commands to it directly:
65
+
66
+ server.ssh('pwd')
67
+ server.ssh(['pwd', 'whoami'])
68
+
69
+ These return an array of results, where each has stdout, stderr and status values so you can check out what your commands accomplished. Now just shut it down to make sure you don't continue getting charged.
70
+
71
+ server.destroy
72
+
73
+ ## Rackspace Cloud Servers
74
+
75
+ Rackspace has <a href="http://www.rackspacecloud.com/cloud_hosting_products/servers">Cloud Servers</a> and you can sign up <a href="https://www.rackspacecloud.com/signup">here</a> and get your credentials <a href="https://manage.rackspacecloud.com/APIAccess.do">here</a>.
76
+
77
+ # create a connection
78
+ connection = Fog::Compute.new(
79
+ :provider => 'Rackspace',
80
+ :rackspace_username => RACKSPACE_USERNAME,
81
+ :rackspace_api_key => RACKSPACE_API_KEY
82
+ )
83
+
84
+ We will skip over learning how to do this the 'Rackspace Way' and instead jump right to using bootstrap to get their smallest Ubuntu 10.04 LTS server.
85
+
86
+ server = connection.servers.bootstrap
87
+
88
+ You can run all the same ssh commands and do what you need to, then once again shutdown to ensure you are not charged once you are done.
89
+
90
+ server.destroy
91
+
92
+ ## Mocking out Compute
93
+
94
+ You can also start any of these scripts with `Fog.mock!` or start the fog interactive tool from the command line with `FOG_MOCK=true fog` to run in mock mode. In this mode commands are run as local simulation, so no cloud resources are ever consumed and things operate much faster.
95
+
96
+ ## Cleaning up
97
+
98
+ To cover your tracks its a good idea to check for running servers and shut them down, here is one way you might do that.
99
+
100
+ connection.servers.select {|server| server.ready? && server.destroy}
101
+
102
+ ## Summary
103
+
104
+ Compute can be tricky, but the abstractions in fog make it much easier to get started. With your servers up and running you can then focus on the task at hand and get some work done. Congratulations on adding a new tool to your arsenal and let us know what we can do better.
@@ -61,6 +61,7 @@ Wonder how you can get a lovely fog shirt? Look no further!
61
61
  Enjoy, and let me know what I can do to continue improving fog!
62
62
 
63
63
  * Work through the [fog tutorial](https://github.com/downloads/geemus/learn_fog/learn_fog.tar.gz)
64
+ * Read fog's [API documentation](/latest/rdoc)
64
65
  * Stay up to date by following [@fog](http://twitter.com/fog) and/or [@geemus](http://twitter.com/geemus) on Twitter.
65
66
  * Get and give help on the [#ruby-fog](irc://irc.freenode.net/ruby-fog) irc channel on Freenode
66
67
  * Follow release notes and discussions on the [mailing list](http://groups.google.com/group/ruby-fog)
@@ -170,6 +170,23 @@ Fog takes care of the rest so you can focus on your cover letter. And with the a
170
170
  file.destroy
171
171
  directory.destroy
172
172
 
173
+ ## Checking if a file already exists
174
+
175
+ Sometimes you might want to find out some information about a file without retrieving the whole file. You can do that using 'head'.
176
+
177
+ #returns nil if the file doesn't exist
178
+ unless directory.files.head('resume.html')
179
+ #do something, like creating the file
180
+ end
181
+
182
+ #returns a hash with the following data:
183
+ # 'key' - Key for the object
184
+ # 'Content-Length' - Size of object contents
185
+ # 'Content-Type' - MIME type of object
186
+ # 'ETag' - Etag of object
187
+ # 'Last-Modified' - Last modified timestamp for object
188
+ puts directory.files.head('resume.html')
189
+
173
190
  ## Summary
174
191
 
175
192
  All done. Try out all the different options and let me know if you have any bugs or issues. I also wrote up a more <a href="https://gist.github.com/710869">consolidated example as a script</a> that you can use for reference.
@@ -6,8 +6,8 @@ Gem::Specification.new do |s|
6
6
  ## If your rubyforge_project name is different, then edit it and comment out
7
7
  ## the sub! line in the Rakefile
8
8
  s.name = 'fog'
9
- s.version = '0.8.1'
10
- s.date = '2011-05-13'
9
+ s.version = '0.8.2'
10
+ s.date = '2011-05-26'
11
11
  s.rubyforge_project = 'fog'
12
12
 
13
13
  ## Make sure your summary is short. The description may be as long
@@ -49,6 +49,7 @@ Gem::Specification.new do |s|
49
49
  ## those that are only needed during development
50
50
  s.add_development_dependency('jekyll')
51
51
  s.add_development_dependency('rake')
52
+ s.add_development_dependency('rdoc')
52
53
  s.add_development_dependency('rspec', '1.3.1')
53
54
  s.add_development_dependency('shindo', '0.3.4')
54
55
  s.add_development_dependency('virtualbox', '0.8.3')
data/lib/fog.rb CHANGED
@@ -3,7 +3,7 @@ require File.join(File.dirname(__FILE__), 'fog', 'core')
3
3
  module Fog
4
4
 
5
5
  unless const_defined?(:VERSION)
6
- VERSION = '0.8.1'
6
+ VERSION = '0.8.2'
7
7
  end
8
8
 
9
9
  end
@@ -37,6 +37,7 @@ module Fog
37
37
  class Mock
38
38
 
39
39
  def initialize(options={})
40
+ Fog::Mock.not_implemented
40
41
  end
41
42
 
42
43
  end
@@ -45,6 +45,7 @@ module Fog
45
45
  class Mock
46
46
 
47
47
  def initialize(options={})
48
+ Fog::Mock.not_implemented
48
49
  end
49
50
 
50
51
  end