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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11de8d1ced349e47d834f7027c6fe84a67d625c6
|
4
|
+
data.tar.gz: 29db709224300d4b08603b4b6f000ef7d938468a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17c2c3f0a1dfa71dddb30d57792a395f064a458e2017205a36769c9006cae60a043b3074a15fcb5c6bb77b6af4f9496697036775c709bac5f7e391274b9b8ff1
|
7
|
+
data.tar.gz: 673f473fd1cdeedc70c859b8f932dfcada3d6dbbcad415399eec091dbc2d8ea6a03122e8a6b245e936ca8198dc7f310500ee76e6572ba6e653f1fb5026f0d7ba
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# chef-provisioning-oneview
|
2
|
-
Chef Provisioning driver for HPE OneView
|
3
2
|
|
3
|
+
Chef Provisioning driver for HPE OneView
|
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)
|
6
6
|
[![Gem Version](https://badge.fury.io/rb/chef-provisioning-oneview.svg)](https://badge.fury.io/rb/chef-provisioning-oneview)
|
@@ -8,40 +8,65 @@ Chef Provisioning driver for HPE OneView
|
|
8
8
|
Questions or comments? Join the Gitter room [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/HewlettPackard/chef-provisioning-oneview?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
|
9
9
|
|
10
10
|
|
11
|
-
|
11
|
+
Verified on (may support other versions too, but no guarantees):
|
12
12
|
- OneView v1.2.0 - 2.0.0
|
13
13
|
- ICsp v7.4.0 - 7.5.0
|
14
14
|
|
15
15
|
# Installation
|
16
16
|
|
17
|
-
- This program is meant to run inside the chef-client
|
17
|
+
- This program is meant to run inside the chef-client. To install it, add the following to a Chef recipe and run it:
|
18
|
+
|
18
19
|
```ruby
|
19
20
|
chef_gem 'chef-provisioning-oneview'
|
20
21
|
```
|
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`
|
27
22
|
|
28
23
|
|
29
|
-
#
|
30
|
-
|
24
|
+
# Credentials & Configuration
|
25
|
+
|
26
|
+
There are a few different ways to provide credentials and configuration for this driver.
|
27
|
+
|
28
|
+
- In a recipe using the `with_driver` method:
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
# The basic usage is:
|
32
|
+
# with_driver canonical_url, driver_options
|
33
|
+
|
34
|
+
with_driver 'oneview:https://oneview.example.com', {
|
35
|
+
oneview: {
|
36
|
+
url: 'https://oneview2.example.com' # Will be overridden by the canonical url above
|
37
|
+
user: 'Administrator',
|
38
|
+
password: 'secret123',
|
39
|
+
token: 'token123', # Optional. Use EITHER this or the username & password
|
40
|
+
ssl_enabled: true, # Optional. Defaults to true
|
41
|
+
timeout: 10 # Optional. In seconds
|
42
|
+
},
|
43
|
+
icsp: {
|
44
|
+
url: 'https://icsp.example.com'
|
45
|
+
user: 'Admin',
|
46
|
+
password: 'secret456',
|
47
|
+
ssl_enabled: true, # Optional. Defaults to true
|
48
|
+
timeout: 20 # Optional. In seconds
|
49
|
+
}
|
50
|
+
}
|
51
|
+
```
|
52
|
+
|
53
|
+
- You can also use the following options in your `knife.rb` file:
|
31
54
|
|
32
55
|
```ruby
|
33
56
|
# (knife.rb)
|
34
57
|
# (in addition to all the normal stuff like node_name, client_key, validation_client_name, validation_key, chef_server_url, etc.)
|
35
|
-
knife[:oneview_url] = 'https://
|
58
|
+
knife[:oneview_url] = 'https://oneview.example.com'
|
36
59
|
knife[:oneview_username] = 'Administrator'
|
37
60
|
knife[:oneview_password] = 'password123'
|
38
|
-
knife[:
|
39
|
-
knife[:
|
61
|
+
knife[:oneview_token] = 'token123' # Use EITHER this or the username & password
|
62
|
+
knife[:oneview_ignore_ssl] = true # For self-signed certs (discouraged)
|
63
|
+
knife[:oneview_timeout] = 10 # Optional. In seconds
|
40
64
|
|
41
|
-
knife[:icsp_url] = 'https://
|
65
|
+
knife[:icsp_url] = 'https://icsp.example.com'
|
42
66
|
knife[:icsp_username] = 'Administrator'
|
43
67
|
knife[:icsp_password] = 'password123'
|
44
|
-
knife[:icsp_ignore_ssl] = true # For self-signed certs
|
68
|
+
knife[:icsp_ignore_ssl] = true # For self-signed certs (discouraged)
|
69
|
+
knife[:icsp_timeout] = 20 # Optional. In seconds
|
45
70
|
|
46
71
|
knife[:node_root_password] = 'password123'
|
47
72
|
|
@@ -50,69 +75,84 @@ Currently supports:
|
|
50
75
|
ssl_verify_mode :verify_none
|
51
76
|
```
|
52
77
|
|
78
|
+
- Finally, there are a few environment variables that you can set:
|
79
|
+
|
80
|
+
```bash
|
81
|
+
export ONEVIEWSDK_USER='Administrator'
|
82
|
+
export ONEVIEWSDK_PASSWORD='secret123'
|
83
|
+
export ONEVIEWSDK_TOKEN='token123'
|
84
|
+
```
|
85
|
+
|
86
|
+
Since there are a few diferent ways of providing the same config values, here's the order of evaluation:
|
87
|
+
- **OneView URL:** canonical_url (ie `oneview:https://oneview.example.com`), driver_options[:oneview][:url], knife[:oneview_url], ENV['ONEVIEWSDK_URL']
|
88
|
+
- **OneView user, password, & token:** driver_options, knife, environment variable
|
89
|
+
- **ICSP url, user, & password:** driver_options, knife
|
90
|
+
|
91
|
+
Note: ICSP is not required, so if you don't want to use it, you can leave out those config options and it will be ignored.
|
92
|
+
|
93
|
+
### Additional Setup
|
94
|
+
|
53
95
|
- 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.
|
96
|
+
- You can also use the OneView SDK cli tool to import your OneView cert. See [this](https://github.com/HewlettPackard/oneview-sdk-ruby#cli).
|
54
97
|
- Your OneView and ICSP servers must be set up beforehand. Unfortunately, this driver doesn't do that for you too.
|
55
98
|
|
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
|
-
|
58
99
|
# Usage
|
59
100
|
|
60
101
|
Example recipe:
|
61
102
|
```ruby
|
62
103
|
require 'chef/provisioning'
|
63
104
|
|
64
|
-
with_driver 'oneview'
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
:signing_key_filename => Chef::Config[:client_key] # NOTE: This must have node & client creation privileges (ie admin group)
|
105
|
+
with_driver 'oneview:https://oneview.example.com', {
|
106
|
+
oneview: { user: 'Administrator', password: 'secret123' },
|
107
|
+
icsp: { url: 'https://icsp.example.com' user: 'Admin', password: 'secret456' }
|
108
|
+
}
|
69
109
|
|
70
110
|
machine 'web01' do
|
71
111
|
recipe 'my_server_cookbook::default'
|
72
112
|
|
73
|
-
machine_options :
|
74
|
-
:
|
75
|
-
:
|
76
|
-
:
|
113
|
+
machine_options driver_options: {
|
114
|
+
server_template: 'Web Server Template', # Name of Template OR Server Profile
|
115
|
+
os_build: 'CHEF-RHEL-6.5-x64', # Name of OS Build Plan on ICSP. Supports array of strings also.
|
116
|
+
server_location: 'Encl1, bay 16', # Optional. Use to provision a specific server
|
77
117
|
|
78
|
-
:
|
79
|
-
:
|
80
|
-
:
|
81
|
-
:
|
82
|
-
:
|
83
|
-
:
|
84
|
-
:
|
85
|
-
:
|
86
|
-
:
|
118
|
+
host_name: 'chef-web01',
|
119
|
+
ip_address: 'xx.xx.xx.xx', # For bootstrapping. Deprecated in favor of { bootstrap: true } in connection; see below
|
120
|
+
domainType: 'workgroup',
|
121
|
+
domainName: 'sub.domain.com',
|
122
|
+
mask: '255.255.255.0', # Can set here or in individual connections below
|
123
|
+
dhcp: false, # Can set here or in individual connections below
|
124
|
+
gateway: 'xx.xx.xx.1', # Can set here or in individual connections below
|
125
|
+
dns: 'xx.xx.xx.xx,xx.xx.xx.xx,xx.xx.xx.xx', # Can set here or in individual connections below
|
126
|
+
connections: {
|
87
127
|
#1 => { ... } (Reserved for PXE on our setup)
|
88
128
|
2 => {
|
89
|
-
:
|
90
|
-
:
|
91
|
-
:
|
92
|
-
:
|
93
|
-
:
|
94
|
-
:
|
129
|
+
ip4Address: 'xx.xx.xx.xx',
|
130
|
+
mask: '255.255.254.0', # Optional. Overrides mask property above
|
131
|
+
dhcp: false # Optional. Overrides dhcp property above
|
132
|
+
gateway: 'xx.xx.xx.1' # Optional. Overrides gateway property above
|
133
|
+
dns: 'xx.xx.xx.xx' # Optional. Overrides dns property above
|
134
|
+
bootstrap: true # Set this on 1 connection only. Tells Chef which connection to use to bootstrap.
|
95
135
|
},
|
96
136
|
3 => {
|
97
|
-
:
|
98
|
-
:
|
99
|
-
:
|
137
|
+
dhcp: true # Optional. Overrides dhcp property above
|
138
|
+
gateway: :none # Optional. Overrides gateway property above
|
139
|
+
dns: :none # Optional. Overrides dns property above
|
100
140
|
}
|
101
141
|
},
|
102
|
-
:
|
103
|
-
:
|
104
|
-
:
|
142
|
+
skip_network_configuration: false, # Default. Set to true for EXSi hosts, etc.
|
143
|
+
custom_attributes: {
|
144
|
+
chefCert: 'ssh-rsa AA...' # Optional
|
105
145
|
}
|
106
146
|
},
|
107
|
-
:
|
108
|
-
:
|
109
|
-
:
|
110
|
-
:
|
147
|
+
transport_options: {
|
148
|
+
user: 'root', # Optional. Defaults to 'root'
|
149
|
+
ssh_options: {
|
150
|
+
password: Chef::Config.knife[:node_root_password]
|
111
151
|
}
|
112
152
|
},
|
113
|
-
:
|
114
|
-
:
|
115
|
-
:
|
153
|
+
convergence_options: {
|
154
|
+
ssl_verify_mode: :verify_none, # Optional. For Chef servers with self-signed certs
|
155
|
+
bootstrap_proxy: 'http://proxy.example.com:8080' # Optional
|
116
156
|
}
|
117
157
|
|
118
158
|
chef_environment '_default'
|
@@ -125,11 +165,12 @@ See https://github.com/chef/chef-provisioning-ssh for more transport_options.
|
|
125
165
|
NOTE: Some basic connection settings such as :ip4Address and :dhcp are shown in the example recipe, but you can pass in any interface/nic options that exist in the ICsp api for POST requests to /rest/os-deployment-jobs
|
126
166
|
|
127
167
|
### Custom Attributes
|
168
|
+
|
128
169
|
Insided the custom attributes hash, you can specify any data that you would like to pass into your ICsp build plan scripts or configuration files. For example, to specify a list of trusted public keys to be placed into the node's .ssh/authorized_keys file, add a custom attribute to the machine resource definition:
|
129
170
|
|
130
171
|
```ruby
|
131
|
-
:
|
132
|
-
:
|
172
|
+
custom_attributes: {
|
173
|
+
chefCert: 'ssh-rsa AA...'
|
133
174
|
}
|
134
175
|
```
|
135
176
|
|
@@ -144,13 +185,14 @@ fi
|
|
144
185
|
```
|
145
186
|
|
146
187
|
### SSH Keys
|
188
|
+
|
147
189
|
To use SSH keys insead of passwords to connect to nodes, you'll need to modify your transport_options to look something like:
|
148
190
|
|
149
191
|
```ruby
|
150
|
-
:
|
151
|
-
:
|
152
|
-
:
|
153
|
-
:
|
192
|
+
transport_options: {
|
193
|
+
ssh_options: {
|
194
|
+
auth_methods: ['publickey'],
|
195
|
+
keys: ['~/.ssh/id_rsa']
|
154
196
|
}
|
155
197
|
}
|
156
198
|
```
|
@@ -158,42 +200,54 @@ To use SSH keys insead of passwords to connect to nodes, you'll need to modify y
|
|
158
200
|
You'll also need to put the corresponding public key(s) into the node's authorized_keys file during the OS setup. See the Custom Attributes section above for one way to do this.
|
159
201
|
|
160
202
|
### Behind a proxy
|
161
|
-
|
203
|
+
|
204
|
+
Add `bootstrap_proxy: 'http://proxy.example.com:8080'` to your convergence_options hash.
|
162
205
|
Also, make sure your OS build plans set up the proxy configuration in a post OS install script.
|
163
206
|
|
164
207
|
### SAN Storage
|
208
|
+
|
165
209
|
In order to attach a SAN volume as a bootable volume, the volume name must start with 'boot'; it will be appended with the the profile name on creation.
|
166
210
|
|
167
211
|
### Switching to a different network after provisioning
|
168
|
-
|
212
|
+
|
213
|
+
Add `1 => {net: "Deadnetwork", deployNet: "PXE Network", dhcp: true}` to your connections hash.
|
169
214
|
This will flip the first connection of the newly provisioned machine off of your pxe network to your Deadnetwork right after provisioning. This is helpful for taking the newly provisioned machine off the PXE network as soon as possible.
|
170
215
|
|
171
216
|
### Adding Nic Teams
|
172
|
-
|
217
|
+
|
218
|
+
Add `team: 'TeamName'` into a connection in your connections hash. Make sure that you have 2 connections in a team and the name does not include hyphens. This information will be passed to ISCP as the 'teams' custom attribute in the format: `"TeamName1-mac1,mac2|TeamName2-mac6,mac7,mac8"` to be consumed in a custom build plan script.
|
173
219
|
|
174
220
|
# Doing a test run
|
221
|
+
|
175
222
|
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.
|
176
223
|
|
177
224
|
|
178
225
|
# Troubleshooting
|
226
|
+
|
179
227
|
See the [Trouleshooting wiki page](https://github.com/HewlettPackard/chef-provisioning-oneview/wiki/Troubleshooting)
|
180
228
|
|
181
229
|
|
182
230
|
# Contributing
|
231
|
+
|
183
232
|
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.
|
184
233
|
|
185
234
|
### Building the Gem
|
235
|
+
|
186
236
|
To build this gem, run `$ rake build` or `gem build chef-provisioning-oneview.gemspec`.
|
187
237
|
|
188
238
|
Then once it's built you can install it by running `$ rake install` or `$ gem install ./chef-provisioning-oneview-<VERSION>.gem`.
|
189
239
|
|
240
|
+
Note: You may need to first install the `ruby-devel` or `ruby-dev` package for your system.
|
241
|
+
|
190
242
|
### Testing
|
243
|
+
|
191
244
|
- RuboCop: `$ rake rubocop` or `$ rubocop .`
|
192
245
|
- Rspec: `$ rake spec` or `$ rspec`
|
193
246
|
- Both: Run `$ rake test` to run both RuboCop and Rspec tests.
|
194
247
|
|
195
248
|
# Authors
|
249
|
+
|
196
250
|
- Jared Smartt - [@jsmartt](https://github.com/jsmartt)
|
197
|
-
- Gunjan Kamle - [@kgunjan](https://github.com/kgunjan)
|
198
251
|
- Matthew Frahry - [@mbfrahry](https://github.com/mbfrahry)
|
199
252
|
- Andy Claiborne - [@veloandy](https://github.com/veloandy)
|
253
|
+
- Gunjan Kamle - [@kgunjan](https://github.com/kgunjan)
|
@@ -0,0 +1,39 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/lib')
|
2
|
+
require 'chef/provisioning/version'
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = 'chef-provisioning-oneview'
|
6
|
+
s.version = Chef::Provisioning::ONEVIEW_DRIVER_VERSION
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.extra_rdoc_files = ['README.md', 'LICENSE']
|
9
|
+
s.summary = 'Chef Provisioning driver for OneView'
|
10
|
+
s.description = 'Chef Provisioning driver for creating and managing OneView infrastructure.'
|
11
|
+
s.author = 'Hewlett Packard Enterprise'
|
12
|
+
s.email = ['jared.smartt@hpe.com', 'gunjan.kamle@hpe.com']
|
13
|
+
s.homepage = 'https://github.com/HewlettPackard/chef-provisioning-oneview'
|
14
|
+
s.license = 'Apache-2.0'
|
15
|
+
|
16
|
+
case RUBY_VERSION
|
17
|
+
when /^2\.0/
|
18
|
+
s.add_dependency 'chef', '~> 12.0', '< 12.9'
|
19
|
+
when /^2\.(1|2\.[01])/
|
20
|
+
s.add_dependency 'chef', '~> 12.0', '< 12.14'
|
21
|
+
else
|
22
|
+
s.add_dependency 'chef', '~> 12.0'
|
23
|
+
end
|
24
|
+
s.add_dependency 'oneview-sdk', '~> 2.1'
|
25
|
+
s.add_dependency 'chef-provisioning', '~> 1.0'
|
26
|
+
|
27
|
+
s.add_development_dependency 'rspec', '~> 3.0'
|
28
|
+
s.add_development_dependency 'rake'
|
29
|
+
s.add_development_dependency 'sinatra'
|
30
|
+
s.add_development_dependency 'webmock'
|
31
|
+
s.add_development_dependency 'simplecov'
|
32
|
+
s.add_development_dependency 'rubocop', '= 0.40.0'
|
33
|
+
s.add_development_dependency 'pry'
|
34
|
+
|
35
|
+
s.require_path = 'lib'
|
36
|
+
|
37
|
+
all_files = `git ls-files -z`.split("\x0")
|
38
|
+
s.files = Dir['LICENSE', 'README.md', '*.gemspec', 'lib/**/*'].reject { |f| !all_files.include?(f) }
|
39
|
+
end
|
@@ -1,51 +1,48 @@
|
|
1
|
-
module
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
action_handler.perform_action "Initialize creation of server profile for #{machine_spec.name}" do
|
26
|
-
action_handler.report_progress "INFO: Initializing creation of server profile for #{machine_spec.name}"
|
27
|
-
|
28
|
-
# Add name & hardware uri to template
|
29
|
-
template['name'] = host_name
|
30
|
-
template['serverHardwareUri'] = chosen_blade['uri']
|
31
|
-
|
32
|
-
update_san_info(machine_spec, template)
|
1
|
+
module OneviewChefProvisioningDriver
|
2
|
+
# Handles allocation of OneView ServerProfile
|
3
|
+
module CreateMachine
|
4
|
+
# Allocate OneView server profile
|
5
|
+
def create_machine(action_handler, machine_name, machine_options)
|
6
|
+
host_name = machine_options[:driver_options][:host_name] || machine_name
|
7
|
+
profile_name = machine_options[:driver_options][:profile_name] || host_name
|
8
|
+
|
9
|
+
# Check if profile exists first
|
10
|
+
matching_profile = OneviewSDK::ServerProfile.find_by(@ov, name: host_name).first
|
11
|
+
return matching_profile if matching_profile
|
12
|
+
|
13
|
+
# Search for OneView Template or Profile by name
|
14
|
+
template_name = machine_options[:driver_options][:server_template]
|
15
|
+
profile = profile_from_template(template_name, profile_name)
|
16
|
+
|
17
|
+
# Get first availabe (and compatible) OneView server blade.
|
18
|
+
# If a server_location has been specified, uses that
|
19
|
+
hw = available_hardware_for_profile(profile, machine_options[:driver_options][:server_location])
|
20
|
+
|
21
|
+
action_handler.perform_action "Power off server #{hw['name']} for machine '#{machine_name}'" do
|
22
|
+
action_handler.report_progress "INFO: Powering off server #{hw['name']} for machine '#{machine_name}'"
|
23
|
+
hw.power_off
|
24
|
+
end
|
33
25
|
|
34
|
-
#
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
26
|
+
# Create new ServerProfile from the template
|
27
|
+
action_handler.perform_action "Create server profile for #{machine_name}" do
|
28
|
+
action_handler.report_progress "INFO: Creating server profile for #{machine_name}"
|
29
|
+
profile.set_server_hardware(hw)
|
30
|
+
update_san_info(machine_name, profile)
|
31
|
+
response = @ov.rest_post(profile.class::BASE_URI, { 'body' => profile.data }, profile.api_version)
|
32
|
+
unless response.code.to_i == 202
|
33
|
+
task = JSON.parse(response.body)
|
34
|
+
raise "Server profile couldn't be created! #{task['taskStatus']}. #{task['taskErrors'].first['message'] rescue nil}"
|
35
|
+
end
|
36
|
+
60.times do # Wait for up to 5 min for profile to appear in OneView
|
37
|
+
return profile if profile.retrieve!
|
38
|
+
task = @ov.response_handler(@ov.rest_get(response.header['location'] || JSON.parse(response.body)['uri']))
|
39
|
+
break if task['taskState'] == 'Error'
|
40
|
+
print '.'
|
41
|
+
sleep 5
|
42
|
+
end
|
43
|
+
raise "Server profile couldn't be created! #{task['taskStatus']}. #{task['taskErrors'].first['message'] rescue nil}"
|
46
44
|
end
|
47
|
-
|
48
|
-
raise "Server profile couldn't be created! #{task['taskStatus']}. #{task['taskErrors'].first['message']}"
|
45
|
+
profile
|
49
46
|
end
|
50
47
|
end
|
51
48
|
end
|