vcloud-core 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. data/.travis.yml +2 -0
  2. data/CHANGELOG.md +10 -1
  3. data/CONTRIBUTING.md +66 -0
  4. data/README.md +5 -5
  5. data/Rakefile +1 -1
  6. data/lib/vcloud/core/config_validator.rb +20 -20
  7. data/lib/vcloud/core/query_cli.rb +1 -1
  8. data/lib/vcloud/core/version.rb +1 -1
  9. data/lib/vcloud/core/vm.rb +2 -39
  10. data/lib/vcloud/fog/service_interface.rb +10 -5
  11. data/spec/integration/README.md +1 -1
  12. data/spec/integration/core/edge_gateway_spec.rb +133 -0
  13. data/spec/integration/core/query_runner_spec.rb +10 -4
  14. data/spec/integration/core/vapp_spec.rb +249 -0
  15. data/spec/integration/core/vdc_spec.rb +6 -4
  16. data/spec/integration/core/vm_spec.rb +24 -12
  17. data/spec/spec_helper.rb +21 -10
  18. data/spec/support/integration_helper.rb +27 -0
  19. data/spec/vcloud/core/config_loader_spec.rb +10 -10
  20. data/spec/vcloud/core/config_validator_spec.rb +7 -0
  21. data/spec/vcloud/core/edge_gateway_spec.rb +10 -10
  22. data/spec/vcloud/core/metadata_helper_spec.rb +2 -2
  23. data/spec/vcloud/core/org_vdc_network_spec.rb +15 -15
  24. data/spec/vcloud/core/query_runner_spec.rb +13 -13
  25. data/spec/vcloud/core/query_spec.rb +9 -9
  26. data/spec/vcloud/core/vapp_spec.rb +19 -19
  27. data/spec/vcloud/core/vapp_template_spec.rb +9 -9
  28. data/spec/vcloud/core/vdc_spec.rb +6 -6
  29. data/spec/vcloud/core/vm_spec.rb +50 -118
  30. data/spec/vcloud/fog/fog_model_interface_spec.rb +3 -3
  31. data/spec/vcloud/fog/service_interface_spec.rb +9 -9
  32. data/vcloud-core.gemspec +6 -6
  33. metadata +36 -35
  34. data/spec/integration/edge_gateway/configure_edge_gateway_services_spec.rb +0 -55
  35. data/spec/integration/edge_gateway/edge_gateway_spec.rb +0 -45
@@ -7,11 +7,11 @@ module Vcloud
7
7
  before(:each) do
8
8
  @id = 'vappTemplate-12345678-1234-1234-1234-000000234121'
9
9
  @mock_fog_interface = StubFogInterface.new
10
- Vcloud::Fog::ServiceInterface.stub(:new).and_return(@mock_fog_interface)
10
+ allow(Vcloud::Fog::ServiceInterface).to receive(:new).and_return(@mock_fog_interface)
11
11
  end
12
12
 
13
13
  context "Class public interface" do
14
- it { VappTemplate.should respond_to(:get) }
14
+ it { expect(VappTemplate).to respond_to(:get) }
15
15
  end
16
16
 
17
17
  context "Instance public interface" do
@@ -47,8 +47,8 @@ module Vcloud
47
47
  it 'should raise a RuntimeError if there is no template' do
48
48
  q_results = [ ]
49
49
  mock_query = double(:query_runner)
50
- Vcloud::Core::QueryRunner.should_receive(:new).and_return(mock_query)
51
- mock_query.should_receive(:run).
50
+ expect(Vcloud::Core::QueryRunner).to receive(:new).and_return(mock_query)
51
+ expect(mock_query).to receive(:run).
52
52
  with('vAppTemplate', :filter => "name==test_template;catalogName==test_catalog").
53
53
  and_return(q_results)
54
54
  expect { VappTemplate.get('test_template', 'test_catalog') }.
@@ -63,8 +63,8 @@ module Vcloud
63
63
  :href => "/vappTemplate-12345678-90ab-cdef-0123-4567890ab002" },
64
64
  ]
