chef-provisioning-oneview 1.2.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +119 -65
- data/chef-provisioning-oneview.gemspec +39 -0
- data/lib/chef/provisioning/create_machine.rb +43 -46
- data/lib/chef/provisioning/customize_machine.rb +50 -48
- data/lib/chef/provisioning/helpers.rb +18 -0
- data/lib/chef/provisioning/icsp/api_v104.rb +3 -2
- data/lib/chef/provisioning/icsp/icsp_helper.rb +288 -0
- data/lib/chef/provisioning/icsp/rest.rb +50 -0
- data/lib/chef/provisioning/oneview/oneview_helper.rb +53 -0
- data/lib/chef/provisioning/oneview/san_storage.rb +69 -69
- data/lib/chef/provisioning/oneview_driver.rb +124 -105
- data/lib/chef/provisioning/version.rb +1 -1
- metadata +23 -61
- data/Rakefile +0 -19
- data/lib/chef/provisioning/icsp/icsp_api.rb +0 -284
- data/lib/chef/provisioning/oneview/oneview_api.rb +0 -186
- data/lib/chef/provisioning/oneview/v1.2/api.rb +0 -3
- data/lib/chef/provisioning/oneview/v2.0/api.rb +0 -3
- data/lib/chef/provisioning/rest.rb +0 -52
- data/spec/shared_context.rb +0 -78
- data/spec/spec_helper.rb +0 -23
- data/spec/support/fake_action_handler.rb +0 -6
- data/spec/support/fake_icsp.rb +0 -73
- data/spec/support/fake_machine_spec.rb +0 -18
- data/spec/support/fake_oneview.rb +0 -148
- data/spec/support/fixtures/icsp/v102/error_404.json +0 -14
- data/spec/support/fixtures/icsp/v102/login.json +0 -5
- data/spec/support/fixtures/icsp/v102/os-deployment-build-plans.json +0 -99
- data/spec/support/fixtures/icsp/v102/os-deployment-servers.json +0 -179
- data/spec/support/fixtures/icsp/v102/os-deployment-servers_1670001.json +0 -83
- data/spec/support/fixtures/icsp/v102/os-deployment-servers_fakesn.json +0 -9
- data/spec/support/fixtures/icsp/v102/server_by_sn_VCGE9KB041.json +0 -45
- data/spec/support/fixtures/icsp/v102/server_by_sn_empty.json +0 -16
- data/spec/support/fixtures/icsp/v102/version.json +0 -4
- data/spec/support/fixtures/oneview/v120/error_404.json +0 -14
- data/spec/support/fixtures/oneview/v120/login.json +0 -5
- data/spec/support/fixtures/oneview/v120/server-hardware.json +0 -1476
- data/spec/support/fixtures/oneview/v120/server-hardware_Template-WebServer.json +0 -468
- data/spec/support/fixtures/oneview/v120/server-hardware_specific.json +0 -151
- data/spec/support/fixtures/oneview/v120/server-profiles.json +0 -369
- data/spec/support/fixtures/oneview/v120/server-profiles_invalid_filter.json +0 -14
- data/spec/support/fixtures/oneview/v120/server-profiles_name_Template-WebServer.json +0 -133
- data/spec/support/fixtures/oneview/v120/server-profiles_name_Template-WebServerWithSAN.json +0 -200
- data/spec/support/fixtures/oneview/v120/server-profiles_name_chef-web01.json +0 -133
- data/spec/support/fixtures/oneview/v120/server-profiles_name_chef-web03.json +0 -133
- data/spec/support/fixtures/oneview/v120/server-profiles_name_empty.json +0 -15
- data/spec/support/fixtures/oneview/v120/server-profiles_sn_VCGE9KB041.json +0 -133
- data/spec/support/fixtures/oneview/v120/server-profiles_sn_VCGE9KB042.json +0 -206
- data/spec/support/fixtures/oneview/v120/server-profiles_sn_empty.json +0 -15
- data/spec/support/fixtures/oneview/v120/storage-volumes_1B5D3CA2-6C5B-41C2-8B97-1821F1883F22.json +0 -26
- data/spec/support/fixtures/oneview/v120/tasks_fake_active.json +0 -5
- data/spec/support/fixtures/oneview/v120/tasks_fake_complete.json +0 -5
- data/spec/support/fixtures/oneview/v120/version.json +0 -4
- data/spec/support/fixtures/oneview/v200/server-profile-templates_WebServerTemplate.json +0 -109
- data/spec/support/fixtures/oneview/v200/server-profile-templates_WebServerTemplateWithSAN.json +0 -144
- data/spec/support/fixtures/oneview/v200/server-profile-templates_invalid.json +0 -16
- data/spec/support/fixtures/oneview/v200/server-profile-templates_new-profile_WebServerTemplate.json +0 -125
- data/spec/support/fixtures/oneview/v200/server-profile-templates_new-profile_WebServerTemplateWithSAN.json +0 -178
- data/spec/support/fixtures/oneview/v200/version.json +0 -4
- data/spec/unit/create_machine_spec.rb +0 -78
- data/spec/unit/destroy_spec.rb +0 -26
- data/spec/unit/icsp_nic_teams_spec.rb +0 -38
- data/spec/unit/icsp_search_spec.rb +0 -25
- data/spec/unit/oneview_driver_spec.rb +0 -79
- data/spec/unit/oneview_login_spec.rb +0 -17
- data/spec/unit/oneview_power_spec.rb +0 -51
- data/spec/unit/oneview_san_spec.rb +0 -86
- data/spec/unit/oneview_search_spec.rb +0 -63
- data/spec/unit/rest_api_spec.rb +0 -115
@@ -1,51 +0,0 @@
|
|
1
|
-
require_relative './../spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe Chef::Provisioning::OneViewDriver do
|
4
|
-
include_context 'shared context'
|
5
|
-
|
6
|
-
describe '#power_on' do
|
7
|
-
it 'calls set_power_state with correct params' do
|
8
|
-
a = action_handler
|
9
|
-
m = machine_spec
|
10
|
-
ret_val = @instance.instance_eval { power_on(a, m) }
|
11
|
-
expect(a_request(:get, %r{/rest/server-hardware/.*})).to have_been_made
|
12
|
-
expect(a_request(:put, %r{/rest/server-hardware/.*/powerState}).with(body: '{"powerState":"On","powerControl":"MomentaryPress"}')).to have_been_made
|
13
|
-
expect(ret_val).to match(%r{\/rest\/server-hardware\/.+})
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'allows hardware_uri to be passed in' do
|
17
|
-
a = action_handler
|
18
|
-
m = machine_spec
|
19
|
-
@instance.instance_eval { power_on(a, m, '/rest/server-hardware/31363636-3136-584D-5132-333230314D38') }
|
20
|
-
expect(a_request(:get, %r{/rest/server-profiles})).to_not have_been_made
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe '#power_off' do
|
25
|
-
it 'calls set_power_state with correct params' do
|
26
|
-
a = action_handler
|
27
|
-
m = machine_spec
|
28
|
-
ret_val = @instance.instance_eval { power_off(a, m) }
|
29
|
-
expect(ret_val).to match(%r{\/rest\/server-hardware\/.+})
|
30
|
-
expect(a_request(:put, %r{/rest/server-hardware/.*/powerState}).with(body: '{"powerState":"Off","powerControl":"MomentaryPress"}')).to have_been_made
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'allows hardware_uri to be passed in' do
|
34
|
-
a = action_handler
|
35
|
-
m = machine_spec
|
36
|
-
@instance.instance_eval { power_off(a, m, '/rest/server-hardware/31363636-3136-584D-5132-333230314D38') }
|
37
|
-
expect(a_request(:get, %r{/rest/server-profiles})).to_not have_been_made
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
describe '#set_power_state' do
|
42
|
-
|
43
|
-
it 'fails when an invalid state is requested' do
|
44
|
-
a = action_handler
|
45
|
-
m = machine_spec
|
46
|
-
expect { @instance.instance_eval { set_power_state(a, m, :invalid) } }.to raise_error('Invalid power state invalid')
|
47
|
-
end
|
48
|
-
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
@@ -1,86 +0,0 @@
|
|
1
|
-
require_relative './../spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe Chef::Provisioning::OneViewDriver do
|
4
|
-
include_context 'shared context'
|
5
|
-
|
6
|
-
describe '#fill_volume_details' do
|
7
|
-
it 'fills the correct volume details' do
|
8
|
-
profile = @instance.instance_eval { get_oneview_template('Template - Web Server with SAN') }
|
9
|
-
v = profile['sanStorage']['volumeAttachments'].first
|
10
|
-
expect(v['volumeName']).to be_nil
|
11
|
-
expect(v['volumeShareable']).to be_nil
|
12
|
-
@instance.instance_eval { fill_volume_details(v) }
|
13
|
-
expect(a_request(:get, /#{v['volumeUri']}/)).to have_been_made
|
14
|
-
expect(v['volumeName']).to eq('bootVol')
|
15
|
-
expect(v['volumeShareable']).to be false
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe '#update_san_info' do
|
20
|
-
context 'profile coppies (OV 1.2)' do
|
21
|
-
it 'prepares copies of profiles for SAN storage' do
|
22
|
-
m = machine_spec
|
23
|
-
profile = @instance.instance_eval { get_oneview_template('Template - Web Server with SAN') }
|
24
|
-
profile['name'] = 'web01'
|
25
|
-
ret_val = @instance.instance_eval { update_san_info(m, profile) }
|
26
|
-
v = ret_val['sanStorage']['volumeAttachments'].first
|
27
|
-
expect(v['uri']).to be_nil
|
28
|
-
expect(v['volumeName']).to eq('bootVol web01')
|
29
|
-
expect(v['lun']).to eq('0')
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
context 'Server Profile Templates (OV 2.0)' do
|
34
|
-
before :each do
|
35
|
-
@instance.instance_variable_set('@current_oneview_api_version', 200)
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'leaves profiles from Templates largely the same' do
|
39
|
-
m = machine_spec
|
40
|
-
profile = @instance.instance_eval { get_oneview_template('Web Server Template with SAN') }
|
41
|
-
ret_val = @instance.instance_eval { update_san_info(m, profile) }
|
42
|
-
expect(ret_val['sanStorage']['volumeAttachments'].first['storagePaths'].first.key?('state')).to be false
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'appends the profile name to the volume name' do
|
46
|
-
m = machine_spec
|
47
|
-
profile = @instance.instance_eval { get_oneview_template('Web Server Template with SAN') }
|
48
|
-
profile['name'] = 'web01'
|
49
|
-
ret_val = @instance.instance_eval { update_san_info(m, profile) }
|
50
|
-
expect(ret_val['sanStorage']['volumeAttachments'].first['volumeName']).to eq('bootVol web01')
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'requires profiles to specify the volumeShareable attribute' do
|
54
|
-
m = machine_spec
|
55
|
-
profile = @instance.instance_eval { get_oneview_template('Web Server Template with SAN') }
|
56
|
-
profile['sanStorage']['volumeAttachments'].first.delete('volumeShareable')
|
57
|
-
expect { @instance.instance_eval { update_san_info(m, profile) } }.to raise_error(/Should know if volume is sharable/)
|
58
|
-
end
|
59
|
-
|
60
|
-
it 'only allows 1 SAN boot volume' do
|
61
|
-
m = machine_spec
|
62
|
-
profile = @instance.instance_eval { get_oneview_template('Web Server Template with SAN') }
|
63
|
-
profile['sanStorage']['volumeAttachments'].push('id' => 2, 'volumeName' => 'bootVol2', 'volumeShareable' => true)
|
64
|
-
expect { @instance.instance_eval { update_san_info(m, profile) } }.to raise_error(/should only be 1 SAN boot volume/)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
describe '#enable_boot_from_san' do
|
70
|
-
context 'Server Profile Templates (OV 2.0)' do
|
71
|
-
before :each do
|
72
|
-
@instance.instance_variable_set('@current_oneview_api_version', 200)
|
73
|
-
end
|
74
|
-
|
75
|
-
it 'configures connections to boot from a SAN volume' do
|
76
|
-
a = action_handler
|
77
|
-
m = machine_spec
|
78
|
-
profile = @instance.instance_eval { get_oneview_profile_by_sn('VCGE9KB042') }
|
79
|
-
ret_val = @instance.instance_eval { enable_boot_from_san(a, m, profile) }
|
80
|
-
expect(a_request(:get, /#{profile['sanStorage']['volumeAttachments'].first['volumeUri']}/)).to have_been_made
|
81
|
-
expect(ret_val['connections'].last['boot']['targets'].first['arrayWwpn']).to eq('21210002AC00159E')
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
require_relative './../spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe Chef::Provisioning::OneViewDriver do
|
4
|
-
include_context 'shared context'
|
5
|
-
|
6
|
-
describe '#get_oneview_profile_by_sn' do
|
7
|
-
|
8
|
-
it 'gets profile for a valid SN' do
|
9
|
-
ret_val = @instance.instance_eval { get_oneview_profile_by_sn('VCGE9KB041') }
|
10
|
-
expect(ret_val).to_not be_nil
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'returns nil for fake SN' do
|
14
|
-
ret_val = @instance.instance_eval { get_oneview_profile_by_sn('11111BBBBB') }
|
15
|
-
expect(ret_val).to be_nil
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'fails when an empty SN is given' do
|
19
|
-
expect { @instance.instance_eval { get_oneview_profile_by_sn('') } }.to raise_error('Must specify a serialNumber!')
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'fails when an invalid filter is specified' do
|
23
|
-
expect { @instance.instance_eval { get_oneview_profile_by_sn('INVALIDFILTER') } }.to raise_error(/Failed to get oneview profile by serialNumber/)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe '#get_oneview_template' do
|
28
|
-
|
29
|
-
context 'OneView 120' do
|
30
|
-
it 'gets profile template by name' do
|
31
|
-
ret_val = @instance.instance_eval { get_oneview_template('Template - Web Server') }
|
32
|
-
expect(ret_val['name']).to eq('Template - Web Server')
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'clears necessary attributes from profile' do
|
36
|
-
ret_val = @instance.instance_eval { get_oneview_template('Template - Web Server') }
|
37
|
-
expect(ret_val['name']).to_not be_nil
|
38
|
-
%w(uri serialNumber uuid taskUri).each { |key| expect(ret_val[key]).to be_nil }
|
39
|
-
ret_val['connections'].each do |c|
|
40
|
-
%w(wwnn wwpn mac deploymentStatus interconnectUri wwpnType macType).each { |key| expect(c[key]).to be_nil }
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
context 'OneView 200' do
|
46
|
-
before :each do
|
47
|
-
@instance.instance_variable_set('@current_oneview_api_version', 200)
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'gets template by name' do
|
51
|
-
ret_val = @instance.instance_eval { get_oneview_template('Web Server Template') }
|
52
|
-
expect(ret_val['uri']).to be_nil
|
53
|
-
expect(ret_val['serverProfileTemplateUri']).to_not be_nil
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'gets profile template by name' do
|
57
|
-
ret_val = @instance.instance_eval { get_oneview_template('Template - Web Server') }
|
58
|
-
expect(ret_val['name']).to eq('Template - Web Server')
|
59
|
-
expect(ret_val['uri']).to be_nil
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
data/spec/unit/rest_api_spec.rb
DELETED
@@ -1,115 +0,0 @@
|
|
1
|
-
require_relative './../spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe Chef::Provisioning::OneViewDriver do
|
4
|
-
include_context 'shared context'
|
5
|
-
|
6
|
-
describe '#rest_api' do
|
7
|
-
|
8
|
-
context 'fake_oneview' do
|
9
|
-
it 'completes get request with correct parameters' do
|
10
|
-
resp = @instance.instance_eval { rest_api(:oneview, :get, '/', {}) }
|
11
|
-
expect(resp['method']).to eq('GET')
|
12
|
-
expect(resp['message']).to eq('Fake OneView works!')
|
13
|
-
expect(resp['content_type']).to eq('application/json')
|
14
|
-
expect(resp['api_version']).to eq(@instance.instance_variable_get('@oneview_api_version'))
|
15
|
-
expect(resp['auth']).to eq(@oneview_key)
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'completes post request with correct parameters' do
|
19
|
-
resp = @instance.instance_eval { rest_api(:oneview, :post, '/', {}) }
|
20
|
-
expect(resp['method']).to eq('POST')
|
21
|
-
expect(resp['message']).to eq('Fake OneView works!')
|
22
|
-
expect(resp['content_type']).to eq('application/json')
|
23
|
-
expect(resp['api_version']).to eq(@instance.instance_variable_get('@oneview_api_version'))
|
24
|
-
expect(resp['auth']).to eq(@oneview_key)
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'completes put request with correct parameters' do
|
28
|
-
resp = @instance.instance_eval { rest_api(:oneview, :put, '/', {}) }
|
29
|
-
expect(resp['method']).to eq('PUT')
|
30
|
-
expect(resp['message']).to eq('Fake OneView works!')
|
31
|
-
expect(resp['content_type']).to eq('application/json')
|
32
|
-
expect(resp['api_version']).to eq(@instance.instance_variable_get('@oneview_api_version'))
|
33
|
-
expect(resp['auth']).to eq(@oneview_key)
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'completes delete request with correct parameters' do
|
37
|
-
resp = @instance.instance_eval { rest_api(:oneview, :delete, '/', {}) }
|
38
|
-
expect(resp['method']).to eq('DELETE')
|
39
|
-
expect(resp['message']).to eq('Fake OneView works!')
|
40
|
-
expect(resp['content_type']).to eq('application/json')
|
41
|
-
expect(resp['api_version']).to eq(@instance.instance_variable_get('@oneview_api_version'))
|
42
|
-
expect(resp['auth']).to eq(@oneview_key)
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'returns 404 error for invalid get request' do
|
46
|
-
resp = @instance.instance_eval { rest_api(:oneview, :get, '/invalid_path', {}) }
|
47
|
-
expect(resp['errorCode']).to eq('GENERIC_HTTP_404')
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
context 'fake_icsp' do
|
52
|
-
it 'completes get request with correct parameters' do
|
53
|
-
resp = @instance.instance_eval { rest_api(:icsp, :get, '/', {}) }
|
54
|
-
expect(resp['method']).to eq('GET')
|
55
|
-
expect(resp['message']).to eq('Fake ICsp works!')
|
56
|
-
expect(resp['content_type']).to eq('application/json')
|
57
|
-
expect(resp['api_version']).to eq(@instance.instance_variable_get('@icsp_api_version'))
|
58
|
-
expect(resp['auth']).to eq(@icsp_key)
|
59
|
-
end
|
60
|
-
|
61
|
-
it 'completes post request with correct parameters' do
|
62
|
-
resp = @instance.instance_eval { rest_api(:icsp, :post, '/', {}) }
|
63
|
-
expect(resp['method']).to eq('POST')
|
64
|
-
expect(resp['message']).to eq('Fake ICsp works!')
|
65
|
-
expect(resp['content_type']).to eq('application/json')
|
66
|
-
expect(resp['api_version']).to eq(@instance.instance_variable_get('@icsp_api_version'))
|
67
|
-
expect(resp['auth']).to eq(@icsp_key)
|
68
|
-
end
|
69
|
-
|
70
|
-
it 'completes put request with correct parameters' do
|
71
|
-
resp = @instance.instance_eval { rest_api(:icsp, :put, '/', {}) }
|
72
|
-
expect(resp['method']).to eq('PUT')
|
73
|
-
expect(resp['message']).to eq('Fake ICsp works!')
|
74
|
-
expect(resp['content_type']).to eq('application/json')
|
75
|
-
expect(resp['api_version']).to eq(nil)
|
76
|
-
expect(resp['auth']).to eq(@icsp_key)
|
77
|
-
end
|
78
|
-
|
79
|
-
it 'completes delete request with correct parameters' do
|
80
|
-
resp = @instance.instance_eval { rest_api(:icsp, :delete, '/', {}) }
|
81
|
-
expect(resp['method']).to eq('DELETE')
|
82
|
-
expect(resp['message']).to eq('Fake ICsp works!')
|
83
|
-
expect(resp['content_type']).to eq('application/json')
|
84
|
-
expect(resp['api_version']).to eq(@instance.instance_variable_get('@icsp_api_version'))
|
85
|
-
expect(resp['auth']).to eq(@icsp_key)
|
86
|
-
end
|
87
|
-
|
88
|
-
it 'returns 404 error for invalid get request' do
|
89
|
-
resp = @instance.instance_eval { rest_api(:icsp, :get, '/invalid_path', {}) }
|
90
|
-
expect(resp['errorCode']).to eq('GENERIC_HTTP_404')
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
it 'only accepts oneview or icsp hosts parameter' do
|
95
|
-
expect { @instance.instance_eval { rest_api(:invalid, :get, '/', {}) } }.to raise_error(/Invalid rest host/)
|
96
|
-
end
|
97
|
-
|
98
|
-
it 'only accepts rest action parameters' do
|
99
|
-
expect { @instance.instance_eval { rest_api(:oneview, :invalid, '/', {}) } }.to raise_error(/Invalid rest call/)
|
100
|
-
end
|
101
|
-
|
102
|
-
end
|
103
|
-
|
104
|
-
describe 'get api versions' do
|
105
|
-
|
106
|
-
it 'can parse the oneview api version' do
|
107
|
-
expect(@instance.instance_eval { get_oneview_api_version }).to match(120)
|
108
|
-
end
|
109
|
-
|
110
|
-
it 'can parse the icsp api version' do
|
111
|
-
expect(@instance.instance_eval { get_icsp_api_version }).to match(102)
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
end
|