vcloud-core 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -73,7 +73,7 @@ describe Vcloud::Core::IndependentDisk do
73
73
  end
74
74
 
75
75
  it "should raise an error if multiple Independent Disks with " +
76
- "that name exists (NB: prescribes unique disk names!)" do
76
+ "that name exists (NB: prescribes unique disk names!)" do
77
77
  q_results = [
78
78
  { :name => @disk_name, :href => @disk_id },
79
79
  { :name => @disk_name, :href => '12341234-1234-1234-1234-123456789012' },
@@ -87,7 +87,7 @@ describe Vcloud::Core::IndependentDisk do
87
87
  expect {
88
88
  Vcloud::Core::IndependentDisk.get_by_name_and_vdc_name(@disk_name, @vdc_name)
89
89
  }.to raise_exception(RuntimeError)
90
- end
90
+ end
91
91
 
92
92
  end
93
93
 
@@ -192,16 +192,16 @@ describe Vcloud::Core::IndependentDisk do
192
192
 
193
193
  before(:each) {
194
194
  @stub_attrs = {
195
- :name => @disk_name,
196
- :href => "https://api.vcloud-director.example.com/api/disk/#{@disk_id}",
197
- :Link => [{
198
- :rel => 'up',
199
- :type => 'application/vnd.vmware.vcloud.vdc+xml',
200
- :href => 'https://api.vcloud-director.example.com/api/vdc/074aea1e-a5e9-4dd1-a028-40db8c98d237'
201
- }]
202
- }
203
- allow_any_instance_of(StubFogInterface).to receive(:get_disk).and_return(@stub_attrs)
204
- @disk = Vcloud::Core::IndependentDisk.new(@disk_id)
195
+ :name => @disk_name,
196
+ :href => "https://api.vcloud-director.example.com/api/disk/#{@disk_id}",
197
+ :Link => [{
198
+ :rel => 'up',
199
+ :type => 'application/vnd.vmware.vcloud.vdc+xml',
200
+ :href => 'https://api.vcloud-director.example.com/api/vdc/074aea1e-a5e9-4dd1-a028-40db8c98d237'
201
+ }]
202
+ }
203
+ allow_any_instance_of(StubFogInterface).to receive(:get_disk).and_return(@stub_attrs)
204
+ @disk = Vcloud::Core::IndependentDisk.new(@disk_id)
205
205
  }
206
206
 
207
207
  it { expect(@disk.name).to eq(@disk_name) }
@@ -225,9 +225,9 @@ describe Vcloud::Core::IndependentDisk do
225
225
  })
226
226
  expect(@mock_fog_interface).to receive(:get_vms_disk_attached_to).
227
227
  with(subject.id).and_return({:VmReference=>[
228
- { :href => '/vm-12341234-1234-1234-1234-123412340001' },
229
- { :href => '/vm-12341234-1234-1234-1234-123412340002' },
230
- ]})
228
+ { :href => '/vm-12341234-1234-1234-1234-123412340001' },
229
+ { :href => '/vm-12341234-1234-1234-1234-123412340002' },
230
+ ]})
231
231
  vms = subject.attached_vms
232
232
  expect(vms[0].id).to eq('vm-12341234-1234-1234-1234-123412340001')
233
233
  expect(vms[1].id).to eq('vm-12341234-1234-1234-1234-123412340002')
@@ -1,89 +1,85 @@
1
1
  require 'spec_helper'
2
2
 
3
- module Vcloud
4
- module Core
5
- describe MetadataHelper do
6
- context "get_metadata" do
3
+ describe Vcloud::Core::MetadataHelper do
4
+ context "get_metadata" do
7
5
 
