chef-provisioning-oneview 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 167f2e17cf7e59a72a324e3e85741f0db2e61053
4
- data.tar.gz: 0a0147bce30c20646fe355a5575ba75a8bced856
3
+ metadata.gz: 6fd131178c928b19abb6e06f8136b4d3b9e9a2eb
4
+ data.tar.gz: 80c192d8030a22b2d78ac8e58328265b83231718
5
5
  SHA512:
6
- metadata.gz: 7e505bed54f9b378f6b0b4a21d879f968289547b75a2f239c138cefaf0d17990ba3cf1bccfd10cf05e12e558251139df1480ff8adea7b74f202e07e31ecb33e5
7
- data.tar.gz: 259f701926f031b620b9db49de16ef2c8bf03c50b197c3833b9acfd8260d884a5cb4246589e5277b1f202a1abe9af43f8161cc879c7d7ae18c00a35f47c1ed3e
6
+ metadata.gz: 5e901b072f088b01d67943bda4af6aedcfb73e7eb5514388fda9e1d27df911f3c2c738daea6b8f7f7d696fc8145d784a15989a1e007bb03c814dbebae60bd53a
7
+ data.tar.gz: e5a12ab051c95788e8e6dc4e0c62e7d50caa8c810e16662e37f3fd76e91dd95dc9737181ba8a9330237636a313cef0ff50f2dd6c037c319a735de7c3bac185cf
data/README.md CHANGED
@@ -14,6 +14,8 @@ Currently supports:
14
14
 
15
15
  # Installation
16
16
 
17
+ - Install Ruby and the `ruby-devel` or `ruby-dev` package for your system.
18
+
17
19
  - Require the gem in your Gemfile: `gem 'chef-provisioning-oneview'`
18
20
 
19
21
  Then run `$ bundle install`
@@ -37,7 +37,7 @@ module CreateMachine
37
37
  options['X-API-Version'] = 200 if @current_oneview_api_version >= 200 && template['type'] == 'ServerProfileV5'
38
38
  task = rest_api(:oneview, :post, '/rest/server-profiles', options)
39
39
  task_uri = task['uri']
40
- fail "Failed to create OneView server profile #{host_name}. Details: " unless task_uri
40
+ raise "Failed to create OneView server profile #{host_name}. Details: " unless task_uri
41
41
  # Wait for profile to be created
42
42
  60.times do # Wait for up to 5 min
43
43
  matching_profiles = rest_api(:oneview, :get, "/rest/server-profiles?filter=name matches '#{host_name}'&sort=name:asc")
@@ -46,7 +46,7 @@ module CreateMachine
46
46
  sleep 5
47
47
  end
48
48
  task = rest_api(:oneview, :get, task_uri)
49
- fail "Server profile couldn't be created! #{task['taskStatus']}. #{task['taskErrors'].first['message']}"
49
+ raise "Server profile couldn't be created! #{task['taskStatus']}. #{task['taskErrors'].first['message']}"
50
50
  end
51
51
  end
52
52
  end
@@ -10,14 +10,14 @@ module CustomizeMachine
10
10
  action_handler.perform_action "Wait for #{machine_spec.name} server to start and profile to be applied" do
11
11
  action_handler.report_progress "INFO: Waiting for #{machine_spec.name} server to start and profile to be applied"
12
12
  task = oneview_wait_for(profile['taskUri'], 360) # Wait up to 60 min for profile to be created
13
- fail 'Timed out waiting for server to start and profile to be applied' if task == false
13
+ raise 'Timed out waiting for server to start and profile to be applied' if task == false
14
14
  unless task == true
15
15
  server_template = machine_options[:driver_options][:server_template]
16
- fail "Error creating server profile from template #{server_template}: #{task['taskErrors'].first['message']}"
16
+ raise "Error creating server profile from template #{server_template}: #{task['taskErrors'].first['message']}"
17
17
  end
18
18
  end
19
19
  profile = get_oneview_profile_by_sn(machine_spec.reference['serial_number']) # Refresh profile
20
- fail "Server profile state '#{profile['state']}' not 'Normal'" unless profile['state'] == 'Normal'
20
+ raise "Server profile state '#{profile['state']}' not 'Normal'" unless profile['state'] == 'Normal'
21
21
  end
22
22
 
23
23
  # Configure SAN storage (if applicable)
@@ -36,7 +36,7 @@ module CustomizeMachine
36
36
  print '.'
37
37
  sleep 10
38
38
  end
39
- fail "Timeout waiting for server #{machine_spec.name} to register with ICSP" if my_server.nil?
39
+ raise "Timeout waiting for server #{machine_spec.name} to register with ICSP" if my_server.nil?
40
40
  end
41
41
 
42
42
  icsp_configure_nic_teams(machine_options, profile)
