chef-provisioning-oneview 1.1.3 → 1.2.0

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: 6fd131178c928b19abb6e06f8136b4d3b9e9a2eb
4
- data.tar.gz: 80c192d8030a22b2d78ac8e58328265b83231718
3
+ metadata.gz: c6e2ebd112f8cb2206a8129177013c86dcf7c5a3
4
+ data.tar.gz: 08b98d7116f8f185dff1c56f1d4cae90a6121352
5
5
  SHA512:
6
- metadata.gz: 5e901b072f088b01d67943bda4af6aedcfb73e7eb5514388fda9e1d27df911f3c2c738daea6b8f7f7d696fc8145d784a15989a1e007bb03c814dbebae60bd53a
7
- data.tar.gz: e5a12ab051c95788e8e6dc4e0c62e7d50caa8c810e16662e37f3fd76e91dd95dc9737181ba8a9330237636a313cef0ff50f2dd6c037c319a735de7c3bac185cf
6
+ metadata.gz: b085577a2d4a4a2679de0376d86f7d2ebaf095ec5181140550028c19bfebfb083b24dee139c3d40eceacc0a9977bded027ade2f4d679bc4b0c46e79b5794463e
7
+ data.tar.gz: 8edd83dcebba1e142d15da9abfece53fa0a945292570eb75bac79f882c4f136ce016036335ab512de2cacbcd99f89d6d493b3cb7e0aa2ce172223cbc6766db3b
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # chef-provisioning-oneview
2
- Chef Provisioning driver for HP OneView
2
+ Chef Provisioning driver for HPE OneView
3
3
 
4
4
 
