fog 1.16.0 → 1.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. data/.travis.yml +6 -0
  2. data/README.md +25 -0
  3. data/changelog.txt +108 -0
  4. data/fog.gemspec +7 -5
  5. data/lib/fog/aws.rb +8 -2
  6. data/lib/fog/aws/cloud_formation.rb +0 -1
  7. data/lib/fog/aws/compute.rb +1 -1
  8. data/lib/fog/aws/elb.rb +0 -1
  9. data/lib/fog/aws/iam.rb +4 -1
  10. data/lib/fog/aws/models/iam/access_key.rb +5 -1
  11. data/lib/fog/aws/models/iam/access_keys.rb +0 -1
  12. data/lib/fog/aws/parsers/compute/describe_reserved_instances.rb +2 -1
  13. data/lib/fog/aws/parsers/storage/get_bucket_tagging.rb +37 -0
  14. data/lib/fog/aws/requests/compute/copy_image.rb +1 -1
  15. data/lib/fog/aws/requests/compute/describe_reserved_instances.rb +1 -0
  16. data/lib/fog/aws/requests/compute/purchase_reserved_instances_offering.rb +1 -0
  17. data/lib/fog/aws/requests/iam/create_access_key.rb +22 -15
  18. data/lib/fog/aws/requests/iam/list_access_keys.rb +15 -11
  19. data/lib/fog/aws/requests/iam/update_access_key.rb +22 -0
  20. data/lib/fog/aws/requests/storage/delete_bucket_tagging.rb +46 -0
  21. data/lib/fog/aws/requests/storage/get_bucket_tagging.rb +53 -0
  22. data/lib/fog/aws/requests/storage/put_bucket_tagging.rb +60 -0
  23. data/lib/fog/aws/storage.rb +32 -19
  24. data/lib/fog/brightbox/models/compute/load_balancer.rb +47 -2
  25. data/lib/fog/core/logger.rb +4 -5
  26. data/lib/fog/core/service.rb +1 -1
  27. data/lib/fog/google/README.md +2 -2
  28. data/lib/fog/google/compute.rb +2 -1
  29. data/lib/fog/google/examples/bootstrap.rb +1 -1
  30. data/lib/fog/google/examples/get_list_images.rb +1 -2
  31. data/lib/fog/google/examples/network.rb +2 -0
  32. data/lib/fog/google/models/compute/disk.rb +23 -0
  33. data/lib/fog/google/models/compute/snapshot.rb +1 -0
  34. data/lib/fog/google/requests/compute/insert_server.rb +1 -1
  35. data/lib/fog/google/requests/compute/insert_snapshot.rb +49 -0
  36. data/lib/fog/google/storage.rb +54 -29
  37. data/lib/fog/hp.rb +0 -4
  38. data/lib/fog/hp/block_storage.rb +2 -2
  39. data/lib/fog/hp/cdn.rb +2 -2
  40. data/lib/fog/hp/compute.rb +2 -2
  41. data/lib/fog/hp/storage.rb +3 -3
  42. data/lib/fog/linode/compute.rb +1 -1
  43. data/lib/fog/linode/dns.rb +1 -1
  44. data/lib/fog/rackspace/block_storage.rb +0 -2
  45. data/lib/fog/vcloud_director/compute.rb +76 -2
  46. data/lib/fog/vcloud_director/generators/compute/{edge_gateway.rb → edge_gateway_service_configuration.rb} +2 -1
  47. data/lib/fog/vcloud_director/requests/compute/delete_disk.rb +33 -0
  48. data/lib/fog/vcloud_director/requests/compute/delete_media.rb +82 -2
  49. data/lib/fog/vcloud_director/requests/compute/get_disk.rb +99 -1
  50. data/lib/fog/vcloud_director/requests/compute/get_disk_owner.rb +45 -0
  51. data/lib/fog/vcloud_director/requests/compute/get_edge_gateway.rb +33 -19
  52. data/lib/fog/vcloud_director/requests/compute/get_media.rb +75 -4
  53. data/lib/fog/vcloud_director/requests/compute/get_media_owner.rb +34 -4
  54. data/lib/fog/vcloud_director/requests/compute/get_task.rb +122 -3
  55. data/lib/fog/vcloud_director/requests/compute/get_task_list.rb +80 -37
  56. data/lib/fog/vcloud_director/requests/compute/{get_vms_disks_attached_to.rb → get_vms_disk_attached_to.rb} +16 -2
  57. data/lib/fog/vcloud_director/requests/compute/post_cancel_task.rb +18 -0
  58. data/lib/fog/vcloud_director/requests/compute/post_clone_media.rb +52 -1
  59. data/lib/fog/vcloud_director/requests/compute/post_configure_edge_gateway_services.rb +14 -2
  60. data/lib/fog/vcloud_director/requests/compute/post_instantiate_vapp_template.rb +2 -2
  61. data/lib/fog/vcloud_director/requests/compute/post_upload_disk.rb +133 -0
  62. data/lib/fog/vcloud_director/requests/compute/post_upload_media.rb +48 -4
  63. data/lib/fog/vcloud_director/requests/compute/put_guest_customization_section_vapp.rb +103 -26
  64. data/lib/fog/vcloud_director/requests/compute/put_network_connection_system_section_vapp.rb +90 -32
  65. data/lib/fog/version.rb +1 -1
  66. data/lib/fog/vsphere/compute.rb +29 -14
  67. data/lib/fog/vsphere/models/compute/server.rb +18 -6
  68. data/lib/fog/vsphere/requests/compute/create_vm.rb +1 -0
  69. data/lib/fog/vsphere/requests/compute/vm_clone.rb +2 -9
  70. data/lib/fog/vsphere/requests/compute/vm_reconfig_cpus.rb +2 -2
  71. data/lib/fog/xenserver/requests/compute/create_server.rb +1 -1
  72. data/tests/aws/requests/compute/instance_tests.rb +1 -0
  73. data/tests/aws/requests/storage/bucket_tests.rb +19 -3
  74. data/tests/brightbox/compute/schema.rb +1 -0
  75. data/tests/core/credential_tests.rb +7 -1
  76. data/tests/core/parser_tests.rb +1 -1
  77. data/tests/rackspace/block_storage_tests.rb +1 -1
  78. data/tests/rackspace/cdn_tests.rb +1 -1
  79. data/tests/rackspace/compute_tests.rb +1 -1
  80. data/tests/rackspace/compute_v2_tests.rb +1 -1
  81. data/tests/rackspace/databases_tests.rb +1 -1
  82. data/tests/rackspace/dns_tests.rb +1 -1
  83. data/tests/rackspace/load_balancer_tests.rb +1 -1
  84. data/tests/rackspace/storage_tests.rb +1 -1
  85. data/tests/vcloud_director/ensure_list_tests.rb +30 -2
  86. data/tests/vcloud_director/requests/compute/disk_tests.rb +160 -5
  87. data/tests/vcloud_director/requests/compute/edge_gateway_tests.rb +59 -1
  88. data/tests/vcloud_director/requests/compute/helper.rb +5 -1
  89. data/tests/vcloud_director/requests/compute/media_tests.rb +109 -99
  90. data/tests/vcloud_director/requests/compute/schema_helper.rb +15 -2
  91. data/tests/vcloud_director/requests/compute/task_tests.rb +21 -6
  92. metadata +27 -21
