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.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.rubocop.yml +4 -240
- data/.rubocop_local.yml +1 -0
- data/.travis.yml +5 -10
- data/README.md +3 -0
- data/docs/examples-vm-reconfigure.md +39 -0
- data/docs/vm-to-reconfigure.xml +373 -0
- data/fog-vcloud-director.gemspec +4 -1
- data/lib/fog/vcloud_director.rb +14 -1
- data/lib/fog/vcloud_director/compute.rb +34 -8
- data/lib/fog/vcloud_director/core.rb +0 -3
- data/lib/fog/vcloud_director/generators/compute/org_vdc_network.rb +1 -1
- data/lib/fog/vcloud_director/generators/compute/reconfigure_vm.rb +110 -0
- data/lib/fog/vcloud_director/generators/compute/vapp.rb +0 -1
- data/lib/fog/vcloud_director/models/compute/catalog.rb +0 -2
- data/lib/fog/vcloud_director/models/compute/catalog_item.rb +0 -2
- data/lib/fog/vcloud_director/models/compute/catalog_items.rb +0 -1
- data/lib/fog/vcloud_director/models/compute/catalogs.rb +0 -1
- data/lib/fog/vcloud_director/models/compute/custom_field.rb +0 -2
- data/lib/fog/vcloud_director/models/compute/disk.rb +1 -2
- data/lib/fog/vcloud_director/models/compute/disks.rb +0 -1
- data/lib/fog/vcloud_director/models/compute/media.rb +0 -2
- data/lib/fog/vcloud_director/models/compute/medias.rb +0 -1
- data/lib/fog/vcloud_director/models/compute/network.rb +0 -2
- data/lib/fog/vcloud_director/models/compute/networks.rb +0 -1
- data/lib/fog/vcloud_director/models/compute/organization.rb +0 -2
- data/lib/fog/vcloud_director/models/compute/organizations.rb +0 -1
- data/lib/fog/vcloud_director/models/compute/tag.rb +1 -2
- data/lib/fog/vcloud_director/models/compute/tags.rb +0 -1
- data/lib/fog/vcloud_director/models/compute/task.rb +0 -2
- data/lib/fog/vcloud_director/models/compute/tasks.rb +0 -1
- data/lib/fog/vcloud_director/models/compute/template_vm.rb +0 -1
- data/lib/fog/vcloud_director/models/compute/template_vms.rb +2 -3
- data/lib/fog/vcloud_director/models/compute/vapp.rb +25 -8
- data/lib/fog/vcloud_director/models/compute/vapp_template.rb +0 -2
- data/lib/fog/vcloud_director/models/compute/vapp_templates.rb +0 -1
- data/lib/fog/vcloud_director/models/compute/vapps.rb +0 -1
- data/lib/fog/vcloud_director/models/compute/vdc.rb +0 -2
- data/lib/fog/vcloud_director/models/compute/vdcs.rb +0 -1
- data/lib/fog/vcloud_director/models/compute/vm.rb +10 -30
- data/lib/fog/vcloud_director/models/compute/vm_customization.rb +0 -2
- data/lib/fog/vcloud_director/models/compute/vm_customizations.rb +0 -1
- data/lib/fog/vcloud_director/models/compute/vm_network.rb +0 -2
- data/lib/fog/vcloud_director/models/compute/vm_networks.rb +0 -1
- data/lib/fog/vcloud_director/models/compute/vms.rb +1 -2
- data/lib/fog/vcloud_director/parsers/compute/vapp.rb +93 -0
- data/lib/fog/vcloud_director/parsers/compute/vm.rb +3 -62
- data/lib/fog/vcloud_director/parsers/compute/vm_parser_helper.rb +47 -0
- data/lib/fog/vcloud_director/parsers/compute/vms.rb +2 -23
- data/lib/fog/vcloud_director/query.rb +0 -1
- data/lib/fog/vcloud_director/requests/compute/delete_vapp.rb +1 -1
- data/lib/fog/vcloud_director/requests/compute/get_lease_settings_section_vapp.rb +1 -1
- data/lib/fog/vcloud_director/requests/compute/get_template_vm.rb +1 -47
- data/lib/fog/vcloud_director/requests/compute/get_template_vms.rb +0 -13
- data/lib/fog/vcloud_director/requests/compute/get_vapp.rb +4 -3
- data/lib/fog/vcloud_director/requests/compute/get_vapp_metadata.rb +1 -1
- data/lib/fog/vcloud_director/requests/compute/get_vapp_owner.rb +1 -1
- data/lib/fog/vcloud_director/requests/compute/get_vm.rb +0 -46
- data/lib/fog/vcloud_director/requests/compute/instantiate_vapp_template.rb +1 -1
- data/lib/fog/vcloud_director/requests/compute/post_power_on_vapp.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/post_reconfigure_vm.rb +4 -84
- data/lib/fog/vcloud_director/requests/compute/post_update_vapp_metadata.rb +1 -1
- data/lib/fog/vcloud_director/requests/compute/put_cpu.rb +1 -1
- data/lib/fog/vcloud_director/requests/compute/put_memory.rb +1 -1
- data/lib/fog/vcloud_director/requests/compute/put_metadata_value.rb +1 -1
- data/lib/fog/vcloud_director/requests/compute/put_network_connection_system_section_vapp.rb +1 -1
- data/lib/fog/vcloud_director/requests/compute/put_vm.rb +1 -1
- data/lib/fog/vcloud_director/version.rb +1 -1
- data/spec/common_assertions.rb +42 -0
- data/spec/fixtures/vm.xml +419 -0
- data/spec/secrets.yaml.templ +3 -0
- data/spec/spec_helper.rb +5 -5
- data/spec/vcloud_director/generators/compute/compose_common_spec.rb +1 -6
- data/spec/vcloud_director/generators/compute/compose_vapp_spec.rb +67 -0
- data/spec/vcloud_director/generators/compute/create_snapshot_spec.rb +4 -0
- data/spec/vcloud_director/generators/compute/customization_spec.rb +4 -0
- data/spec/vcloud_director/generators/compute/disks_spec.rb +4 -0
- data/spec/vcloud_director/generators/compute/edge_gateway_service_configuration_spec.rb +4 -0
- data/spec/vcloud_director/generators/compute/instantiate_vapp_template_params_spec.rb +1 -4
- data/spec/vcloud_director/generators/compute/metadata_spec.rb +4 -0
- data/spec/vcloud_director/generators/compute/org_vdc_network_spec.rb +4 -0
- data/spec/vcloud_director/generators/compute/recompose_vapp_spec.rb +4 -0
- data/spec/vcloud_director/generators/compute/reconfigure_vm_spec.rb +117 -0
- data/spec/vcloud_director/generators/compute/vapp_spec.rb +4 -0
- data/spec/vcloud_director/generators/compute/vm_network_spec.rb +4 -0
- data/spec/vcloud_director/generators/compute/vm_spec.rb +4 -0
- data/spec/vcloud_director/models/compute/basic_spec.rb +44 -0
- data/spec/vcloud_director/models/compute/vapps_spec.rb +104 -0
- data/spec/vcloud_director/models/compute/vms_spec.rb +54 -0
- data/spec/vcloud_director/parsers/compute/disks_spec.rb +4 -0
- data/spec/vcloud_director/parsers/compute/metadata_spec.rb +4 -0
- data/spec/vcloud_director/parsers/compute/network_spec.rb +4 -0
- data/spec/vcloud_director/parsers/compute/vm_customization_spec.rb +4 -0
- data/spec/vcloud_director/parsers/compute/vm_network_spec.rb +4 -0
- data/spec/vcloud_director/parsers/compute/vm_parser_helper_spec.rb +4 -0
- data/spec/vcloud_director/parsers/compute/vm_spec.rb +4 -0
- data/spec/vcloud_director/parsers/compute/vms_by_metadata_spec.rb +4 -0
- data/spec/vcloud_director/parsers/compute/vms_spec.rb +4 -0
- data/spec/vcloud_director/requests/compute/basic_spec.rb +212 -0
- data/spec/vcloud_director/requests/compute/get_vapp_spec.rb +11 -0
- data/spec/vcloud_director/requests/compute/get_vdc_spec.rb +10 -0
- data/spec/vcloud_director/requests/compute/instantiate_vapp_template_spec.rb +1 -3
- data/spec/vcloud_director/requests/compute/post_reconfigure_vm_spec.rb +26 -0
- data/spec/vcr_cassettes/authentication.yml +48 -0
- data/spec/vcr_cassettes/get_vapp.yml +937 -0
- data/spec/vcr_cassettes/get_vapps-expired.yml +918 -0
- data/spec/vcr_cassettes/get_vapps-novms.yml +215 -0
- data/spec/vcr_cassettes/get_vapps.yml +118 -0
- data/spec/vcr_cassettes/get_vdc.yml +118 -0
- data/spec/vcr_cassettes/get_vm.yml +398 -0
- data/spec/vcr_cassettes/post_reconfigure_vm-virtual_hardware.yml +445 -0
- data/spec/vcr_spec_helper.rb +34 -0
- data/tasks/test.rake +3 -10
- metadata +129 -5
- data/lib/fog/vcloud_director/requests/compute/get_vms.rb +0 -41
- data/spec/vcloud_director/spec_helper.rb +0 -13
data/spec/spec_helper.rb
CHANGED
@@ -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
|
-
|
15
|
-
|
14
|
+
def secrets
|
15
|
+
@secrets ||= File.file?(secrets_path) ? YAML.load_file(secrets_path) : {}
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
19
|
-
|
18
|
+
def secrets_path
|
19
|
+
'spec/secrets.yaml'
|
20
20
|
end
|
@@ -1,9 +1,4 @@
|
|
1
|
-
require './spec/
|
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
|
@@ -1,7 +1,4 @@
|
|
1
|
-
require './spec/
|
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,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,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
|