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
@@ -1,3 +1,3 @@
1
1
  module Fog
2
- VERSION = '1.16.0'
2
+ VERSION = '1.17.0'
3
3
  end
@@ -103,6 +103,7 @@ module Fog
103
103
  :tools_version => 'guest.toolsVersionStatus',
104
104
  :memory_mb => 'config.hardware.memoryMB',
105
105
  :cpus => 'config.hardware.numCPU',
106
+ :corespersocket => 'config.hardware.numCoresPerSocket',
106
107
  :overall_status => 'overallStatus',
107
108
  :guest_id => 'config.guestId',
108
109
  }
@@ -342,8 +343,35 @@ module Fog
342
343
  @vsphere_ssl = options[:vsphere_ssl] || true
343
344
  @vsphere_expected_pubkey_hash = options[:vsphere_expected_pubkey_hash]
344
345
  @vsphere_must_reauthenticate = false
345
-
346
+ @vsphere_is_vcenter = nil
346
347
  @connection = nil
348
+ connect
349
+ negotiate_revision(options[:vsphere_rev])
350
+ authenticate
351
+ end
352
+
353
+ def reload
354
+ connect
355
+ # Check if the negotiation was ever run
356
+ if @vsphere_is_vcenter.nil?
357
+ negotiate
358
+ end
359
+ authenticate
360
+ end
361
+
362
+ private
363
+ def negotiate_revision(revision = nil)
364
+ # Negotiate the API revision
365
+ if not revision
366
+ rev = @connection.serviceContent.about.apiVersion
367
+ @connection.rev = [ rev, ENV['FOG_VSPHERE_REV'] || '4.1' ].min
368
+ end
369
+
370
+ @vsphere_is_vcenter = @connection.serviceContent.about.apiType == "VirtualCenter"
371
+ @vsphere_rev = @connection.rev
372
+ end
373
+
374
+ def connect
347
375
  # This is a state variable to allow digest validation of the SSL cert
348
376
  bad_cert = false
349
377
  loop do
@@ -365,21 +393,8 @@ module Fog
365
393
  if bad_cert then
366
394
  validate_ssl_connection
367
395
  end
368
-
369
- # Negotiate the API revision
370
- if not options[:vsphere_rev]
371
- rev = @connection.serviceContent.about.apiVersion
372
- @connection.rev = [ rev, ENV['FOG_VSPHERE_REV'] || '4.1' ].min
373
- end
374
-
375
- @vsphere_is_vcenter = @connection.serviceContent.about.apiType == "VirtualCenter"
376
- @vsphere_rev = @connection.rev
377
-
378
- authenticate
379
396
  end
380
397
 
381
- private
382
-
383
398
  def authenticate
384
399
  begin
385
400
  @connection.serviceContent.sessionManager.Login :userName => @vsphere_username,
@@ -36,6 +36,7 @@ module Fog
36
36
  attribute :relative_path
37
37
  attribute :memory_mb
38
38
  attribute :cpus
39
+ attribute :corespersocket
39
40
  attribute :interfaces
40
41
  attribute :volumes
41
42
  attribute :customvalues
@@ -66,12 +67,12 @@ module Fog
66
67
 
67
68
  def vm_reconfig_memory(options = {})
68
69
  requires :instance_uuid, :memory
69
- service.vm_reconfig_memory('instance_uuid' => instance_uuid, 'memory' => memory)
70
+ service.vm_reconfig_memory('instance_uuid' => instance_uuid, 'memory' => memory_mb)
70
71
  end
71
72
 
72
73
  def vm_reconfig_cpus(options = {})
73
- requires :instance_uuid, :cpus
74
- service.vm_reconfig_cpus('instance_uuid' => instance_uuid, 'cpus' => cpus)
74
+ requires :instance_uuid, :cpus, :corespersocket
75
+ service.vm_reconfig_cpus('instance_uuid' => instance_uuid, 'cpus' => cpus, 'corespersocket' => corespersocket)
75
76
  end
76
77
 
77
78
  def vm_reconfig_hardware(hardware_spec, options = {})
@@ -121,19 +122,25 @@ module Fog
121
122
  #
122
123
  def clone(options = {})
123
124
  requires :name, :datacenter, :relative_path
125
+
124
126
  # Convert symbols to strings
125
127
  req_options = options.inject({}) { |hsh, (k,v)| hsh[k.to_s] = v; hsh }
128
+
126
129
  # Give our path to the request