@@ -211,7 +211,7 @@ module Fog
211
211
  unless recognizes.empty?
212
212
  unrecognized = options.keys - requirements - recognized
213
213
  unless unrecognized.empty?
214
- raise ArgumentError, "Unrecognized arguments: #{unrecognized.join(', ')}"
214
+ Fog::Logger.warning("Unrecognized arguments: #{unrecognized.join(', ')}")
215
215
  end
216
216
  end
217
217
  end
@@ -8,7 +8,7 @@ Google Cloud Storage originally was very similar to Amazon's S3. Because of this
8
8
 
9
9
  ## Compute
10
10
 
11
- Google Compute Engine is a Virtual Machine hosting service. Currently it is built on version [v1beta15](https://developers.google.com/compute/docs/reference/v1beta15/) of the GCE API.
11
+ Google Compute Engine is a Virtual Machine hosting service. Currently it is built on version [v1beta16](https://developers.google.com/compute/docs/reference/v1beta16/) of the GCE API.
12
12
 
13
13
  Our implementation of the API currently supports
14
14
 
@@ -23,6 +23,6 @@ Features we are looking forward to implementing in the future:
23
23
  * Global Metadata support
24
24
  * Image creation
25
25
 
26
- v1beta15 is still in beta, so we can imagine lots of changes to the API. If you are using Fog to interact with GCE, please keep Fog up to date and [file issues](https://github.com/fog/fog/issues?labels=google) for any anomalies you see.
26
+ v1beta16 is still in beta, so we can imagine lots of changes to the API. If you are using Fog to interact with GCE, please keep Fog up to date and [file issues](https://github.com/fog/fog/issues?labels=google) for any anomalies you see.
27
27
 
28
28
  Thanks!
@@ -42,6 +42,7 @@ module Fog
42
42
  request :insert_image
43
43
  request :insert_network
44
44
  request :insert_server
45
+ request :insert_snapshot
45
46
 
46
47
  request :set_metadata
47
48
 
@@ -763,7 +764,7 @@ module Fog
763
764
 
764
765
  def initialize(options)
765
766
  base_url = 'https://www.googleapis.com/compute/'
766
- api_version = 'v1beta15'
767
+ api_version = 'v1beta16'
767
768
  api_scope_url = 'https://www.googleapis.com/auth/compute'
768
769
 
769
770
  @project = options[:google_project]
@@ -5,5 +5,5 @@ def test
5
5
  server.wait_for { sshable? }
6
6
 
7
7
  raise "Could not bootstrap sshable server." unless server.ssh("whoami")
8
- raise "Cloud note delete server." unless server.destroy
8
+ raise "Could not delete server." unless server.destroy
9
9
  end
@@ -19,9 +19,8 @@ def test
19
19
  if custom_img_name
20
20
  # puts 'Fetching a single image from the custom project'
21
21
  # puts '----------------------------------------------'
22
- img = connection.images.get(custom_img_name)
22
+ img = connection.images.get(custom_img_name.name)
23
23
  raise 'Could not GET the (custom) image' unless img
24
24
  # puts img.inspect
25
25
  end
26
-
27
26
  end
@@ -18,4 +18,6 @@ def test
18
18
 
19
19
  # The network won't have any firewall rules, so we won't be able to ssh in.
20
20
  server.wait_for { ready? }
21
+
22
+ raise "Could not delete server." unless server.destroy
21
23
  end
@@ -84,6 +84,29 @@ module Fog
84
84
  self
85
85
  end
86
86
 
87
+ def create_snapshot(snap_name, snap_desc)
88
+ requires :name
89
+ requires :zone_name
90
+
91
+ if snap_name.nil? or snap_name.empty?
92
+ raise ArgumentError, 'Invalid snapshot name'
93
+ end
94
+
95
+ options = {
96
+ 'name' => snap_name,
97
+ 'description' => snap_desc,
98
+ }
99
+
100
+ service.insert_snapshot(name, self.zone, service.project, options)
101
+ data = service.backoff_if_unfound {
102
+ service.get_snapshot(snap_name, service.project).body
103
+ }
104
+ service.snapshots.merge_attributes(data)
105
+
106
+ # Try to return the representation of the snapshot we created
107
+ service.snapshots.get(snap_name)
108
+ end
109
+
87
110
  RUNNING_STATE = "READY"
88
111
 
89
112
  end
@@ -15,6 +15,7 @@ module Fog
15
15
  attribute :source_disk , :aliases => 'sourceDisk'
16
16
  attribute :source_disk_id , :aliases => 'sourceDiskId'
17
17
  attribute :description
18
+ attribute :status
18
19
 
19
20
  def reload
20
21
  requires :name
@@ -125,7 +125,7 @@ module Fog
125
125
  if ! network.nil?
126
126
  networkInterface = { 'network' => @api_url + @project + "/global/networks/#{network}" }
127
127
  if external_ip
128
- networkInterface['accessConfigs'] = [{'type' => 'ONE_TO_ONE_NAT', 'name' => 'External NAT'}]
128
+ networkInterface['accessConfigs'] = [{'type' => 'ONE_TO_ONE_NAT', 'name' => 'External NAT', 'natIP' => external_ip}]
129
129
  end
130
130
  networkInterfaces << networkInterface
131
131
  end
@@ -0,0 +1,49 @@
1
+ module Fog
2
+ module Compute
3
+ class Google
4
+
5
+ class Mock
6
+
7
+ def insert_snapshot(snap_name)
8
+ Fog::Mock.not_implemented
9
+ end
10
+
11
+ end
12
+
13
+ class Real
14
+
15
+ def insert_snapshot(disk_name, zone_name, project=@project, opts={})
16
+
17
+ # This is unfortunate, since we might be called from 2 contexts
18
+ # 1. disk.snapshot <-- here validation of disk_name is not needed
19
+ # 2. snapshot.create <-- here we must validate the disk_name
20
+ #
21
+ # Validation would involve 'get'ing the disk by that name. This is
22
+ # redundant (and expensive) for case (1) which is likely the common
23
+ # codepath. So we won't do it.
24
+
25
+ api_method = @compute.disks.create_snapshot
26
+
27
+ parameters = {
28
+ 'disk' => disk_name,
29
+ 'zone' => zone_name,
30
+ 'project' => @project,
31
+ }
32
+
33
+ snap_name = opts.delete('name')
34
+ raise ArgumentError.new('Must specify snapshot name') unless snap_name
35
+ body_object = { 'name' => snap_name }
36
+
37
+ # Merge in any remaining options (description)
38
+ body_object.merge(opts)
39
+
40
+ result = self.build_result(api_method, parameters,
41
+ body_object)
42
+ response = self.build_response(result)
43
+ end
44
+
45
+ end
46
+
47
+ end
48
+ end
49
+ end
@@ -61,6 +61,39 @@ module Fog
61
61
  "#{params[:host]}/#{params[:path]}?#{query.join('&')}"
62
62
  end
63
63
 
64
+ def request_params(params)
65
+ subdomain = params[:host].split(".#{@host}").first
66
+ unless subdomain =~ /^(?!goog)(?:[a-z]|\d(?!\d{0,2}(?:\.\d{1,3}){3}$))(?:[a-z0-9]|\.(?![\.\-])|\-(?![\.])){1,61}[a-z0-9]$/
67
+ if subdomain =~ /_/
68
+ # https://github.com/fog/fog/pull/1258#issuecomment-10248620.
69
+ Fog::Logger.warning("fog: the specified google storage bucket name (#{subdomain}) is not DNS compliant (only characters a through z, digits 0 through 9, and the hyphen).")
70
+ else
71
+ # - Bucket names must contain only lowercase letters, numbers, dashes (-), underscores (_), and dots (.). Names containing dots require verification.
72
+ # - Bucket names must start and end with a number or letter.
73
+ # - Bucket names must contain 3 to 63 characters. Names containing dots can contain up to 222 characters, but each dot-separated component can be no longer than 63 characters.
74
+ # - Bucket names cannot be represented as an IP address in dotted-decimal notation (for example, 192.168.5.4).
75
+ # - Bucket names cannot begin with the "goog" prefix.
76
+ # - Also, for DNS compliance, you should not have a period adjacent to another period or dash. For example, ".." or "-." or ".-" are not acceptable.
77
+ Fog::Logger.warning("fog: the specified google storage bucket name (#{subdomain}) is not a valid dns name. See: https://developers.google.com/storage/docs/bucketnaming")
78
+ end
79
+ params[:host] = params[:host].split("#{subdomain}.")[-1]
80
+ if params[:path]
81
+ params[:path] = "#{subdomain}/#{params[:path]}"
82
+ else
83
+ params[:path] = "#{subdomain}"
84
+ end
85
+ subdomain = nil
86
+ end
87
+
88
+ if subdomain && subdomain != @host
89
+ params[:subdomain] = subdomain
90
+ end
91
+
92
+ params[:scheme] ||= @scheme
93
+ params[:port] ||= @port
94
+ params
95
+ end
96
+
64
97
  end
65
98
 
66
99
  class Mock
@@ -193,11 +226,10 @@ module Fog
193
226
  @persistent = options.fetch(:persistent, true)
194
227
  @port = options[:port] || 443
195
228
  @scheme = options[:scheme] || 'https'
196
- @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
197
229
  end
198
230
 
199
231
  def reload
200
- @connection.reset
232
+ @connection.reset if @connection
201
233
  end
202
234
 
203
235
  def signature(params)
@@ -222,31 +254,8 @@ DATA
222
254
  end
223
255
  string_to_sign << "#{canonical_google_headers}"
224
256
 
225
- subdomain = params[:host].split(".#{@host}").first
226
- unless subdomain =~ /^(?!goog)(?:[a-z]|\d(?!\d{0,2}(?:\.\d{1,3}){3}$))(?:[a-z0-9]|\.(?![\.\-])|\-(?![\.])){1,61}[a-z0-9]$/
227
- if subdomain =~ /_/
228
- # https://github.com/fog/fog/pull/1258#issuecomment-10248620.
229
- Fog::Logger.warning("fog: the specified google storage bucket name (#{subdomain}) is not DNS compliant (only characters a through z, digits 0 through 9, and the hyphen).")
230
- else
231
- # - Bucket names must contain only lowercase letters, numbers, dashes (-), underscores (_), and dots (.). Names containing dots require verification.
232
- # - Bucket names must start and end with a number or letter.
233
- # - Bucket names must contain 3 to 63 characters. Names containing dots can contain up to 222 characters, but each dot-separated component can be no longer than 63 characters.
234
- # - Bucket names cannot be represented as an IP address in dotted-decimal notation (for example, 192.168.5.4).
235
- # - Bucket names cannot begin with the "goog" prefix.
236
- # - Also, for DNS compliance, you should not have a period adjacent to another period or dash. For example, ".." or "-." or ".-" are not acceptable.
237
- Fog::Logger.warning("fog: the specified google storage bucket name (#{subdomain}) is not a valid dns name. See: https://developers.google.com/storage/docs/bucketnaming")
238
- end
239
- params[:host] = params[:host].split("#{subdomain}.")[-1]
240
- if params[:path]
241
- params[:path] = "#{subdomain}/#{params[:path]}"
242
- else
243
- params[:path] = "#{subdomain}"
244
- end
245
- subdomain = nil
246
- end
247
-
248
257
  canonical_resource = "/"
249
- unless subdomain.nil? || subdomain == @host
258
+ if subdomain = params.delete(:subdomain)
250
259
  canonical_resource << "#{CGI.escape(subdomain).downcase}/"
251
260
  end
252
261
  canonical_resource << "#{params[:path]}"
@@ -263,16 +272,32 @@ DATA
263
272
  Base64.encode64(signed_string).chomp!
264
273
  end
265
274
 
275
+ def connection(scheme, host, port)
276
+ uri = "#{scheme}://#{host}:#{port}"
277
+ if @persistent
278
+ unless uri == @connection_uri
279
+ @connection_uri = uri
280
+ reload
281
+ @connection = nil
282
+ end
283
+ else
284
+ @connection = nil
285
+ end
286
+ @connection ||= Fog::Connection.new(uri, @persistent, @connection_options)
287
+ end
266
288
 
267
289
  private
268
290
 
269
291
  def request(params, &block)
292
+ params = request_params(params)
293
+ scheme = params.delete(:scheme)
294
+ host = params.delete(:host)
295
+ port = params.delete(:port)
296
+
270
297
  params[:headers]['Date'] = Fog::Time.now.to_date_header
271
298
  params[:headers]['Authorization'] = "GOOG1 #{@google_storage_access_key_id}:#{signature(params)}"
272
299
 
273
- response = @connection.request(params, &block)
274
-
275
- response
300
+ connection(scheme, host, port).request(params, &block)
276
301
  end
277
302
  end
278
303
  end
@@ -85,8 +85,6 @@ module Fog
85
85
  'X-Auth-Key' => @hp_secret_key,
86
86
  'X-Auth-User' => @hp_access_key
87
87
  },
88
- :host => @host,
89
- :port => @port,
90
88
  :method => 'GET',
91
89
  :path => @auth_path
92
90
  })
@@ -162,8 +160,6 @@ module Fog
162
160
  :headers => {
163
161
  'Content-Type' => 'application/json'
164
162
  },
165
- :host => @host,
166
- :port => @port,
167
163
  :method => 'POST',
168
164
  :body => Fog::JSON.encode(request_body),
169
165
  :path => @auth_path
@@ -5,7 +5,7 @@ module Fog
5
5
  class BlockStorage < Fog::Service
6
6
 
7
7
  requires :hp_secret_key, :hp_tenant_id, :hp_avl_zone
8
- recognizes :hp_auth_uri
8
+ recognizes :hp_auth_uri, :hp_service_type
9
9
  recognizes :persistent, :connection_options
10
10
  recognizes :hp_use_upass_auth_style, :hp_auth_version, :user_agent
11
11
  recognizes :hp_access_key, :hp_account_id # :hp_account_id is deprecated use hp_access_key instead
@@ -109,7 +109,7 @@ module Fog
109
109
  auth_version = auth_version.to_s.downcase.to_sym
110
110
 
111
111
  ### Pass the service name for object storage to the authentication call
112
- options[:hp_service_type] = "Block Storage"
112
+ options[:hp_service_type] ||= "Block Storage"
113
113
  @hp_tenant_id = options[:hp_tenant_id]
114
114
  @hp_avl_zone = options[:hp_avl_zone]
115
115
 
@@ -6,7 +6,7 @@ module Fog
6
6
  class HP < Fog::Service
7
7
 
8
8
  requires :hp_secret_key, :hp_tenant_id, :hp_avl_zone
9
- recognizes :hp_auth_uri, :hp_cdn_uri
9
+ recognizes :hp_auth_uri, :hp_cdn_uri, :hp_service_type
10
10
  recognizes :hp_use_upass_auth_style, :hp_auth_version, :user_agent
11
11
  recognizes :persistent, :connection_options
12
12
  recognizes :hp_access_key, :hp_account_id # :hp_account_id is deprecated use hp_access_key instead
@@ -84,7 +84,7 @@ module Fog
84
84
  auth_version = auth_version.to_s.downcase.to_sym
85
85
 
86
86
  ### Pass the service name for object storage to the authentication call
87
- options[:hp_service_type] = "CDN"
87
+ options[:hp_service_type] ||= "CDN"
88
88
  @hp_tenant_id = options[:hp_tenant_id]
89
89
 
90
90
  ### Make the authentication call
@@ -6,7 +6,7 @@ module Fog
6
6
  class HP < Fog::Service
7
7
 
8
8
  requires :hp_secret_key, :hp_tenant_id, :hp_avl_zone
9
- recognizes :hp_auth_uri
9
+ recognizes :hp_auth_uri, :hp_service_type
10
10
  recognizes :hp_use_upass_auth_style, :hp_auth_version, :user_agent
11
11
  recognizes :persistent, :connection_options
12
12
  recognizes :hp_access_key, :hp_account_id # :hp_account_id is deprecated use hp_access_key instead
@@ -193,7 +193,7 @@ module Fog
193
193
  auth_version = auth_version.to_s.downcase.to_sym
194
194
 
195
195
  ### Pass the service name for compute via the options hash
196
- options[:hp_service_type] = "Compute"
196
+ options[:hp_service_type] ||= "Compute"
197
197
  @hp_tenant_id = options[:hp_tenant_id]
198
198
 
199
199
  ### Make the authentication call
@@ -6,11 +6,11 @@ module Fog
6
6
  class HP < Fog::Service
7
7
 
8
8
  requires :hp_secret_key, :hp_tenant_id, :hp_avl_zone
9
- recognizes :hp_auth_uri, :hp_cdn_ssl, :hp_cdn_uri
9
+ recognizes :hp_auth_uri, :hp_cdn_ssl, :hp_cdn_uri, :hp_service_type
10
10
  recognizes :persistent, :connection_options
11
11
  recognizes :hp_use_upass_auth_style, :hp_auth_version, :user_agent
12
12
  recognizes :hp_access_key, :hp_account_id # :hp_account_id is deprecated use hp_access_key instead
13
-
13
+
14
14
  # :os_account_meta_temp_url_key is an OpenStack specific setting used to generate temporary urls.
15
15
  recognizes :os_account_meta_temp_url_key
16
16
 
@@ -321,7 +321,7 @@ module Fog
321
321
  auth_version = auth_version.to_s.downcase.to_sym
322
322
 
323
323
  ### Pass the service name for object storage to the authentication call
324
- options[:hp_service_type] = "Object Storage"
324
+ options[:hp_service_type] ||= "Object Storage"
325
325
  @hp_tenant_id = options[:hp_tenant_id]
326
326
  @hp_avl_zone = options[:hp_avl_zone]
327
327
  @os_account_meta_temp_url_key = options[:os_account_meta_temp_url_key]
@@ -95,7 +95,7 @@ module Fog
95
95
  params[:query] ||= {}
96
96
  params[:query].merge!(:api_key => @linode_api_key)
97
97
 
98
- response = @connection.request(params.merge!({:host => @host}))
98
+ response = @connection.request(params)
99
99
 
100
100
  unless response.body.empty?
101
101
  response.body = Fog::JSON.decode(response.body)
@@ -70,7 +70,7 @@ module Fog
70
70
  params[:query] ||= {}
71
71
  params[:query].merge!(:api_key => @linode_api_key)
72
72
 
73
- response = @connection.request(params.merge!({:host => @host}))
73
+ response = @connection.request(params)
74
74
 
75
75
  unless response.body.empty?
76
76
  response.body = Fog::JSON.decode(response.body)
@@ -26,8 +26,6 @@ module Fog
26
26
 
27
27
  model :volume_type
28
28
  collection :volume_types
29
- model :snapshot
30
- collection :snapshots
31
29
 
32
30
  model :snapshot
33
31
  collection :snapshots
@@ -187,7 +187,7 @@ module Fog
187
187
  request :get_vm_pending_question
188
188
  request :get_vms
189
189
  request :get_vms_by_metadata
190
- request :get_vms_disks_attached_to
190
+ request :get_vms_disk_attached_to
191
191
  request :get_vms_in_lease_from_query
192
192
  request :instantiate_vapp_template # to be deprecated
193
193
  request :post_acquire_ticket
@@ -231,6 +231,7 @@ module Fog
231
231
  request :post_update_vapp_metadata
232
232
  request :post_update_vapp_template_metadata
233
233
  request :post_upgrade_hw_version
234
+ request :post_upload_disk
234
235
  request :post_upload_media
235
236
  request :post_upload_vapp_template
236
237
  request :put_catalog_item_metadata_item_metadata
@@ -482,11 +483,27 @@ module Fog
482
483
  :name => 'vAppTemplate 1'
483
484
  }