@@ -58,16 +58,16 @@ module CustomizeMachine
58
58
  action_handler.report_progress "INFO: Performing network flipping on #{machine_spec.name}, connection #{id}"
59
59
  deploy_network = available_networks['ethernetNetworks'].find {|n| n['name'] == data[:deployNet] }
60
60
  new_network = available_networks['ethernetNetworks'].find {|n| n['name'] == data[:net] }
61
- fail "Failed to perform network flipping on #{machine_spec.name}, connection #{id}. '#{data[:net]}' network not found" if new_network.nil?
62
- fail "Failed to perform network flipping on #{machine_spec.name}, connection #{id}. '#{data[:deployNet]}' network not found" if deploy_network.nil?
61
+ raise "Failed to perform network flipping on #{machine_spec.name}, connection #{id}. '#{data[:net]}' network not found" if new_network.nil?
62
+ raise "Failed to perform network flipping on #{machine_spec.name}, connection #{id}. '#{data[:deployNet]}' network not found" if deploy_network.nil?
63
63
  profile = get_oneview_profile_by_sn(machine_spec.reference['serial_number'])
64
64
  profile['connections'].find {|c| c['networkUri'] == deploy_network['uri'] }['networkUri'] = new_network['uri']
65
65
  options = { 'body' => profile }
66
66
  task = rest_api(:oneview, :put, profile['uri'], options)
67
- fail "Failed to perform network flipping on #{machine_spec.name}. Details: #{task['message'] || task}" unless task['uri']
67
+ raise "Failed to perform network flipping on #{machine_spec.name}. Details: #{task['message'] || task}" unless task['uri']
68
68
  task = oneview_wait_for(task['uri']) # Wait up to 10 min
69
- fail "Timed out waiting for network flipping on #{machine_spec.name}" if task == false
70
- fail "Error performing network flip on #{machine_spec.name}. Response: #{task}" unless task == true
69
+ raise "Timed out waiting for network flipping on #{machine_spec.name}" if task == false
70
+ raise "Error performing network flip on #{machine_spec.name}. Response: #{task}" unless task == true
71
71
  end
72
72
  end
73
73
  machine_spec.reference['network_personalitation_finished'] = true
@@ -8,10 +8,10 @@ module ICspAPI
8
8
  def get_icsp_api_version
9
9
  begin
10
10
  version = rest_api(:icsp, :get, '/rest/version', { 'Content-Type' => :none, 'X-API-Version' => :none, 'auth' => :none })['currentVersion']
11
- fail "Couldn't get API version" unless version
11
+ raise "Couldn't get API version" unless version
12
12
  if version.class != Fixnum
13
13
  version = version.to_i
14
- fail 'API version type mismatch' if !version > 0
14
+ raise 'API version type mismatch' if !version > 0
15
15
  end
16
16
  rescue
17
17
  puts 'Failed to get ICSP API version. Setting to default (102)'
@@ -31,11 +31,11 @@ module ICspAPI
31
31
  }
32
32
  response = rest_api(:icsp, :post, path, options)
33
33
  return response['sessionID'] if response['sessionID']
34
- fail("\nERROR! Couldn't log into OneView server at #{@oneview_base_url}. Response:\n#{response}")
34
+ raise("\nERROR! Couldn't log into ICSP server at #{@icsp_base_url}. Response:\n#{response}")
35
35
  end
36
36
 
37
37
  def get_icsp_server_by_sn(serial_number)
38
- fail 'Must specify a serialNumber!' if serial_number.nil? || serial_number.empty?
38
+ raise 'Must specify a serialNumber!' if serial_number.nil? || serial_number.empty?
39
39
  search_result = rest_api(:icsp, :get,
40
40
  "/rest/index/resources?category=osdserver&query='osdServerSerialNumber:\"#{serial_number}\"'")['members'] rescue nil
41
41
  if search_result && search_result.size == 1 && search_result.first['attributes']['osdServerSerialNumber'] == serial_number
@@ -57,7 +57,7 @@ module ICspAPI
57
57
  end
58
58
 
59
59
  def icsp_wait_for(task_uri, wait_iterations = 60, sleep_seconds = 10)
60
- fail 'Must specify a task_uri!' if task_uri.nil? || task_uri.empty?
60
+ raise 'Must specify a task_uri!' if task_uri.nil? || task_uri.empty?
61
61
  wait_iterations.times do
62
62
  task = rest_api(:icsp, :get, task_uri)
63
63
  if task['taskState']
@@ -108,7 +108,7 @@ module ICspAPI
108
108
  print '.'
109
109
  sleep 10
110
110
  end
111
- fail "Timed out waiting for #{machine_spec.name} to go into maintenance mode in ICsp. State: #{my_server['state']}" unless my_server['state'] == 'MAINTENANCE'
111
+ raise "Timed out waiting for #{machine_spec.name} to go into maintenance mode in ICsp. State: #{my_server['state']}" unless my_server['state'] == 'MAINTENANCE'
112
112
  end