127
130
  req_options['template_path'] ="#{relative_path}/#{name}"
128
131
  req_options['datacenter'] = "#{datacenter}"
132
+
129
133
  # Perform the actual clone
130
134
  clone_results = service.vm_clone(req_options)
135
+
136
+ # We need to assign the service, otherwise we can't reload the model
131
137
  # Create the new VM model. TODO This only works when "wait=true"
132
- new_vm = self.class.new(clone_results['new_vm'])
133
- # We need to assign the collection and the connection otherwise we
138
+ new_vm = self.class.new(clone_results['new_vm'].merge(:service => self.service))
139
+
140
+ # We need to assign the collection otherwise we
134
141
  # cannot reload the model.
135
142
  new_vm.collection = self.collection
136
- new_vm.service = service
143
+
137
144
  # Return the new VM model.
138
145
  new_vm
139
146
  end
@@ -162,6 +169,10 @@ module Fog
162
169
  memory_mb * 1024 * 1024
163
170
  end
164
171
 
172
+ def sockets
173
+ cpus / corespersocket
174
+ end
175
+
165
176
  def mac
166
177
  interfaces.first.mac unless interfaces.empty?
167
178
  end
@@ -230,6 +241,7 @@ module Fog
230
241
  def defaults
231
242
  {
232
243
  :cpus => 1,
244
+ # :corespersocket => 1,
233
245
  :memory_mb => 512,
234
246
  # :guest_id => 'otherGuest',
235
247
  :path => '/'
@@ -10,6 +10,7 @@ module Fog
10
10
  :guestId => attributes[:guest_id],
11
11
  :files => { :vmPathName => vm_path_name(attributes) },
12
12
  :numCPUs => attributes[:cpus],
13
+ :numCoresPerSocket => attributes[:corespersocket],
13
14
  :memoryMB => attributes[:memory_mb],
14
15
  :deviceChange => device_change(attributes),
15
16
  :extraConfig => extra_config(attributes),
@@ -141,6 +141,8 @@ module Fog
141
141
  # Options['numCPUs'] or Options['memoryMB']
142
142
  # Build up the specification for Hardware, for more details see ____________
143
143
  # https://github.com/rlane/rbvmomi/blob/master/test/test_serialization.rb
144
+ # http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.vm.ConfigSpec.html
145
+ # FIXME: pad this out with the rest of the useful things in VirtualMachineConfigSpec
144
146
  virtual_machine_config_spec.numCPUs = options['numCPUs'] if ( options.has_key?('numCPUs') )
145
147
  virtual_machine_config_spec.memoryMB = options['memoryMB'] if ( options.has_key?('memoryMB') )
146
148
  # Options['customization_spec']
@@ -189,15 +191,6 @@ module Fog
189
191
  end
190
192
  customization_spec ||= nil
191
193
 
192
- # FIXME: pad this out with the rest of the useful things in VirtualMachineConfigSpec
193
- # http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.vm.ConfigSpec.html
194
- if options.has_key?('memoryMB') || options.has_key?('numCPUs')
195
- virtual_machine_config_spec = {
196
- :memoryMB => options['memoryMB'],
197
- :numCPUs => options['numCPUs']
198
- }
199
- end
200
-
201
194
  relocation_spec=nil
202
195
  if ( options['linked_clone'] )
203
196
  # cribbed heavily from the rbvmomi clone_vm.rb
@@ -5,7 +5,7 @@ module Fog
5
5
  def vm_reconfig_cpus(options = {})
6
6
  raise ArgumentError, "cpus is a required parameter" unless options.has_key? 'cpus'
7
7
  raise ArgumentError, "instance_uuid is a required parameter" unless options.has_key? 'instance_uuid'
8
- hardware_spec={'numCPUs' => options['cpus']}
8
+ hardware_spec={'numCPUs' => options['cpus'], 'numCoresPerSocket' => options['corespersocket']}
9
9
  vm_reconfig_hardware('instance_uuid' => options['instance_uuid'], 'hardware_spec' => hardware_spec )
10
10
  end
11
11
  end
@@ -14,7 +14,7 @@ module Fog
14
14
  def vm_reconfig_cpus(options = {})
15
15
  raise ArgumentError, "cpus is a required parameter" unless options.has_key? 'cpus'
16
16
  raise ArgumentError, "instance_uuid is a required parameter" unless options.has_key? 'instance_uuid'
17
- hardware_spec={'numCPUs' => options['cpus']}
17
+ hardware_spec={'numCPUs' => options['cpus'], 'numCoresPerSocket' => options['corespersocket']}
18
18
  vm_reconfig_hardware('instance_uuid' => options['instance_uuid'], 'hardware_spec' => hardware_spec )
19
19
  end
20
20
  end
@@ -31,7 +31,7 @@ module Fog
31
31
  PV_kernel
32
32
  PV_ramdisk
33
33
  PV_legacy_args
34
- HVM_boot_params
34
+ HVM_boot_policy
35
35
  HVM_boot_params
36
36
  }.each do |k|
