fog-vcloud-director 0.1.10 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.rubocop.yml +4 -240
  4. data/.rubocop_local.yml +1 -0
  5. data/.travis.yml +5 -10
  6. data/README.md +3 -0
  7. data/docs/examples-vm-reconfigure.md +39 -0
  8. data/docs/vm-to-reconfigure.xml +373 -0
  9. data/fog-vcloud-director.gemspec +4 -1
  10. data/lib/fog/vcloud_director.rb +14 -1
  11. data/lib/fog/vcloud_director/compute.rb +34 -8
  12. data/lib/fog/vcloud_director/core.rb +0 -3
  13. data/lib/fog/vcloud_director/generators/compute/org_vdc_network.rb +1 -1
  14. data/lib/fog/vcloud_director/generators/compute/reconfigure_vm.rb +110 -0
  15. data/lib/fog/vcloud_director/generators/compute/vapp.rb +0 -1
  16. data/lib/fog/vcloud_director/models/compute/catalog.rb +0 -2
  17. data/lib/fog/vcloud_director/models/compute/catalog_item.rb +0 -2
  18. data/lib/fog/vcloud_director/models/compute/catalog_items.rb +0 -1
  19. data/lib/fog/vcloud_director/models/compute/catalogs.rb +0 -1
  20. data/lib/fog/vcloud_director/models/compute/custom_field.rb +0 -2
  21. data/lib/fog/vcloud_director/models/compute/disk.rb +1 -2
  22. data/lib/fog/vcloud_director/models/compute/disks.rb +0 -1
  23. data/lib/fog/vcloud_director/models/compute/media.rb +0 -2
  24. data/lib/fog/vcloud_director/models/compute/medias.rb +0 -1
  25. data/lib/fog/vcloud_director/models/compute/network.rb +0 -2
  26. data/lib/fog/vcloud_director/models/compute/networks.rb +0 -1
  27. data/lib/fog/vcloud_director/models/compute/organization.rb +0 -2
  28. data/lib/fog/vcloud_director/models/compute/organizations.rb +0 -1
  29. data/lib/fog/vcloud_director/models/compute/tag.rb +1 -2
  30. data/lib/fog/vcloud_director/models/compute/tags.rb +0 -1
  31. data/lib/fog/vcloud_director/models/compute/task.rb +0 -2
  32. data/lib/fog/vcloud_director/models/compute/tasks.rb +0 -1
  33. data/lib/fog/vcloud_director/models/compute/template_vm.rb +0 -1
  34. data/lib/fog/vcloud_director/models/compute/template_vms.rb +2 -3
  35. data/lib/fog/vcloud_director/models/compute/vapp.rb +25 -8
  36. data/lib/fog/vcloud_director/models/compute/vapp_template.rb +0 -2
  37. data/lib/fog/vcloud_director/models/compute/vapp_templates.rb +0 -1
  38. data/lib/fog/vcloud_director/models/compute/vapps.rb +0 -1
  39. data/lib/fog/vcloud_director/models/compute/vdc.rb +0 -2
  40. data/lib/fog/vcloud_director/models/compute/vdcs.rb +0 -1
  41. data/lib/fog/vcloud_director/models/compute/vm.rb +10 -30
  42. data/lib/fog/vcloud_director/models/compute/vm_customization.rb +0 -2
  43. data/lib/fog/vcloud_director/models/compute/vm_customizations.rb +0 -1
  44. data/lib/fog/vcloud_director/models/compute/vm_network.rb +0 -2
  45. data/lib/fog/vcloud_director/models/compute/vm_networks.rb +0 -1
  46. data/lib/fog/vcloud_director/models/compute/vms.rb +1 -2
  47. data/lib/fog/vcloud_director/parsers/compute/vapp.rb +93 -0
  48. data/lib/fog/vcloud_director/parsers/compute/vm.rb +3 -62
  49. data/lib/fog/vcloud_director/parsers/compute/vm_parser_helper.rb +47 -0
  50. data/lib/fog/vcloud_director/parsers/compute/vms.rb +2 -23
  51. data/lib/fog/vcloud_director/query.rb +0 -1
  52. data/lib/fog/vcloud_director/requests/compute/delete_vapp.rb +1 -1
  53. data/lib/fog/vcloud_director/requests/compute/get_lease_settings_section_vapp.rb +1 -1
  54. data/lib/fog/vcloud_director/requests/compute/get_template_vm.rb +1 -47
  55. data/lib/fog/vcloud_director/requests/compute/get_template_vms.rb +0 -13
  56. data/lib/fog/vcloud_director/requests/compute/get_vapp.rb +4 -3
  57. data/lib/fog/vcloud_director/requests/compute/get_vapp_metadata.rb +1 -1
  58. data/lib/fog/vcloud_director/requests/compute/get_vapp_owner.rb +1 -1
  59. data/lib/fog/vcloud_director/requests/compute/get_vm.rb +0 -46
  60. data/lib/fog/vcloud_director/requests/compute/instantiate_vapp_template.rb +1 -1
  61. data/lib/fog/vcloud_director/requests/compute/post_power_on_vapp.rb +2 -2
  62. data/lib/fog/vcloud_director/requests/compute/post_reconfigure_vm.rb +4 -84
  63. data/lib/fog/vcloud_director/requests/compute/post_update_vapp_metadata.rb +1 -1
  64. data/lib/fog/vcloud_director/requests/compute/put_cpu.rb +1 -1
  65. data/lib/fog/vcloud_director/requests/compute/put_memory.rb +1 -1
  66. data/lib/fog/vcloud_director/requests/compute/put_metadata_value.rb +1 -1
  67. data/lib/fog/vcloud_director/requests/compute/put_network_connection_system_section_vapp.rb +1 -1
  68. data/lib/fog/vcloud_director/requests/compute/put_vm.rb +1 -1
  69. data/lib/fog/vcloud_director/version.rb +1 -1
  70. data/spec/common_assertions.rb +42 -0
  71. data/spec/fixtures/vm.xml +419 -0
  72. data/spec/secrets.yaml.templ +3 -0
  73. data/spec/spec_helper.rb +5 -5
  74. data/spec/vcloud_director/generators/compute/compose_common_spec.rb +1 -6
  75. data/spec/vcloud_director/generators/compute/compose_vapp_spec.rb +67 -0
  76. data/spec/vcloud_director/generators/compute/create_snapshot_spec.rb +4 -0
  77. data/spec/vcloud_director/generators/compute/customization_spec.rb +4 -0
  78. data/spec/vcloud_director/generators/compute/disks_spec.rb +4 -0
  79. data/spec/vcloud_director/generators/compute/edge_gateway_service_configuration_spec.rb +4 -0
  80. data/spec/vcloud_director/generators/compute/instantiate_vapp_template_params_spec.rb +1 -4
  81. data/spec/vcloud_director/generators/compute/metadata_spec.rb +4 -0
  82. data/spec/vcloud_director/generators/compute/org_vdc_network_spec.rb +4 -0
  83. data/spec/vcloud_director/generators/compute/recompose_vapp_spec.rb +4 -0
  84. data/spec/vcloud_director/generators/compute/reconfigure_vm_spec.rb +117 -0
  85. data/spec/vcloud_director/generators/compute/vapp_spec.rb +4 -0
  86. data/spec/vcloud_director/generators/compute/vm_network_spec.rb +4 -0
  87. data/spec/vcloud_director/generators/compute/vm_spec.rb +4 -0
  88. data/spec/vcloud_director/models/compute/basic_spec.rb +44 -0
  89. data/spec/vcloud_director/models/compute/vapps_spec.rb +104 -0
  90. data/spec/vcloud_director/models/compute/vms_spec.rb +54 -0
  91. data/spec/vcloud_director/parsers/compute/disks_spec.rb +4 -0
  92. data/spec/vcloud_director/parsers/compute/metadata_spec.rb +4 -0
  93. data/spec/vcloud_director/parsers/compute/network_spec.rb +4 -0
  94. data/spec/vcloud_director/parsers/compute/vm_customization_spec.rb +4 -0
  95. data/spec/vcloud_director/parsers/compute/vm_network_spec.rb +4 -0
  96. data/spec/vcloud_director/parsers/compute/vm_parser_helper_spec.rb +4 -0
  97. data/spec/vcloud_director/parsers/compute/vm_spec.rb +4 -0
  98. data/spec/vcloud_director/parsers/compute/vms_by_metadata_spec.rb +4 -0
  99. data/spec/vcloud_director/parsers/compute/vms_spec.rb +4 -0
  100. data/spec/vcloud_director/requests/compute/basic_spec.rb +212 -0
  101. data/spec/vcloud_director/requests/compute/get_vapp_spec.rb +11 -0
  102. data/spec/vcloud_director/requests/compute/get_vdc_spec.rb +10 -0
  103. data/spec/vcloud_director/requests/compute/instantiate_vapp_template_spec.rb +1 -3
  104. data/spec/vcloud_director/requests/compute/post_reconfigure_vm_spec.rb +26 -0
  105. data/spec/vcr_cassettes/authentication.yml +48 -0
  106. data/spec/vcr_cassettes/get_vapp.yml +937 -0
  107. data/spec/vcr_cassettes/get_vapps-expired.yml +918 -0
  108. data/spec/vcr_cassettes/get_vapps-novms.yml +215 -0
  109. data/spec/vcr_cassettes/get_vapps.yml +118 -0
  110. data/spec/vcr_cassettes/get_vdc.yml +118 -0
  111. data/spec/vcr_cassettes/get_vm.yml +398 -0
  112. data/spec/vcr_cassettes/post_reconfigure_vm-virtual_hardware.yml +445 -0
  113. data/spec/vcr_spec_helper.rb +34 -0
  114. data/tasks/test.rake +3 -10
  115. metadata +129 -5
  116. data/lib/fog/vcloud_director/requests/compute/get_vms.rb +0 -41
  117. data/spec/vcloud_director/spec_helper.rb +0 -13