113
113
  end
114
114
 
@@ -122,12 +122,12 @@ module ICspAPI
122
122
  uri = "/rest/index/resources?userQuery=\"'#{os_build}'\"&category=osdbuildplan"
123
123
  while uri
124
124
  matching_plans = rest_api(:icsp, :get, uri)
125
- fail "Search failed for OSBP '#{os_build}'. Response: #{matching_plans}" unless matching_plans['members']
125
+ raise "Search failed for OSBP '#{os_build}'. Response: #{matching_plans}" unless matching_plans['members']
126
126
  build_plan_uri = matching_plans['members'].find {|bp| bp['name'] == os_build}['uri'] rescue nil
127
127
  break unless build_plan_uri.nil?
128
128
  uri = URI.unescape(matching_plans['nextPageUri']) rescue nil
129
129
  end
130
- fail "OS build plan #{os_build} not found!" if build_plan_uri.nil?
130
+ raise "OS build plan #{os_build} not found!" if build_plan_uri.nil?
131
131
  build_plan_uris.push build_plan_uri
132
132
  end
133
133
  end
@@ -147,9 +147,9 @@ module ICspAPI
147
147
  action_handler.report_progress "INFO: Running: #{os_builds} OS Build Plan(s) on #{machine_spec.name}"
148
148
  task = rest_api(:icsp, :post, '/rest/os-deployment-jobs/?force=true', options)
149
149
  task_uri = task['uri']
150
- fail "Failed to start OS Deployment Job. Details: #{task['details'] || task['message'] || task}" unless task_uri
150
+ raise "Failed to start OS Deployment Job. Details: #{task['details'] || task['message'] || task}" unless task_uri
151
151
  task = icsp_wait_for(task_uri, 720)
152
- fail "Error running OS build plan(s) #{os_builds}: #{task['jobResult'].first['jobMessage']}\n#{task['jobResult'].first['jobResultErrorDetails']}" unless task == true
152
+ raise "Error running OS build plan(s) #{os_builds}: #{task['jobResult'].first['jobMessage']}\n#{task['jobResult'].first['jobResultErrorDetails']}" unless task == true
153
153
  end
154
154
  end
155
155
 
@@ -169,9 +169,9 @@ module ICspAPI
169
169
 
170
170
  task = rest_api(:icsp, :post, '/rest/os-deployment-jobs/?force=true', options)
171
171
  task_uri = task['uri']
172
- fail "Failed to start network personalization job. Details: #{task['details']}" unless task_uri
172
+ raise "Failed to start network personalization job. Details: #{task['details']}" unless task_uri
173
173
  task = icsp_wait_for(task_uri, 60) # Wait for up to 10 min
174
- fail "Error running network personalization job: #{task['jobResult'].first['jobMessage']}\n#{task['jobResult'].first['jobResultErrorDetails']}" unless task == true
174
+ raise "Error running network personalization job: #{task['jobResult'].first['jobMessage']}\n#{task['jobResult'].first['jobResultErrorDetails']}" unless task == true
175
175
 
176
176
  # Check if ICsp IP config matches machine options
177
177
  requested_ips = []
@@ -246,11 +246,11 @@ module ICspAPI
246
246
  task_uri = task['uri']
247
247
  90.times do # Wait for up to 15 minutes
248
248
  task = rest_api(:icsp, :get, task_uri)
249
- break if task['taskState'].downcase == 'completed'
249
+ break if task['taskState'].casecmp('completed') == 0
250
250
  print '.'
251
251
  sleep 10
252
252
  end
253
- fail "Deleting os deployment server #{machine_spec.name} at icsp failed!" unless task['taskState'].downcase == 'completed'
253
+ raise "Deleting os deployment server #{machine_spec.name} at icsp failed!" unless task['taskState'].casecmp('completed') == 0
254
254
  end
255
255
  end
256
256
  end
@@ -261,7 +261,7 @@ module ICspAPI
261
261
 
262
262
  machine_options[:driver_options][:connections].each do |id, options|
263
263
  next unless options.is_a?(Hash) && options[:team]
264
- fail "#{options[:team]}: Team names must not include hyphens" if options[:team].to_s.match('-')
264
+ raise "#{options[:team]}: Team names must not include hyphens" if options[:team].to_s.include?('-')
265
265
  teams[options[:team].to_s] ||= []
266
266
  begin
267
267
  mac = profile['connections'].find {|x| x['id'] == id}['mac']
@@ -274,7 +274,7 @@ module ICspAPI
274
274
  end
275
275
  team_strings = []
276
276
  teams.each do |name, macs|