37
37
  if config[k.downcase.to_sym]
@@ -116,6 +116,7 @@ Shindo.tests('Fog::Compute[:aws] | instance requests', ['aws']) do
116
116
  'instanceType' => String,
117
117
  'availabilityZone' => String,
118
118
  'start' => Time,
119
+ 'end' => Time,
119
120
  'duration' => Integer,
120
121
  'fixedPrice' => Float,
121
122
  'usagePrice' => Float,
@@ -24,14 +24,14 @@ Shindo.tests('Fog::Storage[:aws] | bucket requests', ["aws"]) do
24
24
  }
25
25
  @bucket_lifecycle_format = {
26
26
  'Rules' => [{
27
- 'ID' => String,
27
+ 'ID' => String,
28
28
  'Prefix' => Fog::Nullable::String,
29
- 'Enabled' => Fog::Boolean,
29
+ 'Enabled' => Fog::Boolean,
30
30
  'Expiration' => Fog::Nullable::Hash,
31
31
  'Transition' => Fog::Nullable::Hash
32
32
  }]
33
33
  }
34
-
34
+
35
35
  @service_format = {
36
36
  'Buckets' => [{
37
37
  'CreationDate' => Time,
@@ -275,6 +275,22 @@ Shindo.tests('Fog::Storage[:aws] | bucket requests', ["aws"]) do
275
275
  Fog::Storage[:aws].put_bucket_cors(@aws_bucket_name, cors)
276
276
  end
277
277
 
278
+ tests("bucket tagging") do
279
+
280
+ tests("#put_bucket_tagging('#{@aws_bucket_name}')").succeeds do
281
+ Fog::Storage[:aws].put_bucket_tagging(@aws_bucket_name, {'Key1' => 'Value1', 'Key2' => 'Value2'})
282
+ end
283
+
284
+ tests("#get_bucket_tagging('#{@aws_bucket_name}')").
285
+ returns('BucketTagging' => {'Key1' => 'Value1', 'Key2' => 'Value2'}) do
286
+ Fog::Storage[:aws].get_bucket_tagging(@aws_bucket_name).body
287
+ end
288
+
289
+ tests("#delete_bucket_tagging('#{@aws_bucket_name}')").succeeds do
290
+ Fog::Storage[:aws].delete_bucket_tagging(@aws_bucket_name)
291
+ end
292
+ end
293
+
278
294
  tests("#delete_bucket('#{@aws_bucket_name}')").succeeds do
279
295
  Fog::Storage[:aws].delete_bucket(@aws_bucket_name)
280
296
  end
@@ -581,6 +581,7 @@ class Brightbox
581
581
  "listeners" => [Brightbox::Compute::Formats::Struct::LB_LISTENER],
582
582
  "policy" => String,
583
583
  "healthcheck" => Brightbox::Compute::Formats::Struct::LB_HEALTHCHECK,
584
+ "certificate" => Fog::Nullable::Hash,
584
585
  "created_at" => String,
585
586
  "deleted_at" => Fog::Nullable::String,
586
587
  "account" => Brightbox::Compute::Formats::Nested::ACCOUNT,
@@ -54,7 +54,13 @@ Shindo.tests do
54
54
  returns(nil, 'File.expand_path raises because of non-absolute path') {
55
55
  ENV.delete('FOG_RC')
56
56
  ENV['HOME'] = '.'
57
- Fog.credentials_path
57
+
58
+ if RUBY_PLATFORM == 'java'
59
+ Fog::Logger.warning("Stubbing out non-absolute path credentials test due to JRuby bug: https://github.com/jruby/jruby/issues/1163")
60
+ nil
61
+ else
62
+ Fog.credentials_path
63
+ end
58
64
  }
59
65
 
60
66
  returns(nil, 'returns nil when neither FOG_RC or HOME are set') {
@@ -46,7 +46,7 @@ posuere eu odio. Donec sodales, ante porta condimentum
46
46
  }
47
47
 
48
48
  @xmlNS = %{
49
- <myns:MyResponse>
49
+ <myns:MyResponse xmlns:myns="http://www.example.com/">
50
50
  <myns:MyObject>
51
51
  <myns:key1>value1</myns:key1>
52
52
  <myns:key2>value2</myns:key2>
@@ -79,7 +79,7 @@ Shindo.tests('Fog::Rackspace::BlockStorage', ['rackspace']) do
79
79
  pending if Fog.mocking?
80
80
 
81
81
  tests('no params').succeeds do
82
- @service = Fog::Rackspace::BlockStorage.new
82
+ @service = Fog::Rackspace::BlockStorage.new :rackspace_region => nil
83
83
  returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
84
84
  returns(true) { (@service.instance_variable_get("@uri").host =~ /dfw/) != nil }
85
85
  @service.list_volumes
@@ -76,7 +76,7 @@ Shindo.tests('Fog::CDN::Rackspace', ['rackspace']) do
76
76
  pending if Fog.mocking?
77
77
 
78
78
  tests('no params').succeeds do
79
- @service = Fog::CDN::Rackspace.new
79
+ @service = Fog::CDN::Rackspace.new :rackspace_region => nil
80
80
  returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
81
81
  returns(true, "uses DFW") { (@service.instance_variable_get("@uri").host =~ /cdn1/) != nil }
82
82
  @service.get_containers
@@ -65,7 +65,7 @@ Shindo.tests('Rackspace | Compute', ['rackspace']) do
65
65
  pending if Fog.mocking?
66
66
 
67
67
  tests('no params').succeeds do
68
- @service = Fog::Compute::Rackspace.new
68
+ @service = Fog::Compute::Rackspace.new :rackspace_region => nil
69
69
  returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
70
70
  returns(true) { (@service.instance_variable_get("@uri").host == 'servers.api.rackspacecloud.com') != nil }
71
71
  @service.list_flavors
@@ -78,7 +78,7 @@ Shindo.tests('Fog::Compute::RackspaceV2', ['rackspace']) do
78
78
  pending if Fog.mocking?
79
79
 
80
80
  tests('no params').succeeds do
81
- @service = Fog::Compute::RackspaceV2.new
81
+ @service = Fog::Compute::RackspaceV2.new :rackspace_region => nil
82
82
  returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
83
83
  returns(true) { (@service.instance_variable_get("@uri").host =~ /dfw/) != nil }
84
84
  @service.list_flavors
@@ -79,7 +79,7 @@ Shindo.tests('Fog::Rackspace::Databases', ['rackspace']) do |variable|
79
79
  pending if Fog.mocking?
80
80
 
81
81
  tests('no params').succeeds do
82
- @service = Fog::Rackspace::Databases.new
82
+ @service = Fog::Rackspace::Databases.new :rackspace_region => nil
83
83
  returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
84
84
  returns(true) { (@service.instance_variable_get("@uri").host =~ /dfw/) != nil }
85
85
  @service.flavors
@@ -69,7 +69,7 @@ Shindo.tests('Fog::DNS::Rackspace', ['rackspace']) do
69
69
  pending if Fog.mocking?
70
70
 
71
71
  tests('no params').succeeds do
72
- @service = Fog::DNS::Rackspace.new
72
+ @service = Fog::DNS::Rackspace.new :rackspace_region => nil
73
73
  returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
74
74
  returns(false, "path populated") { @service.instance_variable_get("@uri").host.nil? }
75
75
  returns(true, "contains tenant id") { (@service.instance_variable_get("@uri").path =~ /\/v1\.0\/\d+$/) != nil} #dns does not error if tenant id is missing
@@ -78,7 +78,7 @@ Shindo.tests('Fog::Rackspace::LoadBalancers', ['rackspace']) do
78
78
  pending if Fog.mocking?
79
79
 
80
80
  tests('no params').succeeds do
81
- @service = Fog::Rackspace::LoadBalancers.new
81
+ @service = Fog::Rackspace::LoadBalancers.new :rackspace_region => nil
82
82
  returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
83
83
  returns(true) { (@service.instance_variable_get("@uri").host =~ /dfw/) != nil }
84
84
  @service.list_load_balancers
@@ -76,7 +76,7 @@ Shindo.tests('Rackspace | Storage', ['rackspace']) do
76
76
  pending if Fog.mocking?
77
77
 
78
78
  tests('no params').succeeds do
79
- @service = Fog::Storage::Rackspace.new
79
+ @service = Fog::Storage::Rackspace.new :rackspace_region => nil
80
80
  returns(true, "auth token populated") { !@service.send(:auth_token).nil? }
81
81
  returns(true) { (@service.instance_variable_get("@uri").host =~ /dfw\d/) != nil }
82
82
  @service.head_containers
@@ -5,7 +5,7 @@ Shindo.tests('Compute::VcloudDirector | ensure_list!', ['vclouddirector']) do
5
5
 
6
6
  @service = Fog::Compute::VcloudDirector.new
7
7
 
8
- tests('#ensure_list! for single key') do
8
+ tests('#ensure_list! for single key ensures our key has an array as a value') do
9
9
  tests('for key with a hash').returns(Array) do
10
10
  testdata = {:k => {:A => '1'}}
11
11
  @service.ensure_list!(testdata, :k)
@@ -31,7 +31,7 @@ Shindo.tests('Compute::VcloudDirector | ensure_list!', ['vclouddirector']) do
31
31
  end
32
32
  end
33
33
 
34
- tests ('#ensure_list! for nested keys') do
34
+ tests('#ensure_list! for nested keys ensures that the child key has an array as a value') do
35
35
  tests('with no key').returns(Array) do
36
36
  testdata = {}
37
37
  @service.ensure_list!(testdata, :keys, :key)
@@ -51,6 +51,34 @@ Shindo.tests('Compute::VcloudDirector | ensure_list!', ['vclouddirector']) do
51
51
  end
52
52
  end
53
53
 
54
+ tests('#ensure_list! with parent and child keys does not effect existing data') do
55
+ tests('for existing array').returns([:one, :two]) do
56
+ testdata = {:keys => {:key => [:one, :two]}}
57
+ @service.ensure_list!(testdata, :keys, :key)
58
+ testdata[:keys][:key]
59
+ end
60
+
61
+ tests('for existing hash').returns([{:one => :two}]) do
62
+ testdata = {:keys => {:key => {:one => :two}}}
63
+ @service.ensure_list!(testdata, :keys, :key)
64
+ testdata[:keys][:key]
65
+ end
66
+ end
67
+
68
+ tests('#ensure_list! with single key does not effect existing data') do
69
+ tests('for existing array').returns([:one, :two]) do
70
+ testdata = {:k => [:one, :two]}
71
+ @service.ensure_list!(testdata, :k)
72
+ testdata[:k]
73
+ end
74
+
75
+ tests('for existing hash').returns([{:one => 'two'}]) do
76
+ testdata = {:k => {:one => 'two'}}
77
+ @service.ensure_list!(testdata, :k)
78
+ testdata[:k]
79
+ end
80
+ end
81
+
54
82
  end
55
83
 
56
84
  end
@@ -1,6 +1,166 @@
1
1
  Shindo.tests('Compute::VcloudDirector | disk requests', ['vclouddirector']) do
2
2
 
3
3
  @service = Fog::Compute::VcloudDirector.new
4
+ @disk_name = VcloudDirector::Compute::Helper.test_name
5
+
6
+ tests('error conditions') do
7
+ tests('#post_upload_disk') do
8
+ tests('Invalid size').raises(Fog::Compute::VcloudDirector::BadRequest) do
9
+ @service.post_upload_disk('00000000-0000-0000-0000-000000000000', @disk_name, -1)
10
+ end
11
+ end
12
+ tests('Upload to non-existent vDC').raises(Fog::Compute::VcloudDirector::Forbidden) do
13
+ @service.post_upload_disk('00000000-0000-0000-0000-000000000000', @disk_name, 0)
14
+ end
15
+ tests('Retrieve non-existent Disk').raises(Fog::Compute::VcloudDirector::Forbidden) do
16
+ @service.get_disk('00000000-0000-0000-0000-000000000000')
17
+ end
18
+ tests('Retrieve owner of non-existent Disk').raises(Fog::Compute::VcloudDirector::Forbidden) do
19
+ @service.get_disk_owner('00000000-0000-0000-0000-000000000000')
20
+ end
21
+ tests('Retrieve VM list for non-existent Disk').raises(Fog::Compute::VcloudDirector::Forbidden) do
22
+ @service.get_vms_disk_attached_to('00000000-0000-0000-0000-000000000000')
23
+ end
24
+ tests('Delete non-existent Disk').raises(Fog::Compute::VcloudDirector::Forbidden) do
25
+ @service.delete_disk('00000000-0000-0000-0000-000000000000')
26
+ end
27
+ end
28
+
29
+ @org = VcloudDirector::Compute::Helper.current_org(@service)
30
+ @size = 1024
31
+
32
+ tests('Upload and manipulate a disk') do
33
+ tests('#post_upload_disk').data_matches_schema(VcloudDirector::Compute::Schema::DISK_TYPE) do
34
+ @vdc_id = VcloudDirector::Compute::Helper.first_vdc_id(@org)
35
+ @disk = @service.post_upload_disk(@vdc_id, @disk_name, @size).body
36
+ end
37
+ @service.process_task(@disk[:Tasks][:Task])
38
+ @disk_id = @disk[:href].split('/').last
39
+
40
+ tests("#get_disk(#{@disk_id})").data_matches_schema(VcloudDirector::Compute::Schema::DISK_TYPE) do
41
+ @disk = @service.get_disk(@disk_id).body
42
+ end
43
+ tests("disk[:name]").returns(@disk_name) { @disk[:name] }
44
+ tests("disk[:size]").returns(@size) { @disk[:size].to_i }
45
+
46
+ tests("#get_disk_owner(#{@disk_id})").data_matches_schema(VcloudDirector::Compute::Schema::OWNER_TYPE) do
47
+ @owner = @service.get_disk_owner(@disk_id).body
48
+ end
49
+ tests("owner[:User][:name]").returns(@service.user_name) { @owner[:User][:name] }
50
+
51
+ #tests("#put_disk(#{@disk_id})").data_matches_schema(VcloudDirector::Compute::Schema::TASK_TYPE) do
52
+ # @disk_name += '-renamed'
53
+ # @task = @service.put_disk(@disk_id, @disk_name).body
54
+ #end
55
+ #@service.process_task(@task)
56
+ #tests("#get_disk(#{@disk_id})").data_matches_schema(VcloudDirector::Compute::Schema::DISK_TYPE) do
57
+ # @disk = @service.get_disk(@disk_id).body
58
+ #end
59
+ #tests("disk[:name]").returns(@disk_name) { @disk[:name] }
60
+ #tests("disk[:size]").returns(@size) { @disk[:size].to_i } # shouldn't change
61
+
62
+ tests('disk metadata') do
63
+ pending if Fog.mocking?
64
+
65
+ tests("#put_disk_metadata_item_metadata(#{@disk_id})").data_matches_schema(VcloudDirector::Compute::Schema::TASK_TYPE) do
66
+ @task = @service.put_disk_metadata_item_metadata(@disk_id, 'fog-test-key', 'fog-test-value').body
67
+ end
68
+ @service.process_task(@task)
69
+
70
+ tests("#put_disk_metadata_item_metadata(#{@disk_id})") do
71
+ tests("#put_disk_metadata_item_metadata(Boolean)").returns(true) do
72
+ task = @service.put_disk_metadata_item_metadata(@disk_id, 'fog-test-boolean', true).body
73
+ @service.process_task(task)
74
+ end
75
+ tests("#put_disk_metadata_item_metadata(DateTime)").returns(true) do
76
+ task = @service.put_disk_metadata_item_metadata(@disk_id, 'fog-test-datetime', DateTime.now).body
77
+ @service.process_task(task)
78
+ end
79
+ tests("#put_disk_metadata_item_metadata(Number)").returns(true) do
80
+ task = @service.put_disk_metadata_item_metadata(@disk_id, 'fog-test-number', 111).body
81
+ @service.process_task(task)
82
+ end
83
+ end
84
+
85
+ tests("#post_update_disk_metadata(#{@disk_id})").data_matches_schema(VcloudDirector::Compute::Schema::TASK_TYPE) do
86
+ metadata = {
87
+ 'fog-test-key-update' => 'fog-test-value-update',
88
+ 'fog-test-boolean-update' => false,
89
+ 'fog-test-datetime-update' => DateTime.now,
90
+ 'fog-test-number-update' => 222
91
+ }
92
+ @task = @service.post_update_disk_metadata(@disk_id, metadata).body
93
+ end
94
+ @service.process_task(@task)
95
+
96
+ tests("#get_disk_metadata(#{@disk_id})") do
97
+ tests('response format').data_matches_schema(VcloudDirector::Compute::Schema::METADATA_TYPE) do
98
+ @metadata = @service.get_disk_metadata(@disk_id).body
99
+ end
100
+ tests('TypedValue') do
101
+ pending if @service.api_version.to_f < 5.1
102
+ tests('key').returns('MetadataStringValue') do
103
+ entry = @metadata[:MetadataEntry].detect {|e| e[:Key] == 'fog-test-key'}
104
+ entry[:TypedValue][:xsi_type]
105
+ end
106
+ tests('boolean').returns('MetadataBooleanValue') do
107
+ entry = @metadata[:MetadataEntry].detect {|e| e[:Key] == 'fog-test-boolean'}
108
+ entry[:TypedValue][:xsi_type]
109
+ end
110
+ tests('datetime').returns('MetadataDateTimeValue') do
111
+ entry = @metadata[:MetadataEntry].detect {|e| e[:Key] == 'fog-test-datetime'}
112
+ entry[:TypedValue][:xsi_type]
113
+ end
114
+ tests('number').returns('MetadataNumberValue') do
115
+ entry = @metadata[:MetadataEntry].detect {|e| e[:Key] == 'fog-test-number'}
116
+ entry[:TypedValue][:xsi_type]
117
+ end
118
+ tests('key-update').returns('MetadataStringValue') do
119
+ entry = @metadata[:MetadataEntry].detect {|e| e[:Key] == 'fog-test-key-update'}
120
+ entry[:TypedValue][:xsi_type]
121
+ end
122
+ tests('boolean-update').returns('MetadataBooleanValue') do
123
+ entry = @metadata[:MetadataEntry].detect {|e| e[:Key] == 'fog-test-boolean-update'}
124
+ entry[:TypedValue][:xsi_type]
125
+ end
126
+ tests('datetime-update').returns('MetadataDateTimeValue') do
127
+ entry = @metadata[:MetadataEntry].detect {|e| e[:Key] == 'fog-test-datetime-update'}
128
+ entry[:TypedValue][:xsi_type]
129
+ end
130
+ tests('number-update').returns('MetadataNumberValue') do
131
+ entry = @metadata[:MetadataEntry].detect {|e| e[:Key] == 'fog-test-number-update'}
132
+ entry[:TypedValue][:xsi_type]
133
+ end
134
+ end
135
+ end
136
+ end
137
+
138
+ tests("#get_vms_disk_attached_to(#{@disk_id})").data_matches_schema(VcloudDirector::Compute::Schema::VMS_TYPE) do
139
+ pending if Fog.mocking?
140
+ @service.get_vms_disk_attached_to(@disk_id).body
141
+ end
142
+
143
+ tests("#delete_disk(#{@disk_id})").data_matches_schema(VcloudDirector::Compute::Schema::TASK_TYPE) do
144
+ @task = @service.delete_disk(@disk_id).body
145
+ end
146
+ @service.process_task(@task)
147
+ end
148
+
149
+ tests('Disk no longer exists') do
150
+ tests("#get_disk(#{@disk_id})").raises(Fog::Compute::VcloudDirector::Forbidden) do
151
+ @service.get_disk(@disk_id)
152
+ end
153
+ tests("#get_disk_owner(#{@disk_id})").raises(Fog::Compute::VcloudDirector::Forbidden) do
154
+ @service.get_disk_owner(@disk_id)
155
+ end
156
+ tests("#get_disk_metadata(#{@disk_id})").raises(Fog::Compute::VcloudDirector::Forbidden) do
157
+ pending if Fog.mocking?
158
+ @service.get_disk_metadata(@disk_id)
159
+ end
160
+ tests("#delete_disk(#{@disk_id})").raises(Fog::Compute::VcloudDirector::Forbidden) do
161
+ @service.delete_disk(@disk_id)
162
+ end
163
+ end
4
164
 
5
165
  tests('#get_disks_from_query') do
6
166
  pending if Fog.mocking?
@@ -15,9 +175,4 @@ Shindo.tests('Compute::VcloudDirector | disk requests', ['vclouddirector']) do
15
175
  end
16
176
  end
17
177
 
18
- tests('Retrieve non-existent Disk').raises(Fog::Compute::VcloudDirector::Forbidden) do
19
- pending if Fog.mocking?
20
- @service.get_disk('00000000-0000-0000-0000-000000000000')
21
- end
22
-
23
178
  end