8
- it "should process valid metadata types" do
9
- metadata_entries = [
10
- {
11
- :type => Fog::ContentTypes::METADATA,
12
- :Key => 'role_name',
13
- :TypedValue => {
14
- :xsi_type => 'MetadataStringValue',
15
- :Value => 'james-bond'
16
- }},
17
- {
18
- :type => Fog::ContentTypes::METADATA,
19
- :Key => "server_number",
20
- :TypedValue => {:xsi_type => "MetadataNumberValue", :Value => "-10"}
21
- },
22
- {
23
- :type => Fog::ContentTypes::METADATA,
24
- :Key => "created_at",
25
- :TypedValue => {:xsi_type => "MetadataDateTimeValue", :Value => "2013-12-16T14:30:05.000Z"}
26
- },
27
- {
28
- :type => Fog::ContentTypes::METADATA,
29
- :Key => "daily_shutdown",
30
- :TypedValue => {:xsi_type => "MetadataBooleanValue", :Value => "false"}
31
- }
32
- ]
33
- metadata = MetadataHelper.extract_metadata(metadata_entries)
34
- expect(metadata.count).to eq(4)
35
- expect(metadata[:role_name]).to eq('james-bond')
36
- expect(metadata[:server_number]).to eq(-10)
37
- expect(metadata[:created_at]).to eq(DateTime.parse("2013-12-16T14:30:05.000Z"))
38
- expect(metadata[:daily_shutdown]).to be_false
39
- end
40
-
41
- it "should skip metadata entry if entry type is not application/vnd.vmware.vcloud.metadata.value+xml" do
42
- metadata_entries = [
43
- {
44
- :type => Fog::ContentTypes::METADATA,
45
- :Key => 'role_name',
46
- :TypedValue => {
47
- :xsi_type => 'MetadataStringValue',
48
- :Value => 'james-bond'
49
- }},
50
- {
51
- :Key => "untyped_key",
52
- :TypedValue => {:xsi_type => "MetadataNumberValue", :Value => "-10"}
53
- },
6
+ it "should process valid metadata types" do
7
+ metadata_entries = [
8
+ {
9
+ :type => Vcloud::Core::Fog::ContentTypes::METADATA,
10
+ :Key => 'role_name',
11
+ :TypedValue => {
12
+ :xsi_type => 'MetadataStringValue',
13
+ :Value => 'james-bond'
14
+ }},
15
+ {
16
+ :type => Vcloud::Core::Fog::ContentTypes::METADATA,
17
+ :Key => "server_number",
18
+ :TypedValue => {:xsi_type => "MetadataNumberValue", :Value => "-10"}
19
+ },
20
+ {
21
+ :type => Vcloud::Core::Fog::ContentTypes::METADATA,
22
+ :Key => "created_at",
23
+ :TypedValue => {:xsi_type => "MetadataDateTimeValue", :Value => "2013-12-16T14:30:05.000Z"}
24
+ },
25
+ {
26
+ :type => Vcloud::Core::Fog::ContentTypes::METADATA,
27
+ :Key => "daily_shutdown",
28
+ :TypedValue => {:xsi_type => "MetadataBooleanValue", :Value => "false"}
29
+ }
30
+ ]
31
+ metadata = Vcloud::Core::MetadataHelper.extract_metadata(metadata_entries)
32
+ expect(metadata.count).to eq(4)
33
+ expect(metadata[:role_name]).to eq('james-bond')
34
+ expect(metadata[:server_number]).to eq(-10)
35
+ expect(metadata[:created_at]).to eq(DateTime.parse("2013-12-16T14:30:05.000Z"))
36
+ expect(metadata[:daily_shutdown]).to be_false
37
+ end
54
38
 
55
- ]
56
- metadata = MetadataHelper.extract_metadata(metadata_entries)
57
- expect(metadata.count).to eq(1)
58
- expect(metadata.keys).not_to include :untyped_key
59
- end
39
+ it "should skip metadata entry if entry type is not application/vnd.vmware.vcloud.metadata.value+xml" do
40
+ metadata_entries = [
41
+ {
42
+ :type => Vcloud::Core::Fog::ContentTypes::METADATA,
43
+ :Key => 'role_name',
44
+ :TypedValue => {
45
+ :xsi_type => 'MetadataStringValue',
46
+ :Value => 'james-bond'
47
+ }},
48
+ {
49
+ :Key => "untyped_key",
50
+ :TypedValue => {:xsi_type => "MetadataNumberValue", :Value => "-10"}
51
+ },
60
52
 
61
- it "should include unrecognized metadata types" do
62
- metadata_entries = [
63
- {
64
- :type => Fog::ContentTypes::METADATA,
65
- :Key => 'role_name',
66
- :TypedValue => {
67
- :xsi_type => 'MetadataStringValue',
68
- :Value => 'james-bond'
69
- }},
70
- {
71
- :type => Fog::ContentTypes::METADATA,
72
- :Key => "unrecognized_type_key",
73
- :TypedValue => {:xsi_type => "MetadataWholeNumberValue", :Value => "-10"}
74
- },
53
+ ]
54
+ metadata = Vcloud::Core::MetadataHelper.extract_metadata(metadata_entries)
55
+ expect(metadata.count).to eq(1)
56
+ expect(metadata.keys).not_to include :untyped_key
57
+ end
75
58
 
76
- ]
77
- metadata = MetadataHelper.extract_metadata(metadata_entries)
78
- expect(metadata.count).to eq(2)
79
- expect(metadata.keys).to include :unrecognized_type_key
80
- end
59
+ it "should include unrecognized metadata types" do
60
+ metadata_entries = [
61
+ {
62
+ :type => Vcloud::Core::Fog::ContentTypes::METADATA,
63
+ :Key => 'role_name',
64
+ :TypedValue => {
65
+ :xsi_type => 'MetadataStringValue',
66
+ :Value => 'james-bond'
67
+ }},
68
+ {
69
+ :type => Vcloud::Core::Fog::ContentTypes::METADATA,
70
+ :Key => "unrecognized_type_key",
71
+ :TypedValue => {:xsi_type => "MetadataWholeNumberValue", :Value => "-10"}
72
+ },
81
73
 
74
+ ]
75
+ metadata = Vcloud::Core::MetadataHelper.extract_metadata(metadata_entries)
76
+ expect(metadata.count).to eq(2)
77
+ expect(metadata.keys).to include :unrecognized_type_key
78
+ end
82
79
 