65
65
  mock_query = double(:query_runner)
66
- Vcloud::Core::QueryRunner.should_receive(:new).and_return(mock_query)
67
- mock_query.should_receive(:run).
66
+ expect(Vcloud::Core::QueryRunner).to receive(:new).and_return(mock_query)
67
+ expect(mock_query).to receive(:run).
68
68
  with('vAppTemplate', :filter => "name==test_template;catalogName==test_catalog").
69
69
  and_return(q_results)
70
70
  expect { VappTemplate.get('test_template', 'test_catalog') }.
@@ -77,12 +77,12 @@ module Vcloud
77
77
  :href => "/vappTemplate-12345678-90ab-cdef-0123-4567890abcde" }
78
78
  ]
79
79
  mock_query = double(:query)
80
- Vcloud::Core::QueryRunner.should_receive(:new).and_return(mock_query)
81
- mock_query.should_receive(:run).
80
+ expect(Vcloud::Core::QueryRunner).to receive(:new).and_return(mock_query)
81
+ expect(mock_query).to receive(:run).
82
82
  with('vAppTemplate', :filter => "name==test_template;catalogName==test_catalog").
83
83
  and_return(q_results)
84
84
  test_template = VappTemplate.get('test_template', 'test_catalog')
85
- test_template.id.should == 'vappTemplate-12345678-90ab-cdef-0123-4567890abcde'
85
+ expect(test_template.id).to eq('vappTemplate-12345678-90ab-cdef-0123-4567890abcde')
86
86
  end
87
87
 
88
88
  end
@@ -7,11 +7,11 @@ module Vcloud
7
7
  before(:each) do
8
8
  @vdc_id = '12345678-1234-1234-1234-000000111232'
9
9
  @mock_fog_interface = StubFogInterface.new
10
- Vcloud::Fog::ServiceInterface.stub(:new).and_return(@mock_fog_interface)
10
+ allow(Vcloud::Fog::ServiceInterface).to receive(:new).and_return(@mock_fog_interface)
11
11
  end
12
12
 
13
13
  context "Class public interface" do
14
- it { Vdc.should respond_to(:get_by_name) }
14
+ it { expect(Vdc).to respond_to(:get_by_name) }
15
15
  end
16
16
 
17
17
  context "Instance public interface" do
@@ -47,8 +47,8 @@ module Vcloud
47
47
  { :name => 'vdc-test-1', :href => @vdc_id }
48
48
  ]
49
49
  mock_query = double(:query_runner)
50
- Vcloud::Core::QueryRunner.should_receive(:new).and_return(mock_query)
51
- mock_query.should_receive(:run).with('orgVdc', :filter => "name==vdc-test-1").and_return(q_results)
50
+ expect(Vcloud::Core::QueryRunner).to receive(:new).and_return(mock_query)
51
+ expect(mock_query).to receive(:run).with('orgVdc', :filter => "name==vdc-test-1").and_return(q_results)
52
52
  obj = Vdc.get_by_name('vdc-test-1')
53
53
  expect(obj.class).to be(Vcloud::Core::Vdc)
54
54
  end
@@ -56,8 +56,8 @@ module Vcloud
56
56
  it "should raise an error if no vDC with that name exists" do
57
57
  q_results = [ ]
58
58
  mock_query = double(:query_runner)
59
- Vcloud::Core::QueryRunner.should_receive(:new).and_return(mock_query)
60
- mock_query.should_receive(:run).with('orgVdc', :filter => "name==vdc-test-1").and_return(q_results)
59
+ expect(Vcloud::Core::QueryRunner).to receive(:new).and_return(mock_query)
60
+ expect(mock_query).to receive(:run).with('orgVdc', :filter => "name==vdc-test-1").and_return(q_results)
61
61
  expect{ Vdc.get_by_name('vdc-test-1') }.to raise_exception(RuntimeError, "vDc vdc-test-1 not found")
62
62
  end
63
63
 
@@ -21,8 +21,8 @@ module Vcloud
21
21
  @mock_vm_cpu_count = 1