277
- fail "Team '#{name}' must have at least 2 associated connections to form a NIC team" unless macs.size >= 2
277
+ raise "Team '#{name}' must have at least 2 associated connections to form a NIC team" unless macs.size >= 2
278
278
  team_strings.push "#{name}-#{macs.join(',')}"
279
279
  end
280
280
  machine_options[:driver_options][:custom_attributes] ||= {}
@@ -10,10 +10,10 @@ module OneViewAPI
10
10
  def get_oneview_api_version
11
11
  begin
12
12
  version = rest_api(:oneview, :get, '/rest/version', { 'Content-Type' => :none, 'X-API-Version' => :none, 'auth' => :none })['currentVersion']
13
- fail "Couldn't get API version" unless version
13
+ raise "Couldn't get API version" unless version
14
14
  if version.class != Fixnum
15
15
  version = version.to_i
16
- fail 'API version type mismatch' if !version > 0
16
+ raise 'API version type mismatch' if !version > 0
17
17
  end
18
18
  rescue
19
19
  puts 'Failed to get OneView API version. Setting to default (120)'
@@ -33,13 +33,13 @@ module OneViewAPI
33
33
  }
34
34
  response = rest_api(:oneview, :post, path, options)
35
35
  return response['sessionID'] if response['sessionID']
36
- fail("\nERROR! Couldn't log into OneView server at #{@oneview_base_url}. Response:\n#{response}")
36
+ raise("\nERROR! Couldn't log into OneView server at #{@oneview_base_url}. Response:\n#{response}")
37
37
  end
38
38
 
39
39
  def get_oneview_profile_by_sn(serial_number)
40
- fail 'Must specify a serialNumber!' if serial_number.nil? || serial_number.empty?
40
+ raise 'Must specify a serialNumber!' if serial_number.nil? || serial_number.empty?
41
41
  matching_profiles = rest_api(:oneview, :get, "/rest/server-profiles?filter=serialNumber matches '#{serial_number}'&sort=name:asc")
42
- fail "Failed to get oneview profile by serialNumber: #{serial_number}. Response: #{matching_profiles}" unless matching_profiles['count']
42
+ raise "Failed to get oneview profile by serialNumber: #{serial_number}. Response: #{matching_profiles}" unless matching_profiles['count']
43
43
  return matching_profiles['members'].first if matching_profiles['count'] > 0
44
44
  nil
45
45
  end
@@ -51,7 +51,7 @@ module OneViewAPI
51
51
  options = { 'X-API-Version' => 200 }
52
52
  templates = rest_api(:oneview, :get, "/rest/server-profile-templates?filter=\"name matches '#{template_name}'\"&sort=name:asc", options)['members']
53
53
  return rest_api(:oneview, :get, "#{templates.first['uri']}/new-profile", options) if templates && templates.count == 1
54
- fail "'#{template_name}' matches multiple templates! Please use a unique template name." if templates && templates.count > 1
54
+ raise "'#{template_name}' matches multiple templates! Please use a unique template name." if templates && templates.count > 1
55
55
  end
56
56
 
57
57
  # Look for Server Profile as second option
@@ -64,27 +64,27 @@ module OneViewAPI
64
64
  end
65
65
  return templates.first
66
66
  end
67
- fail "'#{template_name}' matches multiple profiles! Please use a unique template name." if templates && templates.count > 1
67
+ raise "'#{template_name}' matches multiple profiles! Please use a unique template name." if templates && templates.count > 1
68
68
 
69
- fail "Template '#{template_name}' not found! Please match the template name with one that exists on OneView."
69
+ raise "Template '#{template_name}' not found! Please match the template name with one that exists on OneView."
70
70
  end
71
71
 
72
72
  def available_hardware_for_template(template)
73
73
  server_hardware_type_uri = template['serverHardwareTypeUri']
74
74
  enclosure_group_uri = template['enclosureGroupUri']
75
- fail 'Template must specify a valid hardware type uri!' if server_hardware_type_uri.nil? || server_hardware_type_uri.empty?
76
- fail 'Template must specify a valid hardware type uri!' if enclosure_group_uri.nil? || enclosure_group_uri.empty?
75
+ raise 'Template must specify a valid hardware type uri!' if server_hardware_type_uri.nil? || server_hardware_type_uri.empty?
76
+ raise 'Template must specify a valid hardware type uri!' if enclosure_group_uri.nil? || enclosure_group_uri.empty?
77
77
  params = "sort=name:asc&filter=serverHardwareTypeUri='#{server_hardware_type_uri}'&filter=serverGroupUri='#{enclosure_group_uri}'"
78
78
  blades = rest_api(:oneview, :get, "/rest/server-hardware?#{params}")
79
- fail 'Error! No available blades that are compatible with the server template!' unless blades['count'] > 0
79
+ raise 'Error! No available blades that are compatible with the server template!' unless blades['count'] > 0
80
80
  blades['members'].each do |member|
