oneview-sdk 4.1.0 → 4.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -2
- data/Gemfile +11 -0
- data/Guardfile +26 -0
- data/README.md +9 -3
- data/lib/oneview-sdk.rb +1 -1
- data/lib/oneview-sdk/image-streamer/resource/{api_300.rb → api300.rb} +0 -0
- data/lib/oneview-sdk/image-streamer/resource/api300/artifact_bundle.rb +10 -12
- data/lib/oneview-sdk/image-streamer/resource/api300/golden_image.rb +6 -61
- data/lib/oneview-sdk/resource.rb +23 -6
- data/lib/oneview-sdk/resource/api200/firmware_bundle.rb +4 -37
- data/lib/oneview-sdk/resource/api200/lig_uplink_set.rb +1 -1
- data/lib/oneview-sdk/resource/api200/logical_interconnect_group.rb +47 -29
- data/lib/oneview-sdk/resource/api200/volume.rb +2 -22
- data/lib/oneview-sdk/resource/api300/c7000/server_hardware.rb +1 -13
- data/lib/oneview-sdk/resource/api300/synergy/os_deployment_plan.rb +41 -0
- data/lib/oneview-sdk/resource/api300/synergy/server_profile.rb +13 -0
- data/lib/oneview-sdk/resource/api500.rb +66 -0
- data/lib/oneview-sdk/resource/api500/c7000.rb +27 -0
- data/lib/oneview-sdk/resource/api500/c7000/connection_template.rb +22 -0
- data/lib/oneview-sdk/resource/api500/c7000/datacenter.rb +22 -0
- data/lib/oneview-sdk/resource/api500/c7000/enclosure.rb +22 -0
- data/lib/oneview-sdk/resource/api500/c7000/enclosure_group.rb +22 -0
- data/lib/oneview-sdk/resource/api500/c7000/ethernet_network.rb +22 -0
- data/lib/oneview-sdk/resource/api500/c7000/fabric.rb +22 -0
- data/lib/oneview-sdk/resource/api500/c7000/fc_network.rb +22 -0
- data/lib/oneview-sdk/resource/api500/c7000/fcoe_network.rb +22 -0
- data/lib/oneview-sdk/resource/api500/c7000/firmware_bundle.rb +21 -0
- data/lib/oneview-sdk/resource/api500/c7000/firmware_driver.rb +22 -0
- data/lib/oneview-sdk/resource/api500/c7000/interconnect.rb +22 -0
- data/lib/oneview-sdk/resource/api500/c7000/lig_uplink_set.rb +21 -0
- data/lib/oneview-sdk/resource/api500/c7000/logical_downlink.rb +22 -0
- data/lib/oneview-sdk/resource/api500/c7000/logical_enclosure.rb +22 -0
- data/lib/oneview-sdk/resource/api500/c7000/logical_interconnect.rb +22 -0
- data/lib/oneview-sdk/resource/api500/c7000/logical_interconnect_group.rb +22 -0
- data/lib/oneview-sdk/resource/api500/c7000/logical_switch.rb +22 -0
- data/lib/oneview-sdk/resource/api500/c7000/logical_switch_group.rb +22 -0
- data/lib/oneview-sdk/resource/api500/c7000/managed_san.rb +22 -0
- data/lib/oneview-sdk/resource/api500/c7000/network_set.rb +22 -0
- data/lib/oneview-sdk/resource/api500/c7000/power_device.rb +21 -0
- data/lib/oneview-sdk/resource/api500/c7000/rack.rb +22 -0
- data/lib/oneview-sdk/resource/api500/c7000/resource.rb +21 -0
- data/lib/oneview-sdk/resource/api500/c7000/san_manager.rb +22 -0
- data/lib/oneview-sdk/resource/api500/c7000/scope.rb +22 -0
- data/lib/oneview-sdk/resource/api500/c7000/server_hardware.rb +22 -0
- data/lib/oneview-sdk/resource/api500/c7000/server_hardware_type.rb +21 -0
- data/lib/oneview-sdk/resource/api500/c7000/server_profile.rb +22 -0
- data/lib/oneview-sdk/resource/api500/c7000/server_profile_template.rb +22 -0
- data/lib/oneview-sdk/resource/api500/c7000/storage_pool.rb +22 -0
- data/lib/oneview-sdk/resource/api500/c7000/storage_system.rb +22 -0
- data/lib/oneview-sdk/resource/api500/c7000/switch.rb +22 -0
- data/lib/oneview-sdk/resource/api500/c7000/unmanaged_device.rb +22 -0
- data/lib/oneview-sdk/resource/api500/c7000/uplink_set.rb +22 -0
- data/lib/oneview-sdk/resource/api500/c7000/user.rb +22 -0
- data/lib/oneview-sdk/resource/api500/c7000/volume.rb +22 -0
- data/lib/oneview-sdk/resource/api500/c7000/volume_attachment.rb +22 -0
- data/lib/oneview-sdk/resource/api500/c7000/volume_snapshot.rb +22 -0
- data/lib/oneview-sdk/resource/api500/c7000/volume_template.rb +22 -0
- data/lib/oneview-sdk/resource/api500/synergy.rb +27 -0
- data/lib/oneview-sdk/resource/api500/synergy/connection_template.rb +22 -0
- data/lib/oneview-sdk/resource/api500/synergy/datacenter.rb +22 -0
- data/lib/oneview-sdk/resource/api500/synergy/drive_enclosure.rb +22 -0
- data/lib/oneview-sdk/resource/api500/synergy/enclosure.rb +22 -0
- data/lib/oneview-sdk/resource/api500/synergy/enclosure_group.rb +22 -0
- data/lib/oneview-sdk/resource/api500/synergy/ethernet_network.rb +22 -0
- data/lib/oneview-sdk/resource/api500/synergy/fabric.rb +22 -0
- data/lib/oneview-sdk/resource/api500/synergy/fc_network.rb +22 -0
- data/lib/oneview-sdk/resource/api500/synergy/fcoe_network.rb +22 -0
- data/lib/oneview-sdk/resource/api500/synergy/firmware_bundle.rb +21 -0
- data/lib/oneview-sdk/resource/api500/synergy/firmware_driver.rb +22 -0
- data/lib/oneview-sdk/resource/api500/synergy/interconnect.rb +22 -0
- data/lib/oneview-sdk/resource/api500/synergy/lig_uplink_set.rb +21 -0
- data/lib/oneview-sdk/resource/api500/synergy/logical_downlink.rb +22 -0
- data/lib/oneview-sdk/resource/api500/synergy/logical_enclosure.rb +22 -0
- data/lib/oneview-sdk/resource/api500/synergy/logical_interconnect.rb +22 -0
- data/lib/oneview-sdk/resource/api500/synergy/logical_interconnect_group.rb +22 -0
- data/lib/oneview-sdk/resource/api500/synergy/logical_switch.rb +22 -0
- data/lib/oneview-sdk/resource/api500/synergy/managed_san.rb +22 -0
- data/lib/oneview-sdk/resource/api500/synergy/network_set.rb +22 -0
- data/lib/oneview-sdk/resource/api500/synergy/power_device.rb +21 -0
- data/lib/oneview-sdk/resource/api500/synergy/rack.rb +22 -0
- data/lib/oneview-sdk/resource/api500/synergy/resource.rb +21 -0
- data/lib/oneview-sdk/resource/api500/synergy/san_manager.rb +22 -0
- data/lib/oneview-sdk/resource/api500/synergy/sas_interconnect.rb +22 -0
- data/lib/oneview-sdk/resource/api500/synergy/sas_logical_interconnect.rb +22 -0
- data/lib/oneview-sdk/resource/api500/synergy/sas_logical_interconnect_group.rb +22 -0
- data/lib/oneview-sdk/resource/api500/synergy/scope.rb +22 -0
- data/lib/oneview-sdk/resource/api500/synergy/server_hardware.rb +22 -0
- data/lib/oneview-sdk/resource/api500/synergy/server_hardware_type.rb +22 -0
- data/lib/oneview-sdk/resource/api500/synergy/server_profile.rb +22 -0
- data/lib/oneview-sdk/resource/api500/synergy/server_profile_template.rb +22 -0
- data/lib/oneview-sdk/resource/api500/synergy/storage_pool.rb +22 -0
- data/lib/oneview-sdk/resource/api500/synergy/storage_system.rb +22 -0
- data/lib/oneview-sdk/resource/api500/synergy/switch.rb +22 -0
- data/lib/oneview-sdk/resource/api500/synergy/unmanaged_device.rb +22 -0
- data/lib/oneview-sdk/resource/api500/synergy/uplink_set.rb +22 -0
- data/lib/oneview-sdk/resource/api500/synergy/user.rb +22 -0
- data/lib/oneview-sdk/resource/api500/synergy/volume.rb +22 -0
- data/lib/oneview-sdk/resource/api500/synergy/volume_attachment.rb +22 -0
- data/lib/oneview-sdk/resource/api500/synergy/volume_snapshot.rb +22 -0
- data/lib/oneview-sdk/resource/api500/synergy/volume_template.rb +22 -0
- data/lib/oneview-sdk/rest.rb +21 -8
- data/lib/oneview-sdk/version.rb +1 -1
- metadata +90 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91b49f3734a5341886b50994724e02c367a85572
|
4
|
+
data.tar.gz: 504c62c8c43728d41c60230661d24f44ff79f5ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9193b1927608fbacde28cfeb0d1699a050e12f1741c8d57610e20a704f837918f5f80e9cd1122cf2c55f6f0492be8b17fceaf3cee768da892b44278c6c1016d7
|
7
|
+
data.tar.gz: 19ed880cd4bc058178872b0df2f0bad6623b8c4978495a449fcdda37f0985bde7184241d00b8696b10890964992f39152b2cab4b577d1def2eb45a4267b645d5
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,20 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# v4.2.0
|
2
|
+
|
3
|
+
#### New Resources:
|
4
|
+
- OS Deployment Plan
|
5
|
+
|
6
|
+
#### Bug fixes & Enhancements:
|
7
|
+
- [#89](https://github.com/HewlettPackard/oneview-sdk-ruby/issues/89) Fix like? method for Logical Interconnect Groups
|
8
|
+
- [#119](https://github.com/HewlettPackard/oneview-sdk-ruby/issues/112) VolumeAttachment::remove_extra_unmanaged_volume throw Unexpected Http Error
|
9
|
+
- [#125](https://github.com/HewlettPackard/oneview-sdk-ruby/issues/125) References to resources C7000 in Synergy integration tests
|
10
|
+
- [#189](https://github.com/HewlettPackard/oneview-sdk-ruby/issues/189) Use helper methods of Rest module for upload and download file
|
11
|
+
- [#201](https://github.com/HewlettPackard/oneview-sdk-ruby/issues/201) Code to search the collection of resources (paginated search) is repeated in some resources
|
12
|
+
- [#202](https://github.com/HewlettPackard/oneview-sdk-ruby/issues/202) The method #get_default_settings in LogicalInterconnectGroup is used on integration test
|
13
|
+
- [#212](https://github.com/HewlettPackard/oneview-sdk-ruby/issues/212) Unable to create a Server Profile with Deployment Plan settings
|
14
|
+
- [#219](https://github.com/HewlettPackard/oneview-sdk-ruby/issues/219) Fix like? method for Server Profile
|
15
|
+
|
16
|
+
#### Design changes:
|
17
|
+
- Architecture for future API500 support. Features for API500 are not yet supported.
|
3
18
|
|
4
19
|
# v4.1.0
|
5
20
|
|
data/Gemfile
CHANGED
@@ -1,2 +1,13 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
gemspec
|
3
|
+
|
4
|
+
begin
|
5
|
+
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.2.6')
|
6
|
+
group :development do
|
7
|
+
gem 'guard-rspec'
|
8
|
+
gem 'guard-rubocop'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
rescue StandardError
|
12
|
+
"no big deal; just don't use guard"
|
13
|
+
end
|
data/Guardfile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# (c) Copyright 2017 Hewlett Packard Enterprise Development LP
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
6
|
+
#
|
7
|
+
# Unless required by applicable law or agreed to in writing, software distributed
|
8
|
+
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
9
|
+
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
10
|
+
# specific language governing permissions and limitations under the License.
|
11
|
+
|
12
|
+
guard :rubocop, cmd: 'bundle exec rubocop', cli: ['-D'] do
|
13
|
+
watch('.rubocop.yml')
|
14
|
+
watch(/(.+\.rb)$/)
|
15
|
+
watch(/^(Gemfile|Rakefile)$/)
|
16
|
+
end
|
17
|
+
|
18
|
+
guard :rspec, cmd: 'bundle exec rspec --color -t ~integration', first_match: true do
|
19
|
+
watch(%r{^spec\/(\w+)\.rb$}) { 'spec/unit' }
|
20
|
+
watch(%r{^(spec\/unit\/.+_spec\.rb)$})
|
21
|
+
watch('lib/oneview-sdk/cli.rb') { 'spec/unit/cli' }
|
22
|
+
watch(%r{^lib\/oneview-sdk\/(.+)\.rb$}) { |m| "spec/unit/#{m[1]}_spec.rb" }
|
23
|
+
watch(%r{^(spec\/support\/\w+\.rb)$}) { 'spec/unit' }
|
24
|
+
watch(%r{^spec\/support\/fixtures\/unit\/(\w+)\/.+$}) { |m| "spec/unit/#{m[1]}" }
|
25
|
+
watch(%r{^lib\/(.+)\.rb$}) { 'spec/unit' } # Everything else
|
26
|
+
end
|
data/README.md
CHANGED
@@ -12,7 +12,7 @@ The OneView SDK provides a Ruby library to easily interact with HPE OneView and
|
|
12
12
|
- Require the gem in your Gemfile:
|
13
13
|
|
14
14
|
```ruby
|
15
|
-
gem 'oneview-sdk', '~> 4.
|
15
|
+
gem 'oneview-sdk', '~> 4.2'
|
16
16
|
```
|
17
17
|
|
18
18
|
Then run `$ bundle install`
|
@@ -162,7 +162,7 @@ You may notice resource classes being accessed in a few different ways; for exam
|
|
162
162
|
require 'oneview-sdk'
|
163
163
|
|
164
164
|
# Show defaults:
|
165
|
-
OneviewSDK::SUPPORTED_API_VERSIONS # [200, 300]
|
165
|
+
OneviewSDK::SUPPORTED_API_VERSIONS # [200, 300, 500]
|
166
166
|
OneviewSDK::DEFAULT_API_VERSION # 200
|
167
167
|
OneviewSDK.api_version # 200
|
168
168
|
OneviewSDK.api_version_updated? # false
|
@@ -178,12 +178,17 @@ OneviewSDK.api_version = 300
|
|
178
178
|
OneviewSDK.api_version # 300
|
179
179
|
OneviewSDK.api_version_updated? # true
|
180
180
|
|
181
|
-
# The API200 module has no variants, but API300 has 2 (C7000 & Synergy):
|
181
|
+
# The API200 module has no variants, but API300 and API500 has 2 (C7000 & Synergy):
|
182
182
|
OneviewSDK::API300::SUPPORTED_VARIANTS # ['C7000', 'Synergy']
|
183
183
|
OneviewSDK::API300::DEFAULT_VARIANT # 'C7000'
|
184
184
|
OneviewSDK::API300.variant # 'C7000'
|
185
185
|
OneviewSDK::API300.variant_updated? # false
|
186
186
|
|
187
|
+
OneviewSDK::API500::SUPPORTED_VARIANTS # ['C7000', 'Synergy']
|
188
|
+
OneviewSDK::API500::DEFAULT_VARIANT # 'C7000'
|
189
|
+
OneviewSDK::API500.variant # 'C7000'
|
190
|
+
OneviewSDK::API500.variant_updated? # false
|
191
|
+
|
187
192
|
# Therefore, there is 1 more namespace level to the real resource class name
|
188
193
|
OneviewSDK::EthernetNetwork # OneviewSDK::API300::C7000::EthernetNetwork
|
189
194
|
OneviewSDK::API300::EthernetNetwork # OneviewSDK::API300::C7000::EthernetNetwork
|
@@ -425,6 +430,7 @@ First run `$ bundle` (requires the bundler gem), then...
|
|
425
430
|
### Testing
|
426
431
|
- RuboCop: `$ rake rubocop`
|
427
432
|
- Unit: `$ rake spec`
|
433
|
+
- Optional: Start guard to run unit tests & rubocop automatically on file changes: `$ bundle exec guard`
|
428
434
|
- Integration: See the [spec/integration](spec/integration/) README
|
429
435
|
- All: Run `$ rake test:all` to run RuboCop, unit, & integration tests.
|
430
436
|
- Examples: See the [examples](examples/) README
|
data/lib/oneview-sdk.rb
CHANGED
@@ -24,7 +24,7 @@ module OneviewSDK
|
|
24
24
|
env_i3s = %w(I3S_URL I3S_SSL_ENABLED)
|
25
25
|
ENV_VARS = env_sdk.concat(env_i3s).freeze
|
26
26
|
|
27
|
-
SUPPORTED_API_VERSIONS = [200, 300].freeze
|
27
|
+
SUPPORTED_API_VERSIONS = [200, 300, 500].freeze
|
28
28
|
DEFAULT_API_VERSION = 200
|
29
29
|
@api_version = DEFAULT_API_VERSION
|
30
30
|
@api_version_updated = false # Whether or not the API version has been set by the user
|
File without changes
|
@@ -50,8 +50,7 @@ module OneviewSDK
|
|
50
50
|
file_name = File.basename(file_path)
|
51
51
|
end
|
52
52
|
|
53
|
-
|
54
|
-
body = client.upload_file(file_path, BASE_URI, params, timeout)
|
53
|
+
body = client.upload_file(file_path, BASE_URI, { 'file_name' => file_name }, timeout)
|
55
54
|
ArtifactBundle.new(client, body)
|
56
55
|
end
|
57
56
|
|
@@ -76,22 +75,21 @@ module OneviewSDK
|
|
76
75
|
# If there are any artifacts existing, they will be removed before the extract operation.
|
77
76
|
# @param [OneviewSDK::ImageStreamer::Client] client The client object for the Image Streamer appliance
|
78
77
|
# @param [String] file_path The file path with file extension
|
79
|
-
# @param [String] artifact_name The name for the artifact that will be created
|
78
|
+
# @param [String] artifact_name The name for the artifact that will be created. Default is the file name.
|
80
79
|
# @param [Integer] timeout The number of seconds to wait for completing the request. Default is 300.
|
81
80
|
# @return [Hash] The result hash with DeploymentGroup data
|
82
|
-
def self.create_backup_from_file!(client, deployment_group, file_path, artifact_name, timeout = OneviewSDK::Rest::READ_TIMEOUT)
|
81
|
+
def self.create_backup_from_file!(client, deployment_group, file_path, artifact_name = nil, timeout = OneviewSDK::Rest::READ_TIMEOUT)
|
83
82
|
ensure_resource!(deployment_group)
|
84
83
|
ensure_file_path_extension!(file_path)
|
85
84
|
|
86
|
-
file_name = artifact_name.
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
end
|
85
|
+
file_name = if artifact_name && !artifact_name.empty?
|
86
|
+
artifact_name + File.extname(file_path)
|
87
|
+
else
|
88
|
+
File.basename(file_path)
|
89
|
+
end
|
92
90
|
|
93
|
-
params = { '
|
94
|
-
client.upload_file(file_path, BACKUPS_ARCHIVE_URI, params, timeout)
|
91
|
+
params = { 'deploymentGrpUri' => deployment_group['uri'] }
|
92
|
+
client.upload_file(file_path, BACKUPS_ARCHIVE_URI, { 'file_name' => file_name, 'body' => params }, timeout)
|
95
93
|
end
|
96
94
|
|
97
95
|
# Download the backup bundle
|
@@ -10,7 +10,6 @@
|
|
10
10
|
# language governing permissions and limitations under the License.
|
11
11
|
|
12
12
|
require_relative 'resource'
|
13
|
-
require 'net/http/post/multipart'
|
14
13
|
|
15
14
|
module OneviewSDK
|
16
15
|
module ImageStreamer
|
@@ -18,7 +17,6 @@ module OneviewSDK
|
|
18
17
|
# Golden Image resource implementation for Image Streamer
|
19
18
|
class GoldenImage < Resource
|
20
19
|
BASE_URI = '/rest/golden-images'.freeze
|
21
|
-
READ_TIMEOUT = 300 # in seconds (5 minutes)
|
22
20
|
ACCEPTED_FORMATS = %w(.zip .ZIP).freeze # Supported upload extensions
|
23
21
|
|
24
22
|
# Create a resource object, associate it with a client, and set its properties.
|
@@ -44,36 +42,10 @@ module OneviewSDK
|
|
44
42
|
# Downloads the content of the selected golden image to the specified file path.
|
45
43
|
# @param [String] file_path
|
46
44
|
# @param [Integer] timeout The number of seconds to wait for the request to complete
|
47
|
-
# @return [True] When was saved successfully
|
48
|
-
def download(file_path
|
45
|
+
# @return [True] When it was saved successfully
|
46
|
+
def download(file_path)
|
49
47
|
ensure_client && ensure_uri
|
50
|
-
|
51
|
-
req = Net::HTTP::Get.new(uri.request_uri)
|
52
|
-
|
53
|
-
options = {}
|
54
|
-
options['Content-Type'] = 'application/json'
|
55
|
-
options['X-Api-Version'] = @client.api_version.to_s
|
56
|
-
options['auth'] = @client.token
|
57
|
-
options.each do |key, val|
|
58
|
-
req[key] = val
|
59
|
-
end
|
60
|
-
|
61
|
-
http_request = Net::HTTP.new(uri.host, uri.port)
|
62
|
-
http_request.use_ssl = true
|
63
|
-
http_request.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
64
|
-
http_request.read_timeout = timeout
|
65
|
-
|
66
|
-
http_request.start do |http|
|
67
|
-
http.request(req) do |res|
|
68
|
-
client.response_handler(res) unless res.code.to_i.between?(200, 204)
|
69
|
-
File.open(file_path, 'wb') do |file|
|
70
|
-
res.read_body do |segment|
|
71
|
-
file.write(segment)
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
true
|
48
|
+
client.download_file("#{BASE_URI}/download/#{@data['uri'].split('/').last}", file_path)
|
77
49
|
end
|
78
50
|
|
79
51
|
# Upload a golden image from the specified local file path.
|
@@ -85,40 +57,13 @@ module OneviewSDK
|
|
85
57
|
# @option data_options [String] :description The description of the Golden Image (required)
|
86
58
|
# @param [Integer] timeout The number of seconds to wait for the request to complete
|
87
59
|
# @return [OneviewSDK::ImageStreamer::API300::GoldenImage] if the upload was successful, return a GoldenImage object
|
88
|
-
def self.add(client, file_path, data_options, timeout = READ_TIMEOUT)
|
60
|
+
def self.add(client, file_path, data_options, timeout = OneviewSDK::Rest::READ_TIMEOUT)
|
89
61
|
data_options = Hash[data_options.map { |k, v| [k.to_s, v] }] # Convert symbols hash keys to string
|
90
|
-
raise NotFound, "ERROR: File '#{file_path}' not found!" unless File.file?(file_path)
|
91
62
|
raise InvalidFormat, 'ERROR: File with extension not supported!' unless ACCEPTED_FORMATS.include? File.extname(file_path)
|
92
63
|
raise IncompleteResource, 'Please set the name of the golden image!' unless data_options['name']
|
93
64
|
raise IncompleteResource, 'Please set the description of the golden image!' unless data_options['description']
|
94
|
-
|
95
|
-
|
96
|
-
options['X-Api-Version'] = client.api_version.to_s
|
97
|
-
options['auth'] = client.token
|
98
|
-
options['file'] = File.basename(file_path)
|
99
|
-
url = URI.parse(URI.escape("#{client.url}#{BASE_URI}"))
|
100
|
-
|
101
|
-
File.open(file_path) do |file|
|
102
|
-
req = Net::HTTP::Post::Multipart.new(
|
103
|
-
url.path,
|
104
|
-
{ 'file' => UploadIO.new(file, 'application/octet-stream', File.basename(file_path)) }.merge(data_options),
|
105
|
-
options
|
106
|
-
)
|
107
|
-
|
108
|
-
http_request = Net::HTTP.new(url.host, url.port)
|
109
|
-
http_request.use_ssl = true if url.scheme == 'https'
|
110
|
-
if client.ssl_enabled
|
111
|
-
http_request.cert_store = client.cert_store if client.cert_store
|
112
|
-
else http_request.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
113
|
-
end
|
114
|
-
http_request.read_timeout = timeout
|
115
|
-
|
116
|
-
http_request.start do |http|
|
117
|
-
response = http.request(req)
|
118
|
-
data = client.response_handler(response)
|
119
|
-
return OneviewSDK::ImageStreamer::API300::GoldenImage.new(client, data)
|
120
|
-
end
|
121
|
-
end
|
65
|
+
data = client.upload_file(file_path, BASE_URI, { 'body' => data_options }, timeout)
|
66
|
+
GoldenImage.new(client, data)
|
122
67
|
end
|
123
68
|
|
124
69
|
# Sets the OS volume
|
data/lib/oneview-sdk/resource.rb
CHANGED
@@ -262,20 +262,31 @@ module OneviewSDK
|
|
262
262
|
# @param [String] uri URI of the endpoint
|
263
263
|
# @return [Array<Resource>] Results matching the search
|
264
264
|
def self.find_by(client, attributes, uri = self::BASE_URI)
|
265
|
+
all = find_with_pagination(client, uri)
|
265
266
|
results = []
|
267
|
+
all.each do |member|
|
268
|
+
temp = new(client, member)
|
269
|
+
results.push(temp) if temp.like?(attributes)
|
270
|
+
end
|
271
|
+
results
|
272
|
+
end
|
273
|
+
|
274
|
+
# Make a GET request to the uri, and returns an array with all results (search using resource pagination)
|
275
|
+
# @param [OneviewSDK::Client] client The client object for the OneView appliance
|
276
|
+
# @param [String] uri URI of the endpoint
|
277
|
+
# @return [Array<Hash>] Results
|
278
|
+
def self.find_with_pagination(client, uri)
|
279
|
+
all = []
|
266
280
|
loop do
|
267
281
|
response = client.rest_get(uri)
|
268
282
|
body = client.response_handler(response)
|
269
283
|
members = body['members']
|
270
284
|
break unless members
|
271
|
-
members
|
272
|
-
temp = new(client, member)
|
273
|
-
results.push(temp) if temp.like?(attributes)
|
274
|
-
end
|
285
|
+
all.concat(members)
|
275
286
|
break unless body['nextPageUri'] && (body['nextPageUri'] != body['uri'])
|
276
287
|
uri = body['nextPageUri']
|
277
288
|
end
|
278
|
-
|
289
|
+
all
|
279
290
|
end
|
280
291
|
|
281
292
|
# Make a GET request to the resource base uri, and returns an array with all objects of this type
|
@@ -350,7 +361,13 @@ module OneviewSDK
|
|
350
361
|
return false unless data && data.respond_to?(:[])
|
351
362
|
if val.is_a?(Hash)
|
352
363
|
return false unless data.class == Hash && recursive_like?(val, data[key.to_s])
|
353
|
-
elsif val
|
364
|
+
elsif val.is_a?(Array) && val.first.is_a?(Hash)
|
365
|
+
data_array = data[key.to_s] || data[key.to_sym]
|
366
|
+
return false unless data_array.is_a?(Array)
|
367
|
+
val.each do |other_item|
|
368
|
+
return false unless data_array.find { |data_item| recursive_like?(other_item, data_item) }
|
369
|
+
end
|
370
|
+
elsif val.to_s != data[key.to_s].to_s && val.to_s != data[key.to_sym].to_s
|
354
371
|
return false
|
355
372
|
end
|
356
373
|
end
|
@@ -9,54 +9,21 @@
|
|
9
9
|
# CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
|
10
10
|
# language governing permissions and limitations under the License.
|
11
11
|
|
12
|
-
require 'net/http/post/multipart'
|
13
|
-
|
14
12
|
module OneviewSDK
|
15
13
|
module API200
|
16
14
|
# Firmware bundle resource implementation
|
17
15
|
class FirmwareBundle
|
18
16
|
BASE_URI = '/rest/firmware-bundles'.freeze
|
19
|
-
READ_TIMEOUT = 300 # in seconds, 5 minutes
|
20
17
|
|
21
18
|
# Uploads a firmware bundle file
|
22
19
|
# @param [OneviewSDK::Client] client The client object for the OneView appliance
|
23
20
|
# @param [String] file_path
|
24
21
|
# @param [Integer] timeout The number of seconds to wait for completing the request
|
25
22
|
# @return [OneviewSDK::FirmwareDriver] if the upload was successful, return a FirmwareDriver object
|
26
|
-
def self.add(client, file_path, timeout = READ_TIMEOUT)
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
options['X-Api-Version'] = client.api_version.to_s
|
31
|
-
options['auth'] = client.token
|
32
|
-
options['uploadfilename'] = File.basename(file_path)
|
33
|
-
url = URI.parse(URI.escape("#{client.url}#{BASE_URI}"))
|
34
|
-
|
35
|
-
File.open(file_path) do |file|
|
36
|
-
req = Net::HTTP::Post::Multipart.new(
|
37
|
-
url.path,
|
38
|
-
{ 'file' => UploadIO.new(file, 'application/octet-stream', File.basename(file_path)) },
|
39
|
-
options
|
40
|
-
)
|
41
|
-
|
42
|
-
http_request = Net::HTTP.new(url.host, url.port)
|
43
|
-
http_request.use_ssl = true
|
44
|
-
http_request.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
45
|
-
http_request.read_timeout = timeout
|
46
|
-
|
47
|
-
http_request.start do |http|
|
48
|
-
begin
|
49
|
-
response = http.request(req)
|
50
|
-
data = client.response_handler(response)
|
51
|
-
return OneviewSDK::FirmwareDriver.new(client, data)
|
52
|
-
rescue Net::ReadTimeout
|
53
|
-
raise "The connection was closed because the timeout of #{timeout} seconds has expired."\
|
54
|
-
'You can specify the timeout in seconds by passing the timeout on the method call.'\
|
55
|
-
'Interrupted firmware uploads may result in corrupted firmware remaining in the appliance.'\
|
56
|
-
'HPE recommends checking the appliance for corrupted firmware and removing it.'
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
23
|
+
def self.add(client, file_path, timeout = OneviewSDK::Rest::READ_TIMEOUT)
|
24
|
+
options = { 'header' => { 'uploadfilename' => File.basename(file_path) } }
|
25
|
+
result = client.upload_file(file_path, BASE_URI, options, timeout)
|
26
|
+
OneviewSDK::FirmwareDriver.new(client, result)
|
60
27
|
end
|
61
28
|
end
|
62
29
|
end
|
@@ -25,7 +25,7 @@ module OneviewSDK
|
|
25
25
|
super
|
26
26
|
# Default values:
|
27
27
|
@data['logicalPortConfigInfos'] ||= []
|
28
|
-
@data['lacpTimer'] ||= 'Short'
|
28
|
+
@data['lacpTimer'] ||= 'Short' unless @data['networkType'] == 'FibreChannel' # FibreChannel does not need set up lacpTimer
|
29
29
|
@data['mode'] ||= 'Auto'
|
30
30
|
@data['networkUris'] ||= []
|
31
31
|
end
|
@@ -32,12 +32,6 @@ module OneviewSDK
|
|
32
32
|
@data['type'] ||= 'logical-interconnect-groupV3'
|
33
33
|
@data['interconnectMapTemplate'] ||= {}
|
34
34
|
@data['interconnectMapTemplate']['interconnectMapEntryTemplates'] ||= []
|
35
|
-
|
36
|
-
# User friendly values:
|
37
|
-
@bay_count = 8
|
38
|
-
|
39
|
-
# Create all entries if empty
|
40
|
-
parse_interconnect_map_template if @data['interconnectMapTemplate']['interconnectMapEntryTemplates'] == []
|
41
35
|
end
|
42
36
|
|
43
37
|
# Get the logical interconnect group default settings
|
@@ -51,18 +45,28 @@ module OneviewSDK
|
|
51
45
|
# Adds an interconnect
|
52
46
|
# @param [Fixnum] bay Bay number
|
53
47
|
# @param [String] type Interconnect type
|
54
|
-
# @raise [
|
48
|
+
# @raise [OneviewSDK::NotFound] if an invalid type is given
|
55
49
|
def add_interconnect(bay, type)
|
50
|
+
interconnect_type = OneviewSDK::Interconnect.get_type(@client, type)
|
51
|
+
unless interconnect_type
|
52
|
+
list = OneviewSDK::Interconnect.get_types(@client).map { |t| t['name'] }
|
53
|
+
raise OneviewSDK::NotFound, "Interconnect type #{type} not found! Supported types: #{list}"
|
54
|
+
end
|
55
|
+
|
56
|
+
entry_already_present = false
|
56
57
|
@data['interconnectMapTemplate']['interconnectMapEntryTemplates'].each do |entry|
|
57
58
|
entry['logicalLocation']['locationEntries'].each do |location|
|
58
59
|
if location['type'] == 'Bay' && location['relativeValue'] == bay
|
59
|
-
entry['permittedInterconnectTypeUri'] =
|
60
|
+
entry['permittedInterconnectTypeUri'] = interconnect_type['uri']
|
61
|
+
entry_already_present = true
|
60
62
|
end
|
61
63
|
end
|
62
64
|
end
|
63
|
-
|
64
|
-
|
65
|
-
|
65
|
+
|
66
|
+
unless entry_already_present
|
67
|
+
new_entry = new_interconnect_entry_template(bay, interconnect_type['uri'])
|
68
|
+
@data['interconnectMapTemplate']['interconnectMapEntryTemplates'] << new_entry
|
69
|
+
end
|
66
70
|
end
|
67
71
|
|
68
72
|
# Adds an uplink set
|
@@ -79,11 +83,25 @@ module OneviewSDK
|
|
79
83
|
@client.response_handler(response)
|
80
84
|
end
|
81
85
|
|
82
|
-
#
|
83
|
-
# @
|
84
|
-
# @
|
86
|
+
# Create the resource on OneView using the current data
|
87
|
+
# @note Calls the refresh method to set additional data
|
88
|
+
# @raise [OneviewSDK::IncompleteResource] if the client is not set
|
89
|
+
# @raise [StandardError] if the resource creation fails
|
90
|
+
# @return [Resource] self
|
91
|
+
def create
|
92
|
+
verify_interconnects_before_save!
|
93
|
+
super
|
94
|
+
end
|
95
|
+
|
96
|
+
# Set data and save to OneView
|
97
|
+
# @param [Hash] attributes The attributes to add/change for this resource (key-value pairs)
|
98
|
+
# @raise [OneviewSDK::IncompleteResource] if the client or uri is not set
|
99
|
+
# @raise [StandardError] if the resource save fails
|
100
|
+
# @return [Resource] self
|
85
101
|
def update(attributes = {})
|
86
102
|
set_all(attributes)
|
103
|
+
ensure_client && ensure_uri
|
104
|
+
verify_interconnects_before_save!
|
87
105
|
update_options = {
|
88
106
|
'If-Match' => @data.delete('eTag'),
|
89
107
|
'Body' => @data
|
@@ -95,21 +113,21 @@ module OneviewSDK
|
|
95
113
|
|
96
114
|
private
|
97
115
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
}
|
111
|
-
|
112
|
-
|
116
|
+
def verify_interconnects_before_save!
|
117
|
+
return unless @data['interconnectMapTemplate']['interconnectMapEntryTemplates'].empty?
|
118
|
+
@data['interconnectMapTemplate']['interconnectMapEntryTemplates'] << new_interconnect_entry_template
|
119
|
+
end
|
120
|
+
|
121
|
+
def new_interconnect_entry_template(bay = 1, interconnect_type_uri = nil)
|
122
|
+
{
|
123
|
+
'logicalLocation' => {
|
124
|
+
'locationEntries' => [
|
125
|
+
{ 'relativeValue' => bay, 'type' => 'Bay' },
|
126
|
+
{ 'relativeValue' => 1, 'type' => 'Enclosure' }
|
127
|
+
]
|
128
|
+
},
|
129
|
+
'permittedInterconnectTypeUri' => interconnect_type_uri
|
130
|
+
}
|
113
131
|
end
|
114
132
|
end
|
115
133
|
end
|