83
- end
84
80
 
81
+ end
85
82
 
86
- end
87
83
 
88
- end
89
84
  end
85
+
@@ -1,257 +1,253 @@
1
1
  require 'spec_helper'
2
2
 
3
- module Vcloud
4
- module Core
5
- describe OrgVdcNetwork do
3
+ describe Vcloud::Core::OrgVdcNetwork do
4
+
5
+ before(:each) do
6
+ @vdc_id = '12345678-1234-1234-1234-000000111111'
7
+ @edgegw_id = '12345678-1234-1234-1234-000000222222'
8
+ @net_id = '12345678-1234-1234-1234-000000333333'
9
+ @vdc_name = 'test-vdc-1'
10
+ @net_name = 'test-net-1'
11
+ @mock_fog_interface = StubFogInterface.new
12
+ allow(Vcloud::Core::Fog::ServiceInterface).to receive(:new).and_return(@mock_fog_interface)
13
+ allow_any_instance_of(Vcloud::Core::Vdc).to receive(:id).and_return(@vdc_id)
14
+ @mock_vdc = double(:vdc, :id => @vdc_id)
15
+ allow(Vcloud::Core::Vdc).to receive(:get_by_name).and_return(@mock_vdc)
16
+ end
17
+
18
+ context "Class public interface" do
19
+ it { expect(Vcloud::Core::OrgVdcNetwork).to respond_to(:provision) }
20
+ end
21
+
22
+ context "Object public interface" do
23
+ subject { Vcloud::Core::OrgVdcNetwork.new(@net_id) }
24
+ it { should respond_to(:id) }
25
+ it { should respond_to(:name) }
26
+ it { should respond_to(:href) }
27
+ it { should respond_to(:delete) }
28
+ end
29
+
30
+ context "#initialize" do
31
+
32
+ it "should be constructable from just an id reference" do
33
+ obj = Vcloud::Core::OrgVdcNetwork.new(@net_id)
34
+ expect(obj.class).to be(Vcloud::Core::OrgVdcNetwork)
35
+ end
36
+
37
+ it "should store the id specified" do
38
+ obj = Vcloud::Core::OrgVdcNetwork.new(@net_id)
39
+ expect(obj.id).to eq(@net_id)
40
+ end
41
+
42
+ it "should raise error if id is not in correct format" do
43
+ bogus_id = '123123-bogus-id-123445'
44
+ expect{ Vcloud::Core::OrgVdcNetwork.new(bogus_id) }.
45
+ to raise_error("orgVdcNetwork id : #{bogus_id} is not in correct format" )
46
+ end
47
+
48
+ end
49
+
50
+ context "#delete" do
51
+ it "should call down to Fog::ServiceInterface.delete_network with the correct id" do
52
+ expect(@mock_fog_interface).to receive(:delete_network).with(@net_id)
53
+ Vcloud::Core::OrgVdcNetwork.new(@net_id).delete
54
+ end
55
+ end
56
+
57
+ context "#provision" do
58
+
59
+ before(:each) do
60
+ @mock_vdc = double(
61
+ :vdc,
62
+ :id => @vdc_id,
63
+ :href => "/#{@vdc_id}",
64
+ :name => @vdc_name
65
+ )
66
+ allow(Vcloud::Core::Vdc).to receive(:get_by_name).and_return(@mock_vdc)
67
+ end
68
+
69
+ context "should fail gracefully on bad input" do
6
70
 
7
71
  before(:each) do
8
- @vdc_id = '12345678-1234-1234-1234-000000111111'
9
- @edgegw_id = '12345678-1234-1234-1234-000000222222'
10
- @net_id = '12345678-1234-1234-1234-000000333333'
11
- @vdc_name = 'test-vdc-1'
12
- @net_name = 'test-net-1'
13
- @mock_fog_interface = StubFogInterface.new
14
- allow(Vcloud::Core::Fog::ServiceInterface).to receive(:new).and_return(@mock_fog_interface)
15
- allow_any_instance_of(Vdc).to receive(:id).and_return(@vdc_id)
16
- @mock_vdc = double(:vdc, :id => @vdc_id)
17
- allow(Vdc).to receive(:get_by_name).and_return(@mock_vdc)
72
+ @config = {
73
+ :name => @net_name,
74
+ :vdc_name => @vdc_name,
75
+ :fence_mode => 'isolated'
76
+ }
18
77
  end
19
78
 
20
- context "Class public interface" do
21
- it { expect(OrgVdcNetwork).to respond_to(:provision) }
79
+ it "should fail if :name is not set" do
80
+ @config.delete(:name)
81
+ expect { Vcloud::Core::OrgVdcNetwork.provision(@config) }.
82
+ to raise_exception(RuntimeError)
22
83
  end
23
84
 
24
- context "Object public interface" do
25
- subject { OrgVdcNetwork.new(@net_id) }
26
- it { should respond_to(:id) }
27
- it { should respond_to(:name) }
28
- it { should respond_to(:href) }
29
- it { should respond_to(:delete) }
85
+ it "should fail if :vdc_name is not set" do
86
+ @config.delete(:vdc_name)
87
+ expect { Vcloud::Core::OrgVdcNetwork.provision(@config) }.
88
+ to raise_exception(RuntimeError)
30
89
  end
31
90
 
32
- context "#initialize" do
91
+ it "should fail if :fence_mode is not set" do
92
+ @config.delete(:fence_mode)
93
+ expect { Vcloud::Core::OrgVdcNetwork.provision(@config) }.
94
+ to raise_exception(RuntimeError)
95
+ end
33
96
 
34
- it "should be constructable from just an id reference" do
35
- obj = OrgVdcNetwork.new(@net_id)
36
- expect(obj.class).to be(Vcloud::Core::OrgVdcNetwork)
37
- end
97
+ it "should fail if :fence_mode is not 'isolated' or 'natRouted'" do
98
+ @config[:fence_mode] = 'testfail'
99
+ expect { Vcloud::Core::OrgVdcNetwork.provision(@config) }.
100
+ to raise_exception(RuntimeError)
101
+ end
38
102
 
39
- it "should store the id specified" do
40
- obj = OrgVdcNetwork.new(@net_id)
41
- expect(obj.id).to eq(@net_id)
42
- end
103
+ end
43
104
 
44
- it "should raise error if id is not in correct format" do
45
- bogus_id = '123123-bogus-id-123445'
46
- expect{ OrgVdcNetwork.new(bogus_id) }.
47
- to raise_error("orgVdcNetwork id : #{bogus_id} is not in correct format" )
48
- end
105
+ context "isolated orgVdcNetwork" do
49
106
 
107
+ before(:each) do
108
+ q_results = [
109
+ { :name => @net_name, :href => "/#{@net_id}" }
110
+ ]
111
+ @mock_net_query = double(:query_runner, :run => q_results)
112
+ @config = {
113
+ :name => @net_name,
114
+ :vdc_name => @vdc_name,
115
+ :fence_mode => 'isolated'
116
+ }
50
117
  end