81
81
  return member if member['state'] == 'NoProfileApplied'
82
82
  end
83
- fail 'No more blades are available for provisioning!' # Every bay is full and no more machines can be allocated
83
+ raise 'No more blades are available for provisioning!' # Every bay is full and no more machines can be allocated
84
84
  end
85
85
 
86
86
  def oneview_wait_for(task_uri, wait_iterations = 60, sleep_seconds = 10) # Default time is 10 min
87
- fail 'Must specify a task_uri!' if task_uri.nil? || task_uri.empty?
87
+ raise 'Must specify a task_uri!' if task_uri.nil? || task_uri.empty?
88
88
  wait_iterations.times do
89
89
  task = rest_api(:oneview, :get, task_uri)
90
90
  case task['taskState'].downcase
@@ -114,28 +114,28 @@ module OneViewAPI
114
114
  state = 'on'
115
115
  when :off, 'off', false
116
116
  state = 'off'
117
- else fail "Invalid power state #{state}"
117
+ else raise "Invalid power state #{state}"
118
118
  end
119
119
 
120
120
  if hardware_uri.nil?
121
121
  profile = get_oneview_profile_by_sn(machine_spec.reference['serial_number'])
122
- fail "Could not power #{state} #{machine_spec.name}: Profile with serial number '#{machine_spec.reference['serial_number']}' not found!" unless profile
122
+ raise "Could not power #{state} #{machine_spec.name}: Profile with serial number '#{machine_spec.reference['serial_number']}' not found!" unless profile
123
123
  hardware_uri = profile['serverHardwareUri']
124
124
  end
125
125
 
126
126
  hardware_info = rest_api(:oneview, :get, hardware_uri)
127
- unless hardware_info['powerState'].downcase == state
127
+ unless hardware_info['powerState'].casecmp(state) == 0
128
128
  action_handler.perform_action "Power #{state} server #{hardware_info['name']} for #{machine_spec.name}" do
129
129
  action_handler.report_progress "INFO: Powering #{state} server #{hardware_info['name']} for #{machine_spec.name}"
130
130
  task = rest_api(:oneview, :put, "#{hardware_uri}/powerState", { 'body' => { 'powerState' => state.capitalize, 'powerControl' => 'MomentaryPress' } })
131
131
  task_uri = task['uri']
132
132
  60.times do # Wait for up to 10 minutes
133
133
  task = rest_api(:oneview, :get, task_uri)
134
- break if task['taskState'].downcase == 'completed'
134
+ break if task['taskState'].casecmp('completed') == 0
135
135
  print '.'
136
136
  sleep 10
137
137
  end
138
- fail "Powering #{state} machine #{machine_spec.name} failed!" unless task['taskState'].downcase == 'completed'
138
+ raise "Powering #{state} machine #{machine_spec.name} failed!" unless task['taskState'].casecmp('completed') == 0
139
139
  end
140
140
  end
141
141
  hardware_uri
@@ -150,16 +150,16 @@ module OneViewAPI
150
150
  else
151
151
  action_handler.perform_action "Delete server #{machine_spec.name} from oneview" do
152
152
  action_handler.report_progress "INFO: Deleting server profile #{machine_spec.name}"
153
- task = rest_api(:oneview, :Delete, "#{profile['uri']}")
153
+ task = rest_api(:oneview, :Delete, profile['uri'])
154
154
  task_uri = task['uri']
155
155
 
156
156
  60.times do # Wait for up to 10 minutes
157
157
  task = rest_api(:oneview, :get, task_uri)
158
- break if task['taskState'].downcase == 'completed'
158
+ break if task['taskState'].casecmp('completed') == 0
159
159
  print '.'
160
160
  sleep 10
161
161
  end
162
- fail "Deleting server profile #{machine_spec.name} failed!" unless task['taskState'].downcase == 'completed'
162
+ raise "Deleting server profile #{machine_spec.name} failed!" unless task['taskState'].casecmp('completed') == 0
163
163
  end
164
164
  end
165
165
  end
@@ -20,10 +20,10 @@ module OneViewSanStorage
20
20
  boot_vols = []
21
21
  san_storage['volumeAttachments'].each do |v|
22
22
  fill_volume_details(v) unless profile['serverProfileTemplateUri']
23
- fail "#{machine_spec.name}: Should know if volume is sharable:\n#{v}" unless v.key?('volumeShareable')
23
+ raise "#{machine_spec.name}: Should know if volume is sharable:\n#{v}" unless v.key?('volumeShareable')
24
24
 
25
25
  # Match boot disks by name
26
- boot_vols.push(v['volumeName']) if v['volumeName'].downcase.match(/^boot/)
26
+ boot_vols.push(v['volumeName']) if v['volumeName'] =~ /^boot/i
27
27
  v['volumeName'] += " #{profile['name']}" unless v['volumeShareable'] # Append profile name to volume name
