chef-provisioning-oneview 1.0.1 → 1.1.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 +43 -3
- data/lib/chef/provisioning/create_machine.rb +52 -0
- data/lib/chef/provisioning/customize_machine.rb +78 -0
- data/lib/chef/provisioning/icsp/api_v104.rb +27 -0
- data/lib/chef/provisioning/icsp/icsp_api.rb +282 -0
- data/lib/chef/provisioning/oneview/oneview_api.rb +56 -357
- data/lib/chef/provisioning/oneview/san_storage.rb +91 -0
- data/lib/chef/provisioning/oneview/v1.2/api.rb +3 -0
- data/lib/chef/provisioning/oneview_driver.rb +42 -5
- data/lib/chef/provisioning/rest.rb +51 -0
- data/lib/chef/provisioning/{oneview/version.rb → version.rb} +1 -1
- data/spec/shared_context.rb +77 -0
- data/spec/spec_helper.rb +8 -6
- data/spec/{unit/support → support}/fake_action_handler.rb +0 -0
- data/spec/support/fake_icsp.rb +73 -21
- data/spec/support/fake_machine_spec.rb +18 -0
- data/spec/support/fake_oneview.rb +148 -21
- data/spec/support/fixtures/icsp/v102/error_404.json +13 -13
- data/spec/support/fixtures/icsp/v102/login.json +4 -4
- data/spec/support/fixtures/icsp/v102/os-deployment-build-plans.json +99 -99
- data/spec/support/fixtures/icsp/v102/{os-deployment-servers_managed.json → os-deployment-servers.json} +178 -178
- data/spec/support/fixtures/icsp/v102/os-deployment-servers_1670001.json +83 -0
- data/spec/support/fixtures/icsp/v102/os-deployment-servers_fakesn.json +9 -0
- data/spec/support/fixtures/icsp/v102/{server_by_sn.json → server_by_sn_VCGE9KB041.json} +44 -44
- data/spec/support/fixtures/icsp/v102/server_by_sn_empty.json +16 -0
- data/spec/support/fixtures/icsp/v102/version.json +3 -3
- data/spec/support/fixtures/oneview/v120/error_404.json +13 -13
- data/spec/support/fixtures/oneview/v120/login.json +4 -4
- data/spec/support/fixtures/oneview/v120/server-hardware.json +1475 -1475
- data/spec/support/fixtures/oneview/v120/server-hardware_Template-WebServer.json +468 -0
- data/spec/support/fixtures/oneview/v120/server-hardware_specific.json +151 -0
- data/spec/support/fixtures/oneview/v120/server-profiles.json +368 -746
- data/spec/support/fixtures/oneview/v120/server-profiles_invalid_filter.json +14 -0
- data/spec/support/fixtures/oneview/v120/{server-profiles_specific.json → server-profiles_name_Template-WebServer.json} +132 -132
- data/spec/support/fixtures/oneview/v120/server-profiles_name_Template-WebServerWithSAN.json +200 -0
- data/spec/support/fixtures/oneview/v120/server-profiles_name_chef-web01.json +133 -0
- data/spec/support/fixtures/oneview/v120/server-profiles_name_chef-web03.json +133 -0
- data/spec/support/fixtures/oneview/v120/server-profiles_name_empty.json +15 -0
- data/spec/support/fixtures/oneview/v120/server-profiles_sn_VCGE9KB041.json +133 -0
- data/spec/support/fixtures/oneview/v120/server-profiles_sn_VCGE9KB042.json +206 -0
- data/spec/support/fixtures/oneview/v120/server-profiles_sn_empty.json +15 -0
- data/spec/support/fixtures/oneview/v120/storage-volumes_1B5D3CA2-6C5B-41C2-8B97-1821F1883F22.json +26 -0
- data/spec/support/fixtures/oneview/v120/tasks_fake_active.json +5 -0
- data/spec/support/fixtures/oneview/v120/tasks_fake_complete.json +5 -0
- data/spec/support/fixtures/oneview/v120/version.json +3 -3
- data/spec/support/fixtures/oneview/v200/server-profile-templates_WebServerTemplate.json +109 -0
- data/spec/support/fixtures/oneview/v200/server-profile-templates_WebServerTemplateWithSAN.json +144 -0
- data/spec/support/fixtures/oneview/v200/server-profile-templates_invalid.json +16 -0
- data/spec/support/fixtures/oneview/v200/server-profile-templates_new-profile_WebServerTemplate.json +125 -0
- data/spec/support/fixtures/oneview/v200/server-profile-templates_new-profile_WebServerTemplateWithSAN.json +178 -0
- data/spec/support/fixtures/oneview/v200/version.json +4 -0
- data/spec/unit/create_machine_spec.rb +78 -0
- data/spec/unit/destroy_spec.rb +26 -0
- data/spec/unit/icsp_nic_teams_spec.rb +38 -0
- data/spec/unit/icsp_search_spec.rb +25 -0
- data/spec/unit/oneview_driver_spec.rb +37 -64
- data/spec/unit/oneview_login_spec.rb +23 -0
- data/spec/unit/oneview_power_spec.rb +51 -0
- data/spec/unit/oneview_san_spec.rb +86 -0
- data/spec/unit/oneview_search_spec.rb +63 -0
- data/spec/unit/rest_api_spec.rb +115 -0
- metadata +90 -9
- data/lib/chef/provisioning/oneview/v1.20/api.rb +0 -3
@@ -0,0 +1,178 @@
|
|
1
|
+
{
|
2
|
+
"type": "ServerProfileV5",
|
3
|
+
"uri": null,
|
4
|
+
"name": null,
|
5
|
+
"description": "Web server template with SAN",
|
6
|
+
"serialNumber": null,
|
7
|
+
"uuid": null,
|
8
|
+
"serverProfileTemplateUri": "/rest/server-profile-templates/d64da635-f08a-41d4-b6eb-6517206a8baf",
|
9
|
+
"templateCompliance": "Unknown",
|
10
|
+
"serverHardwareUri": null,
|
11
|
+
"serverHardwareTypeUri": "/rest/server-hardware-types/5B42EABE-5140-4E38-91F0-68367B529DE9",
|
12
|
+
"enclosureGroupUri": "/rest/enclosure-groups/c0f86584-5a82-4480-ad13-8ed6544d6c98",
|
13
|
+
"enclosureUri": null,
|
14
|
+
"enclosureBay": null,
|
15
|
+
"affinity": "Bay",
|
16
|
+
"associatedServer": null,
|
17
|
+
"hideUnusedFlexNics": true,
|
18
|
+
"firmware": {
|
19
|
+
"firmwareInstallType": null,
|
20
|
+
"forceInstallFirmware": false,
|
21
|
+
"manageFirmware": false,
|
22
|
+
"firmwareBaselineUri": null
|
23
|
+
},
|
24
|
+
"macType": "Virtual",
|
25
|
+
"wwnType": "Virtual",
|
26
|
+
"serialNumberType": "Virtual",
|
27
|
+
"category": "server-profiles",
|
28
|
+
"created": null,
|
29
|
+
"modified": null,
|
30
|
+
"status": "OK",
|
31
|
+
"state": "Creating",
|
32
|
+
"inProgress": false,
|
33
|
+
"taskUri": null,
|
34
|
+
"connections": [
|
35
|
+
{
|
36
|
+
"id": 7,
|
37
|
+
"name": "Altair PXE",
|
38
|
+
"functionType": "Ethernet",
|
39
|
+
"deploymentStatus": null,
|
40
|
+
"networkUri": "/rest/ethernet-networks/7984a764-69ae-48c0-aec2-780d4f0366f8",
|
41
|
+
"portId": "Flb 1:1-a",
|
42
|
+
"requestedVFs": "Auto",
|
43
|
+
"allocatedVFs": null,
|
44
|
+
"interconnectUri": null,
|
45
|
+
"macType": null,
|
46
|
+
"wwpnType": null,
|
47
|
+
"mac": null,
|
48
|
+
"wwnn": null,
|
49
|
+
"wwpn": null,
|
50
|
+
"requestedMbps": "1000",
|
51
|
+
"allocatedMbps": 0,
|
52
|
+
"maximumMbps": 0,
|
53
|
+
"boot": {
|
54
|
+
"priority": "Primary"
|
55
|
+
}
|
56
|
+
},
|
57
|
+
{
|
58
|
+
"id": 8,
|
59
|
+
"name": "Corpnet",
|
60
|
+
"functionType": "Ethernet",
|
61
|
+
"deploymentStatus": null,
|
62
|
+
"networkUri": "/rest/ethernet-networks/52b6f044-f51b-4d4c-8d59-497c14c4681c",
|
63
|
+
"portId": "Flb 1:1-c",
|
64
|
+
"requestedVFs": "Auto",
|
65
|
+
"allocatedVFs": null,
|
66
|
+
"interconnectUri": null,
|
67
|
+
"macType": null,
|
68
|
+
"wwpnType": null,
|
69
|
+
"mac": null,
|
70
|
+
"wwnn": null,
|
71
|
+
"wwpn": null,
|
72
|
+
"requestedMbps": "2500",
|
73
|
+
"allocatedMbps": 0,
|
74
|
+
"maximumMbps": 0,
|
75
|
+
"boot": {
|
76
|
+
"priority": "NotBootable"
|
77
|
+
}
|
78
|
+
},
|
79
|
+
{
|
80
|
+
"id": 9,
|
81
|
+
"name": "san1",
|
82
|
+
"functionType": "FibreChannel",
|
83
|
+
"deploymentStatus": null,
|
84
|
+
"networkUri": "/rest/fc-networks/2c04a682-66b4-4a64-8c2d-3095937a8e7e",
|
85
|
+
"portId": "Flb 1:1-b",
|
86
|
+
"requestedVFs": null,
|
87
|
+
"allocatedVFs": null,
|
88
|
+
"interconnectUri": null,
|
89
|
+
"macType": null,
|
90
|
+
"wwpnType": null,
|
91
|
+
"mac": null,
|
92
|
+
"wwnn": null,
|
93
|
+
"wwpn": null,
|
94
|
+
"requestedMbps": "4000",
|
95
|
+
"allocatedMbps": 0,
|
96
|
+
"maximumMbps": 0,
|
97
|
+
"boot": {
|
98
|
+
"priority": "Primary"
|
99
|
+
}
|
100
|
+
},
|
101
|
+
{
|
102
|
+
"id": 10,
|
103
|
+
"name": "san2",
|
104
|
+
"functionType": "FibreChannel",
|
105
|
+
"deploymentStatus": null,
|
106
|
+
"networkUri": "/rest/fc-networks/93c97ad9-3e6d-4cc4-8b37-3ef3a6a9cf77",
|
107
|
+
"portId": "Flb 1:2-b",
|
108
|
+
"requestedVFs": null,
|
109
|
+
"allocatedVFs": null,
|
110
|
+
"interconnectUri": null,
|
111
|
+
"macType": null,
|
112
|
+
"wwpnType": null,
|
113
|
+
"mac": null,
|
114
|
+
"wwnn": null,
|
115
|
+
"wwpn": null,
|
116
|
+
"requestedMbps": "4000",
|
117
|
+
"allocatedMbps": 0,
|
118
|
+
"maximumMbps": 0,
|
119
|
+
"boot": {
|
120
|
+
"priority": "Secondary"
|
121
|
+
}
|
122
|
+
}
|
123
|
+
],
|
124
|
+
"bootMode": null,
|
125
|
+
"boot": {
|
126
|
+
"order": [
|
127
|
+
"HardDisk",
|
128
|
+
"PXE",
|
129
|
+
"CD",
|
130
|
+
"Floppy",
|
131
|
+
"USB"
|
132
|
+
],
|
133
|
+
"manageBoot": true
|
134
|
+
},
|
135
|
+
"bios": {
|
136
|
+
"overriddenSettings": [
|
137
|
+
|
138
|
+
],
|
139
|
+
"manageBios": false
|
140
|
+
},
|
141
|
+
"localStorage": {
|
142
|
+
"controllers": []
|
143
|
+
},
|
144
|
+
"sanStorage": {
|
145
|
+
"volumeAttachments": [
|
146
|
+
{
|
147
|
+
"permanent": false,
|
148
|
+
"storagePaths": [
|
149
|
+
{
|
150
|
+
"storageTargets": [],
|
151
|
+
"storageTargetType": "Auto",
|
152
|
+
"connectionId": 3,
|
153
|
+
"isEnabled": true
|
154
|
+
},
|
155
|
+
{
|
156
|
+
"storageTargets": [],
|
157
|
+
"storageTargetType": "Auto",
|
158
|
+
"connectionId": 4,
|
159
|
+
"isEnabled": true
|
160
|
+
}
|
161
|
+
],
|
162
|
+
"volumeStoragePoolUri": "/rest/storage-pools/707E383B-56F6-48A1-BFF1-782BB2AC6BA7",
|
163
|
+
"volumeStorageSystemUri": "/rest/storage-systems/1405534",
|
164
|
+
"volumeDescription": "",
|
165
|
+
"volumeShareable": false,
|
166
|
+
"volumeProvisionType": "Thin",
|
167
|
+
"volumeProvisionedCapacityBytes": "53687091200",
|
168
|
+
"lun": "0",
|
169
|
+
"lunType": "Manual",
|
170
|
+
"volumeName": "bootVol",
|
171
|
+
"id": 1
|
172
|
+
}
|
173
|
+
],
|
174
|
+
"hostOSType": "RHE Linux (5.x, 6.x)",
|
175
|
+
"manageSanStorage": true
|
176
|
+
},
|
177
|
+
"eTag": null
|
178
|
+
}
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require_relative './../spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Chef::Provisioning::OneViewDriver do
|
4
|
+
include_context 'shared context'
|
5
|
+
|
6
|
+
describe '#create_machine' do
|
7
|
+
before :each do
|
8
|
+
$server_created = nil
|
9
|
+
end
|
10
|
+
|
11
|
+
context 'OneView 120' do
|
12
|
+
it 'skips creating machines that already exist' do
|
13
|
+
a = action_handler
|
14
|
+
m = machine_spec
|
15
|
+
o = valid_machine_options
|
16
|
+
ret_val = @instance.instance_eval { create_machine(a, m, o) }
|
17
|
+
expect(a_request(:post, %r{/rest/server-profiles})).to_not have_been_made
|
18
|
+
expect(ret_val['name']).to eq('chef-web01')
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'creates a machine from a Profile Template if it does not exist' do
|
22
|
+
a = action_handler
|
23
|
+
m = machine_spec
|
24
|
+
o = valid_machine_options
|
25
|
+
o[:driver_options][:host_name] = 'chef-web03'
|
26
|
+
@instance.instance_eval { create_machine(a, m, o) }
|
27
|
+
expect(a_request(:post, %r{/rest/server-profiles})).to have_been_made.times(1)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'sets the correct HW uri to create a machine if it does not exist' do
|
31
|
+
a = action_handler
|
32
|
+
m = machine_spec
|
33
|
+
o = valid_machine_options
|
34
|
+
o[:driver_options][:host_name] = 'chef-web03'
|
35
|
+
@instance.instance_eval { create_machine(a, m, o) }
|
36
|
+
expect(a_request(:post, %r{/rest/server-profiles}).with do |req|
|
37
|
+
req.body.match('"serverHardwareUri":"/rest/server-hardware/31363636-3136-584D-5132-333230314D38"') &&
|
38
|
+
req.body.match('"serverHardwareTypeUri":"/rest/server-hardware-types/2947DC35-BE48-4075-A3FD-254A9B42F5BD"') &&
|
39
|
+
req.body.match('"enclosureGroupUri":"/rest/enclosure-groups/3a11ccdd-b352-4046-a568-a8b0faa6cc39"') &&
|
40
|
+
!req.body.match('"enclosureUri":"') &&
|
41
|
+
!req.body.match('"enclosureBay":"')
|
42
|
+
end).to have_been_made
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'OneView 200' do
|
47
|
+
before :each do
|
48
|
+
@instance.instance_variable_set('@current_oneview_api_version', 200)
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'creates a machine from a Template if it does not exist' do
|
52
|
+
a = action_handler
|
53
|
+
m = machine_spec
|
54
|
+
o = valid_machine_options
|
55
|
+
o[:driver_options][:host_name] = 'chef-web03'
|
56
|
+
o[:driver_options][:server_template] = 'Web Server Template'
|
57
|
+
@instance.instance_eval { create_machine(a, m, o) }
|
58
|
+
expect(a_request(:post, %r{/rest/server-profiles})).to have_been_made.times(1)
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'sets the correct HW uri from a Template to create a machine if it does not exist' do
|
62
|
+
a = action_handler
|
63
|
+
m = machine_spec
|
64
|
+
o = valid_machine_options
|
65
|
+
o[:driver_options][:host_name] = 'chef-web03'
|
66
|
+
o[:driver_options][:server_template] = 'Web Server Template'
|
67
|
+
@instance.instance_eval { create_machine(a, m, o) }
|
68
|
+
expect(a_request(:post, %r{/rest/server-profiles}).with do |req|
|
69
|
+
req.body.match('"serverHardwareUri":"/rest/server-hardware/37333036-3831-584D-5131-303030323037"') &&
|
70
|
+
req.body.match('"serverHardwareTypeUri":"/rest/server-hardware-types/5B42EABE-5140-4E38-91F0-68367B529DE9"') &&
|
71
|
+
req.body.match('"enclosureGroupUri":"/rest/enclosure-groups/c0f86584-5a82-4480-ad13-8ed6544d6c98"') &&
|
72
|
+
!req.body.match('"enclosureUri":"') &&
|
73
|
+
!req.body.match('"enclosureBay":"')
|
74
|
+
end).to have_been_made
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative './../spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Chef::Provisioning::OneViewDriver do
|
4
|
+
include_context 'shared context'
|
5
|
+
|
6
|
+
describe '#destroy_oneview_profile' do
|
7
|
+
it 'destroys the profile' do
|
8
|
+
a = action_handler
|
9
|
+
m = machine_spec
|
10
|
+
@instance.instance_eval { destroy_oneview_profile(a, m) }
|
11
|
+
expect(a_request(:get, %r{/rest/server-hardware/.*})).to have_been_made
|
12
|
+
expect(a_request(:get, %r{/rest/tasks/.*})).to have_been_made
|
13
|
+
expect(a_request(:delete, %r{/rest/server-profiles/.*})).to have_been_made
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#destroy_icsp_server' do
|
18
|
+
it 'destroys the server' do
|
19
|
+
a = action_handler
|
20
|
+
m = machine_spec
|
21
|
+
@instance.instance_eval { destroy_icsp_server(a, m) }
|
22
|
+
expect(a_request(:delete, %r{/rest/os-deployment-servers/.*})).to have_been_made
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require_relative './../spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Chef::Provisioning::OneViewDriver do
|
4
|
+
include_context 'shared context'
|
5
|
+
|
6
|
+
describe '#icsp_configure_nic_teams' do
|
7
|
+
|
8
|
+
it 'configures nic teams properly' do
|
9
|
+
machine_options = valid_machine_options
|
10
|
+
profile = @instance.instance_eval { get_oneview_profile_by_sn('VCGE9KB041') }
|
11
|
+
ret_val = @instance.instance_eval { icsp_configure_nic_teams(machine_options, profile) }
|
12
|
+
expect(ret_val).to eq('team1-11:11:11:11:01:14,11:11:11:11:01:15')
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'requires connection IDs to map to valid OneView connection IDs' do
|
16
|
+
machine_options = valid_machine_options
|
17
|
+
profile = @instance.instance_eval { get_oneview_profile_by_sn('VCGE9KB041') }
|
18
|
+
machine_options[:driver_options][:connections][3] = { team: 'team2' }
|
19
|
+
expect { @instance.instance_eval { icsp_configure_nic_teams(machine_options, profile) } }.to raise_error(/make sure the connection ids map to those on OneView/)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'does not allow nic teams with hyphens' do
|
23
|
+
machine_options = valid_machine_options
|
24
|
+
profile = @instance.instance_eval { get_oneview_profile_by_sn('VCGE9KB041') }
|
25
|
+
machine_options[:driver_options][:connections][1][:team] = 'team-1'
|
26
|
+
expect { @instance.instance_eval { icsp_configure_nic_teams(machine_options, profile) } }.to raise_error(/must not include hyphens/)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'requires at least 2 connections per team' do
|
30
|
+
machine_options = valid_machine_options
|
31
|
+
profile = @instance.instance_eval { get_oneview_profile_by_sn('VCGE9KB041') }
|
32
|
+
machine_options[:driver_options][:connections].delete(2)
|
33
|
+
expect { @instance.instance_eval { icsp_configure_nic_teams(machine_options, profile) } }.to raise_error(/must have at least 2 associated connections/)
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require_relative './../spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Chef::Provisioning::OneViewDriver do
|
4
|
+
include_context 'shared context'
|
5
|
+
|
6
|
+
describe '#get_icsp_server_by_sn' do
|
7
|
+
|
8
|
+
it 'gets info for a valid SN' do
|
9
|
+
ret_val = @instance.instance_eval { get_icsp_server_by_sn('VCGE9KB041') }
|
10
|
+
expect(ret_val['serialNumber']).to eq('VCGE9KB041')
|
11
|
+
expect(ret_val['uri']).to match(%r{\/rest\/os-deployment-servers\/.+})
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'returns nil for fake SN' do
|
15
|
+
ret_val = @instance.instance_eval { get_icsp_server_by_sn('FAKESN') }
|
16
|
+
expect(ret_val).to be_nil
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'fails when an empty SN is given' do
|
20
|
+
expect { @instance.instance_eval { get_icsp_server_by_sn('') } }.to raise_error('Must specify a serialNumber!')
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -1,62 +1,7 @@
|
|
1
1
|
require_relative './../spec_helper'
|
2
|
-
require_relative 'support/fake_action_handler'
|
3
2
|
|
4
3
|
RSpec.describe Chef::Provisioning::OneViewDriver do
|
5
|
-
|
6
|
-
{ knife: {
|
7
|
-
oneview_url: 'https://my-oneview.my-domain.com',
|
8
|
-
oneview_username: 'Administrator',
|
9
|
-
oneview_password: 'password12',
|
10
|
-
oneview_ignore_ssl: true,
|
11
|
-
|
12
|
-
icsp_url: 'https://my-icsp.my-domain.com',
|
13
|
-
icsp_username: 'administrator',
|
14
|
-
icsp_password: 'password123'
|
15
|
-
} }
|
16
|
-
end
|
17
|
-
|
18
|
-
let(:valid_machine_options) do
|
19
|
-
{
|
20
|
-
convergence_options: {
|
21
|
-
ssl_verify_mode: :verify_none,
|
22
|
-
bootstrap_proxy: 'http://proxy.my-domain.com:8080',
|
23
|
-
chef_server: {
|
24
|
-
chef_server_url: 'https://my-chef-server.my-domain.com/organizations/oneview',
|
25
|
-
options: {
|
26
|
-
client_name: 'user',
|
27
|
-
signing_key_filename: 'spec/fixtures/.chef/user.pem'
|
28
|
-
}
|
29
|
-
}
|
30
|
-
},
|
31
|
-
driver_options: {
|
32
|
-
server_template: 'Template - Web Server',
|
33
|
-
os_build: 'CHEF-RHEL-6.5-x64',
|
34
|
-
host_name: 'chef-web03',
|
35
|
-
ip_address: '192.168.1.2',
|
36
|
-
domainType: 'workgroup',
|
37
|
-
domainName: 'my-domain.com',
|
38
|
-
gateway: '192.168.1.1',
|
39
|
-
dns: '192.168.1.1,10.1.1.1',
|
40
|
-
connections: {
|
41
|
-
2 => { ip4Address: '192.168.1.2', mask: '255.255.254.0', dhcp: false }
|
42
|
-
}
|
43
|
-
},
|
44
|
-
custom_attributes: {
|
45
|
-
|
46
|
-
},
|
47
|
-
transport_options: {
|
48
|
-
ssh_options: { password: 'password1234' }
|
49
|
-
}
|
50
|
-
}
|
51
|
-
end
|
52
|
-
|
53
|
-
let(:action_handler) do
|
54
|
-
@handler ||= ChefProvisioningOneviewHelpers::FakeActionHandler.new
|
55
|
-
end
|
56
|
-
|
57
|
-
let(:machine_spec) do
|
58
|
-
# TODO
|
59
|
-
end
|
4
|
+
include_context 'shared context'
|
60
5
|
|
61
6
|
describe '#canonicalize_url' do
|
62
7
|
it 'canonicalizes the url' do
|
@@ -73,26 +18,54 @@ RSpec.describe Chef::Provisioning::OneViewDriver do
|
|
73
18
|
end
|
74
19
|
|
75
20
|
describe '#initialize' do
|
76
|
-
before :each do
|
77
|
-
@url = 'https://oneview.domain.com'
|
78
|
-
canonical_url = "oneview:#{@url}"
|
79
|
-
@instance = Chef::Provisioning::OneViewDriver.new(canonical_url, knife_config)
|
80
|
-
end
|
81
21
|
|
82
22
|
it 'reads all necessary values from knife config during initialization' do
|
83
23
|
expect(@instance.instance_variable_get('@oneview_base_url')).to eq('https://my-oneview.my-domain.com')
|
84
24
|
expect(@instance.instance_variable_get('@oneview_username')).to eq('Administrator')
|
85
25
|
expect(@instance.instance_variable_get('@oneview_password')).to eq('password12')
|
86
26
|
expect(@instance.instance_variable_get('@oneview_disable_ssl')).to eq(true)
|
87
|
-
expect(@instance.instance_variable_get('@oneview_api_version')).to eq(120)
|
88
|
-
expect(@instance.instance_variable_get('@oneview_key')).to eq('long_oneview_key')
|
89
27
|
|
90
28
|
expect(@instance.instance_variable_get('@icsp_base_url')).to eq('https://my-icsp.my-domain.com')
|
91
29
|
expect(@instance.instance_variable_get('@icsp_username')).to eq('administrator')
|
92
30
|
expect(@instance.instance_variable_get('@icsp_password')).to eq('password123')
|
93
31
|
expect(@instance.instance_variable_get('@icsp_disable_ssl')).to eq(nil)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'uses the correct api versions' do
|
35
|
+
expect(@instance.instance_variable_get('@oneview_api_version')).to eq(120)
|
94
36
|
expect(@instance.instance_variable_get('@icsp_api_version')).to eq(102)
|
95
|
-
expect(@instance.instance_variable_get('@
|
37
|
+
expect(@instance.instance_variable_get('@current_oneview_api_version')).to eq(120)
|
38
|
+
expect(@instance.instance_variable_get('@current_icsp_api_version')).to eq(102)
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'requires the oneview_url knife param' do
|
42
|
+
knife_config[:knife].delete(:oneview_url)
|
43
|
+
expect { Chef::Provisioning::OneViewDriver.new(@canonical_url, knife_config) }.to raise_error('Must set the knife[:oneview_url] attribute!')
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'requires the oneview_username knife param' do
|
47
|
+
knife_config[:knife].delete(:oneview_username)
|
48
|
+
expect { Chef::Provisioning::OneViewDriver.new(@canonical_url, knife_config) }.to raise_error('Must set the knife[:oneview_username] attribute!')
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'requires the oneview_password knife param' do
|
52
|
+
knife_config[:knife].delete(:oneview_password)
|
53
|
+
expect { Chef::Provisioning::OneViewDriver.new(@canonical_url, knife_config) }.to raise_error('Must set the knife[:oneview_password] attribute!')
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'requires the icsp_url knife param' do
|
57
|
+
knife_config[:knife].delete(:icsp_url)
|
58
|
+
expect { Chef::Provisioning::OneViewDriver.new(@canonical_url, knife_config) }.to raise_error('Must set the knife[:icsp_url] attribute!')
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'requires the icsp_username knife param' do
|
62
|
+
knife_config[:knife].delete(:icsp_username)
|
63
|
+
expect { Chef::Provisioning::OneViewDriver.new(@canonical_url, knife_config) }.to raise_error('Must set the knife[:icsp_username] attribute!')
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'requires the icsp_password knife param' do
|
67
|
+
knife_config[:knife].delete(:icsp_password)
|
68
|
+
expect { Chef::Provisioning::OneViewDriver.new(@canonical_url, knife_config) }.to raise_error('Must set the knife[:icsp_password] attribute!')
|
96
69
|
end
|
97
70
|
end
|
98
71
|
end
|