@@ -0,0 +1,3 @@
1
+ :hostname: 10.11.12.13
2
+ :username: user
3
+ :password: pass
@@ -3,18 +3,18 @@ require "minitest/spec"
3
3
  require "minitest/unit"
4
4
  require "mocha/minitest"
5
5
  require "yaml"
6
- require "vcr"
7
6
 
8
7
  $LOAD_PATH.unshift "lib"
9
8
 
10
9
  require "fog/vcloud_director"
10
+ require "./spec/common_assertions"
11
11
 
12
12
  include Fog::Generators::Compute::VcloudDirector::ComposeCommon
13
13
 
14
- VCR.configure do |config|
15
- config.cassette_library_dir = File.join('./spec/vcr_cassettes')
14
+ def secrets
15
+ @secrets ||= File.file?(secrets_path) ? YAML.load_file(secrets_path) : {}
16
16
  end
17
17
 
18
- def load_secrets
19
- YAML.load_file('spec/secrets.yaml')
18
+ def secrets_path
19
+ 'spec/secrets.yaml'
20
20
  end
@@ -1,9 +1,4 @@
1
- require './spec/vcloud_director/spec_helper.rb'
2
- require 'minitest/autorun'
3
- require 'nokogiri'
4
- require './lib/fog/vcloud_director/generators/compute/compose_common.rb'
5
-
6
- include Fog::Generators::Compute::VcloudDirector::ComposeCommon
1
+ require './spec/spec_helper.rb'
7
2
 