28
28
 
29
29
  unless profile['serverProfileTemplateUri'] # Only needed when coppied from profile
@@ -37,11 +37,11 @@ module OneViewSanStorage
37
37
 
38
38
  # Assumes all cloned volumes are non-permanet. Might want some global config to control this
39
39
  v['permanent'] = false
40
- v['lun'] = nil if v['lunType'].downcase == 'auto'
40
+ v['lun'] = nil if v['lunType'].casecmp('auto') == 0
41
41
  end
42
42
  end
43
43
  end
44
- fail "#{machine_spec.name}: There should only be 1 SAN boot volume. Boot volumes: #{boot_vols}" if boot_vols.size > 1
44
+ raise "#{machine_spec.name}: There should only be 1 SAN boot volume. Boot volumes: #{boot_vols}" if boot_vols.size > 1
45
45
  profile
46
46
  end
47
47
 
@@ -53,15 +53,15 @@ module OneViewSanStorage
53
53
  update_needed = false
54
54
  profile['sanStorage']['volumeAttachments'].each do |v|
55
55
  vol_details = rest_api(:oneview, :get, v['volumeUri'])
56
- next unless vol_details['name'].downcase.match(/^boot/)
56
+ next unless vol_details['name'] =~ /^boot/i
57
57
  # Find the enabled path(s), get target wwpn, and then update connection, setting boot targets
58
58
  v['storagePaths'].each do |s|
59
59
  next if !s['isEnabled'] || s['storageTargets'].nil? || s['storageTargets'].empty?
60
60
  connection = profile['connections'].find { |c| c['id'] == s['connectionId'] }
61
- fail "#{machine_spec.name}: Connection #{s['connectionId']} not found! Check SAN settings" unless connection
61
+ raise "#{machine_spec.name}: Connection #{s['connectionId']} not found! Check SAN settings" unless connection
62
62
  if connection['boot'].nil? || connection['boot']['priority'] == 'NotBootable'
63
63
  msg = "#{machine_spec.name}: Connection #{s['connectionId']} is labeled for boot, but the connection is not marked as bootable."
64
- fail "#{msg} Set the connection boot target to Primary or Secondary"
64
+ raise "#{msg} Set the connection boot target to Primary or Secondary"
65
65
  end
66
66
  target = {}
67
67
  target['arrayWwpn'] = s['storageTargets'].first.delete(':')
@@ -81,8 +81,8 @@ module OneViewSanStorage
81
81
  power_off(action_handler, machine_spec, profile['serverHardwareUri'])
82
82
  task = rest_api(:oneview, :put, profile['uri'], { 'body' => profile })
83
83
  task = oneview_wait_for(task['uri'], 90) # Wait for up to 15 min for profile to be updated
84
- fail "Timed out waiting for enabling SAN-bootable connections on #{machine_spec.name}" if task == false
85
- fail "Error enabling SAN-bootable connections on #{machine_spec.name}. Response: #{task}" unless task == true
84
+ raise "Timed out waiting for enabling SAN-bootable connections on #{machine_spec.name}" if task == false
85
+ raise "Error enabling SAN-bootable connections on #{machine_spec.name}. Response: #{task}" unless task == true
86
86
  end
87
87
  profile = rest_api(:oneview, :get, profile['uri'])
88
88
  end
@@ -28,7 +28,7 @@ module Chef::Provisioning
28
28
  if oneview_url.nil? || oneview_url == ''
29
29
  oneview_url = config[:knife][:oneview_url]
30
30
  end
31
- fail 'Must set the knife[:oneview_url] attribute!' if oneview_url.nil? || oneview_url.empty?
31
+ raise 'Must set the knife[:oneview_url] attribute!' if oneview_url.nil? || oneview_url.empty?
32
32
  'oneview:' + oneview_url
33
33
  end
34
34
 
@@ -40,22 +40,22 @@ module Chef::Provisioning
40
40
  super(canonical_url, config)
41
41
 
42
42
  @oneview_base_url = config[:knife][:oneview_url]
43
- fail 'Must set the knife[:oneview_url] attribute!' if @oneview_base_url.nil? || @oneview_base_url.empty?
43
+ raise 'Must set the knife[:oneview_url] attribute!' if @oneview_base_url.nil? || @oneview_base_url.empty?
44
44
  @oneview_username = config[:knife][:oneview_username]
45
- fail 'Must set the knife[:oneview_username] attribute!' if @oneview_username.nil? || @oneview_username.empty?
45
+ raise 'Must set the knife[:oneview_username] attribute!' if @oneview_username.nil? || @oneview_username.empty?
46
46
  @oneview_password = config[:knife][:oneview_password]