22
22
  @fog_interface = StubFogInterface.new
23
23
  @mock_vapp = double(:vappm, :name => @vapp_name, :id => @vapp_id)
24
- Vcloud::Fog::ServiceInterface.stub(:new).and_return(@fog_interface)
25
- @fog_interface.stub(:get_vapp).with(@vm_id).and_return({
24
+ allow(Vcloud::Fog::ServiceInterface).to receive(:new).and_return(@fog_interface)
25
+ allow(@fog_interface).to receive(:get_vapp).with(@vm_id).and_return({
26
26
  :name => "#{@vm_name}",
27
27
  :href => "vm-href/#{@vm_id}",
28
28
  :'ovf:VirtualHardwareSection' => {
@@ -58,7 +58,6 @@ module Vcloud
58
58
  it { should respond_to(:add_extra_disks) }
59
59
  it { should respond_to(:configure_network_interfaces) }
60
60
  it { should respond_to(:configure_guest_customization_section) }
61
- it { should respond_to(:generate_preamble) }
62
61
  end
63
62
 
64
63
  context "#initialize" do
@@ -82,144 +81,77 @@ module Vcloud
82
81
 
83
82
  context "update memory in VM" do
84
83
  it "should not allow memory size < 64MB" do
85
- @fog_interface.should_not_receive(:put_memory)
84
+ expect(@fog_interface).not_to receive(:put_memory)
86
85
  @vm.update_memory_size_in_mb(63)
87
86
  end
88
87
  it "should not update memory if is size has not changed" do
89
- @fog_interface.should_not_receive(:put_memory)
88
+ expect(@fog_interface).not_to receive(:put_memory)
90
89
  @vm.update_memory_size_in_mb(@mock_vm_memory_size)
91
90
  end
92
91
  it "should gracefully handle a nil memory size" do
93
- @fog_interface.should_not_receive(:put_memory)
92
+ expect(@fog_interface).not_to receive(:put_memory)
94
93
  @vm.update_memory_size_in_mb(nil)
95
94
  end
96
95
  it "should set memory size 64MB" do
97
- @fog_interface.should_receive(:put_memory).with(@vm_id, 64)
96
+ expect(@fog_interface).to receive(:put_memory).with(@vm_id, 64)
98
97
  @vm.update_memory_size_in_mb(64)
99
98
  end
100
99
  it "should set memory size 4096MB" do
101
- @fog_interface.should_receive(:put_memory).with(@vm_id, 4096)
100
+ expect(@fog_interface).to receive(:put_memory).with(@vm_id, 4096)
102
101
  @vm.update_memory_size_in_mb(4096)
103
102
  end
104
103
  end
105
104
 
106
105
  context "update the number of cpus in vm" do
107
106
  it "should gracefully handle nil cpu count" do
108
- @fog_interface.should_not_receive(:put_cpu)
107
+ expect(@fog_interface).not_to receive(:put_cpu)
109
108
  @vm.update_cpu_count(nil)
110
109
  end
111
110
  it "should not update cpu if is count has not changed" do
112
- @fog_interface.should_not_receive(:put_cpu)
111
+ expect(@fog_interface).not_to receive(:put_cpu)
113
112
  @vm.update_cpu_count(@mock_vm_cpu_count)
114
113
  end
115
114
  it "should not allow a zero cpu count" do
116
- @fog_interface.should_not_receive(:put_cpu)
115
+ expect(@fog_interface).not_to receive(:put_cpu)
117
116
  @vm.update_cpu_count(0)
118
117
  end
119
118
  it "should update cpu count in input is ok" do
120
- @fog_interface.should_receive(:put_cpu).with(@vm_id, 2)
119
+ expect(@fog_interface).to receive(:put_cpu).with(@vm_id, 2)
121
120
  @vm.update_cpu_count(2)
122
121
  end
123
122
  end
124
123
 
125
124
  context '#configure_guest_customization_section' do
126
-
127
- it "should handle complete configuration" do
128
- name = 'test-vm'
129
- bootstrap_config = {
130
- script_path: 'hello_world.erb',
131
- script_post_processor: 'remove_hello.rb',
132
- vars: { bob: 'hello', mary: 'hello' },
133
- }
134
- extra_disks = []
135
- @vm.should_receive(:generate_preamble).
136
- with('hello_world.erb', 'remove_hello.rb', {
137
- bob: "hello",
138
- mary: "hello",
139
- extra_disks: [] }).
140
- and_return('RETURNED_PREAMBLE')
141
- @fog_interface.should_receive(:put_guest_customization_section).
142
- with(@vm_id, 'test-vm', 'RETURNED_PREAMBLE')
143
- @vm.configure_guest_customization_section(name, bootstrap_config, extra_disks)
144
- end
145
-
146
- it "should handle nil configuration" do
147
- name = 'test-vm'
148
- bootstrap_config = nil
149
- extra_disks = nil
150
- @vm.should_not_receive(:generate_preamble)
151
- @fog_interface.should_receive(:put_guest_customization_section).
152
- with(@vm_id, 'test-vm', '')
153
- @vm.configure_guest_customization_section(name, bootstrap_config, extra_disks)
154
- end
155
-
156
- it "should handle empty configuration" do
157
- name = 'test-vm'
158
- bootstrap_config = {}
159
- extra_disks = nil
160
- @vm.should_not_receive(:generate_preamble)
161
- @fog_interface.should_receive(:put_guest_customization_section).
162
- with(@vm_id, 'test-vm', '')
163
- @vm.configure_guest_customization_section(name, bootstrap_config, extra_disks)
125
+ let(:preamble) do
126
+ <<-'EOF'
127
+ #!/usr/bin/env bash
128
+ echo "Hello World"
129
+ EOF
164
130
  end
165
131
 
166
- it "should handle bootstrap vars being missing" do
167
- name = 'test-vm'
168
- bootstrap_config = {
169
- script_path: 'hello_world.erb',
170
- script_post_processor: 'remove_hello.rb',
171
- }
172
- extra_disks = []
173
- @vm.should_receive(:generate_preamble).
174
- with('hello_world.erb', 'remove_hello.rb', { extra_disks: [] }).
175
- and_return('RETURNED_PREAMBLE')
176
- @fog_interface.should_receive(:put_guest_customization_section).
177
- with(@vm_id, 'test-vm', 'RETURNED_PREAMBLE')
178
- @vm.configure_guest_customization_section(name, bootstrap_config, extra_disks)
179
- end
180
-
181
- end
182
-
183
- context '#generate_preamble' do
184
- it "should interpolate vars hash, ENV, and vapp_name into template" do
185
- vars = {
186
- :message => 'hello world',
187
- :array_test => [ 'foo', 'bar' ],
188
- }
189
- stub_const('ENV', {'TEST_INTERPOLATED_ENVVAR' => 'test_interpolated_env'})
190
- erbfile = "#{@data_dir}/basic_preamble_test.erb"
191
- expected_output = File.read("#{erbfile}.OUT")
192
- @vm.generate_preamble(erbfile, nil, vars).should == expected_output
193
- end
132
+ it 'passes a pre-generated preamble to fog' do
133
+ expect(@fog_interface).to receive(:put_guest_customization_section).with(@vm_id, @vapp_name, preamble)
194
134
 
195
- it "passes the output of ERB through an optional post-processor tool" do
196
- # we use 'wc' as post processor since it will give us the character
197
- # count in the file, which we can easily match on, and is common
198
- # across most OSes.
199
- vars = {}
200
- erbfile = "#{@data_dir}/preamble_post_processor_test_input.erb"
201
- characters_in_file = File.read(erbfile).size
202
- expect(@vm.generate_preamble(erbfile, '/usr/bin/wc', vars)).
203
- to match(/^\s+\d+\s+\d+\s+#{characters_in_file}\s/)
135
+ @vm.configure_guest_customization_section(preamble)
204
136
  end
205
137
  end
206
138
 
207
139
  context "update metadata" do
208
140
  it "should handle empty metadata hash" do
209
- @fog_interface.should_not_receive(:put_vapp_metadata_value)
141
+ expect(@fog_interface).not_to receive(:put_vapp_metadata_value)
210
142
  @vm.update_metadata(nil)
211
143
  end
212
144
  it "should handle metadata of multiple types" do
213
- @fog_interface.should_receive(:put_vapp_metadata_value).with(@vm_id, :foo, 'bar')
214
- @fog_interface.should_receive(:put_vapp_metadata_value).with(@vm_id, :false_thing, false)
215
- @fog_interface.should_receive(:put_vapp_metadata_value).with(@vm_id, :true_thing, true)
216
- @fog_interface.should_receive(:put_vapp_metadata_value).with(@vm_id, :number, 53)
217
- @fog_interface.should_receive(:put_vapp_metadata_value).with(@vm_id, :zero, 0)
218
- @fog_interface.should_receive(:put_vapp_metadata_value).with(@vapp_id, :foo, 'bar')
219
- @fog_interface.should_receive(:put_vapp_metadata_value).with(@vapp_id, :false_thing, false)
220
- @fog_interface.should_receive(:put_vapp_metadata_value).with(@vapp_id, :true_thing, true)
221
- @fog_interface.should_receive(:put_vapp_metadata_value).with(@vapp_id, :number, 53)
222
- @fog_interface.should_receive(:put_vapp_metadata_value).with(@vapp_id, :zero, 0)
145
+ expect(@fog_interface).to receive(:put_vapp_metadata_value).with(@vm_id, :foo, 'bar')
146
+ expect(@fog_interface).to receive(:put_vapp_metadata_value).with(@vm_id, :false_thing, false)
147
+ expect(@fog_interface).to receive(:put_vapp_metadata_value).with(@vm_id, :true_thing, true)
148
+ expect(@fog_interface).to receive(:put_vapp_metadata_value).with(@vm_id, :number, 53)
149
+ expect(@fog_interface).to receive(:put_vapp_metadata_value).with(@vm_id, :zero, 0)
150
+ expect(@fog_interface).to receive(:put_vapp_metadata_value).with(@vapp_id, :foo, 'bar')
151
+ expect(@fog_interface).to receive(:put_vapp_metadata_value).with(@vapp_id, :false_thing, false)
152
+ expect(@fog_interface).to receive(:put_vapp_metadata_value).with(@vapp_id, :true_thing, true)
153
+ expect(@fog_interface).to receive(:put_vapp_metadata_value).with(@vapp_id, :number, 53)
154
+ expect(@fog_interface).to receive(:put_vapp_metadata_value).with(@vapp_id, :zero, 0)
223
155
  @vm.update_metadata(@mock_metadata)
224
156
  end
225
157
  end
@@ -227,7 +159,7 @@ module Vcloud
227
159
  context "configure vm network interfaces" do
228
160
  it "should configure single nic without an IP" do
229
161
  network_config = [{:name => 'Default'}]
230
- @fog_interface.should_receive(:put_network_connection_system_section_vapp).with(@vm_id, {
162
+ expect(@fog_interface).to receive(:put_network_connection_system_section_vapp).with(@vm_id, {
231
163
  :PrimaryNetworkConnectionIndex => 0,
232
164
  :NetworkConnection => [
233
165
  {
@@ -243,7 +175,7 @@ module Vcloud
243
175
 
244
176
  it "should configure nic from pool" do
245
177
  network_config = [{:name => 'Default', :allocation_mode => 'pool'}]
246
- @fog_interface.should_receive(:put_network_connection_system_section_vapp).with(@vm_id, {
178
+ expect(@fog_interface).to receive(:put_network_connection_system_section_vapp).with(@vm_id, {
247
179
  :PrimaryNetworkConnectionIndex => 0,
248
180
  :NetworkConnection => [
249
181
  {
@@ -259,7 +191,7 @@ module Vcloud
259
191
 
260
192
  it "should prefer configuring nic with static address" do
261
193
  network_config = [{:name => 'Default', :allocation_mode => 'dhcp', :ip_address => '192.168.1.1'}]
262
- @fog_interface.should_receive(:put_network_connection_system_section_vapp).with(@vm_id, {
194
+ expect(@fog_interface).to receive(:put_network_connection_system_section_vapp).with(@vm_id, {
263
195
  :PrimaryNetworkConnectionIndex => 0,
264
196
  :NetworkConnection => [
265
197
  {
@@ -276,7 +208,7 @@ module Vcloud
276
208
 
277
209
  it "should configure single nic" do
278
210
  network_config = [{:name => 'Default', :ip_address => '192.168.1.1'}]
279
- @fog_interface.should_receive(:put_network_connection_system_section_vapp).with(@vm_id, {
211
+ expect(@fog_interface).to receive(:put_network_connection_system_section_vapp).with(@vm_id, {
280
212
  :PrimaryNetworkConnectionIndex => 0,
281
213
  :NetworkConnection => [
282
214
  {
@@ -297,7 +229,7 @@ module Vcloud
297
229
  {:name => 'Monitoring', :ip_address => '192.168.2.1'}
298
230
  ]
299
231
 
300
- @fog_interface.should_receive(:put_network_connection_system_section_vapp).with(@vm_id, {
232
+ expect(@fog_interface).to receive(:put_network_connection_system_section_vapp).with(@vm_id, {
301
233
  :PrimaryNetworkConnectionIndex => 0,
302
234
  :NetworkConnection => [
303
235
  {
@@ -322,7 +254,7 @@ module Vcloud
322
254
 
323
255
  it "should configure no nics" do
324
256
  network_config = nil
325
- @fog_interface.should_not_receive(:put_network_connection_system_section_vapp)
257
+ expect(@fog_interface).not_to receive(:put_network_connection_system_section_vapp)
326
258
  @vm.configure_network_interfaces(network_config)
327
259
  end
328
260
 
@@ -341,16 +273,16 @@ module Vcloud
341
273
  ]
342
274
  mock_sp_query = double(:query_runner)
343
275
 
344
- Vcloud::Core::QueryRunner.should_receive(:new).and_return(mock_vdc_query)
345
- mock_vdc_query.should_receive(:run).with('vApp', :filter => "name==#{@vapp_name}").and_return(vdc_results)
346
- Vcloud::Core::QueryRunner.should_receive(:new).and_return(mock_sp_query)
347
- mock_sp_query.should_receive(:run).
276
+ expect(Vcloud::Core::QueryRunner).to receive(:new).and_return(mock_vdc_query)
277
+ expect(mock_vdc_query).to receive(:run).with('vApp', :filter => "name==#{@vapp_name}").and_return(vdc_results)
278
+ expect(Vcloud::Core::QueryRunner).to receive(:new).and_return(mock_sp_query)
279
+ expect(mock_sp_query).to receive(:run).
348
280
  with('orgVdcStorageProfile', :filter => "name==storage_profile_name;vdcName==vdc-test-1").
349
281
  and_return(storage_profile_results)
350
282
 
351
283
  generated_storage_profile = { name: 'storage_profile_name', href: 'test-href' }
352
- @fog_interface.should_receive(:put_vm).with(@vm_id, @vm_name, { :StorageProfile => generated_storage_profile} ).and_return(true)
353
- @vm.update_storage_profile(storage_profile).should == true
284
+ expect(@fog_interface).to receive(:put_vm).with(@vm_id, @vm_name, { :StorageProfile => generated_storage_profile} ).and_return(true)
285
+ expect(@vm.update_storage_profile(storage_profile)).to eq(true)
354
286
  end
355
287
 
356
288
  it "should raise an error if storage profile is not found" do
@@ -363,10 +295,10 @@ module Vcloud
363
295
  storage_profile_results = []
364
296
  mock_sp_query = double(:query_runner)
365
297
 
366
- Vcloud::Core::QueryRunner.should_receive(:new).and_return(mock_vdc_query)
367
- mock_vdc_query.should_receive(:run).with('vApp', :filter => "name==#{@vapp_name}").and_return(vdc_results)
368
- Vcloud::Core::QueryRunner.should_receive(:new).and_return(mock_sp_query)
369
- mock_sp_query.should_receive(:run).
298
+ expect(Vcloud::Core::QueryRunner).to receive(:new).and_return(mock_vdc_query)
299
+ expect(mock_vdc_query).to receive(:run).with('vApp', :filter => "name==#{@vapp_name}").and_return(vdc_results)
300
+ expect(Vcloud::Core::QueryRunner).to receive(:new).and_return(mock_sp_query)
301
+ expect(mock_sp_query).to receive(:run).
370
302
  with('orgVdcStorageProfile', :filter => "name==storage_profile_name;vdcName==vdc-test-1").
371
303
  and_return(storage_profile_results)
372
304
 
@@ -383,10 +315,10 @@ module Vcloud
383
315
  storage_profile_results = [ { :id => 'test-href' }]
384
316
  mock_sp_query = double(:query_runner)
385
317
 
386
- Vcloud::Core::QueryRunner.should_receive(:new).and_return(mock_vdc_query)
387
- mock_vdc_query.should_receive(:run).with('vApp', :filter => "name==#{@vapp_name}").and_return(vdc_results)
388
- Vcloud::Core::QueryRunner.should_receive(:new).and_return(mock_sp_query)
389
- mock_sp_query.should_receive(:run).
318
+ expect(Vcloud::Core::QueryRunner).to receive(:new).and_return(mock_vdc_query)
319
+ expect(mock_vdc_query).to receive(:run).with('vApp', :filter => "name==#{@vapp_name}").and_return(vdc_results)
320
+ expect(Vcloud::Core::QueryRunner).to receive(:new).and_return(mock_sp_query)
321
+ expect(mock_sp_query).to receive(:run).
390
322
  with('orgVdcStorageProfile', :filter => "name==storage_profile_name;vdcName==vdc-test-1").
391
323
  and_return(storage_profile_results)
392
324
 
@@ -12,14 +12,14 @@ describe Vcloud::Fog::ModelInterface do
12
12
  org = double(:hr, :name => 'HR ORG', :vdcs => [vdc])
13
13
 
14
14
  vcloud = double(:mock_vcloud, :org_name => 'HR', :organizations => double(:orgs, :get_by_name => org))
15
- vcloud.should_receive(:get_vms_in_lease_from_query).with({:filter => "href==#{vm_href}"}).and_return(
15
+ expect(vcloud).to receive(:get_vms_in_lease_from_query).with({:filter => "href==#{vm_href}"}).and_return(
16
16
  double(
17
17
  :vm_query_record,
18
18
  :body => {:VMRecord => [{:href => vm_href, :containerName => 'vapp-1', :vdc => vdc_href}]}
19
19
  )
20
20
  )
21
- Fog::Compute::VcloudDirector.should_receive(:new).and_return(vcloud)
21
+ expect(Fog::Compute::VcloudDirector).to receive(:new).and_return(vcloud)
22
22
 
23
- Vcloud::Fog::ModelInterface.new.get_vm_by_href(vm_href).should == vm
23
+ expect(Vcloud::Fog::ModelInterface.new.get_vm_by_href(vm_href)).to eq(vm)
24
24
  end
25
25
  end
@@ -10,8 +10,8 @@ module Vcloud
10
10
  it 'should raise a exception if named vdc not found in the data returned' do
11
11
 
12
12
  fog_facade = double(:FogFacade)
13
- expect(fog_facade).to receive(:session).and_return { FOG_SESSION_RESPONSE }
14
- expect(fog_facade).to receive(:get_organization).and_return { FOG_ORGANIZATION_RESPONSE }
13
+ expect(fog_facade).to receive(:session) { FOG_SESSION_RESPONSE }
14
+ expect(fog_facade).to receive(:get_organization) { FOG_ORGANIZATION_RESPONSE }
15
15
 
16
16
  service_interface = ServiceInterface.new(fog_facade)
17
17
 
@@ -22,25 +22,25 @@ module Vcloud
22
22
  before(:each) do
23
23
  @config = { :Blah => 'TestData' }
24
24
  @vcloud = double(:vcloud)
25
- ::Fog::Compute::VcloudDirector.should_receive(:new).and_return(@vcloud)
25
+ expect(::Fog::Compute::VcloudDirector).to receive(:new).and_return(@vcloud)
26
26
  end
27
27
 
28
28
  it "should configure firewall for given edge gateway id" do
29
29
  task = double(:task)
30
- Vcloud::Core::logger.should_receive(:info).with("Updating EdgeGateway 1234")
31
- @vcloud.should_receive(:post_configure_edge_gateway_services).with("1234", @config).
30
+ expect(Vcloud::Core::logger).to receive(:info).with("Updating EdgeGateway 1234")
31
+ expect(@vcloud).to receive(:post_configure_edge_gateway_services).with("1234", @config).
32
32
  and_return(double(:response, :body => task ))
33
- @vcloud.should_receive(:process_task).with(task)
33
+ expect(@vcloud).to receive(:process_task).with(task)
34
34
 
35
35
  ServiceInterface.new.post_configure_edge_gateway_services "1234", @config
36
36
  end
37
37
 
38
38
 
39
39
  it "should log and return exceptions without swallowing" do
40
- Vcloud::Core::logger.should_receive(:info).with("Updating EdgeGateway 1234")
40
+ expect(Vcloud::Core::logger).to receive(:info).with("Updating EdgeGateway 1234")
41
41
  runtime_error = RuntimeError.new('Test Error')
42
- Vcloud::Core::logger.should_receive(:error).with("Could not update EdgeGateway 1234 : #{runtime_error}")
43
- @vcloud.should_receive(:post_configure_edge_gateway_services).with("1234", @config).
42
+ expect(Vcloud::Core::logger).to receive(:error).with("Could not update EdgeGateway 1234 : #{runtime_error}")
43
+ expect(@vcloud).to receive(:post_configure_edge_gateway_services).with("1234", @config).
44
44
  and_raise(runtime_error)
45
45
  expect{ ServiceInterface.new.post_configure_edge_gateway_services("1234", @config) }.to raise_error("Test Error")
46
46
  end
data/vcloud-core.gemspec CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
  s.email = ['anna.shipman@digital.cabinet-office.gov.uk']
13
13
  s.summary = 'Core tools for interacting with VMware vCloud Director'
14
14
  s.description = 'Core tools for interacting with VMware vCloud Director. Includes VCloud Query, a light wrapper round the vCloud Query API.'
15
- s.homepage = 'http://github.com/alphagov/vcloud-core'
15
+ s.homepage = 'http://github.com/gds-operations/vcloud-core'
16
16
  s.license = 'MIT'
17
17
 
18
18
  s.files = `git ls-files`.split($/)
@@ -20,15 +20,15 @@ Gem::Specification.new do |s|
20
20
  s.test_files = s.files.grep(%r{^(test|spec|features)/})
21
21
  s.require_paths = ['lib']
22
22
 
23
- s.required_ruby_version = '>= 1.9.2'
23
+ s.required_ruby_version = '>= 1.9.3'
24
24
 
25
25
  s.add_runtime_dependency 'fog', '>= 1.22.0'
26
26
  s.add_runtime_dependency 'mustache'
27
+ s.add_development_dependency 'gem_publisher', '1.2.0'
27
28
  s.add_development_dependency 'pry'
28
29
  s.add_development_dependency 'rake'
29
30
  s.add_development_dependency 'rspec', '~> 2.14.1'
30
- s.add_development_dependency 'rubocop'
31
- s.add_development_dependency 'simplecov', '~> 0.8.2'
32
- s.add_development_dependency 'gem_publisher', '1.2.0'
33
- s.add_development_dependency 'vcloud-tools-tester', '0.0.3'
31
+ s.add_development_dependency 'rubocop', '~> 0.23.0'
32
+ s.add_development_dependency 'simplecov', '~> 0.7.1'
33
+ s.add_development_dependency 'vcloud-tools-tester', '~> 0.1.0'
34
34
  end