5
5
  [![Build Status](https://travis-ci.org/HewlettPackard/chef-provisioning-oneview.svg?branch=master)](https://travis-ci.org/HewlettPackard/chef-provisioning-oneview)
@@ -14,17 +14,16 @@ Currently supports:
14
14
 
15
15
  # Installation
16
16
 
17
- - Install Ruby and the `ruby-devel` or `ruby-dev` package for your system.
18
-
19
- - Require the gem in your Gemfile: `gem 'chef-provisioning-oneview'`
20
-
21
- Then run `$ bundle install`
22
- - Or run the command:
23
-
17
+ - This program is meant to run inside the chef-client, so to install it, add the following to a Chef recipe and run it:
24
18
  ```ruby
25
- $ gem install chef-provisioning-oneview
19
+ chef_gem 'chef-provisioning-oneview'
26
20
  ```
27
-
21
+
22
+ - To install it on your system Ruby for development purposes:
23
+ - Install Ruby and the `ruby-devel` or `ruby-dev` package for your system.
24
+
25
+ - Option 1: Require the gem in your Gemfile: `gem 'chef-provisioning-oneview'`, then run `$ bundle install`
26
+ - Option 2: Run the command: `$ gem install chef-provisioning-oneview`
28
27
 
29
28
 
30
29
  # Prerequisites
@@ -37,6 +36,7 @@ Currently supports:
37
36
  knife[:oneview_username] = 'Administrator'
38
37
  knife[:oneview_password] = 'password123'
39
38
  knife[:oneview_ignore_ssl] = true # For self-signed certs
39
+ knife[:oneview_timeout] = 10 # Optional. 10 (seconds) is the default
40
40
 
41
41
  knife[:icsp_url] = 'https://my-icsp.my-domain.com'
42
42
  knife[:icsp_username] = 'Administrator'
@@ -53,6 +53,8 @@ Currently supports:
53
53
  - Your OneView, Insight Controll Server Provisioning(ICSP), and Chef server must be trusted by your certificate stores. See [examples/ssl_issues.md](examples/ssl_issues.md) for more info on how to do this.
54
54
  - Your OneView and ICSP servers must be set up beforehand. Unfortunately, this driver doesn't do that for you too.
55
55
 
56
+ Note: ICSP is no longer required, so if you don't want to use it, you can leave those config options from your knife.rb.
57
+
56
58
  # Usage
57
59
 
58
60
  Example recipe:
@@ -69,17 +71,18 @@ machine 'web01' do
69
71
  recipe 'my_server_cookbook::default'
70
72
 
71
73
  machine_options :driver_options => {
72
- :server_template => 'Web Server Template',
73
- :os_build => 'CHEF-RHEL-6.5-x64',
74
+ :server_template => 'Web Server Template', # Name of Template OR Server Profile
75
+ :os_build => 'CHEF-RHEL-6.5-x64', # Name of OS Build Plan on ICSP. Supports array of strings also.
76
+ :server_location => 'Encl1, bay 16', # Optional. Use to provision a specific server
77
+
74
78
  :host_name => 'chef-web01',
75
79
  :ip_address => 'xx.xx.xx.xx', # For bootstrapping. Deprecated in favor of { bootstrap: true } in connection; see below
76
-
77
80
  :domainType => 'workgroup',
78
81
  :domainName => 'sub.domain.com',
79
82
  :mask => '255.255.255.0', # Can set here or in individual connections below
80
- :dhcp => false,
81
- :gateway => 'xx.xx.xx.1',
82
- :dns => 'xx.xx.xx.xx,xx.xx.xx.xx,xx.xx.xx.xx',
83
+ :dhcp => false, # Can set here or in individual connections below
84
+ :gateway => 'xx.xx.xx.1', # Can set here or in individual connections below
85
+ :dns => 'xx.xx.xx.xx,xx.xx.xx.xx,xx.xx.xx.xx', # Can set here or in individual connections below
83
86
  :connections => {
84
87
  #1 => { ... } (Reserved for PXE on our setup)
85
88
  2 => {
@@ -172,6 +175,10 @@ Add `:team => 'TeamName'` into a connection in your connections hash. Make sure
172
175
  This repo contains everything you need to get started, including example recipes and knife configuration files. See the README in the [examples](examples/) directory for how to begin provisioning.
173
176
 
174
177
 
178
+ # Troubleshooting
179
+ See the [Trouleshooting wiki page](https://github.com/HewlettPackard/chef-provisioning-oneview/wiki/Troubleshooting)
180
+
181
+
175
182
  # Contributing
176
183
  You know the drill. Fork it, branch it, change it, commit it, pull-request it. We're passionate about improving this driver, and glad to accept help to make it better.
177
184
 
@@ -5,8 +5,6 @@ module CreateMachine
5
5
  def create_machine(action_handler, machine_spec, machine_options)
6
6
  host_name = machine_options[:driver_options][:host_name]
7
7
 
8
- auth_tokens # Login (to both ICSP and OneView)
9
-
10
8
  # Check if profile exists first
11
9
  matching_profiles = rest_api(:oneview, :get, "/rest/server-profiles?filter=name matches '#{host_name}'&sort=name:asc")
12
10
  if matching_profiles['count'] > 0
@@ -18,7 +16,8 @@ module CreateMachine
18
16
  template = get_oneview_template(machine_options[:driver_options][:server_template])
19
17
 
20
18
  # Get first availabe (and compatible) HP OV server blade
21
- chosen_blade = available_hardware_for_template(template)
19
+ # If a server_location has been specified, uses that
20
+ chosen_blade = available_hardware_for_template(template, machine_options[:driver_options][:server_location])
22
21
 
23
22
  power_off(action_handler, machine_spec, chosen_blade['uri'])
24
23
 
@@ -38,7 +37,7 @@ module CreateMachine
38
37
  task = rest_api(:oneview, :post, '/rest/server-profiles', options)
39
38
  task_uri = task['uri']
40
39
  raise "Failed to create OneView server profile #{host_name}. Details: " unless task_uri
41
- # Wait for profile to be created
40
+ # Wait for profile to appear
42
41
  60.times do # Wait for up to 5 min
43
42
  matching_profiles = rest_api(:oneview, :get, "/rest/server-profiles?filter=name matches '#{host_name}'&sort=name:asc")
44
43
  return matching_profiles['members'].first if matching_profiles['members'].first
@@ -3,22 +3,8 @@ module CustomizeMachine
3
3
 
4
4
  # Use ICSP to install OS
5
5
  def customize_machine(action_handler, machine_spec, machine_options, profile)
6
- auth_tokens # Login (to both ICSP and OneView)
7
-
8
6
  # Wait for server profile to finish building
9
- unless profile['state'] == 'Normal'
10
- action_handler.perform_action "Wait for #{machine_spec.name} server to start and profile to be applied" do
11
- action_handler.report_progress "INFO: Waiting for #{machine_spec.name} server to start and profile to be applied"
12
- task = oneview_wait_for(profile['taskUri'], 360) # Wait up to 60 min for profile to be created
13
- raise 'Timed out waiting for server to start and profile to be applied' if task == false
14
- unless task == true
15
- server_template = machine_options[:driver_options][:server_template]
16
- raise "Error creating server profile from template #{server_template}: #{task['taskErrors'].first['message']}"
17
- end
18
- end
19
- profile = get_oneview_profile_by_sn(machine_spec.reference['serial_number']) # Refresh profile
20
- raise "Server profile state '#{profile['state']}' not 'Normal'" unless profile['state'] == 'Normal'
21
- end
7
+ wait_for_profile(action_handler, machine_spec, machine_options, profile)
22
8
 
23
9
  # Configure SAN storage (if applicable)
24
10
  enable_boot_from_san(action_handler, machine_spec, profile) unless machine_spec.reference['network_personalitation_finished']
@@ -16,7 +16,7 @@ module OneViewAPI
16
16
  raise 'API version type mismatch' if !version > 0
17
17
  end
18
18
  rescue
19
- puts 'Failed to get OneView API version. Setting to default (120)'
19
+ Chef::Log.warn 'Failed to get OneView API version. Setting to default (120)'
20
20
  version = 120
21
21
  end
22
22
  version
@@ -69,7 +69,7 @@ module OneViewAPI
69
69
  raise "Template '#{template_name}' not found! Please match the template name with one that exists on OneView."
70
70
  end
71
71
 
72
- def available_hardware_for_template(template)
72
+ def available_hardware_for_template(template, location = nil)
73
73
  server_hardware_type_uri = template['serverHardwareTypeUri']
74
74
  enclosure_group_uri = template['enclosureGroupUri']
75
75
  raise 'Template must specify a valid hardware type uri!' if server_hardware_type_uri.nil? || server_hardware_type_uri.empty?
@@ -77,8 +77,11 @@ module OneViewAPI
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
79
  raise 'Error! No available blades that are compatible with the server template!' unless blades['count'] > 0
80
+ Chef::Log.debug "Specific hardware requested: #{location}" if location
80
81
  blades['members'].each do |member|
81
- return member if member['state'] == 'NoProfileApplied'
82
+ next unless member['state'] == 'NoProfileApplied'
83
+ next if location && member['name'] != location
84
+ return member
82
85
  end
83
86
  raise 'No more blades are available for provisioning!' # Every bay is full and no more machines can be allocated
84
87
  end
@@ -100,6 +103,23 @@ module OneViewAPI
100
103
  false
101
104
  end
102
105
 
106
+ def wait_for_profile(action_handler, machine_spec, machine_options, profile)
107
+ unless profile['state'] == 'Normal'
108
+ action_handler.perform_action "Wait for #{machine_spec.name} server to start and profile to be applied" do
109
+ action_handler.report_progress "INFO: Waiting for #{machine_spec.name} server to start and profile to be applied"
110
+ task = oneview_wait_for(profile['taskUri'], 360) # Wait up to 60 min for profile to be created
111
+ raise 'Timed out waiting for server to start and profile to be applied' if task == false
112
+ unless task == true
113
+ server_template = machine_options[:driver_options][:server_template]
114
+ raise "Error creating server profile from template #{server_template}: #{task['taskErrors'].first['message']}"
115
+ end
116
+ end
117
+ profile = get_oneview_profile_by_sn(machine_spec.reference['serial_number']) # Refresh profile
118
+ raise "Server profile state '#{profile['state']}' not 'Normal'" unless profile['state'] == 'Normal'
119
+ end
120
+ end
121
+
122
+
103
123
  def power_on(action_handler, machine_spec, hardware_uri = nil)
104
124
  set_power_state(action_handler, machine_spec, 'on', hardware_uri)
105
125
  end
@@ -6,7 +6,6 @@ require 'chef/provisioning/driver'
6
6
  require 'chef/provisioning/transport/ssh'
7
7
  require 'chef/provisioning/machine/unix_machine'
8
8
  require 'json'
9
- require 'ridley'
10
9
  require_relative 'driver_init/oneview'
11
10
  require_relative 'version'
12
11
  require_relative 'rest'
@@ -23,6 +22,7 @@ module Chef::Provisioning
23
22
  include OneViewAPI
24
23
  include ICspAPI
25
24
 
25
+
26
26
  def self.canonicalize_url(url, config)
27
27
  _scheme, oneview_url = url.split(':', 2)
28
28
  if oneview_url.nil? || oneview_url == ''
@@ -40,26 +40,35 @@ module Chef::Provisioning
40
40
  super(canonical_url, config)
41
41
 
42
42
  @oneview_base_url = config[:knife][:oneview_url]
43
- raise 'Must set the knife[:oneview_url] attribute!' if @oneview_base_url.nil? || @oneview_base_url.empty?
44
43
  @oneview_username = config[:knife][:oneview_username]
45
- raise 'Must set the knife[:oneview_username] attribute!' if @oneview_username.nil? || @oneview_username.empty?
46
44
  @oneview_password = config[:knife][:oneview_password]
47
- raise 'Must set the knife[:oneview_password] attribute!' if @oneview_password.nil? || @oneview_password.empty?
48
45
  @oneview_disable_ssl = config[:knife][:oneview_ignore_ssl]
46
+ @api_timeout = config[:knife][:oneview_timeout] || 10 # Default timeout: 10 seconds
47
+ raise 'Must set knife[:oneview_url] attribute!' if @oneview_base_url.nil? || @oneview_base_url.empty?
48
+ raise 'Must set knife[:oneview_username] attribute!' if @oneview_username.nil? || @oneview_username.empty?
49
+ raise 'Must set knife[:oneview_password] attribute!' if @oneview_password.nil? || @oneview_password.empty?
49
50
  @oneview_api_version = 120 # Use this version for all calls that don't override it
50
51
  @current_oneview_api_version = get_oneview_api_version
52
+ Chef::Log.debug("Logging into OneView at #{@oneview_base_url}")
51
53
  @oneview_key = login_to_oneview
52
54
 
53
55
  @icsp_base_url = config[:knife][:icsp_url]
54
- raise 'Must set the knife[:icsp_url] attribute!' if @icsp_base_url.nil? || @icsp_base_url.empty?
55
56
  @icsp_username = config[:knife][:icsp_username]
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
- raise 'Must set the knife[:icsp_password] attribute!' if @icsp_password.nil? || @icsp_password.empty?
59
58
  @icsp_disable_ssl = config[:knife][:icsp_ignore_ssl]
60
59
  @icsp_api_version = 102 # Use this version for all calls that don't override it
61
- @current_icsp_api_version = get_icsp_api_version
62
- @icsp_key = login_to_icsp
60
+
61
+ Chef::Log.warn 'knife[:icsp_url] not set in knife.rb!' if @icsp_base_url.nil?
62
+ Chef::Log.warn 'knife[:icsp_username] not set in knife.rb!' if @icsp_username.nil?
63
+ Chef::Log.warn 'knife[:icsp_password] not set in knife.rb!' if @icsp_password.nil?
64
+
65
+ @icsp_ignore = @icsp_base_url.nil? || @icsp_username.nil? || @icsp_password.nil?
66
+ # If the config is not specified, skip ICSP
67
+ unless @icsp_ignore
68
+ Chef::Log.debug("Logging into ICSP at #{@icsp_base_url}")
69
+ @current_icsp_api_version = get_icsp_api_version
70
+ @icsp_key = login_to_icsp
71
+ end
63
72
  end
64
73
 
65
74
 
@@ -93,12 +102,19 @@ module Chef::Provisioning
93
102
  end
94
103
  end
95
104
 
96
-
97
105
  def ready_machine(action_handler, machine_spec, machine_options)
98
106
  profile = get_oneview_profile_by_sn(machine_spec.reference['serial_number'])
99
107
  raise "Failed to retrieve Server Profile for #{machine_spec.name}. Serial Number used to search: #{machine_spec.reference['serial_number']}" unless profile
100
- customize_machine(action_handler, machine_spec, machine_options, profile)
101
- machine_for(machine_spec, machine_options) # Return the Machine object
108
+ if @icsp_ignore == true
109
+ wait_for_profile(action_handler, machine_spec, machine_options, profile)
110
+ Chef::Log.warn('Action converge action being used, without an ICSP configuration')
111
+ Machine::BasicMachine.new(machine_spec, OneViewNilTransport.new, OneViewNilConvergence.new)
112
+ else
113
+ # This function takes care of installing the operating system etc. to the machine (blade)
114
+ customize_machine(action_handler, machine_spec, machine_options, profile)
115
+ # This is a provisining function and handles installing a chef-client
116
+ machine_for(machine_spec, machine_options) # Return the Machine object
117
+ end
102
118
  end
103
119
 
104
120
 
@@ -130,60 +146,39 @@ module Chef::Provisioning
130
146
  ssh_pty_enable: true
131
147
  }
132
148
  options = machine_options[:transport_options][:options] || default_options rescue default_options
133
-
134
149
  transport = Chef::Provisioning::Transport::SSH.new(bootstrap_ip_address, username, ssh_options, options, config)
135
150
  convergence_strategy = Chef::Provisioning::ConvergenceStrategy::InstallSh.new(
136
- machine_options[:convergence_options], {})
151
+ machine_options[:convergence_options], {}
152
+ )
137
153
  Chef::Provisioning::Machine::UnixMachine.new(machine_spec, transport, convergence_strategy)
138
154
  end
139
155
 
140
-
141
156
  def stop_machine(action_handler, machine_spec, _machine_options)
142
157
  power_off(action_handler, machine_spec) if machine_spec.reference
143
158
  end
144
159
 
145
160
 
146
- def destroy_machine(action_handler, machine_spec, machine_options)
161
+ def destroy_machine(action_handler, machine_spec, _machine_options)
147
162
  if machine_spec.reference
148
163
  power_off(action_handler, machine_spec) # Power off server
149
- destroy_icsp_server(action_handler, machine_spec) # Delete os deployment server from ICSP
164
+ destroy_icsp_server(action_handler, machine_spec) unless @icsp_ignore # Delete os deployment server from ICSP
150
165
  destroy_oneview_profile(action_handler, machine_spec) # Delete server profile from OneView
151
166
 
152
167
  name = machine_spec.name # Save for next steps
153
168
 
154
- # Delete the node from the Chef server
155
- action_handler.perform_action "Release machine #{machine_spec.reference['serial_number']}" do
156
- machine_spec.reference = nil
157
- machine_spec.delete(action_handler)
158
- end
159
-
160
- # Delete client from the Chef server
161
- action_handler.perform_action "Delete client '#{name}' from Chef server" do
162
- begin
163
- ridley = Ridley.new(
164
- server_url: machine_options[:convergence_options][:chef_server][:chef_server_url],
165
- client_name: machine_options[:convergence_options][:chef_server][:options][:client_name],
166
- client_key: machine_options[:convergence_options][:chef_server][:options][:signing_key_filename]
167
- )
168
- ridley.client.delete(name)
169
- rescue Exception => e
170
- action_handler.report_progress "WARN: Failed to delete client #{name} from server!"
171
- puts "Error: #{e.message}"
172
- end
173
- end
174
-
175
169
  # Remove entry from known_hosts file(s)
176
- if machine_options[:driver_options][:ip_address]
177
- action_handler.perform_action "Delete entry for '#{machine_options[:driver_options][:ip_address]}' from known_hosts file(s)" do
170
+ ip_address = machine_spec.data['automatic']['ipaddress'] rescue nil
171
+ if ip_address
172
+ action_handler.perform_action "Delete entry for #{name} (#{ip_address}) from known_hosts file(s)" do
178
173
  files = [File.expand_path('~/.ssh/known_hosts'), File.expand_path('/etc/ssh/known_hosts')]
179
174
  files.each do |f|
180
- next if !File.exist?(f)
175
+ next unless File.exist?(f)
181
176
  begin
182
177
  text = File.read(f)
183
- text.gsub!(/#{machine_options[:driver_options][:ip_address]} ssh-rsa.*(\n|\r\n)/, '')
178
+ text.gsub!(/#{ip_address} ssh-rsa.*(\n|\r\n)/, '')
184
179
  File.open(f, 'w') {|file| file.puts text } if text
185
180
  rescue Exception => e
186
- action_handler.report_progress "WARN: Failed to delete entry for '#{machine_options[:driver_options][:ip_address]}' from known_hosts file: '#{f}'! "
181
+ action_handler.report_progress "WARN: Failed to delete entry for #{name} (#{ip_address}) from known_hosts file: '#{f}'! "
187
182
  puts "Error: #{e.message}"
188
183
  end
189
184
  end
@@ -198,14 +193,24 @@ module Chef::Provisioning
198
193
  machine_for(machine_spec, machine_options)
199
194
  end
200
195
 
201
- private
196
+ end # class end
202
197
 
203
- # Login to both OneView and ICsp
204
- def auth_tokens
205
- @icsp_key ||= login_to_icsp
206
- @oneview_key ||= login_to_oneview
207
- { 'icsp_key' => @icsp_key, 'oneview_key' => @oneview_key }
198
+ # Additional No-Op classes to nil return when a :converge is called
199
+ # Returns a OneViewTransport::disconnect (nil)
200
+ class OneViewNilTransport
201
+ def disconnect(*_args, &_block)
202
+ nil
208
203
  end
204
+ end
209
205
 
210
- end # class end
206
+ # Additional Converge class that nils the called methods under a :converge action
207
+ class OneViewNilConvergence
208
+ def setup_convergence(*_args, &_block)
209
+ nil
210
+ end
211
+
212
+ def converge(*_args, &_block)
213
+ nil
214
+ end
215
+ end
211
216
  end # module end
@@ -18,9 +18,10 @@ module RestAPI
18
18
  end
19
19
 
20
20
  http = Net::HTTP.new(uri.host, uri.port)
21
+ http.read_timeout = @api_timeout # timeout for a request
22
+ http.open_timeout = @api_timeout # timeout for a connection
21
23
  http.use_ssl = true if uri.scheme == 'https'
22
24
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE if disable_ssl
23
-
24
25
  case type.downcase
25
26
  when 'get', :get
26
27
  request = Net::HTTP::Get.new(uri.request_uri)
@@ -1,5 +1,5 @@
1
1
  class Chef
2
2
  module Provisioning
3
- ONEVIEW_DRIVER_VERSION = '1.1.3'.freeze
3
+ ONEVIEW_DRIVER_VERSION = '1.2.0'.freeze
4
4
  end
5
5
  end
@@ -11,6 +11,7 @@ RSpec.shared_context 'shared context', a: :b do
11
11
  oneview_username: 'Administrator',
12
12
  oneview_password: 'password12',
13
13
  oneview_ignore_ssl: true,
14
+ oneview_timeout: 15,
14
15
 
15
16
  icsp_url: icsp,
16
17
  icsp_username: 'administrator',
@@ -24,11 +24,13 @@ RSpec.describe Chef::Provisioning::OneViewDriver do
24
24
  expect(@instance.instance_variable_get('@oneview_username')).to eq('Administrator')
25
25
  expect(@instance.instance_variable_get('@oneview_password')).to eq('password12')
26
26
  expect(@instance.instance_variable_get('@oneview_disable_ssl')).to eq(true)
27
+ expect(@instance.instance_variable_get('@api_timeout')).to eq(15)
27
28
 
28
29
  expect(@instance.instance_variable_get('@icsp_base_url')).to eq('https://my-icsp.my-domain.com')
29
30
  expect(@instance.instance_variable_get('@icsp_username')).to eq('administrator')
30
31
  expect(@instance.instance_variable_get('@icsp_password')).to eq('password123')
31
32
  expect(@instance.instance_variable_get('@icsp_disable_ssl')).to eq(nil)
33
+ expect(@instance.instance_variable_get('@icsp_ignore')).to eq(false)
32
34
  end
33
35
 
34
36
  it 'uses the correct api versions' do
@@ -40,32 +42,38 @@ RSpec.describe Chef::Provisioning::OneViewDriver do
40
42
 
41
43
  it 'requires the oneview_url knife param' do
42
44
  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!')
45
+ expect { Chef::Provisioning::OneViewDriver.new(@canonical_url, knife_config) }.to raise_error('Must set knife[:oneview_url] attribute!')
44
46
  end
45
47
 
46
48
  it 'requires the oneview_username knife param' do
47
49
  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!')
50
+ expect { Chef::Provisioning::OneViewDriver.new(@canonical_url, knife_config) }.to raise_error('Must set knife[:oneview_username] attribute!')
49
51
  end
50
52
 
51
53
  it 'requires the oneview_password knife param' do
52
54
  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!')
55
+ expect { Chef::Provisioning::OneViewDriver.new(@canonical_url, knife_config) }.to raise_error('Must set knife[:oneview_password] attribute!')
54
56
  end
55
57
 
56
- it 'requires the icsp_url knife param' do
58
+ it 'gives a warning if the knife[:icsp_url] is not set' do
57
59
  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!')
60
+ expect(Chef::Log).to receive(:warn).with('knife[:icsp_url] not set in knife.rb!')
61
+ driver = Chef::Provisioning::OneViewDriver.new(@canonical_url, knife_config)
62
+ expect(driver.instance_variable_get('@icsp_ignore')).to eq(true)
59
63
  end
60
64
 
61
- it 'requires the icsp_username knife param' do
65
+ it 'gives a warning if the knife[:icsp_username] is not set' do
62
66
  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!')
67
+ expect(Chef::Log).to receive(:warn).with('knife[:icsp_username] not set in knife.rb!')
68
+ driver = Chef::Provisioning::OneViewDriver.new(@canonical_url, knife_config)
69
+ expect(driver.instance_variable_get('@icsp_ignore')).to eq(true)
64
70
  end
65
71
 
66
- it 'requires the icsp_password knife param' do
72
+ it 'gives a warning if the knife[:icsp_password] is not set' do
67
73
  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!')
74
+ expect(Chef::Log).to receive(:warn).with('knife[:icsp_password] not set in knife.rb!')
75
+ driver = Chef::Provisioning::OneViewDriver.new(@canonical_url, knife_config)
76
+ expect(driver.instance_variable_get('@icsp_ignore')).to eq(true)
69
77
  end
70
78
  end
71
79
  end
@@ -12,12 +12,6 @@ RSpec.describe Chef::Provisioning::OneViewDriver do
12
12
  it 'can parse the icsp sessionID' do
13
13
  expect(@instance.instance_eval { login_to_icsp }).to match(@icsp_key)
14
14
  end
15
-
16
- it 'gets both auth tokens via the auth_tokens method' do
17
- @instance.instance_eval { auth_tokens }
18
- expect(@instance.instance_variable_get('@oneview_key')).to match(@oneview_key)
19
- expect(@instance.instance_variable_get('@icsp_key')).to match(@icsp_key)
20
- end
21
15
  end
22
16
 
23
17
  end
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.3
4
+ version: 1.2.0
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-02-08 00:00:00.000000000 Z
11
+ date: 2016-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.0'
41
- - !ruby/object:Gem::Dependency
42
- name: ridley
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '4.2'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '4.2'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: rspec
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -124,6 +110,20 @@ dependencies:
124
110
  version: '0'
125
111
  - !ruby/object:Gem::Dependency
126
112
  name: rubocop
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '='
116
+ - !ruby/object:Gem::Version
117
+ version: 0.40.0
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '='
123
+ - !ruby/object:Gem::Version
124
+ version: 0.40.0
125
+ - !ruby/object:Gem::Dependency
126
+ name: pry
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - ">="
@@ -232,7 +232,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
232
232
  version: '0'
233
233
  requirements: []
234
234
  rubyforge_project:
235
- rubygems_version: 2.4.8
235
+ rubygems_version: 2.5.2
236
236
  signing_key:
237
237
  specification_version: 4
238
238
  summary: Chef Provisioning driver for OneView