vcloud-core 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +13 -1
- data/README.md +13 -8
- data/lib/vcloud/core/version.rb +1 -1
- data/spec/vcloud/core/config_loader_spec.rb +155 -159
- data/spec/vcloud/core/config_validator_spec.rb +615 -619
- data/spec/vcloud/core/edge_gateway_interface_spec.rb +65 -70
- data/spec/vcloud/core/edge_gateway_spec.rb +138 -144
- data/spec/vcloud/core/independent_disk_spec.rb +15 -15
- data/spec/vcloud/core/metadata_helper_spec.rb +73 -77
- data/spec/vcloud/core/org_vdc_network_spec.rb +226 -230
- data/spec/vcloud/core/query_runner_spec.rb +31 -31
- data/spec/vcloud/core/query_spec.rb +1 -1
- data/spec/vcloud/core/vapp_spec.rb +175 -179
- data/spec/vcloud/core/vapp_template_spec.rb +82 -86
- data/spec/vcloud/core/vdc_spec.rb +47 -53
- data/spec/vcloud/core/vm_spec.rb +354 -358
- data/vcloud-core.gemspec +4 -4
- metadata +28 -30
- data/spec/integration/README.md +0 -36
@@ -19,12 +19,12 @@ describe Vcloud::Core::QueryRunner do
|
|
19
19
|
allow(@mock_fog_interface).to receive(:get_execute_query).and_return(
|
20
20
|
{:Link => [
|
21
21
|
{:rel => 'down',
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
22
|
+
:href => 'query?type=alice&format=records'},
|
23
|
+
{:rel => 'down',
|
24
|
+
:href => 'query?type=bob&format=records'},
|
25
|
+
{:rel => 'down',
|
26
|
+
:href => 'query?type=charlie&format=records'},
|
27
|
+
]})
|
28
28
|
expect(@query_runner.available_query_types).to eq(['alice', 'bob', 'charlie'])
|
29
29
|
end
|
30
30
|
|
@@ -32,12 +32,12 @@ describe Vcloud::Core::QueryRunner do
|
|
32
32
|
allow(@mock_fog_interface).to receive(:get_execute_query).and_return(
|
33
33
|
{:Link => [
|
34
34
|
{:rel => 'down',
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
35
|
+
:href => 'query?type=alice&format=references'},
|
36
|
+
{:rel => 'down',
|
37
|
+
:href => 'query?type=bob&format=idrecords'},
|
38
|
+
{:rel => 'down',
|
39
|
+
:href => 'query?type=charlie&format=records'},
|
40
|
+
]})
|
41
41
|
expect(@query_runner.available_query_types).to eq(['charlie'])
|
42
42
|
end
|
43
43
|
|
@@ -58,8 +58,8 @@ describe Vcloud::Core::QueryRunner do
|
|
58
58
|
it 'return no results when fog results do not include a "Record" or a "Reference"' do
|
59
59
|
allow(@mock_fog_interface).to receive(:get_execute_query).and_return(
|
60
60
|
{
|
61
|
-
|
62
|
-
|
61
|
+
:WibbleBlob => {:field1 => 'Stuff 1'}
|
62
|
+
}
|
63
63
|
)
|
64
64
|
expect(@query_runner.run().size).to eq(0)
|
65
65
|
end
|
@@ -68,8 +68,8 @@ describe Vcloud::Core::QueryRunner do
|
|
68
68
|
fields = {:field1 => 'Stuff 1'}
|
69
69
|
allow(@mock_fog_interface).to receive(:get_execute_query).and_return(
|
70
70
|
{
|
71
|
-
|
72
|
-
|
71
|
+
:WibbleRecord => [fields]
|
72
|
+
}
|
73
73
|
)
|
74
74
|
result = @query_runner.run()
|
75
75
|
expect(result.size).to eq(1)
|
@@ -80,8 +80,8 @@ describe Vcloud::Core::QueryRunner do
|
|
80
80
|
fields = {:field1 => 'Stuff 1'}
|
81
81
|
allow(@mock_fog_interface).to receive(:get_execute_query).and_return(
|
82
82
|
{
|
83
|
-
|
84
|
-
|
83
|
+
:WibbleReference => [fields]
|
84
|
+
}
|
85
85
|
)
|
86
86
|
result = @query_runner.run()
|
87
87
|
expect(result.size).to eq(1)
|
@@ -92,8 +92,8 @@ describe Vcloud::Core::QueryRunner do
|
|
92
92
|
fields = {:field1 => 'Stuff 1'}
|
93
93
|
allow(@mock_fog_interface).to receive(:get_execute_query).and_return(
|
94
94
|
{
|
95
|
-
|
96
|
-
|
95
|
+
:WibbleRecord => fields
|
96
|
+
}
|
97
97
|
)
|
98
98
|
result = @query_runner.run()
|
99
99
|
expect(result.size).to eq(1)
|
@@ -105,8 +105,8 @@ describe Vcloud::Core::QueryRunner do
|
|
105
105
|
more_fields = {:field1 => 'More Stuff 1'}
|
106
106
|
allow(@mock_fog_interface).to receive(:get_execute_query).and_return(
|
107
107
|
{
|
108
|
-
|
109
|
-
|
108
|
+
:WibbleRecord => [fields, more_fields]
|
109
|
+
}
|
110
110
|
)
|
111
111
|
result = @query_runner.run()
|
112
112
|
expect(result.size).to eq(2)
|
@@ -119,9 +119,9 @@ describe Vcloud::Core::QueryRunner do
|
|
119
119
|
fields2 = {:field1 => 'Stuff 2'}
|
120
120
|
allow(@mock_fog_interface).to receive(:get_execute_query).and_return(
|
121
121
|
{
|
122
|
-
|
123
|
-
|
124
|
-
|
122
|
+
:WibbleRecord => [fields1],
|
123
|
+
:WobbleRecord => [fields2]
|
124
|
+
}
|
125
125
|
)
|
126
126
|
result = @query_runner.run()
|
127
127
|
expect(result.size).to eq(1)
|
@@ -131,9 +131,9 @@ describe Vcloud::Core::QueryRunner do
|
|
131
131
|
it 'should raise error if lastPage is not an integer' do
|
132
132
|
allow(@mock_fog_interface).to receive(:get_execute_query).and_return(
|
133
133
|
{
|
134
|
-
|
135
|
-
|
136
|
-
|
134
|
+
:lastPage => :qwerty,
|
135
|
+
:WibbleRecord => []
|
136
|
+
}
|
137
137
|
)
|
138
138
|
|
139
139
|
expect { @query_runner.run() }.to raise_error('Invalid lastPage (qwerty) in query results')
|
@@ -143,9 +143,9 @@ describe Vcloud::Core::QueryRunner do
|
|
143
143
|
fields = {:field1 => 'Stuff 1'}
|
144
144
|
allow(@mock_fog_interface).to receive(:get_execute_query).and_return(
|
145
145
|
{
|
146
|
-
|
147
|
-
|
148
|
-
|
146
|
+
:lastPage => 2,
|
147
|
+
:WibbleRecord => [fields]
|
148
|
+
}
|
149
149
|
)
|
150
150
|
result = @query_runner.run()
|
151
151
|
expect(result.size).to eq(2)
|
@@ -1,209 +1,205 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
allow(Vcloud::Core::Fog::ServiceInterface).to receive(:new).and_return(@mock_fog_interface)
|
10
|
-
end
|
3
|
+
describe Vcloud::Core::Vapp do
|
4
|
+
before(:each) do
|
5
|
+
@vapp_id = 'vapp-12345678-1234-1234-1234-000000111111'
|
6
|
+
@mock_fog_interface = StubFogInterface.new
|
7
|
+
allow(Vcloud::Core::Fog::ServiceInterface).to receive(:new).and_return(@mock_fog_interface)
|
8
|
+
end
|
11
9
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
10
|
+
context "Class public interface" do
|
11
|
+
it { expect(Vcloud::Core::Vapp).to respond_to(:instantiate) }
|
12
|
+
it { expect(Vcloud::Core::Vapp).to respond_to(:get_by_name) }
|
13
|
+
it { expect(Vcloud::Core::Vapp).to respond_to(:get_metadata) }
|
14
|
+
end
|
17
15
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
16
|
+
context "Instance public interface" do
|
17
|
+
subject { Vcloud::Core::Vapp.new(@vapp_id) }
|
18
|
+
it { should respond_to(:id) }
|
19
|
+
it { should respond_to(:vcloud_attributes) }
|
20
|
+
it { should respond_to(:name) }
|
21
|
+
it { should respond_to(:href) }
|
22
|
+
it { should respond_to(:vdc_id) }
|
23
|
+
it { should respond_to(:vms) }
|
24
|
+
it { should respond_to(:networks) }
|
25
|
+
it { should respond_to(:power_on) }
|
26
|
+
end
|
27
|
+
|
28
|
+
context "#initialize" do
|
29
|
+
|
30
|
+
it "should be constructable from just an id reference" do
|
31
|
+
obj = Vcloud::Core::Vapp.new(@vapp_id)
|
32
|
+
expect(obj.class).to be(Vcloud::Core::Vapp)
|
33
|
+
end
|
29
34
|
|
30
|
-
|
35
|
+
it "should store the id specified" do
|
36
|
+
obj = Vcloud::Core::Vapp.new(@vapp_id)
|
37
|
+
expect(obj.id).to eq(@vapp_id)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should raise error if id is not in correct format" do
|
41
|
+
bogus_id = '12314124-ede5-4d07-bad5-000000111111'
|
42
|
+
expect{ Vcloud::Core::Vapp.new(bogus_id) }.to raise_error("vapp id : #{bogus_id} is not in correct format" )
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
31
46
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
47
|
+
context "#get_by_name" do
|
48
|
+
|
49
|
+
it "should return a Vcloud::Core::Vapp object if name exists" do
|
50
|
+
q_results = [
|
51
|
+
{ :name => 'vapp-test-1', :href => @vapp_id }
|
52
|
+
]
|
53
|
+
mock_query = double(:query)
|
54
|
+
expect(Vcloud::Core::QueryRunner).to receive(:new).and_return(mock_query)
|
55
|
+
expect(mock_query).to receive(:run).with('vApp', :filter => "name==vapp-test-1").and_return(q_results)
|
56
|
+
obj = Vcloud::Core::Vapp.get_by_name('vapp-test-1')
|
57
|
+
expect(obj.class).to be(Vcloud::Core::Vapp)
|
58
|
+
end
|
36
59
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
60
|
+
it "should raise an error if no vApp with that name exists" do
|
61
|
+
q_results = [ ]
|
62
|
+
mock_query = double(:query_runner)
|
63
|
+
expect(Vcloud::Core::QueryRunner).to receive(:new).and_return(mock_query)
|
64
|
+
expect(mock_query).to receive(:run).with('vApp', :filter => "name==vapp-test-1").and_return(q_results)
|
65
|
+
expect{ Vcloud::Core::Vapp.get_by_name('vapp-test-1') }.to raise_exception(RuntimeError)
|
66
|
+
end
|
41
67
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
68
|
+
it "should raise an error if multiple vApps with that name exists (NB: prescribes unique vApp names!)" do
|
69
|
+
q_results = [
|
70
|
+
{ :name => 'vapp-test-1', :href => @vapp_id },
|
71
|
+
{ :name => 'vapp-test-1', :href => '/bogus' },
|
72
|
+
]
|
73
|
+
mock_query = double(:query)
|
74
|
+
expect(Vcloud::Core::QueryRunner).to receive(:new).and_return(mock_query)
|
75
|
+
expect(mock_query).to receive(:run).with('vApp', :filter => "name==vapp-test-1").and_return(q_results)
|
76
|
+
expect{ Vcloud::Core::Vapp.get_by_name('vapp-test-1') }.to raise_exception(RuntimeError)
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
46
80
|
|
81
|
+
context "attributes" do
|
82
|
+
before(:each) {
|
83
|
+
@stub_attrs = {
|
84
|
+
:name => 'Webserver vapp-1',
|
85
|
+
:href => "https://api.vcd.portal.skyscapecloud.com/api/vApp/#{@vapp_id}",
|
86
|
+
:Link => [{
|
87
|
+
:rel => 'up',
|
88
|
+
:type => 'application/vnd.vmware.vcloud.vdc+xml',
|
89
|
+
:href => 'https://api.vcloud-director.example.com/api/vdc/074aea1e-a5e9-4dd1-a028-40db8c98d237'
|
90
|
+
}],
|
91
|
+
:Children => {:Vm => [{:href => '/vm-123aea1e-a5e9-4dd1-a028-40db8c98d237'}]}
|
92
|
+
}
|
93
|
+
allow_any_instance_of(StubFogInterface).to receive(:get_vapp).and_return(@stub_attrs)
|
94
|
+
@vapp = Vcloud::Core::Vapp.new(@vapp_id)
|
95
|
+
}
|
96
|
+
it { expect(@vapp.name).to eq('Webserver vapp-1') }
|
97
|
+
|
98
|
+
context "id" do
|
99
|
+
it "should extract id correctly" do
|
100
|
+
expect(@vapp.id).to eq(@vapp_id)
|
47
101
|
end
|
102
|
+
end
|
48
103
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
{ :name => 'vapp-test-1', :href => @vapp_id }
|
54
|
-
]
|
55
|
-
mock_query = double(:query)
|
56
|
-
expect(Vcloud::Core::QueryRunner).to receive(:new).and_return(mock_query)
|
57
|
-
expect(mock_query).to receive(:run).with('vApp', :filter => "name==vapp-test-1").and_return(q_results)
|
58
|
-
obj = Vapp.get_by_name('vapp-test-1')
|
59
|
-
expect(obj.class).to be(Vcloud::Core::Vapp)
|
60
|
-
end
|
61
|
-
|
62
|
-
it "should raise an error if no vApp with that name exists" do
|
63
|
-
q_results = [ ]
|
64
|
-
mock_query = double(:query_runner)
|
65
|
-
expect(Vcloud::Core::QueryRunner).to receive(:new).and_return(mock_query)
|
66
|
-
expect(mock_query).to receive(:run).with('vApp', :filter => "name==vapp-test-1").and_return(q_results)
|
67
|
-
expect{ Vapp.get_by_name('vapp-test-1') }.to raise_exception(RuntimeError)
|
68
|
-
end
|
69
|
-
|
70
|
-
it "should raise an error if multiple vApps with that name exists (NB: prescribes unique vApp names!)" do
|
71
|
-
q_results = [
|
72
|
-
{ :name => 'vapp-test-1', :href => @vapp_id },
|
73
|
-
{ :name => 'vapp-test-1', :href => '/bogus' },
|
74
|
-
]
|
75
|
-
mock_query = double(:query)
|
76
|
-
expect(Vcloud::Core::QueryRunner).to receive(:new).and_return(mock_query)
|
77
|
-
expect(mock_query).to receive(:run).with('vApp', :filter => "name==vapp-test-1").and_return(q_results)
|
78
|
-
expect{ Vapp.get_by_name('vapp-test-1') }.to raise_exception(RuntimeError)
|
79
|
-
end
|
104
|
+
context "vapp should have parent vdc" do
|
105
|
+
it "should load parent vdc id from fog attributes" do
|
106
|
+
expect(@vapp.vdc_id).to eq('074aea1e-a5e9-4dd1-a028-40db8c98d237')
|
107
|
+
end
|
80
108
|
|
109
|
+
it "should raise error if vapp without parent vdc found" do
|
110
|
+
@stub_attrs[:Link] = []
|
111
|
+
expect { @vapp.vdc_id }.to raise_error('a vapp without parent vdc found')
|
81
112
|
end
|
113
|
+
end
|
114
|
+
|
115
|
+
it "should return vms" do
|
116
|
+
expect(@vapp.vms.count).to eq(1)
|
117
|
+
expect(@vapp.vms.first[:href]).to eq('/vm-123aea1e-a5e9-4dd1-a028-40db8c98d237')
|
118
|
+
end
|
119
|
+
end
|
82
120
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
}
|
95
|
-
allow_any_instance_of(StubFogInterface).to receive(:get_vapp).and_return(@stub_attrs)
|
96
|
-
@vapp = Vapp.new(@vapp_id)
|
121
|
+
context "power on" do
|
122
|
+
context "successful power on" do
|
123
|
+
before(:each) do
|
124
|
+
@fog_vapp_body = {
|
125
|
+
:name => "Webserver vapp-1",
|
126
|
+
:href => "https://api.vcloud-director.example.com/api/vApp/vapp-63d3be58-2d5c-477d-8410-267e7c3c4a02",
|
127
|
+
:Link => [{
|
128
|
+
:rel => "up",
|
129
|
+
:type => "application/vnd.vmware.vcloud.vdc+xml",
|
130
|
+
:href => "https://api.vcloud-director.example.com/api/vdc/074aea1e-a5e9-4dd1-a028-40db8c98d237"
|
131
|
+
}]
|
97
132
|
}
|
98
|
-
it { expect(@vapp.name).to eq('Webserver vapp-1') }
|
99
|
-
|
100
|
-
context "id" do
|
101
|
-
it "should extract id correctly" do
|
102
|
-
expect(@vapp.id).to eq(@vapp_id)
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
context "vapp should have parent vdc" do
|
107
|
-
it "should load parent vdc id from fog attributes" do
|
108
|
-
expect(@vapp.vdc_id).to eq('074aea1e-a5e9-4dd1-a028-40db8c98d237')
|
109
|
-
end
|
110
|
-
|
111
|
-
it "should raise error if vapp without parent vdc found" do
|
112
|
-
@stub_attrs[:Link] = []
|
113
|
-
expect { @vapp.vdc_id }.to raise_error('a vapp without parent vdc found')
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
it "should return vms" do
|
118
|
-
expect(@vapp.vms.count).to eq(1)
|
119
|
-
expect(@vapp.vms.first[:href]).to eq('/vm-123aea1e-a5e9-4dd1-a028-40db8c98d237')
|
120
|
-
end
|
121
133
|
end
|
122
134
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
}]
|
134
|
-
}
|
135
|
-
end
|
136
|
-
|
137
|
-
it "should power on a vapp that is not powered on" do
|
138
|
-
vapp = Vapp.new(@vapp_id)
|
139
|
-
expect(@mock_fog_interface).to receive(:get_vapp).twice().and_return(
|
140
|
-
{:status => Vcloud::Core::Vapp::STATUS::POWERED_OFF},
|
141
|
-
{:status => Vcloud::Core::Vapp::STATUS::RUNNING}
|
142
|
-
)
|
143
|
-
expect(@mock_fog_interface).to receive(:power_on_vapp).with(vapp.id)
|
144
|
-
state = vapp.power_on
|
145
|
-
expect(state).to be_true
|
146
|
-
end
|
147
|
-
|
148
|
-
it "should not power on a vapp that is already powered on, but should return true" do
|
149
|
-
vapp = Vapp.new(@vapp_id)
|
150
|
-
expect(@mock_fog_interface).to receive(:get_vapp).and_return(
|
151
|
-
{:status => Vcloud::Core::Vapp::STATUS::RUNNING}
|
152
|
-
)
|
153
|
-
expect(@mock_fog_interface).not_to receive(:power_on_vapp)
|
154
|
-
state = vapp.power_on
|
155
|
-
expect(state).to be_true
|
156
|
-
end
|
157
|
-
end
|
135
|
+
it "should power on a vapp that is not powered on" do
|
136
|
+
vapp = Vcloud::Core::Vapp.new(@vapp_id)
|
137
|
+
expect(@mock_fog_interface).to receive(:get_vapp).twice().and_return(
|
138
|
+
{:status => Vcloud::Core::Vapp::STATUS::POWERED_OFF},
|
139
|
+
{:status => Vcloud::Core::Vapp::STATUS::RUNNING}
|
140
|
+
)
|
141
|
+
expect(@mock_fog_interface).to receive(:power_on_vapp).with(vapp.id)
|
142
|
+
state = vapp.power_on
|
143
|
+
expect(state).to be_true
|
144
|
+
end
|
158
145
|
|
146
|
+
it "should not power on a vapp that is already powered on, but should return true" do
|
147
|
+
vapp = Vcloud::Core::Vapp.new(@vapp_id)
|
148
|
+
expect(@mock_fog_interface).to receive(:get_vapp).and_return(
|
149
|
+
{:status => Vcloud::Core::Vapp::STATUS::RUNNING}
|
150
|
+
)
|
151
|
+
expect(@mock_fog_interface).not_to receive(:power_on_vapp)
|
152
|
+
state = vapp.power_on
|
153
|
+
expect(state).to be_true
|
159
154
|
end
|
155
|
+
end
|
160
156
|
|
161
|
-
|
157
|
+
end
|
162
158
|
|
163
|
-
|
164
|
-
allow_any_instance_of(StubFogInterface).to receive(:get_vapp_by_name_and_vdc_name)
|
165
|
-
.with('vapp_name', 'vdc_name').and_return(nil)
|
166
|
-
expect(Vapp.get_by_name_and_vdc_name('vapp_name', 'vdc_name')).to be_nil
|
167
|
-
end
|
159
|
+
context "#get_by_name_and_vdc_name" do
|
168
160
|
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
end
|
161
|
+
it "should return nil if fog returns nil" do
|
162
|
+
allow_any_instance_of(StubFogInterface).to receive(:get_vapp_by_name_and_vdc_name)
|
163
|
+
.with('vapp_name', 'vdc_name').and_return(nil)
|
164
|
+
expect(Vcloud::Core::Vapp.get_by_name_and_vdc_name('vapp_name', 'vdc_name')).to be_nil
|
165
|
+
end
|
175
166
|
|
176
|
-
|
167
|
+
it "should return vapp instance if found" do
|
168
|
+
vcloud_attr_vapp = { :href => "/#{@vapp_id}" }
|
169
|
+
allow_any_instance_of(StubFogInterface).to receive(:get_vapp_by_name_and_vdc_name)
|
170
|
+
.with('vapp_name', 'vdc_name').and_return(vcloud_attr_vapp)
|
171
|
+
expect(Vcloud::Core::Vapp.get_by_name_and_vdc_name('vapp_name', 'vdc_name').class).to eq(Vcloud::Core::Vapp)
|
172
|
+
end
|
177
173
|
|
178
|
-
|
179
|
-
|
180
|
-
it "should raise an ArgumentError if an invalid VM id is supplied" do
|
181
|
-
vm_id = 'vapp-12341234-1234-1234-1234-123412341234'
|
182
|
-
expect {Vapp.get_by_child_vm_id(vm_id)}.to raise_error(ArgumentError)
|
183
|
-
end
|
184
|
-
|
185
|
-
it "should return a vApp object if we supply an existing VM id" do
|
186
|
-
vm_id = "vm-12341234-1234-1234-1234-123412340001"
|
187
|
-
vapp_id = "vapp-12341234-1234-1234-1234-123412349999"
|
188
|
-
expect(@mock_fog_interface).to receive(:get_vapp).with(vm_id).and_return({
|
189
|
-
:Link => [
|
190
|
-
{ :rel => 'down',
|
191
|
-
:type => "application/vnd.vmware.vcloud.metadata+xml",
|
192
|
-
:href => "/api/vApp/#{vm_id}/metadata"
|
193
|
-
},
|
194
|
-
{ :rel => 'up',
|
195
|
-
:type => "application/vnd.vmware.vcloud.vApp+xml",
|
196
|
-
:href => "/api/vApp/#{vapp_id}"
|
197
|
-
}
|
198
|
-
]
|
199
|
-
})
|
200
|
-
obj = Vapp.get_by_child_vm_id(vm_id)
|
201
|
-
expect(obj.id).to eq(vapp_id)
|
202
|
-
end
|
174
|
+
end
|
203
175
|
|
204
|
-
|
176
|
+
context "#get_by_child_vm_id" do
|
205
177
|
|
178
|
+
it "should raise an ArgumentError if an invalid VM id is supplied" do
|
179
|
+
vm_id = 'vapp-12341234-1234-1234-1234-123412341234'
|
180
|
+
expect {Vcloud::Core::Vapp.get_by_child_vm_id(vm_id)}.to raise_error(ArgumentError)
|
206
181
|
end
|
182
|
+
|
183
|
+
it "should return a vApp object if we supply an existing VM id" do
|
184
|
+
vm_id = "vm-12341234-1234-1234-1234-123412340001"
|
185
|
+
vapp_id = "vapp-12341234-1234-1234-1234-123412349999"
|
186
|
+
expect(@mock_fog_interface).to receive(:get_vapp).with(vm_id).and_return({
|
187
|
+
:Link => [
|
188
|
+
{ :rel => 'down',
|
189
|
+
:type => "application/vnd.vmware.vcloud.metadata+xml",
|
190
|
+
:href => "/api/vApp/#{vm_id}/metadata"
|
191
|
+
},
|
192
|
+
{ :rel => 'up',
|
193
|
+
:type => "application/vnd.vmware.vcloud.vApp+xml",
|
194
|
+
:href => "/api/vApp/#{vapp_id}"
|
195
|
+
}
|
196
|
+
]
|
197
|
+
})
|
198
|
+
obj = Vcloud::Core::Vapp.get_by_child_vm_id(vm_id)
|
199
|
+
expect(obj.id).to eq(vapp_id)
|
200
|
+
end
|
201
|
+
|
207
202
|
end
|
203
|
+
|
208
204
|
end
|
209
205
|
|