8
3
  describe Fog::Generators::Compute::VcloudDirector::ComposeCommon do
9
4
  describe '.calculate_fence_mode' do
@@ -0,0 +1,67 @@
1
+ require './spec/spec_helper.rb'
2
+
3
+ describe Fog::Generators::Compute::VcloudDirector::ComposeVapp do
4
+ describe '.calculate_fence_mode' do
5
+ [
6
+ {
7
+ :case => 'default',
8
+ :mode => nil,
9
+ :parent => nil,
10
+ :parent_name => nil,
11
+ :expected => 'isolated'
12
+ },
13
+ {
14
+ :case => 'prevent isolated when parent',
15
+ :mode => 'isolated',
16
+ :parent => 'parent-id',
17
+ :parent_name => nil,
18
+ :expected => 'bridged'
19
+ },
20
+ {
21
+ :case => 'keep natRouted when parent',
22
+ :mode => 'natRouted',
23
+ :parent => 'parent-id',
24
+ :parent_name => nil,
25
+ :expected => 'natRouted'
26
+ },
27
+ {
28
+ :case => 'keep bridged when parent',
29
+ :mode => 'bridged',
30
+ :parent => 'parent-id',
31
+ :parent_name => nil,
32
+ :expected => 'bridged'
33
+ },
34
+ {
35
+ :case => 'prevent bridged when no parent',
36
+ :mode => 'bridged',
37
+ :parent => nil,
38
+ :parent_name => nil,
39
+ :expected => 'isolated'
40
+ },
41
+ {
42
+ :case => 'prevent natRouted when no parent',
43
+ :mode => 'natRouted',
44
+ :parent => nil,
45
+ :parent_name => nil,
46
+ :expected => 'isolated'
47
+ },
48
+ {
49
+ :case => 'prevent isolated when parent_name',
50
+ :mode => 'isolated',
51
+ :parent => nil,
52
+ :parent_name => 'parent-name',
53
+ :expected => 'bridged'
54
+ },
55
+ ].each do |args|
56
+ it args[:case].to_s do
57
+ mode = Fog::Generators::Compute::VcloudDirector::ComposeCommon.send(
58
+ :calculate_fence_mode,
59
+ args[:mode],
60
+ args[:parent],
61
+ args[:parent_name]
62
+ )
63
+ mode.must_equal(args[:expected])
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,4 @@
1
+ require './spec/spec_helper.rb'
2
+
3
+ describe Fog::Generators::Compute::VcloudDirector::CreateSnapshot do
4
+ end
@@ -0,0 +1,4 @@
1
+ require './spec/spec_helper.rb'
2
+
3
+ describe Fog::Generators::Compute::VcloudDirector::Customization do
4
+ end
@@ -0,0 +1,4 @@
1
+ require './spec/spec_helper.rb'
2
+
3
+ describe Fog::Generators::Compute::VcloudDirector::Disks do
4
+ end
@@ -0,0 +1,4 @@
1
+ require './spec/spec_helper.rb'
2
+
3
+ describe Fog::Generators::Compute::VcloudDirector::EdgeGatewayServiceConfiguration do
4
+ end
@@ -1,7 +1,4 @@
1
- require './spec/vcloud_director/spec_helper.rb'
2
- require 'minitest/autorun'
3
- require 'nokogiri'
4
- require './lib/fog/vcloud_director/generators/compute/instantiate_vapp_template_params.rb'
1
+ require './spec/spec_helper.rb'
5
2
 