47
- fail 'Must set the knife[:oneview_password] attribute!' if @oneview_password.nil? || @oneview_password.empty?
47
+ raise 'Must set the knife[:oneview_password] attribute!' if @oneview_password.nil? || @oneview_password.empty?
48
48
  @oneview_disable_ssl = config[:knife][:oneview_ignore_ssl]
49
49
  @oneview_api_version = 120 # Use this version for all calls that don't override it
50
50
  @current_oneview_api_version = get_oneview_api_version
51
51
  @oneview_key = login_to_oneview
52
52
 
53
53
  @icsp_base_url = config[:knife][:icsp_url]
54
- fail 'Must set the knife[:icsp_url] attribute!' if @icsp_base_url.nil? || @icsp_base_url.empty?
54
+ raise 'Must set the knife[:icsp_url] attribute!' if @icsp_base_url.nil? || @icsp_base_url.empty?
55
55
  @icsp_username = config[:knife][:icsp_username]
56
- fail 'Must set the knife[:icsp_username] attribute!' if @icsp_username.nil? || @icsp_username.empty?
56
+ raise 'Must set the knife[:icsp_username] attribute!' if @icsp_username.nil? || @icsp_username.empty?
57
57
  @icsp_password = config[:knife][:icsp_password]
58
- fail 'Must set the knife[:icsp_password] attribute!' if @icsp_password.nil? || @icsp_password.empty?
58
+ raise 'Must set the knife[:icsp_password] attribute!' if @icsp_password.nil? || @icsp_password.empty?
59
59
  @icsp_disable_ssl = config[:knife][:icsp_ignore_ssl]
60
60
  @icsp_api_version = 102 # Use this version for all calls that don't override it
61
61
  @current_icsp_api_version = get_icsp_api_version
@@ -96,7 +96,7 @@ module Chef::Provisioning
96
96
 
97
97
  def ready_machine(action_handler, machine_spec, machine_options)
98
98
  profile = get_oneview_profile_by_sn(machine_spec.reference['serial_number'])
99
- fail "Failed to retrieve Server Profile for #{machine_spec.name}. Serial Number used to search: #{machine_spec.reference['serial_number']}" unless profile
99
+ raise "Failed to retrieve Server Profile for #{machine_spec.name}. Serial Number used to search: #{machine_spec.reference['serial_number']}" unless profile
100
100
  customize_machine(action_handler, machine_spec, machine_options, profile)
101
101
  machine_for(machine_spec, machine_options) # Return the Machine object
102
102
  end
@@ -106,7 +106,7 @@ module Chef::Provisioning
106
106
  bootstrap_ip_address = machine_options[:driver_options][:ip_address]
107
107
  unless bootstrap_ip_address
108
108
  id, connection = machine_options[:driver_options][:connections].find { |_id, c| c[:bootstrap] == true }
109
- fail 'Must specify a connection to use to bootstrap!' unless id && connection
109
+ raise 'Must specify a connection to use to bootstrap!' unless id && connection
110
110
  bootstrap_ip_address = connection[:ip4Address] # For static IPs
111
111
  unless bootstrap_ip_address # Look for dhcp address given to this connection
112
112
  profile = get_oneview_profile_by_sn(machine_spec.reference['serial_number'])
@@ -117,7 +117,7 @@ module Chef::Provisioning
117
117
  end
118
118
  bootstrap_ip_address ||= my_server['hostName'] # Fall back on hostName
119
119
  end
120
- fail 'Server IP address not specified and could not be retrieved!' unless bootstrap_ip_address
120
+ raise 'Server IP address not specified and could not be retrieved!' unless bootstrap_ip_address
121
121
  username = machine_options[:transport_options][:user] || 'root' rescue 'root'
