oneview-sdk 2.2.1 → 3.0.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 +50 -0
- data/README.md +61 -15
- data/Rakefile +39 -1
- data/lib/oneview-sdk.rb +38 -3
- data/lib/oneview-sdk/cli.rb +85 -30
- data/lib/oneview-sdk/client.rb +21 -18
- data/lib/oneview-sdk/config_loader.rb +1 -1
- data/lib/oneview-sdk/resource.rb +44 -36
- data/lib/oneview-sdk/resource/api200.rb +34 -0
- data/lib/oneview-sdk/resource/api200/connection_template.rb +52 -0
- data/lib/oneview-sdk/resource/api200/datacenter.rb +81 -0
- data/lib/oneview-sdk/resource/api200/enclosure.rb +203 -0
- data/lib/oneview-sdk/resource/api200/enclosure_group.rb +86 -0
- data/lib/oneview-sdk/resource/api200/ethernet_network.rb +60 -0
- data/lib/oneview-sdk/resource/api200/fabric.rb +45 -0
- data/lib/oneview-sdk/resource/api200/fc_network.rb +34 -0
- data/lib/oneview-sdk/resource/api200/fcoe_network.rb +32 -0
- data/lib/oneview-sdk/resource/api200/firmware_bundle.rb +56 -0
- data/lib/oneview-sdk/resource/{fcoe_network.rb → api200/firmware_driver.rb} +21 -12
- data/lib/oneview-sdk/resource/api200/interconnect.rb +112 -0
- data/lib/oneview-sdk/resource/api200/lig_uplink_set.rb +84 -0
- data/lib/oneview-sdk/resource/api200/logical_downlink.rb +57 -0
- data/lib/oneview-sdk/resource/api200/logical_enclosure.rb +88 -0
- data/lib/oneview-sdk/resource/api200/logical_interconnect.rb +251 -0
- data/lib/oneview-sdk/resource/api200/logical_interconnect_group.rb +116 -0
- data/lib/oneview-sdk/resource/api200/logical_switch.rb +188 -0
- data/lib/oneview-sdk/resource/api200/logical_switch_group.rb +70 -0
- data/lib/oneview-sdk/resource/api200/managed_san.rb +83 -0
- data/lib/oneview-sdk/resource/api200/network_set.rb +68 -0
- data/lib/oneview-sdk/resource/api200/power_device.rb +178 -0
- data/lib/oneview-sdk/resource/api200/rack.rb +88 -0
- data/lib/oneview-sdk/resource/api200/resource.rb +18 -0
- data/lib/oneview-sdk/resource/api200/san_manager.rb +92 -0
- data/lib/oneview-sdk/resource/api200/server_hardware.rb +244 -0
- data/lib/oneview-sdk/resource/api200/server_hardware_type.rb +61 -0
- data/lib/oneview-sdk/resource/api200/server_profile.rb +385 -0
- data/lib/oneview-sdk/resource/api200/server_profile_template.rb +217 -0
- data/lib/oneview-sdk/resource/api200/storage_pool.rb +92 -0
- data/lib/oneview-sdk/resource/api200/storage_system.rb +157 -0
- data/lib/oneview-sdk/resource/api200/switch.rb +91 -0
- data/lib/oneview-sdk/resource/api200/unmanaged_device.rb +59 -0
- data/lib/oneview-sdk/resource/api200/uplink_set.rb +83 -0
- data/lib/oneview-sdk/resource/api200/volume.rb +192 -0
- data/lib/oneview-sdk/resource/api200/volume_attachment.rb +83 -0
- data/lib/oneview-sdk/resource/api200/volume_snapshot.rb +50 -0
- data/lib/oneview-sdk/resource/api200/volume_template.rb +99 -0
- data/lib/oneview-sdk/resource/api300.rb +66 -0
- data/lib/oneview-sdk/resource/api300/c7000.rb +27 -0
- data/lib/oneview-sdk/resource/api300/c7000/connection_template.rb +30 -0
- data/lib/oneview-sdk/resource/api300/c7000/datacenter.rb +22 -0
- data/lib/oneview-sdk/resource/api300/c7000/enclosure.rb +48 -0
- data/lib/oneview-sdk/resource/api300/c7000/enclosure_group.rb +37 -0
- data/lib/oneview-sdk/resource/api300/c7000/ethernet_network.rb +35 -0
- data/lib/oneview-sdk/resource/api300/c7000/fabric.rb +22 -0
- data/lib/oneview-sdk/resource/api300/c7000/fc_network.rb +37 -0
- data/lib/oneview-sdk/resource/api300/c7000/fcoe_network.rb +35 -0
- data/lib/oneview-sdk/resource/api300/c7000/firmware_bundle.rb +21 -0
- data/lib/oneview-sdk/resource/api300/c7000/firmware_driver.rb +22 -0
- data/lib/oneview-sdk/resource/api300/c7000/interconnect.rb +21 -0
- data/lib/oneview-sdk/resource/api300/c7000/lig_uplink_set.rb +21 -0
- data/lib/oneview-sdk/resource/api300/c7000/logical_downlink.rb +34 -0
- data/lib/oneview-sdk/resource/api300/c7000/logical_enclosure.rb +35 -0
- data/lib/oneview-sdk/resource/api300/c7000/logical_interconnect.rb +21 -0
- data/lib/oneview-sdk/resource/api300/c7000/logical_interconnect_group.rb +33 -0
- data/lib/oneview-sdk/resource/api300/c7000/logical_switch.rb +51 -0
- data/lib/oneview-sdk/resource/api300/c7000/logical_switch_group.rb +33 -0
- data/lib/oneview-sdk/resource/api300/c7000/managed_san.rb +36 -0
- data/lib/oneview-sdk/resource/api300/c7000/network_set.rb +37 -0
- data/lib/oneview-sdk/resource/api300/c7000/power_device.rb +21 -0
- data/lib/oneview-sdk/resource/api300/c7000/rack.rb +22 -0
- data/lib/oneview-sdk/resource/api300/c7000/resource.rb +21 -0
- data/lib/oneview-sdk/resource/api300/c7000/san_manager.rb +22 -0
- data/lib/oneview-sdk/resource/api300/c7000/server_hardware.rb +93 -0
- data/lib/oneview-sdk/resource/api300/c7000/server_hardware_type.rb +21 -0
- data/lib/oneview-sdk/resource/api300/c7000/server_profile.rb +33 -0
- data/lib/oneview-sdk/resource/api300/c7000/server_profile_template.rb +50 -0
- data/lib/oneview-sdk/resource/api300/c7000/storage_pool.rb +29 -0
- data/lib/oneview-sdk/resource/api300/c7000/storage_system.rb +21 -0
- data/lib/oneview-sdk/resource/api300/c7000/switch.rb +31 -0
- data/lib/oneview-sdk/resource/api300/c7000/unmanaged_device.rb +21 -0
- data/lib/oneview-sdk/resource/api300/c7000/uplink_set.rb +21 -0
- data/lib/oneview-sdk/resource/api300/c7000/volume.rb +22 -0
- data/lib/oneview-sdk/resource/api300/c7000/volume_attachment.rb +21 -0
- data/lib/oneview-sdk/resource/api300/c7000/volume_snapshot.rb +21 -0
- data/lib/oneview-sdk/resource/api300/c7000/volume_template.rb +32 -0
- data/lib/oneview-sdk/resource/api300/synergy.rb +27 -0
- data/lib/oneview-sdk/resource/api300/synergy/connection_template.rb +30 -0
- data/lib/oneview-sdk/resource/api300/synergy/datacenter.rb +22 -0
- data/lib/oneview-sdk/resource/api300/synergy/drive_enclosure.rb +71 -0
- data/lib/oneview-sdk/resource/api300/synergy/enclosure.rb +110 -0
- data/lib/oneview-sdk/resource/api300/synergy/enclosure_group.rb +43 -0
- data/lib/oneview-sdk/resource/api300/synergy/ethernet_network.rb +35 -0
- data/lib/oneview-sdk/resource/api300/synergy/fabric.rb +46 -0
- data/lib/oneview-sdk/resource/api300/synergy/fc_network.rb +37 -0
- data/lib/oneview-sdk/resource/api300/synergy/fcoe_network.rb +35 -0
- data/lib/oneview-sdk/resource/api300/synergy/firmware_bundle.rb +21 -0
- data/lib/oneview-sdk/resource/api300/synergy/firmware_driver.rb +22 -0
- data/lib/oneview-sdk/resource/api300/synergy/interconnect.rb +43 -0
- data/lib/oneview-sdk/resource/api300/synergy/lig_uplink_set.rb +21 -0
- data/lib/oneview-sdk/resource/api300/synergy/logical_downlink.rb +34 -0
- data/lib/oneview-sdk/resource/api300/synergy/logical_enclosure.rb +59 -0
- data/lib/oneview-sdk/resource/api300/synergy/logical_interconnect.rb +21 -0
- data/lib/oneview-sdk/resource/api300/synergy/logical_interconnect_group.rb +119 -0
- data/lib/oneview-sdk/resource/api300/synergy/logical_switch.rb +33 -0
- data/lib/oneview-sdk/resource/api300/synergy/logical_switch_group.rb +45 -0
- data/lib/oneview-sdk/resource/{firmware_driver.rb → api300/synergy/managed_san.rb} +7 -17
- data/lib/oneview-sdk/resource/api300/synergy/network_set.rb +37 -0
- data/lib/oneview-sdk/resource/api300/synergy/power_device.rb +21 -0
- data/lib/oneview-sdk/resource/api300/synergy/rack.rb +22 -0
- data/lib/oneview-sdk/resource/api300/synergy/resource.rb +21 -0
- data/lib/oneview-sdk/resource/api300/synergy/san_manager.rb +22 -0
- data/lib/oneview-sdk/resource/api300/synergy/sas_interconnect.rb +87 -0
- data/lib/oneview-sdk/resource/api300/synergy/sas_logical_interconnect.rb +110 -0
- data/lib/oneview-sdk/resource/api300/synergy/sas_logical_interconnect_group.rb +87 -0
- data/lib/oneview-sdk/resource/api300/synergy/server_hardware.rb +30 -0
- data/lib/oneview-sdk/resource/api300/synergy/server_hardware_type.rb +21 -0
- data/lib/oneview-sdk/resource/api300/synergy/server_profile.rb +78 -0
- data/lib/oneview-sdk/resource/api300/synergy/server_profile_template.rb +34 -0
- data/lib/oneview-sdk/resource/api300/synergy/storage_pool.rb +22 -0
- data/lib/oneview-sdk/resource/api300/synergy/storage_system.rb +21 -0
- data/lib/oneview-sdk/resource/api300/synergy/switch.rb +37 -0
- data/lib/oneview-sdk/resource/api300/synergy/unmanaged_device.rb +21 -0
- data/lib/oneview-sdk/resource/api300/synergy/uplink_set.rb +21 -0
- data/lib/oneview-sdk/resource/api300/synergy/volume.rb +22 -0
- data/lib/oneview-sdk/resource/api300/synergy/volume_attachment.rb +21 -0
- data/lib/oneview-sdk/resource/api300/synergy/volume_snapshot.rb +21 -0
- data/lib/oneview-sdk/resource/api300/synergy/volume_template.rb +32 -0
- data/lib/oneview-sdk/rest.rb +7 -10
- data/lib/oneview-sdk/ssl_helper.rb +3 -3
- data/lib/oneview-sdk/version.rb +1 -1
- data/oneview-sdk.gemspec +5 -5
- metadata +126 -47
- data/.gitattributes +0 -2
- data/.gitignore +0 -29
- data/.rubocop.yml +0 -80
- data/.travis.yml +0 -12
- data/lib/oneview-sdk/resource/connection_template.rb +0 -48
- data/lib/oneview-sdk/resource/datacenter.rb +0 -77
- data/lib/oneview-sdk/resource/enclosure.rb +0 -191
- data/lib/oneview-sdk/resource/enclosure_group.rb +0 -82
- data/lib/oneview-sdk/resource/ethernet_network.rb +0 -56
- data/lib/oneview-sdk/resource/fabric.rb +0 -41
- data/lib/oneview-sdk/resource/fc_network.rb +0 -30
- data/lib/oneview-sdk/resource/firmware_bundle.rb +0 -50
- data/lib/oneview-sdk/resource/interconnect.rb +0 -107
- data/lib/oneview-sdk/resource/lig_uplink_set.rb +0 -80
- data/lib/oneview-sdk/resource/logical_downlink.rb +0 -53
- data/lib/oneview-sdk/resource/logical_enclosure.rb +0 -86
- data/lib/oneview-sdk/resource/logical_interconnect.rb +0 -247
- data/lib/oneview-sdk/resource/logical_interconnect_group.rb +0 -112
- data/lib/oneview-sdk/resource/logical_switch.rb +0 -184
- data/lib/oneview-sdk/resource/logical_switch_group.rb +0 -66
- data/lib/oneview-sdk/resource/managed_san.rb +0 -79
- data/lib/oneview-sdk/resource/network_set.rb +0 -64
- data/lib/oneview-sdk/resource/power_device.rb +0 -174
- data/lib/oneview-sdk/resource/rack.rb +0 -83
- data/lib/oneview-sdk/resource/san_manager.rb +0 -88
- data/lib/oneview-sdk/resource/server_hardware.rb +0 -209
- data/lib/oneview-sdk/resource/server_hardware_type.rb +0 -58
- data/lib/oneview-sdk/resource/server_profile.rb +0 -380
- data/lib/oneview-sdk/resource/server_profile_template.rb +0 -213
- data/lib/oneview-sdk/resource/storage_pool.rb +0 -63
- data/lib/oneview-sdk/resource/storage_system.rb +0 -113
- data/lib/oneview-sdk/resource/switch.rb +0 -86
- data/lib/oneview-sdk/resource/unmanaged_device.rb +0 -55
- data/lib/oneview-sdk/resource/uplink_set.rb +0 -79
- data/lib/oneview-sdk/resource/volume.rb +0 -188
- data/lib/oneview-sdk/resource/volume_attachment.rb +0 -79
- data/lib/oneview-sdk/resource/volume_snapshot.rb +0 -46
- data/lib/oneview-sdk/resource/volume_template.rb +0 -95
@@ -0,0 +1,244 @@
|
|
1
|
+
# (C) Copyright 2016 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 specific
|
10
|
+
# language governing permissions and limitations under the License.
|
11
|
+
|
12
|
+
require_relative 'resource'
|
13
|
+
|
14
|
+
module OneviewSDK
|
15
|
+
module API200
|
16
|
+
# Server hardware resource implementation
|
17
|
+
class ServerHardware < Resource
|
18
|
+
BASE_URI = '/rest/server-hardware'.freeze
|
19
|
+
UNIQUE_IDENTIFIERS = %w(name uri serialNumber virtualSerialNumber serverProfileUri).freeze
|
20
|
+
|
21
|
+
# Remove resource from OneView
|
22
|
+
# @return [true] if resource was removed successfully
|
23
|
+
alias remove delete
|
24
|
+
|
25
|
+
# Create a resource object, associate it with a client, and set its properties.
|
26
|
+
# @param [OneviewSDK::Client] client The client object for the OneView appliance
|
27
|
+
# @param [Hash] params The options for this resource (key-value pairs)
|
28
|
+
# @param [Integer] api_ver The api version to use when interracting with this resource.
|
29
|
+
def initialize(client, params = {}, api_ver = nil)
|
30
|
+
super
|
31
|
+
# Default values
|
32
|
+
@data['type'] ||= 'server-hardware-4'
|
33
|
+
end
|
34
|
+
|
35
|
+
# Retrieve resource details based on this resource's name or URI.
|
36
|
+
# @note one of the UNIQUE_IDENTIFIERS must be specified in the resource
|
37
|
+
# @return [Boolean] Whether or not retrieve was successful
|
38
|
+
def retrieve!
|
39
|
+
hostname = @data['hostname'] || @data['mpHostInfo']['mpHostName'] rescue nil
|
40
|
+
if hostname
|
41
|
+
results = self.class.find_by(@client, 'mpHostInfo' => { 'mpHostName' => hostname })
|
42
|
+
if results.size == 1
|
43
|
+
set_all(results[0].data)
|
44
|
+
return true
|
45
|
+
end
|
46
|
+
end
|
47
|
+
super
|
48
|
+
rescue IncompleteResource => e
|
49
|
+
raise e unless hostname
|
50
|
+
false
|
51
|
+
end
|
52
|
+
|
53
|
+
# Check if a resource exists
|
54
|
+
# @note one of the UNIQUE_IDENTIFIERS must be specified in the resource
|
55
|
+
# @return [Boolean] Whether or not resource exists
|
56
|
+
def exists?
|
57
|
+
hostname = @data['hostname'] || @data['mpHostInfo']['mpHostName'] rescue nil
|
58
|
+
return true if hostname && self.class.find_by(@client, 'mpHostInfo' => { 'mpHostName' => hostname }).size == 1
|
59
|
+
super
|
60
|
+
rescue IncompleteResource => e
|
61
|
+
raise e unless hostname
|
62
|
+
false
|
63
|
+
end
|
64
|
+
|
65
|
+
# Method is not available
|
66
|
+
# @raise [OneviewSDK::MethodUnavailable] method is not available
|
67
|
+
def create
|
68
|
+
unavailable_method
|
69
|
+
end
|
70
|
+
|
71
|
+
# Method is not available
|
72
|
+
# @raise [OneviewSDK::MethodUnavailable] method is not available
|
73
|
+
def delete
|
74
|
+
unavailable_method
|
75
|
+
end
|
76
|
+
|
77
|
+
# Adds the resource on OneView using the current data
|
78
|
+
# @raise [OneviewSDK::IncompleteResource] if the client is not set or required attributes are missing
|
79
|
+
# @return [OneviewSDK::ServerHardware] self
|
80
|
+
def add
|
81
|
+
ensure_client
|
82
|
+
required_attributes = %w(hostname username password licensingIntent)
|
83
|
+
required_attributes.each { |k| raise IncompleteResource, "Missing required attribute: '#{k}'" unless @data.key?(k) }
|
84
|
+
|
85
|
+
optional_attrs = %w(configurationState force restore)
|
86
|
+
temp_data = @data.select { |k, _v| required_attributes.include?(k) || optional_attrs.include?(k) }
|
87
|
+
response = @client.rest_post(self.class::BASE_URI, { 'body' => temp_data }, @api_version)
|
88
|
+
body = @client.response_handler(response)
|
89
|
+
set_all(body)
|
90
|
+
%w(username password hostname).each { |k| @data.delete(k) } # These are no longer needed
|
91
|
+
self
|
92
|
+
end
|
93
|
+
|
94
|
+
# Method is not available
|
95
|
+
# @raise [OneviewSDK::MethodUnavailable] method is not available
|
96
|
+
def update(*)
|
97
|
+
unavailable_method
|
98
|
+
end
|
99
|
+
|
100
|
+
# Power on the server hardware
|
101
|
+
# @param [Boolean] force Use 'PressAndHold' action?
|
102
|
+
# @return [Boolean] Returns whether or not the server was powered on
|
103
|
+
def power_on(force = false)
|
104
|
+
set_power_state('on', force)
|
105
|
+
end
|
106
|
+
|
107
|
+
# Power off the server hardware
|
108
|
+
# @param [Boolean] force Use 'PressAndHold' action?
|
109
|
+
# @return [Boolean] Returns whether or not the server was powered off
|
110
|
+
def power_off(force = false)
|
111
|
+
set_power_state('off', force)
|
112
|
+
end
|
113
|
+
|
114
|
+
# Gets a list of BIOS/UEFI values on the physical server
|
115
|
+
# @return [Hash] List with BIOS/UEFI settings
|
116
|
+
def get_bios
|
117
|
+
response = @client.rest_get(@data['uri'] + '/bios')
|
118
|
+
@client.response_handler(response)
|
119
|
+
end
|
120
|
+
|
121
|
+
# Gets a url to the iLO web interface
|
122
|
+
# @return [Hash] url
|
123
|
+
def get_ilo_sso_url
|
124
|
+
response = @client.rest_get(@data['uri'] + '/iloSsoUrl')
|
125
|
+
@client.response_handler(response)
|
126
|
+
end
|
127
|
+
|
128
|
+
# Gets a Single Sign-On session for the Java Applet console
|
129
|
+
# @return [Hash] url
|
130
|
+
def get_java_remote_sso_url
|
131
|
+
response = @client.rest_get(@data['uri'] + '/javaRemoteConsoleUrl')
|
132
|
+
@client.response_handler(response)
|
133
|
+
end
|
134
|
+
|
135
|
+
# Gets a url to the iLO web interface
|
136
|
+
# @return [Hash] url
|
137
|
+
def get_remote_console_url
|
138
|
+
response = @client.rest_get(@data['uri'] + '/remoteConsoleUrl')
|
139
|
+
@client.response_handler(response)
|
140
|
+
end
|
141
|
+
|
142
|
+
# Refreshes the enclosure along with all of its components
|
143
|
+
# @param [String] state NotRefreshing, RefreshFailed, RefreshPending, Refreshing
|
144
|
+
# @param [Hash] options Optional force fields for refreshing the enclosure
|
145
|
+
def set_refresh_state(state, options = {})
|
146
|
+
ensure_client && ensure_uri
|
147
|
+
s = state.to_s rescue state
|
148
|
+
requestBody = {
|
149
|
+
'body' => {
|
150
|
+
refreshState: s
|
151
|
+
}
|
152
|
+
}
|
153
|
+
requestBody['body'].merge(options)
|
154
|
+
response = @client.rest_put(@data['uri'] + '/refreshState', requestBody, @api_version)
|
155
|
+
new_data = @client.response_handler(response)
|
156
|
+
set_all(new_data)
|
157
|
+
end
|
158
|
+
|
159
|
+
# Updates the iLO firmware on a physical server to a minimum iLO firmware required by OneView
|
160
|
+
def update_ilo_firmware
|
161
|
+
response = @client.rest_put(@data['uri'] + '/mpFirmwareVersion')
|
162
|
+
@client.response_handler(response)
|
163
|
+
end
|
164
|
+
|
165
|
+
# Gets the settings that describe the environmental configuration
|
166
|
+
def environmental_configuration
|
167
|
+
ensure_client && ensure_uri
|
168
|
+
response = @client.rest_get(@data['uri'] + '/environmentalConfiguration', @api_version)
|
169
|
+
@client.response_handler(response)
|
170
|
+
end
|
171
|
+
|
172
|
+
# Retrieves historical utilization
|
173
|
+
# @param [Hash] queryParameters query parameters (ie :startDate, :endDate, :fields, :view, etc.)
|
174
|
+
# @option queryParameters [Array] :fields
|
175
|
+
# @option queryParameters [Time, Date, String] :startDate
|
176
|
+
# @option queryParameters [Time, Date, String] :endDate
|
177
|
+
def utilization(queryParameters = {})
|
178
|
+
ensure_client && ensure_uri
|
179
|
+
uri = "#{@data['uri']}/utilization?"
|
180
|
+
|
181
|
+
queryParameters[:endDate] = convert_time(queryParameters[:endDate])
|
182
|
+
queryParameters[:startDate] = convert_time(queryParameters[:startDate])
|
183
|
+
|
184
|
+
queryParameters.each do |key, value|
|
185
|
+
next if value.nil?
|
186
|
+
uri += case key.to_sym
|
187
|
+
when :fields
|
188
|
+
"fields=#{value.join(',')}"
|
189
|
+
when :startDate, :endDate
|
190
|
+
"filter=#{key}=#{value}"
|
191
|
+
else
|
192
|
+
"#{key}=#{value}"
|
193
|
+
end
|
194
|
+
uri += '&'
|
195
|
+
end
|
196
|
+
uri.chop! # Get rid of trailing '&' or '?'
|
197
|
+
response = @client.rest_get(uri, @api_version)
|
198
|
+
@client.response_handler(response)
|
199
|
+
end
|
200
|
+
|
201
|
+
private
|
202
|
+
|
203
|
+
# Converts Date, Time, or String objects to iso8601 string
|
204
|
+
def convert_time(t)
|
205
|
+
case t
|
206
|
+
when nil then nil
|
207
|
+
when Date then t.to_time.utc.iso8601(3)
|
208
|
+
when Time then t.utc.iso8601(3)
|
209
|
+
when String then Time.parse(t).utc.iso8601(3)
|
210
|
+
else raise InvalidResource, "Invalid time format '#{t.class}'. Valid options are Time, Date, or String"
|
211
|
+
end
|
212
|
+
rescue StandardError => e
|
213
|
+
raise InvalidResource, "Failed to parse time value '#{t}'. #{e.message}"
|
214
|
+
end
|
215
|
+
|
216
|
+
# Set power state. Takes into consideration the current state and does the right thing
|
217
|
+
def set_power_state(state, force)
|
218
|
+
refresh
|
219
|
+
return true if @data['powerState'].downcase == state
|
220
|
+
@logger.debug "Powering #{state} server hardware '#{@data['name']}'. Current state: '#{@data['powerState']}'"
|
221
|
+
|
222
|
+
action = 'PressAndHold' if force
|
223
|
+
action ||= case @data['powerState'].downcase
|
224
|
+
when 'poweringon', 'poweringoff' # Wait
|
225
|
+
sleep 5
|
226
|
+
return set_power_state(state, force)
|
227
|
+
when 'resetting'
|
228
|
+
if state == 'on' # Wait
|
229
|
+
sleep 5
|
230
|
+
return set_power_state(state, force)
|
231
|
+
end
|
232
|
+
'PressAndHold'
|
233
|
+
when 'unknown' then state == 'on' ? 'ColdBoot' : 'PressAndHold'
|
234
|
+
else 'MomentaryPress'
|
235
|
+
end
|
236
|
+
options = { 'body' => { powerState: state.capitalize, powerControl: action } }
|
237
|
+
response = @client.rest_put("#{@data['uri']}/powerState", options)
|
238
|
+
body = @client.response_handler(response)
|
239
|
+
set_all(body)
|
240
|
+
true
|
241
|
+
end
|
242
|
+
end
|
243
|
+
end
|
244
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# (C) Copyright 2016 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 specific
|
10
|
+
# language governing permissions and limitations under the License.
|
11
|
+
|
12
|
+
require_relative 'resource'
|
13
|
+
|
14
|
+
module OneviewSDK
|
15
|
+
module API200
|
16
|
+
# Server hardware type resource implementation
|
17
|
+
class ServerHardwareType < Resource
|
18
|
+
BASE_URI = '/rest/server-hardware-types'.freeze
|
19
|
+
|
20
|
+
# Remove resource from OneView
|
21
|
+
# @return [true] if resource was removed successfully
|
22
|
+
alias remove delete
|
23
|
+
|
24
|
+
# Create a resource object, associate it with a client, and set its properties.
|
25
|
+
# @param [OneviewSDK::Client] client The client object for the OneView appliance
|
26
|
+
# @param [Hash] params The options for this resource (key-value pairs)
|
27
|
+
# @param [Integer] api_ver The api version to use when interracting with this resource.
|
28
|
+
def initialize(client, params = {}, api_ver = nil)
|
29
|
+
super
|
30
|
+
# Default values
|
31
|
+
@data['type'] ||= 'server-hardware-type-4'
|
32
|
+
end
|
33
|
+
|
34
|
+
# Method is not available
|
35
|
+
# @raise [OneviewSDK::MethodUnavailable] method is not available
|
36
|
+
def create
|
37
|
+
unavailable_method
|
38
|
+
end
|
39
|
+
|
40
|
+
# Method is not available
|
41
|
+
# @raise [OneviewSDK::MethodUnavailable] method is not available
|
42
|
+
def delete
|
43
|
+
unavailable_method
|
44
|
+
end
|
45
|
+
|
46
|
+
# Update resource attributes
|
47
|
+
# @param [Hash] attributes attributes to be updated
|
48
|
+
# @option attributes [String] :name server hardware type name
|
49
|
+
# @option attributes [String] :description server hardware type description
|
50
|
+
# @return [OneviewSDK::ServerHardwareType] self
|
51
|
+
def update(attributes = {})
|
52
|
+
set_all(attributes)
|
53
|
+
ensure_client && ensure_uri
|
54
|
+
data = @data.select { |k, _v| %w(name description).include?(k) }
|
55
|
+
response = @client.rest_put(@data['uri'], { 'body' => data }, @api_version)
|
56
|
+
@client.response_handler(response)
|
57
|
+
self
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,385 @@
|
|
1
|
+
# (C) Copyright 2016 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 specific
|
10
|
+
# language governing permissions and limitations under the License.
|
11
|
+
|
12
|
+
require_relative 'resource'
|
13
|
+
|
14
|
+
module OneviewSDK
|
15
|
+
module API200
|
16
|
+
# Server profile resource implementation
|
17
|
+
class ServerProfile < Resource
|
18
|
+
BASE_URI = '/rest/server-profiles'.freeze
|
19
|
+
UNIQUE_IDENTIFIERS = %w(name uri associatedServer serialNumber serverHardwareUri).freeze
|
20
|
+
|
21
|
+
def initialize(client, params = {}, api_ver = nil)
|
22
|
+
super
|
23
|
+
# Default values
|
24
|
+
@data['type'] ||= 'ServerProfileV5'
|
25
|
+
end
|
26
|
+
|
27
|
+
# Sets the Server Hardware for the resource
|
28
|
+
# @param [OneviewSDK::ServerHardware] server_hardware Server Hardware resource
|
29
|
+
def set_server_hardware(server_hardware)
|
30
|
+
self['serverHardwareUri'] = server_hardware['uri'] if server_hardware['uri'] || server_hardware.retrieve!
|
31
|
+
raise "Resource #{server_hardware['name']} could not be found!" unless server_hardware['uri']
|
32
|
+
end
|
33
|
+
|
34
|
+
# Sets the Server Hardware Type for the resource
|
35
|
+
# @param [OneviewSDK::ServerHardwareType] server_hardware_type Type of the desired Server Hardware
|
36
|
+
def set_server_hardware_type(server_hardware_type)
|
37
|
+
self['serverHardwareTypeUri'] = server_hardware_type['uri'] if server_hardware_type['uri'] || server_hardware_type.retrieve!
|
38
|
+
raise "Resource #{server_hardware_type['name']} could not be found!" unless server_hardware_type['uri']
|
39
|
+
end
|
40
|
+
|
41
|
+
# Sets the Enclosure Group for the resource
|
42
|
+
# @param [OneviewSDK::EnclosureGroup] enclosure_group Enclosure Group that the Server is a member
|
43
|
+
def set_enclosure_group(enclosure_group)
|
44
|
+
self['enclosureGroupUri'] = enclosure_group['uri'] if enclosure_group['uri'] || enclosure_group.retrieve!
|
45
|
+
raise "Resource #{enclosure_group['name']} could not be found!" unless enclosure_group['uri']
|
46
|
+
end
|
47
|
+
|
48
|
+
# Sets the Enclosure Group for the resource
|
49
|
+
# @param [OneviewSDK::Enclosure] enclosure Enclosure that the Server is a member
|
50
|
+
def set_enclosure(enclosure)
|
51
|
+
self['enclosureUri'] = enclosure['uri'] if enclosure['uri'] || enclosure.retrieve!
|
52
|
+
raise "Resource #{enclosure['name']} could not be found!" unless enclosure['uri']
|
53
|
+
end
|
54
|
+
|
55
|
+
# Gets the preview of manual and automatic updates required to make the server profile consistent with its template.
|
56
|
+
# @return [Hash] Hash containing the required information
|
57
|
+
def get_compliance_preview
|
58
|
+
ensure_client & ensure_uri
|
59
|
+
response = @client.rest_get("#{self['uri']}/compliance-preview")
|
60
|
+
@client.response_handler(response)
|
61
|
+
end
|
62
|
+
|
63
|
+
# Retrieves the error or status messages associated with the specified profile.
|
64
|
+
# @return [Hash] Hash containing the required information
|
65
|
+
def get_messages
|
66
|
+
ensure_client & ensure_uri
|
67
|
+
response = @client.rest_get("#{self['uri']}/messages")
|
68
|
+
@client.response_handler(response)
|
69
|
+
end
|
70
|
+
|
71
|
+
# Transforms an existing profile by supplying a new server hardware type and/or enclosure group.
|
72
|
+
# A profile will be returned with a new configuration based on the capabilities of the supplied
|
73
|
+
# server hardware type and/or enclosure group. All deployed connections will have their port assignment
|
74
|
+
# set to 'Auto'. Re-selection of the server hardware may also be required. The new profile can subsequently
|
75
|
+
# be used for the PUT https://{appl}/rest/server- profiles/{id} API but is not guaranteed to pass
|
76
|
+
# validation. Any incompatibilities will be flagged when the transformed server profile is submitted.
|
77
|
+
# @param [Hash<String,Object>] query Query parameters
|
78
|
+
# @option query [OneviewSDK::EnclosureGroup] 'enclosure_group' Enclosure Group associated with the resource
|
79
|
+
# @option query [OneviewSDK::ServerHardware] 'server_hardware' The server hardware associated with the resource
|
80
|
+
# @option query [OneviewSDK::ServerHardwareType] 'server_hardware_type' The server hardware type associated with the resource
|
81
|
+
# @return [Hash] Hash containing the required information
|
82
|
+
def get_transformation(query = nil)
|
83
|
+
ensure_client & ensure_uri
|
84
|
+
query_uri = OneviewSDK::Resource.build_query(query) if query
|
85
|
+
response = @client.rest_get("#{self['uri']}/transformation#{query_uri}")
|
86
|
+
@client.response_handler(response)
|
87
|
+
end
|
88
|
+
|
89
|
+
# Updates the server profile from the server profile template.
|
90
|
+
def update_from_template
|
91
|
+
ensure_client & ensure_uri
|
92
|
+
patch_operation = { 'op' => 'replace', 'path' => '/templateCompliance', 'value' => 'Compliant' }
|
93
|
+
patch_options = {
|
94
|
+
'If-Match' => self['eTag'],
|
95
|
+
'body' => [patch_operation]
|
96
|
+
}
|
97
|
+
response = @client.rest_patch(self['uri'], patch_options)
|
98
|
+
@client.response_handler(response)
|
99
|
+
end
|
100
|
+
|
101
|
+
# @!group Helpers
|
102
|
+
|
103
|
+
# Gets attached ServerHardware for the profile
|
104
|
+
# @return [OneviewSDK::ServerHardware] if hardware is attached
|
105
|
+
# @return [nil] if no hardware is attached
|
106
|
+
def get_server_hardware
|
107
|
+
return nil unless self['serverHardwareUri']
|
108
|
+
sh = OneviewSDK::ServerHardware.new(@client, uri: self['serverHardwareUri'])
|
109
|
+
sh.retrieve!
|
110
|
+
sh
|
111
|
+
end
|
112
|
+
|
113
|
+
# Gets all the available Ethernet and FC Networks, and Network Sets
|
114
|
+
# @return [Hash]
|
115
|
+
# A hash containing the lists of Ethernet Networks and FC Networks
|
116
|
+
def get_available_networks
|
117
|
+
query = { enclosure_group_uri: @data['enclosureGroupUri'], server_hardware_type_uri: @data['serverHardwareTypeUri'] }
|
118
|
+
self.class.get_available_networks(@client, query)
|
119
|
+
end
|
120
|
+
|
121
|
+
# Gets available server hardware
|
122
|
+
# @return [Array<OneviewSDK::ServerHardware>] Array of ServerHardware resources that matches this
|
123
|
+
# profile's server hardware type and enclosure group and who's state is 'NoProfileApplied'
|
124
|
+
def get_available_hardware
|
125
|
+
ensure_client
|
126
|
+
raise IncompleteResource, 'Must set @data[\'serverHardwareTypeUri\']' unless @data['serverHardwareTypeUri']
|
127
|
+
raise IncompleteResource, 'Must set @data[\'enclosureGroupUri\']' unless @data['enclosureGroupUri']
|
128
|
+
params = {
|
129
|
+
state: 'NoProfileApplied',
|
130
|
+
serverHardwareTypeUri: @data['serverHardwareTypeUri'],
|
131
|
+
serverGroupUri: @data['enclosureGroupUri']
|
132
|
+
}
|
133
|
+
OneviewSDK::ServerHardware.find_by(@client, params)
|
134
|
+
rescue StandardError => e
|
135
|
+
raise IncompleteResource, "Failed to get available hardware. Message: #{e.message}"
|
136
|
+
end
|
137
|
+
|
138
|
+
# Adds a connection entry to Server profile template
|
139
|
+
# @param [OneviewSDK::EthernetNetwork,OneviewSDK::FCNetwork] network Network associated with the connection
|
140
|
+
# @param [Hash<String,String>] connection_options Hash containing the configuration of the connection
|
141
|
+
# @option connection_options [Integer] 'allocatedMbps' The transmit throughput (mbps) currently allocated to
|
142
|
+
# this connection. When Fibre Channel connections are set to Auto for requested bandwidth, the value can be set to -2000
|
143
|
+
# to indicate that the actual value is unknown until OneView is able to negotiate the actual speed.
|
144
|
+
# @option connection_options [Integer] 'allocatedVFs' The number of virtual functions allocated to this connection. This value will be null.
|
145
|
+
# @option connection_options [Hash] 'boot' indicates that the server will attempt to boot from this connection.
|
146
|
+
# This object can only be specified if "boot.manageBoot" is set to 'true'
|
147
|
+
# @option connection_options [String] 'deploymentStatus' The deployment status of the connection.
|
148
|
+
# The value can be 'Undefined', 'Reserved', or 'Deployed'.
|
149
|
+
# @option connection_options [String] 'functionType' Type of function required for the connection.
|
150
|
+
# functionType cannot be modified after the connection is created.
|
151
|
+
# @option connection_options [String] 'mac' The MAC address that is currently programmed on the FlexNic.
|
152
|
+
# @option connection_options [String] 'macType' Specifies the type of MAC address to be programmed into the IO Devices.
|
153
|
+
# The value can be 'Virtual', 'Physical' or 'UserDefined'.
|
154
|
+
# @option connection_options [String] 'maximumMbps' Maximum transmit throughput (mbps) allowed on this connection.
|
155
|
+
# The value is limited by the maximum throughput of the network link and maximumBandwidth of the selected network (networkUri).
|
156
|
+
# For Fibre Channel connections, the value is limited to the same value as the allocatedMbps.
|
157
|
+
# @option connection_options [String] 'name' A string used to identify the respective connection.
|
158
|
+
# The connection name is case insensitive, limited to 63 characters and must be unique within the profile.
|
159
|
+
# @option connection_options [String] 'portId' Identifies the port (FlexNIC) used for this connection.
|
160
|
+
# @option connection_options [String] 'requestedMbps' The transmit throughput (mbps) that should be allocated to this connection.
|
161
|
+
# @option connection_options [String] 'requestedVFs' This value can be "Auto" or 0.
|
162
|
+
# @option connection_options [String] 'wwnn' The node WWN address that is currently programmed on the FlexNic.
|
163
|
+
# @option connection_options [String] 'wwpn' The port WWN address that is currently programmed on the FlexNic.
|
164
|
+
# @option connection_options [String] 'wwpnType' Specifies the type of WWN address to be porgrammed on the FlexNIC.
|
165
|
+
# The value can be 'Virtual', 'Physical' or 'UserDefined'.
|
166
|
+
def add_connection(network, connection_options = {})
|
167
|
+
self['connections'] = [] unless self['connections']
|
168
|
+
connection_options['id'] = 0 # Letting OneView treat the ID registering
|
169
|
+
connection_options['networkUri'] = network['uri'] if network['uri'] || network.retrieve!
|
170
|
+
self['connections'] << connection_options
|
171
|
+
end
|
172
|
+
|
173
|
+
# Removes a connection entry in Server profile template
|
174
|
+
# @param [String] connection_name Name of the connection
|
175
|
+
# @return Returns the connection hash if found, otherwise returns nil
|
176
|
+
def remove_connection(connection_name)
|
177
|
+
desired_connection = nil
|
178
|
+
return desired_connection unless self['connections']
|
179
|
+
self['connections'].each do |con|
|
180
|
+
desired_connection = self['connections'].delete(con) if con['name'] == connection_name
|
181
|
+
end
|
182
|
+
desired_connection
|
183
|
+
end
|
184
|
+
|
185
|
+
# Adds volume attachment entry with associated Volume in Server profile
|
186
|
+
# @param [OneviewSDK::Volume] volume Volume Resource to add an attachment
|
187
|
+
# @param [Hash] attachment_options Options of the new attachment
|
188
|
+
# @option attachment_options [Fixnum] 'id' The ID of the attached storage volume. Do not use it if you want it to be created automatically.
|
189
|
+
# @option attachment_options [String] 'lun' The logical unit number.
|
190
|
+
# @option attachment_options [String] 'lunType' The logical unit number type: Auto or Manual.
|
191
|
+
# @option attachment_options [Boolean] 'permanent' Required. If true, indicates that the volume will persist when the profile is deleted.
|
192
|
+
# If false, then the volume will be deleted when the profile is deleted.
|
193
|
+
# @option attachment_options [Array] 'storagePaths' A list of host-to-target path associations.
|
194
|
+
# @return Returns the connection hash if found, otherwise returns nil
|
195
|
+
def add_volume_attachment(volume, attachment_options = {})
|
196
|
+
self['sanStorage'] ||= {}
|
197
|
+
self['sanStorage']['volumeAttachments'] ||= []
|
198
|
+
attachment_options['id'] ||= 0
|
199
|
+
|
200
|
+
volume.retrieve! unless volume['uri'] || volume['storagePoolUri'] || volume['storageSystemUri']
|
201
|
+
attachment_options['volumeUri'] = volume['uri']
|
202
|
+
attachment_options['volumeStoragePoolUri'] = volume['storagePoolUri']
|
203
|
+
attachment_options['volumeStorageSystemUri'] = volume['storageSystemUri']
|
204
|
+
|
205
|
+
self['sanStorage']['volumeAttachments'] << attachment_options
|
206
|
+
end
|
207
|
+
|
208
|
+
# Adds volume attachment entry and creates a new Volume associated in the Server profile
|
209
|
+
# @param [OneviewSDK::Volume] volume Volume Resource to add an attachment
|
210
|
+
# @param [Hash] volume_options Options to create a new Volume.
|
211
|
+
# Please refer to OneviewSDK::Volume documentation for the data necessary to create a new Volume.
|
212
|
+
# @param [Hash] attachment_options Options of the new attachment
|
213
|
+
# @option attachment_options [Fixnum] 'id' The ID of the attached storage volume. Do not use it if you want it to be created automatically.
|
214
|
+
# @option attachment_options [String] 'lun' The logical unit number.
|
215
|
+
# @option attachment_options [String] 'lunType' The logical unit number type: Auto or Manual.
|
216
|
+
# @option attachment_options [Boolean] 'permanent' Required. If true, indicates that the volume will persist when the profile is deleted.
|
217
|
+
# If false, then the volume will be deleted when the profile is deleted.
|
218
|
+
# @option attachment_options [Array] 'storagePaths' A list of host-to-target path associations.
|
219
|
+
# @return Returns the connection hash if found, otherwise returns nil
|
220
|
+
def create_volume_with_attachment(storage_pool, volume_options, attachment_options = {})
|
221
|
+
self['sanStorage'] ||= {}
|
222
|
+
self['sanStorage']['volumeAttachments'] ||= []
|
223
|
+
attachment_options['id'] ||= 0
|
224
|
+
# Removing provisioningParameters and adding them to the top level hash
|
225
|
+
provision_param = volume_options.delete('provisioningParameters') || volume_options.delete(:provisioningParameters)
|
226
|
+
provision_param.each do |k, v|
|
227
|
+
volume_options[k] = v
|
228
|
+
end
|
229
|
+
# Each provisioningParameter has the prefix 'volume' attached to its name in the original options
|
230
|
+
# Also, it needs to respect the lower camel case
|
231
|
+
volume_options.each do |k, v|
|
232
|
+
attachment_options["volume#{k.to_s[0].capitalize}#{k.to_s[1, k.to_s.length - 1]}"] = v
|
233
|
+
end
|
234
|
+
|
235
|
+
attachment_options['volumeStoragePoolUri'] = storage_pool['uri'] if storage_pool['uri'] || storage_pool.retrieve!
|
236
|
+
|
237
|
+
# Since the volume is being created in this method, it needs to be nil
|
238
|
+
attachment_options['volumeUri'] = nil
|
239
|
+
attachment_options['volumeStorageSystemUri'] = nil
|
240
|
+
|
241
|
+
# volumeProvisionedCapacityBytes is not following the same pattern in Volume
|
242
|
+
attachment_options['volumeProvisionedCapacityBytes'] ||= attachment_options.delete('volumeRequestedCapacity')
|
243
|
+
|
244
|
+
# Defaults
|
245
|
+
attachment_options['permanent'] ||= true
|
246
|
+
attachment_options['lunType'] ||= 'Auto'
|
247
|
+
attachment_options['lun'] ||= nil
|
248
|
+
attachment_options['storagePaths'] ||= []
|
249
|
+
|
250
|
+
self['sanStorage']['volumeAttachments'] << attachment_options
|
251
|
+
end
|
252
|
+
|
253
|
+
# Removes a volume attachment entry in the Server profile
|
254
|
+
# @param [Fixnum] id ID number of the attachment entry
|
255
|
+
# @return Returns the volume hash if found, otherwise returns nil
|
256
|
+
def remove_volume_attachment(id)
|
257
|
+
self['sanStorage'] ||= {}
|
258
|
+
self['sanStorage']['volumeAttachments'] ||= []
|
259
|
+
return if self['sanStorage'].empty? || self['sanStorage']['volumeAttachments'].empty?
|
260
|
+
|
261
|
+
volume_attachment = nil
|
262
|
+
self['sanStorage']['volumeAttachments'].each do |entry|
|
263
|
+
volume_attachment = self['sanStorage']['volumeAttachments'].delete(entry) if entry['id'] == id
|
264
|
+
end
|
265
|
+
volume_attachment
|
266
|
+
end
|
267
|
+
|
268
|
+
# Sets the Firmware Driver for the server profile
|
269
|
+
# @param [OneviewSDK::FirmwareDriver] firmware Firmware Driver to be associated with the resource
|
270
|
+
# @param [Hash<String,Object>] firmware_options Firmware Driver options
|
271
|
+
# @option firmware_options [Boolean] 'manageFirmware' Indicates that the server firmware is configured using the server profile.
|
272
|
+
# Value can be 'true' or 'false'.
|
273
|
+
# @option firmware_options [Boolean] 'forceInstallFirmware' Force installation of firmware even if same or newer version is installed.
|
274
|
+
# Downgrading the firmware can result in the installation of unsupported firmware and cause server hardware to cease operation.
|
275
|
+
# Value can be 'true' or 'false'.
|
276
|
+
# @option firmware_options [String] 'firmwareInstallType' Specifies the way a Service Pack for ProLiant (SPP) is installed.
|
277
|
+
# This field is used if the 'manageFirmware' field is true.
|
278
|
+
# Values are 'FirmwareAndOSDrivers', 'FirmwareOnly', and 'FirmwareOnlyOfflineMode'.
|
279
|
+
def set_firmware_driver(firmware, firmware_options = {})
|
280
|
+
firmware_options['firmwareBaselineUri'] = firmware['uri'] if firmware['uri'] || firmware.retrieve!
|
281
|
+
self['firmware'] = firmware_options
|
282
|
+
end
|
283
|
+
|
284
|
+
# @!endgroup
|
285
|
+
|
286
|
+
# Gets all the available ethernet and fc networks, and network sets
|
287
|
+
# @param [OneviewSDK::Client] client The client object for the OneView appliance
|
288
|
+
# @param [Hash<String,Object>] query Query parameters
|
289
|
+
# @option query [OneviewSDK::EnclosureGroup] 'enclosure_group' Enclosure Group associated with the resource
|
290
|
+
# @option query [String] 'function_type' The FunctionType (Ethernet or FibreChannel) to filter the list of networks returned
|
291
|
+
# @option query [OneviewSDK::ServerHardware] 'server_hardware' The server hardware associated with the resource
|
292
|
+
# @option query [OneviewSDK::ServerHardwareType] 'server_hardware_type' The server hardware type associated with the resource
|
293
|
+
# @option query [String] 'view' Name of a predefined view to return a specific subset of the attributes of the resource or collection
|
294
|
+
# @return [Hash]
|
295
|
+
# A hash containing the lists of Ethernet and FC Networks, and Network Sets
|
296
|
+
# Options:
|
297
|
+
# * [String] 'ethernetNetworks' The list of Ethernet Networks
|
298
|
+
# * [String] 'fcNetworks' The list of FC Networks
|
299
|
+
# * [String] 'networkSets' The list of Networks Sets
|
300
|
+
def self.get_available_networks(client, query)
|
301
|
+
query_uri = build_query(query) if query
|
302
|
+
response = client.rest_get("#{BASE_URI}/available-networks#{query_uri}")
|
303
|
+
body = client.response_handler(response)
|
304
|
+
body.select { |k, _v| %w(ethernetNetworks networkSets fcNetworks).include?(k) }
|
305
|
+
end
|
306
|
+
|
307
|
+
# Gets the available servers based on the query parameters
|
308
|
+
# @param [OneviewSDK::Client] client The client object for the OneView appliance
|
309
|
+
# @param [Hash<String,Object>] query Query parameters
|
310
|
+
# @option query [OneviewSDK::EnclosureGroup] 'enclosure_group' Enclosure Group associated with the resource
|
311
|
+
# @option query [OneviewSDK::ServerProfile] 'server_profile' The server profile associated with the resource
|
312
|
+
# @option query [OneviewSDK::ServerHardwareType] 'server_hardware_type' The server hardware type associated with the resource
|
313
|
+
# @return [Hash] Hash containing all the available server information
|
314
|
+
def self.get_available_servers(client, query = nil)
|
315
|
+
if query
|
316
|
+
query_uri = build_query(query)
|
317
|
+
# profileUri attribute is not following the standards in OneView
|
318
|
+
query_uri.sub!('serverProfileUri', 'profileUri')
|
319
|
+
end
|
320
|
+
response = client.rest_get("#{BASE_URI}/available-servers#{query_uri}")
|
321
|
+
client.response_handler(response)
|
322
|
+
end
|
323
|
+
|
324
|
+
# Gets the available storage systems based on the query parameters
|
325
|
+
# @param [OneviewSDK::Client] client The client object for the OneView appliance
|
326
|
+
# @param [Hash<String,Object>] query Query parameters
|
327
|
+
# @option query [OneviewSDK::EnclosureGroup] 'enclosure_group' Enclosure Group associated with the resource
|
328
|
+
# @option query [OneviewSDK::ServerHardwareType] 'server_hardware_type' The server hardware type associated with the resource
|
329
|
+
# @option query [OneviewSDK::StorageSystem] 'storage_system' The Storage System the resources are associated with
|
330
|
+
def self.get_available_storage_system(client, query = nil)
|
331
|
+
# For storage_system the query requires the ID instead the URI
|
332
|
+
if query && query['storage_system']
|
333
|
+
query['storage_system'].retrieve! unless query['storage_system']['uri']
|
334
|
+
query['storage_system_id'] = query['storage_system']['uri'].split('/').last
|
335
|
+
query.delete('storage_system')
|
336
|
+
end
|
337
|
+
query_uri = build_query(query) if query
|
338
|
+
response = client.rest_get("#{BASE_URI}/available-storage-system#{query_uri}")
|
339
|
+
client.response_handler(response)
|
340
|
+
end
|
341
|
+
|
342
|
+
# Gets the available storage systems based on the query parameters
|
343
|
+
# @param [OneviewSDK::Client] client The client object for the OneView appliance
|
344
|
+
# @param [Hash<String,Object>] query Query parameters
|
345
|
+
# @option query [OneviewSDK::EnclosureGroup] 'enclosure_group' The enclosure group associated with the resource
|
346
|
+
# @option query [OneviewSDK::ServerHardwareType] 'server_hardware_type' The server hardware type associated with the resource
|
347
|
+
# @option query [Array<String>] 'filter' A general filter/query string to narrow the list of items returned.
|
348
|
+
# The default is no filter - all resources are returned.
|
349
|
+
# @option query [Integer] 'start' The first item to return, using 0-based indexing.
|
350
|
+
# If not specified, the default is 0 - start with the first available item.
|
351
|
+
# @option query [Integer] 'count' The sort order of the returned data set.
|
352
|
+
# By default, the sort order is based on create time, with the oldest entry first.
|
353
|
+
# @option query [String] 'sort' The number of resources to return. A count of -1 requests all the items.
|
354
|
+
def self.get_available_storage_systems(client, query = nil)
|
355
|
+
query_uri = build_query(query) if query
|
356
|
+
response = client.rest_get("#{BASE_URI}/available-storage-systems#{query_uri}")
|
357
|
+
client.response_handler(response)
|
358
|
+
end
|
359
|
+
|
360
|
+
# Get the available targets based on the query parameters
|
361
|
+
# @param [OneviewSDK::Client] client The client object for the OneView appliance
|
362
|
+
# @param [Hash<String,Object>] query Query parameters
|
363
|
+
# @option query [OneviewSDK::EnclosureGroup] 'enclosure_group' Enclosure Group associated with the resource
|
364
|
+
# @option query [OneviewSDK::ServerProfile] 'server_profile' The server profile associated with the resource
|
365
|
+
# @option query [OneviewSDK::ServerHardwareType] 'server_hardware_type' The server hardware type associated with the resource
|
366
|
+
def self.get_available_targets(client, query = nil)
|
367
|
+
query_uri = build_query(query) if query
|
368
|
+
response = client.rest_get("#{BASE_URI}/available-targets#{query_uri}")
|
369
|
+
client.response_handler(response)
|
370
|
+
end
|
371
|
+
|
372
|
+
# Gets all the available ethernet and fc networks
|
373
|
+
# @param [OneviewSDK::Client] client The client object for the OneView appliance
|
374
|
+
# @param [Hash<String,Object>] query Query parameters
|
375
|
+
# @option query [OneviewSDK::EnclosureGroup] 'enclosure_group' Enclosure Group associated with the resource
|
376
|
+
# @option query [OneviewSDK::ServerHardware] 'server_hardware' The server hardware associated with the resource
|
377
|
+
# @option query [OneviewSDK::ServerHardwareType] 'server_hardware_type' The server hardware type associated with the resource
|
378
|
+
def self.get_profile_ports(client, query = nil)
|
379
|
+
query_uri = build_query(query) if query
|
380
|
+
response = client.rest_get("#{BASE_URI}/profile-ports#{query_uri}")
|
381
|
+
client.response_handler(response)
|
382
|
+
end
|
383
|
+
end
|
384
|
+
end
|
385
|
+
end
|