6
3
  describe Fog::Generators::Compute::VcloudDirector::InstantiateVappTemplateParams do
7
4
  describe 'Complete xml' do
@@ -0,0 +1,4 @@
1
+ require './spec/spec_helper.rb'
2
+
3
+ describe Fog::Generators::Compute::VcloudDirector::MetadataBase do
4
+ end
@@ -0,0 +1,4 @@
1
+ require './spec/spec_helper.rb'
2
+
3
+ describe Fog::Generators::Compute::VcloudDirector::OrgVdcNetwork do
4
+ end
@@ -0,0 +1,4 @@
1
+ require './spec/spec_helper.rb'
2
+
3
+ describe Fog::Generators::Compute::VcloudDirector::RecomposeVapp do
4
+ end
@@ -0,0 +1,117 @@
1
+ require './spec/spec_helper.rb'
2
+
3
+ describe Fog::Generators::Compute::VcloudDirector::ReconfigureVm do
4
+ let(:current) { Nokogiri::XML(File.read('./spec/fixtures/vm.xml')) }
5
+ let(:hardware) { {} }
6
+ let(:input) { hardware ? { :hardware => hardware } : {} }
7
+ let(:output) { Nokogiri::XML(Fog::Generators::Compute::VcloudDirector::ReconfigureVm.generate_xml(current, input)) }
8
+
9
+ describe 'reconfigure' do
10
+ describe 'name' do
11
+ let(:input) { { :name => 'new name' } }
12
+
13
+ it 'name' do
14
+ output.xpath('/*/@name').first.value.must_equal 'new name'
15
+ end
16
+ end
17
+
18
+ describe 'description' do
19
+ let(:input) { { :description => 'new description' } }
20
+
21
+ it 'description' do
22
+ output.at('Description').content.must_equal 'new description'
23
+ end
24
+ end
25
+
26
+ describe 'memory' do
27
+ let(:hardware) { { :memory => { :quantity_mb => 123 } } }
28
+
29
+ it 'memory' do
30
+ mem = output.xpath("//ovf:VirtualHardwareSection/ovf:Item[./rasd:ResourceType = '4']")
31
+ mem.xpath('./rasd:VirtualQuantity').text.must_equal '123'
32
+ end
33
+ end
34
+
35
+ describe 'cpu' do
36
+ let(:hardware) { { :cpu => { :num_cores => 8, :cores_per_socket => 4 } } }
37
+
38
+ it 'cpu' do
39
+ cpu = output.xpath("//ovf:VirtualHardwareSection/ovf:Item[./rasd:ResourceType = '3']")
40
+ cpu.xpath('./rasd:VirtualQuantity').text.must_equal '8'
41
+ cpu.xpath('./vmw:CoresPerSocket').text.must_equal '4'
42
+ end
43
+ end
44
+
45
+ describe 'disk' do
46
+ let(:hardware) { { :disk => disks } }
47
+
48
+ describe 'resize' do
49
+ let(:disks) { { :id => '2000', :capacity_mb => 123 } }
50
+
51
+ it 'resize' do
52
+ all_disks(output).count.must_equal 3
53
+ disk_by_id(output, '2000').at('./rasd:HostResource')['ns13:capacity'].must_equal '123'
54
+ end
55
+ end
56
+
57
+ describe 'resize nonexisting' do
58
+ let(:disks) { { :id => 'nonexisting', :capacity_mb => 123 } }
59
+
60
+ it 'resize nonexisting' do
61
+ -> { output }.must_raise Fog::Compute::VcloudDirector::PreProcessingError
62
+ end
63
+ end
64
+
65
+ describe 'remove' do
66
+ let(:disks) { { :id => '2000', :capacity_mb => -1 } }
67
+
68
+ it 'remove' do
69
+ all_disks(output).count.must_equal 2
70
+ disk_by_id(output, '2000').must_be_empty
71
+ end
72
+ end
73
+
74
+ describe 'remove nonexisting' do
75
+ let(:disks) { { :id => 'nonexisting', :capacity_mb => -1 } }
76
+
77
+ it 'remove nonexisting' do
78
+ all_disks(output).count.must_equal 3
79
+ end
80
+ end
81
+
82
+ describe 'add' do
83
+ let(:disks) { { :capacity_mb => 123 } }
84
+
85
+ it 'add' do
86
+ all_disks(output).count.must_equal 4
87
+ all_disks(output).last.at('./rasd:HostResource')['ns13:capacity'].must_equal '123'
88
+ end
89
+ end
90
+
91
+ describe 'resize, remove and add' do
92
+ let(:disks) do
93
+ [
94
+ { :id => '2000', :capacity_mb => 123 },
95
+ { :id => '2001', :capacity_mb => -1 },
96
+ { :capacity_mb => 321 }
97
+ ]
98
+ end
99
+
100
+ it 'resize, remove and add' do
101
+ all_disks(output).count.must_equal 3
102
+ disk_by_id(output, '2000').at('./rasd:HostResource')['ns13:capacity'].must_equal '123'
103
+ disk_by_id(output, '2001').must_be_empty
104
+ all_disks(output).last.at('./rasd:HostResource')['ns13:capacity'].must_equal '321'
105
+ end
106
+ end
107
+
108
+ def all_disks(xml)
109
+ xml.xpath("//ovf:VirtualHardwareSection/ovf:Item[./rasd:ResourceType = '17']")
110
+ end
111
+
112
+ def disk_by_id(xml, id)
113
+ all_disks(xml).xpath("//ovf:Item[./rasd:InstanceID = '#{id}']")
114
+ end
115
+ end
116
+ end
117
+ end
@@ -0,0 +1,4 @@
1
+ require './spec/spec_helper.rb'
2
+
3
+ describe Fog::Generators::Compute::VcloudDirector::Vapp do
4
+ end
@@ -0,0 +1,4 @@
1
+ require './spec/spec_helper.rb'
2
+
3
+ describe Fog::Generators::Compute::VcloudDirector::VmNetwork do
4
+ end
@@ -0,0 +1,4 @@
1
+ require './spec/spec_helper.rb'
2
+
3
+ describe Fog::Generators::Compute::VcloudDirector::Vm do
4
+ end
@@ -0,0 +1,44 @@
1
+ require './spec/spec_helper.rb'
2
+
3
+ describe Fog::Compute::VcloudDirector do
4
+ describe 'No load errors' do
5
+ [
6
+ Fog::Compute::VcloudDirector::Catalogs,
7
+ Fog::Compute::VcloudDirector::Catalog,
8
+ Fog::Compute::VcloudDirector::CatalogItems,
9
+ Fog::Compute::VcloudDirector::CatalogItem,
10
+ Fog::Compute::VcloudDirector::CustomFields,
11
+ Fog::Compute::VcloudDirector::CustomField,
12
+ Fog::Compute::VcloudDirector::Disks,
13
+ Fog::Compute::VcloudDirector::Disk,
14
+ Fog::Compute::VcloudDirector::Medias,
15
+ Fog::Compute::VcloudDirector::Media,
16
+ Fog::Compute::VcloudDirector::Networks,
17
+ Fog::Compute::VcloudDirector::Network,
18
+ Fog::Compute::VcloudDirector::Organizations,
19
+ Fog::Compute::VcloudDirector::Organization,
20
+ Fog::Compute::VcloudDirector::Tags,
21
+ Fog::Compute::VcloudDirector::Tag,
22
+ Fog::Compute::VcloudDirector::Tasks,
23
+ Fog::Compute::VcloudDirector::Task,
24
+ Fog::Compute::VcloudDirector::TemplateVms,
25
+ Fog::Compute::VcloudDirector::TemplateVm,
26
+ Fog::Compute::VcloudDirector::Vapps,
27
+ Fog::Compute::VcloudDirector::Vapp,
28
+ Fog::Compute::VcloudDirector::VappTemplates,
29
+ Fog::Compute::VcloudDirector::VappTemplate,
30
+ Fog::Compute::VcloudDirector::Vdcs,
31
+ Fog::Compute::VcloudDirector::Vdc,
32
+ Fog::Compute::VcloudDirector::Vms,
33
+ Fog::Compute::VcloudDirector::Vm,
34
+ Fog::Compute::VcloudDirector::VmCustomizations,
35
+ Fog::Compute::VcloudDirector::VmCustomization,
36
+ Fog::Compute::VcloudDirector::VmNetworks,
37
+ Fog::Compute::VcloudDirector::VmNetwork
38
+ ].each do |klass|
39
+ it "Instantiating #{klass}" do
40
+ assert_instance_of(klass, klass.new)
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,104 @@
1
+ require './spec/vcr_spec_helper.rb'
2
+
3
+ describe Fog::Compute::VcloudDirector::Vapps do
4
+ let(:subject) { Fog::Compute::VcloudDirector::Vapps.new(:service => vcr_service, :vdc => vdc) }
5
+ let(:vdc_id) { 'cf6ea964-a67f-4ba1-b69e-3dd5d6cb0c89' }
6
+ let(:vdc) { Object.new.tap { |vapp| vapp.stubs(:id).returns(vdc_id) } }
7
+ let(:vapp_id) { 'vapp-fe8d013d-dd2f-4ac6-9e8a-3a4a18e0a62e' }
8
+ let(:vm_id) { 'vm-314172f1-1835-4598-b049-5c1d4dce39ad' }
9
+ let(:vm2_id) { 'vm-8dc9990c-a55a-418e-8e21-5942a20b93ef' }
10
+
11
+ describe '.all' do
12
+ let(:expired_vapp_id) { 'vapp-5d61572f-f76d-45fc-9f59-f36ca6651781' }
13
+ let(:no_vms_vapp_id) { 'vapp-6420bb6b-daab-4015-8ab8-f5d8105040fd' }
14
+
15
+ it 'vapp skeleton' do
16
+ VCR.use_cassette('get_vapps') do
17
+ vapps = subject.all
18
+ vapps.size.must_equal 7
19
+ expect_vapp_skeleton(
20
+ vapps.detect { |vapp| vapp.id == vapp_id },
21
+ :id => vapp_id,
22
+ :name => 'cfme-vapp'
23
+ )
24
+ end
25
+ end
26
+
27
+ it 'expired vapp' do
28
+ VCR.use_cassette('get_vapps-expired') do
29
+ vapps = subject.all
30
+ vapps.size.must_equal 7
31
+ vapp = vapps.detect { |vapp| vapp.id == expired_vapp_id }
32
+
33
+ vms = vapp.vms.all
34
+ vms.size.must_equal 2
35
+ vms[0].vapp_id.must_equal expired_vapp_id
36
+ vms[1].vapp_id.must_equal expired_vapp_id
37
+ end
38
+ end
39
+
40
+ it 'vapp without vms' do
41
+ VCR.use_cassette('get_vapps-novms') do
42
+ vapps = subject.all
43
+ vapps.size.must_equal 7
44
+ vapp = vapps.detect { |vapp| vapp.id == no_vms_vapp_id }
45
+
46
+ vms = vapp.vms.all
47
+ vms.size.must_equal 0
48
+ end
49
+ end
50
+ end
51
+
52
+ it '.get_single_vapp' do
53
+ VCR.use_cassette('get_vapp') do
54
+ vapp = subject.get_single_vapp(vapp_id)
55
+ expect_vapp(
56
+ vapp,
57
+ :id => vapp_id,
58
+ :name => 'cfme-vapp',
59
+ :description => '',
60
+ :deployed => false,
61
+ :status => '8',
62
+ :h_status => 'off',
63
+ :lease => 'not-implemented',
64
+ :net_section => 'not-implemented',
65
+ :net_config => 'not-implemented',
66
+ :owner => 'e0d6e74d-efde-49fe-b19f-ace7e55b68dd',
67
+ :maintenance => false,
68
+ :num_vms => 2
69
+ )
70
+ expect_vm(
71
+ vapp.vms.detect { |vm| vm.id == vm_id },
72
+ :vapp_id => vapp_id,
73
+ :name => 'Web Server VM',
74
+ :status => 'off',
75
+ :deployed => false,
76
+ :os => 'Microsoft Windows Server 2016 (64-bit)',
77
+ :ip => '',
78
+ :cpu => 4,
79
+ :cores_per_socket => 2,
80
+ :cpu_hot => false,
81
+ :mem => 1024,
82
+ :mem_hot => false,
83
+ :num_hdds => 1,
84
+ :num_nics => 2
85
+ )
86
+ expect_vm(
87
+ vapp.vms.detect { |vm| vm.id == vm2_id },
88
+ :vapp_id => vapp_id,
89
+ :name => 'Databasy Machiny',
90
+ :status => 'off',
91
+ :deployed => false,
92
+ :os => 'Microsoft Windows Server 2016 (64-bit)',
93
+ :ip => '192.168.43.2',
94
+ :cpu => 8,
95
+ :cores_per_socket => 4,
96
+ :cpu_hot => true,
97
+ :mem => 4096,
98
+ :mem_hot => true,
99
+ :num_hdds => 3,
100
+ :num_nics => 2
101
+ )
102
+ end
103
+ end
104
+ end
@@ -0,0 +1,54 @@
1
+ require './spec/vcr_spec_helper.rb'
2
+
3
+ describe Fog::Compute::VcloudDirector::Vms do
4
+ let(:subject) { Fog::Compute::VcloudDirector::Vms.new(:service => vcr_service, :vapp => vapp) }
5
+ let(:vapp_id) { 'vapp-fe8d013d-dd2f-4ac6-9e8a-3a4a18e0a62e' }
6
+ let(:vapp) { Object.new.tap { |vapp| vapp.stubs(:id).returns(vapp_id) } }
7
+ let(:vm_id) { 'vm-314172f1-1835-4598-b049-5c1d4dce39ad' }
8
+
9
+ it '.all' do
10
+ VCR.use_cassette('get_vapp') do
11
+ vms = subject.all
12
+ vms.size.must_equal 2
13
+ expect_vm(
14
+ vms.to_a.detect { |vm| vm.id == vm_id },
15
+ :vapp_id => vapp_id,
16
+ :name => 'Web Server VM',
17
+ :status => 'off',
18
+ :deployed => false,
19
+ :os => 'Microsoft Windows Server 2016 (64-bit)',
20
+ :ip => '',
21
+ :cpu => 4,
22
+ :cores_per_socket => 2,
23
+ :cpu_hot => false,
24
+ :mem => 1024,
25
+ :mem_hot => false,
26
+ :num_hdds => 1,
27
+ :num_nics => 2
28
+ )
29
+ end
30
+ end
31
+
32
+ it '.get_single_vm' do
33
+ VCR.use_cassette('get_vm') do
34
+ vm = subject.get_single_vm(vm_id)
35
+ puts vm.network_adapters
36
+ expect_vm(
37
+ vm,
38
+ :vapp_id => vapp_id,
39
+ :name => 'Web Server VM',
40
+ :status => 'off',
41
+ :deployed => false,
42
+ :os => 'Microsoft Windows Server 2016 (64-bit)',
43
+ :ip => '',
44
+ :cpu => 4,
45
+ :cpu_hot => true,
46
+ :cores_per_socket => 2,
47
+ :mem => 1024,
48
+ :mem_hot => true,
49
+ :num_hdds => 1,
50
+ :num_nics => 2
51
+ )
52
+ end
53
+ end
54
+ end