484
485
  },
486
+ :disks => {},
485
487
  :edge_gateways => {
486
488
  uuid => {
487
489
  :name => 'MockEdgeGateway',
488
490
  :networks => [uplink_network_uuid, default_network_uuid],
489
- :vdc => vdc_uuid
491
+ :vdc => vdc_uuid,
492
+ :Configuration => {
493
+ :GatewayBackingConfig => "compact",
494
+ :GatewayInterfaces => {
495
+ :GatewayInterface => []},
496
+ :EdgeGatewayServiceConfiguration => {
497
+ :FirewallService => {
498
+ :IsEnabled => "true",
499
+ :DefaultAction => "drop",
500
+ :LogDefaultAction => "false",
501
+ :FirewallRule => []
502
+ },
503
+ :NatService => {:IsEnabled => "true"}},
504
+ :HaEnabled => "false",
505
+ :UseDefaultRouteForDnsRelay => "false"
506
+ }
490
507
  }
491
508
  },
492
509
  :medias => {},
@@ -612,6 +629,63 @@ module Fog
612
629
  [8,4,4,4,12].map {|i| Fog::Mock.random_hex(i)}.join('-')
613
630
  end
614
631
 
632
+ # Create a task.
633
+ #
634
+ # @param [String] operation A message describing the operation that is
635
+ # tracked by this task.
636
+ # @param [String] operation_name The short name of the operation that
637
+ # is tracked by this task.
638
+ # @param [Hash] owner Reference to the owner of the task. This is
639
+ # typically the object that the task is creating or updating.
640
+ # * :href<~String> - Contains the URI to the entity.
641
+ # * :type<~String> - Contains the MIME type of the entity.
642
+ # @return [String] Object identifier of the task.
643
+ def enqueue_task(operation, operation_name, owner, options={})
644
+ task_id = uuid
645
+ now = DateTime.now
646
+
647
+ data[:tasks][task_id] = {
648
+ :cancel_requested => false,
649
+ :details => '',
650
+ :expiry_time => now + 86400, # in 24 hours
651
+ :name => 'task',
652
+ :progress => 1,
653
+ :service_namespace => 'com.vmware.vcloud',
654
+ :start_time => now,
655
+ :status => 'running',
656
+ }.merge(options).merge(
657
+ :operation => operation,
658
+ :operation_name => operation_name,
659
+ :owner => owner
660
+ )
661
+
662
+ task_id
663
+ end
664
+
665
+ # @note As far as this method is concerned, the only possible task
666
+ # states are 'running' and 'success'.
667
+ #
668
+ # @param [Hash] response_body
669
+ # @return [Boolean]
670
+ def process_task(response_body)
671
+ task_id = response_body[:href].split('/').last
672
+ task = data[:tasks][task_id]
673
+
674
+ if task[:status] == 'running'
675
+ task[:end_time] = DateTime.now
676
+ task[:progress] = 100
677
+ task[:status] = 'success'
678
+
679
+ if task[:on_success]
680
+ task[:on_success].call
681
+ task.delete(:on_success)
682
+ end
683
+ end
684
+
685
+ return true if task[:status] == 'success'
686
+ raise TaskError.new "status: #{task[:status]}, error: #{task[:Error]}"
687
+ end
688
+
615
689
  def add_id_from_href!(data={})
616
690
  data[:id] = data[:href].split('/').last
617
691
  end