51
118
 
52
- context "#delete" do
53
- it "should call down to Fog::ServiceInterface.delete_network with the correct id" do
54
- expect(@mock_fog_interface).to receive(:delete_network).with(@net_id)
55
- OrgVdcNetwork.new(@net_id).delete
56
- end
119
+ it "should create an Vcloud::Core::OrgVdcNetwork with minimal config" do
120
+ expected_vcloud_attrs = {
121
+ :IsShared => false,
122
+ :Configuration => {
123
+ :FenceMode => 'isolated',
124
+ :IpScopes => {
125
+ :IpScope => {
126
+ :IsInherited => false,
127
+ :IsEnabled => true
128
+ }
129
+ }
130
+ },
131
+ }
132
+ expect(Vcloud::Core.logger).to receive(:info)
133
+ expect(@mock_fog_interface).to receive(:post_create_org_vdc_network).
134
+ with(@vdc_id, @config[:name], expected_vcloud_attrs).
135
+ and_return({ :href => "/#{@net_id}" })
136
+ obj = Vcloud::Core::OrgVdcNetwork.provision(@config)
137
+ expect(obj.id).to eq(@net_id)
57
138
  end
58
139
 
59
- context "#provision" do
60
-
61
- before(:each) do
62
- @mock_vdc = double(
63
- :vdc,
64
- :id => @vdc_id,
65
- :href => "/#{@vdc_id}",
66
- :name => @vdc_name
67
- )
68
- allow(Vdc).to receive(:get_by_name).and_return(@mock_vdc)
69
- end
70
-
71
- context "should fail gracefully on bad input" do
72
-
73
- before(:each) do
74
- @config = {
75
- :name => @net_name,
76
- :vdc_name => @vdc_name,
77
- :fence_mode => 'isolated'
78
- }
79
- end
80
-
81
- it "should fail if :name is not set" do
82
- @config.delete(:name)
83
- expect { Vcloud::Core::OrgVdcNetwork.provision(@config) }.
84
- to raise_exception(RuntimeError)
85
- end
86
-
87
- it "should fail if :vdc_name is not set" do
88
- @config.delete(:vdc_name)
89
- expect { Vcloud::Core::OrgVdcNetwork.provision(@config) }.
90
- to raise_exception(RuntimeError)
91
- end
92
-
93
- it "should fail if :fence_mode is not set" do
94
- @config.delete(:fence_mode)
95
- expect { Vcloud::Core::OrgVdcNetwork.provision(@config) }.
96
- to raise_exception(RuntimeError)
97
- end
98
-
99
- it "should fail if :fence_mode is not 'isolated' or 'natRouted'" do
100
- @config[:fence_mode] = 'testfail'
101
- expect { Vcloud::Core::OrgVdcNetwork.provision(@config) }.
102
- to raise_exception(RuntimeError)
103
- end
104
-
105
- end
106
-
107
- context "isolated orgVdcNetwork" do
108
-
109
- before(:each) do
110
- q_results = [
111
- { :name => @net_name, :href => "/#{@net_id}" }
112
- ]
113
- @mock_net_query = double(:query_runner, :run => q_results)
114
- @config = {
115
- :name => @net_name,
116
- :vdc_name => @vdc_name,
117
- :fence_mode => 'isolated'
118
- }
119
- end
120
-
121
- it "should create an OrgVdcNetwork with minimal config" do
122
- expected_vcloud_attrs = {
123
- :IsShared => false,
124
- :Configuration => {
125
- :FenceMode => 'isolated',
126
- :IpScopes => {
127
- :IpScope => {
128
- :IsInherited => false,
129
- :IsEnabled => true
130
- }
131
- }
132
- },
133
- }
134
- expect(Vcloud::Core.logger).to receive(:info)
135
- expect(@mock_fog_interface).to receive(:post_create_org_vdc_network).
136
- with(@vdc_id, @config[:name], expected_vcloud_attrs).
137
- and_return({ :href => "/#{@net_id}" })
138
- obj = Vcloud::Core::OrgVdcNetwork.provision(@config)
139
- expect(obj.id).to eq(@net_id)
140
- end
141
-
142
- it "should handle specification of one ip_ranges" do
143
- @config[:ip_ranges] = [
144
- { :start_address => '10.53.53.100', :end_address => '10.53.53.110' }
145
- ]
146
- expected_vcloud_attrs = {
147
- :IsShared => false,
148
- :Configuration => {
149
- :FenceMode => 'isolated',
150
- :IpScopes => {
151
- :IpScope => {
152
- :IsInherited => false,
153
- :IsEnabled => true,
154
- :IpRanges => [{
155
- :IpRange => {
156
- :StartAddress => '10.53.53.100',
157
- :EndAddress => '10.53.53.110'
158
- },
159
- }],
160
- }
161
- }
140
+ it "should handle specification of one ip_ranges" do
141
+ @config[:ip_ranges] = [
142
+ { :start_address => '10.53.53.100', :end_address => '10.53.53.110' }
143
+ ]
144
+ expected_vcloud_attrs = {
145
+ :IsShared => false,
146
+ :Configuration => {
147
+ :FenceMode => 'isolated',
148
+ :IpScopes => {
149
+ :IpScope => {
150
+ :IsInherited => false,
151
+ :IsEnabled => true,
152
+ :IpRanges => [{
153
+ :IpRange => {
154
+ :StartAddress => '10.53.53.100',
155
+ :EndAddress => '10.53.53.110'
156
+ },
157
+ }],
158
+ }
159
+ }
160
+ }
161
+ }
162
+ expect(Vcloud::Core.logger).to receive(:info)
163
+ expect(@mock_fog_interface).to receive(:post_create_org_vdc_network).
164
+ with(@vdc_id, @config[:name], expected_vcloud_attrs).
165
+ and_return({ :href => "/#{@net_id}" })
166
+ Vcloud::Core::OrgVdcNetwork.provision(@config)
167
+ end
168
+
169
+ it "should handle specification of two ip_ranges" do
170
+ @config[:ip_ranges] = [
171
+ { :start_address => '10.53.53.100', :end_address => '10.53.53.110' },
172
+ { :start_address => '10.53.53.120', :end_address => '10.53.53.130' },
173
+ ]
174
+ expected_vcloud_attrs = {
175
+ :IsShared => false,
176
+ :Configuration => {
177
+ :FenceMode => 'isolated',
178
+ :IpScopes => {
179
+ :IpScope => {
180
+ :IsInherited => false,
181
+ :IsEnabled => true,
182
+ :IpRanges => [
183
+ { :IpRange =>
184
+ {
185
+ :StartAddress => '10.53.53.100',
186
+ :EndAddress => '10.53.53.110'
162
187
  }
188
+ },
189
+ { :IpRange =>
190
+ {
191
+ :StartAddress => '10.53.53.120',
192
+ :EndAddress => '10.53.53.130'
163
193
  }
164
- expect(Vcloud::Core.logger).to receive(:info)
165
- expect(@mock_fog_interface).to receive(:post_create_org_vdc_network).
166
- with(@vdc_id, @config[:name], expected_vcloud_attrs).
167
- and_return({ :href => "/#{@net_id}" })
168
- Vcloud::Core::OrgVdcNetwork.provision(@config)
169
- end
170
-
171
- it "should handle specification of two ip_ranges" do
172
- @config[:ip_ranges] = [
173
- { :start_address => '10.53.53.100', :end_address => '10.53.53.110' },
174
- { :start_address => '10.53.53.120', :end_address => '10.53.53.130' },
175
- ]
176
- expected_vcloud_attrs = {
177
- :IsShared => false,
178
- :Configuration => {
179
- :FenceMode => 'isolated',
180
- :IpScopes => {
181
- :IpScope => {
182
- :IsInherited => false,
183
- :IsEnabled => true,
184
- :IpRanges => [
185
- { :IpRange =>
186
- {
187
- :StartAddress => '10.53.53.100',
188
- :EndAddress => '10.53.53.110'
189
- }
190
- },
191
- { :IpRange =>
192
- {
193
- :StartAddress => '10.53.53.120',
194
- :EndAddress => '10.53.53.130'
195
- }
196
- },
197
- ]
198
- }
199
- }
200
- },
201
- }
202
- expect(Vcloud::Core.logger).to receive(:info)
203
- expect(@mock_fog_interface).to receive(:post_create_org_vdc_network).
204
- with(@vdc_id, @config[:name], expected_vcloud_attrs).
205
- and_return({ :href => "/#{@net_id}" })
206
- Vcloud::Core::OrgVdcNetwork.provision(@config)
207
- end
208
-
209
- end
210
-
211
- context "natRouted orgVdcNetwork" do
212
-
213
- before(:each) do
214
- @config = {
215
- :name => @net_name,
216
- :vdc_name => @vdc_name,
217
- :fence_mode => 'natRouted'
218
- }
219
- end
220
-
221
- it "should fail if an edge_gateway is not supplied" do
222
- expect{ Vcloud::Core::OrgVdcNetwork.provision(@config) }.
223
- to raise_exception(RuntimeError)
224
- end
225
-
226
- it "should handle lack of ip_ranges on natRouted networks" do
227
- @config[:edge_gateway] = 'test gateway'
228
- mock_edgegw = Vcloud::Core::EdgeGateway.new(@edgegw_id)
229
- allow(Vcloud::Core::EdgeGateway).to receive(:get_by_name).and_return(mock_edgegw)
230
-
231
- expected_vcloud_attrs = {
232
- :IsShared => false,
233
- :Configuration => {
234
- :FenceMode => 'natRouted',
235
- :IpScopes => {
236
- :IpScope => {
237
- :IsInherited => false,
238
- :IsEnabled => true
239
- }
240
- }
241
- },
242
- :EdgeGateway => { :href => "/#{@edgegw_id}" },
243
- }
244
- expect(Vcloud::Core.logger).to receive(:info)
245
- expect(@mock_fog_interface).to receive(:post_create_org_vdc_network).
246
- with(@vdc_id, @config[:name], expected_vcloud_attrs).
247
- and_return({ :href => "/#{@net_id}" })
248
- Vcloud::Core::OrgVdcNetwork.provision(@config)
249
- end
194
+ },
195
+ ]
196
+ }
197
+ }
198
+ },
199
+ }
200
+ expect(Vcloud::Core.logger).to receive(:info)
201
+ expect(@mock_fog_interface).to receive(:post_create_org_vdc_network).
202
+ with(@vdc_id, @config[:name], expected_vcloud_attrs).
203
+ and_return({ :href => "/#{@net_id}" })
204
+ Vcloud::Core::OrgVdcNetwork.provision(@config)
205
+ end
206
+
207
+ end
208
+
209
+ context "natRouted orgVdcNetwork" do
210
+
211
+ before(:each) do
212
+ @config = {
213
+ :name => @net_name,
214
+ :vdc_name => @vdc_name,
215
+ :fence_mode => 'natRouted'
216
+ }
217
+ end
250
218
 
251
- end
219
+ it "should fail if an edge_gateway is not supplied" do
220
+ expect{ Vcloud::Core::OrgVdcNetwork.provision(@config) }.
221
+ to raise_exception(RuntimeError)
222
+ end
252
223
 
224
+ it "should handle lack of ip_ranges on natRouted networks" do
225
+ @config[:edge_gateway] = 'test gateway'
226
+ mock_edgegw = Vcloud::Core::EdgeGateway.new(@edgegw_id)
227
+ allow(Vcloud::Core::EdgeGateway).to receive(:get_by_name).and_return(mock_edgegw)
228
+
229
+ expected_vcloud_attrs = {
230
+ :IsShared => false,
231
+ :Configuration => {
232
+ :FenceMode => 'natRouted',
233
+ :IpScopes => {
234
+ :IpScope => {
235
+ :IsInherited => false,
236
+ :IsEnabled => true
237
+ }
238
+ }
239
+ },
240
+ :EdgeGateway => { :href => "/#{@edgegw_id}" },
241
+ }
242
+ expect(Vcloud::Core.logger).to receive(:info)
243
+ expect(@mock_fog_interface).to receive(:post_create_org_vdc_network).
244
+ with(@vdc_id, @config[:name], expected_vcloud_attrs).
245
+ and_return({ :href => "/#{@net_id}" })
246
+ Vcloud::Core::OrgVdcNetwork.provision(@config)
253
247
  end
254
248
 
255
249
  end
250
+
256
251
  end
252
+
257
253
  end