122
122
  default_ssh_options = {
123
123
  # auth_methods: ['password', 'publickey'],
@@ -14,7 +14,7 @@ module RestAPI
14
14
  options['auth'] ||= @oneview_key
15
15
  disable_ssl = true if @oneview_disable_ssl
16
16
  else
17
- fail "Invalid rest host: #{host}"
17
+ raise "Invalid rest host: #{host}"
18
18
  end
19
19
 
20
20
  http = Net::HTTP.new(uri.host, uri.port)
@@ -31,14 +31,14 @@ module RestAPI
31
31
  when 'delete', :delete
32
32
  request = Net::HTTP::Delete.new(uri.request_uri)
33
33
  else
34
- fail "Invalid rest call: #{type}"
34
+ raise "Invalid rest call: #{type}"
35
35
  end
36
36
  options['Content-Type'] ||= 'application/json'
37
37
  options.delete('Content-Type') if [:none, 'none', nil].include?(options['Content-Type'])
38
38
  options.delete('X-API-Version') if [:none, 'none', nil].include?(options['X-API-Version'])
39
39
  options.delete('auth') if [:none, 'none', nil].include?(options['auth'])
40
40
  options.each do |key, val|
41
- if key.downcase == 'body'
41
+ if key.casecmp('body') == 0
42
42
  request.body = val.to_json rescue val
43
43
  else
44
44
  request[key] = val
@@ -1,5 +1,5 @@
1
1
  class Chef
2
2
  module Provisioning
3
- ONEVIEW_DRIVER_VERSION = '1.1.2'
3
+ ONEVIEW_DRIVER_VERSION = '1.1.3'.freeze
4
4
  end
5
5
  end
@@ -15,10 +15,10 @@ class FakeOneView < Sinatra::Base
15
15
  get '/rest/server-profile-templates' do
16
16
  version = env['HTTP_X_API_VERSION']
17
17
  file_name = 'server-profile-templates_invalid.json'
18
- if params['filter'] && params['filter'].match('name matches')
19
- if params['filter'].match('Web Server Template with SAN')
18
+ if params['filter'] && params['filter'] =~ /name matches/
19
+ if params['filter'] =~ /Web Server Template with SAN/
20
20
  file_name = 'server-profile-templates_WebServerTemplateWithSAN.json'
21
- elsif params['filter'].match('Web Server Template')
21
+ elsif params['filter'] =~ /Web Server Template/
22
22
  file_name = 'server-profile-templates_WebServerTemplate.json'
23
23
  end
24
24
  end
@@ -40,28 +40,28 @@ class FakeOneView < Sinatra::Base
40
40
  version = env['HTTP_X_API_VERSION']
41
41
  file_name = 'server-profiles.json'
42
42
  if params['filter']
43
- if params['filter'].match('matches \'\'') || params['filter'].match('INVALIDFILTER')
43
+ if params['filter'].match('matches \'\'') || params['filter'] =~ /INVALIDFILTER/
44
44
  file_name = 'server-profiles_invalid_filter.json'
45
- elsif params['filter'].match('serialNumber matches')
46
- if params['filter'].match('VCGE9KB041')
47
- file_name = 'server-profiles_sn_VCGE9KB041.json'
48
- elsif params['filter'].match('VCGE9KB042')
49
- file_name = 'server-profiles_sn_VCGE9KB042.json'
50
- else
51
- file_name = 'server-profiles_sn_empty.json'
52
- end
53
- elsif params['filter'].match('name matches')
54
- if params['filter'].match('Template - Web Server with SAN')
55
- file_name = 'server-profiles_name_Template-WebServerWithSAN.json'
56
- elsif params['filter'].match('Template - Web Server')
57
- file_name = 'server-profiles_name_Template-WebServer.json'
58
- elsif params['filter'].match('chef-web01')
59
- file_name = 'server-profiles_name_chef-web01.json'
60
- elsif $server_created == 'chef-web03'
61
- file_name = 'server-profiles_name_chef-web03.json'
62
- else
63
- file_name = 'server-profiles_name_empty.json'
64
- end
45
+ elsif params['filter'] =~ /serialNumber matches/
46
+ file_name = if params['filter'] =~ /VCGE9KB041/
47
+ 'server-profiles_sn_VCGE9KB041.json'
48
+ elsif params['filter'] =~ /VCGE9KB042/
49
+ 'server-profiles_sn_VCGE9KB042.json'
50
+ else
51
+ 'server-profiles_sn_empty.json'
52
+ end
53
+ elsif params['filter'] =~ /name matches/
54
+ file_name = if params['filter'] =~ /Template - Web Server with SAN/
55
+ 'server-profiles_name_Template-WebServerWithSAN.json'
56
+ elsif params['filter'] =~ /Template - Web Server/
57
+ 'server-profiles_name_Template-WebServer.json'
58
+ elsif params['filter'] =~ /chef-web01/
59
+ 'server-profiles_name_chef-web01.json'
60
+ elsif $server_created == 'chef-web03'
61
+ 'server-profiles_name_chef-web03.json'
62
+ else
63
+ 'server-profiles_name_empty.json'
64
+ end
65
65
  end
66
66
  end
67
67
  json_response(200, file_name, version)
@@ -80,7 +80,7 @@ class FakeOneView < Sinatra::Base
80
80
  get '/rest/server-hardware' do
81
81
  version = env['HTTP_X_API_VERSION']
82
82
  file_name = 'server-hardware.json'
83
- if params['filter'].match('enclosure-groups/3a11ccdd-b352-4046-a568-a8b0faa6cc39') # && params['filter'].match('') # TODO
83
+ if params['filter'] =~ %r{enclosure-groups/3a11ccdd-b352-4046-a568-a8b0faa6cc39}
84
84
  file_name = 'server-hardware_Template-WebServer.json'
85
85
  end
86
86
  json_response(200, file_name, version)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-provisioning-oneview
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hewlett Packard Enterprise
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-04 00:00:00.000000000 Z
11
+ date: 2016-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef