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,68 @@
|
|
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
|
+
# Network set resource implementation
|
17
|
+
class NetworkSet < Resource
|
18
|
+
BASE_URI = '/rest/network-sets'.freeze
|
19
|
+
|
20
|
+
# Create a resource object, associate it with a client, and set its properties.
|
21
|
+
# @param [OneviewSDK::Client] client The client object for the OneView appliance
|
22
|
+
# @param [Hash] params The options for this resource (key-value pairs)
|
23
|
+
# @param [Integer] api_ver The api version to use when interracting with this resource.
|
24
|
+
def initialize(client, params = {}, api_ver = nil)
|
25
|
+
super
|
26
|
+
# Default values:
|
27
|
+
@data['connectionTemplateUri'] ||= nil
|
28
|
+
@data['nativeNetworkUri'] ||= nil
|
29
|
+
@data['networkUris'] ||= []
|
30
|
+
@data['type'] ||= 'network-set'
|
31
|
+
end
|
32
|
+
|
33
|
+
# Sets the native network for the network set
|
34
|
+
# @param [OneviewSDK::EthernetNetwork] ethernet_network Ethernet Network
|
35
|
+
def set_native_network(ethernet_network)
|
36
|
+
@data['nativeNetworkUri'] = ethernet_network['uri']
|
37
|
+
@data['networkUris'] << ethernet_network['uri'] unless @data['networkUris'].include?(ethernet_network['uri'])
|
38
|
+
end
|
39
|
+
|
40
|
+
# Adds an ethernet network to the network set
|
41
|
+
# @param [OneviewSDK::EthernetNetwork] ethernet_network Ethernet Network
|
42
|
+
def add_ethernet_network(ethernet_network)
|
43
|
+
@data['networkUris'] << ethernet_network['uri'] unless @data['networkUris'].include?(ethernet_network['uri'])
|
44
|
+
end
|
45
|
+
|
46
|
+
# Removes an ethernet network from the network set
|
47
|
+
# @param [OneviewSDK::EthernetNetwork] ethernet_network Ethernet Network
|
48
|
+
def remove_ethernet_network(ethernet_network)
|
49
|
+
@data['networkUris'].delete(ethernet_network['uri']) if @data['networkUris'].include?(ethernet_network['uri'])
|
50
|
+
end
|
51
|
+
|
52
|
+
# Lists network sets excluding ethernet networks
|
53
|
+
# @param [OneviewSDK::Client] client The client object for the OneView appliance
|
54
|
+
# @return [Array] List of network sets
|
55
|
+
def self.get_without_ethernet(client)
|
56
|
+
response = client.rest_get(BASE_URI + '/withoutEthernet')
|
57
|
+
client.response_handler(response)
|
58
|
+
end
|
59
|
+
|
60
|
+
# Lists network set excluding ethernet networks
|
61
|
+
# @return [OneviewSDK::NetworkSet] Network set
|
62
|
+
def get_without_ethernet
|
63
|
+
response = @client.rest_get(@data['uri'] + '/withoutEthernet')
|
64
|
+
@client.response_handler(response)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,178 @@
|
|
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
|
+
# Power device resource implementation
|
17
|
+
class PowerDevice < Resource
|
18
|
+
BASE_URI = '/rest/power-devices'.freeze
|
19
|
+
|
20
|
+
# Add the resource on OneView using the current data
|
21
|
+
# @note Calls the refresh method to set additional data
|
22
|
+
# @raise [OneviewSDK::IncompleteResource] if the client is not set
|
23
|
+
# @raise [StandardError] if the resource creation fails
|
24
|
+
# @return [OneviewSDK::PowerDevice] self
|
25
|
+
alias add create
|
26
|
+
|
27
|
+
# Remove resource from OneView
|
28
|
+
# @return [true] if resource was removed successfully
|
29
|
+
alias remove delete
|
30
|
+
|
31
|
+
# Create a resource object, associate it with a client, and set its properties.
|
32
|
+
# @param [OneviewSDK::Client] client The client object for the OneView appliance
|
33
|
+
# @param [Hash] params The options for this resource (key-value pairs)
|
34
|
+
# @param [Integer] api_ver The api version to use when interracting with this resource.
|
35
|
+
def initialize(client, params = {}, api_ver = nil)
|
36
|
+
super
|
37
|
+
# Default values
|
38
|
+
@data['deviceType'] ||= 'BranchCircuit'
|
39
|
+
@data['phaseType'] ||= 'Unknown'
|
40
|
+
@data['powerConnections'] ||= []
|
41
|
+
end
|
42
|
+
|
43
|
+
# Method is not available
|
44
|
+
# @raise [OneviewSDK::MethodUnavailable] method is not available
|
45
|
+
def create
|
46
|
+
unavailable_method
|
47
|
+
end
|
48
|
+
|
49
|
+
# Method is not available
|
50
|
+
# @raise [OneviewSDK::MethodUnavailable] method is not available
|
51
|
+
def delete
|
52
|
+
unavailable_method
|
53
|
+
end
|
54
|
+
|
55
|
+
# Adds an iPDU and bring all components under management by discovery of its management modules
|
56
|
+
# @param [OneviewSDK::Client] client The client object for the OneView appliance
|
57
|
+
# @param [Hash] options options for the iPDU
|
58
|
+
# @return [OneviewSDK::PowerDevice] The iPDU power device created in OneView
|
59
|
+
def self.discover(client, options)
|
60
|
+
options['force'] ||= options[:force] || false
|
61
|
+
response = client.rest_post(BASE_URI + '/discover', 'body' => options)
|
62
|
+
power_device_info = client.response_handler(response)
|
63
|
+
new(client, power_device_info)
|
64
|
+
end
|
65
|
+
|
66
|
+
# Retrieves the list of power devices given an iPDU hostname
|
67
|
+
# @param [OneviewSDK::Client] client The client object for the OneView appliance
|
68
|
+
# @param [String] hostname The iPDU hostname
|
69
|
+
# @return [Array] array of OneviewSDK::PowerDevice
|
70
|
+
def self.get_ipdu_devices(client, hostname)
|
71
|
+
find_by(client, managedBy: { hostName: hostname })
|
72
|
+
end
|
73
|
+
|
74
|
+
# Gets the power state of a power device
|
75
|
+
# @return [String] Power state
|
76
|
+
def get_power_state
|
77
|
+
response = @client.rest_get(@data['uri'] + '/powerState')
|
78
|
+
response.body
|
79
|
+
end
|
80
|
+
|
81
|
+
# Adds a power connection
|
82
|
+
# @param [OneviewSDK::Resource] resource
|
83
|
+
# @param [Integer] connection connection number
|
84
|
+
def add_connection(resource, connection)
|
85
|
+
@data['powerConnections'] << {
|
86
|
+
'connectionUri' => resource['uri'],
|
87
|
+
'deviceConnection' => connection,
|
88
|
+
'sourceConnection' => connection
|
89
|
+
}
|
90
|
+
end
|
91
|
+
|
92
|
+
# Removes the power connection
|
93
|
+
# @param [OneviewSDK::Resource] resource
|
94
|
+
# @param [Integer] connection connection number
|
95
|
+
def remove_connection(resource, connection)
|
96
|
+
@data['powerConnections'].reject! do |conn|
|
97
|
+
conn['connectionUri'] == resource['uri'] && conn['deviceConnection'] == connection
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
# Sets the power state of the power delivery device
|
102
|
+
# @param [String] state On|Off
|
103
|
+
def set_power_state(state)
|
104
|
+
response = @client.rest_put(@data['uri'] + '/powerState', 'body' => { powerState: state })
|
105
|
+
@client.response_handler(response)
|
106
|
+
end
|
107
|
+
|
108
|
+
# Refreshes a power delivery device
|
109
|
+
# @param [Hash] options
|
110
|
+
# @option options [String] :refreshState
|
111
|
+
# @option options [String] :username
|
112
|
+
# @option options [String] :password
|
113
|
+
def set_refresh_state(options)
|
114
|
+
response = @client.rest_put(@data['uri'] + '/refreshState', 'body' => options)
|
115
|
+
@client.response_handler(response)
|
116
|
+
end
|
117
|
+
|
118
|
+
# Retrieves the unit identification state of the specified power outlet
|
119
|
+
# @return [String] Uid state
|
120
|
+
def get_uid_state
|
121
|
+
response = @client.rest_get(@data['uri'] + '/uidState')
|
122
|
+
response.body
|
123
|
+
end
|
124
|
+
|
125
|
+
# Sets the unit identification light state of the power delivery device
|
126
|
+
# @param [String] state On|Off
|
127
|
+
def set_uid_state(state)
|
128
|
+
response = @client.rest_put(@data['uri'] + '/uidState', 'body' => { uidState: state })
|
129
|
+
@client.response_handler(response)
|
130
|
+
end
|
131
|
+
|
132
|
+
# Retrieves historical utilization
|
133
|
+
# @param [Hash] queryParameters query parameters (ie :startDate, :endDate, :fields, :view, etc.)
|
134
|
+
# @option queryParameters [Array] :fields
|
135
|
+
# @option queryParameters [Time, Date, String] :startDate
|
136
|
+
# @option queryParameters [Time, Date, String] :endDate
|
137
|
+
# @return [Hash] Utilization data
|
138
|
+
def utilization(queryParameters = {})
|
139
|
+
ensure_client && ensure_uri
|
140
|
+
uri = "#{@data['uri']}/utilization?"
|
141
|
+
|
142
|
+
queryParameters[:endDate] = convert_time(queryParameters[:endDate])
|
143
|
+
queryParameters[:startDate] = convert_time(queryParameters[:startDate])
|
144
|
+
|
145
|
+
queryParameters.each do |key, value|
|
146
|
+
next if value.nil?
|
147
|
+
uri += case key.to_sym
|
148
|
+
when :fields
|
149
|
+
"fields=#{value.join(',')}"
|
150
|
+
when :startDate, :endDate
|
151
|
+
"filter=#{key}=#{value}"
|
152
|
+
else
|
153
|
+
"#{key}=#{value}"
|
154
|
+
end
|
155
|
+
uri += '&'
|
156
|
+
end
|
157
|
+
uri.chop! # Get rid of trailing '&' or '?'
|
158
|
+
response = @client.rest_get(uri, @api_version)
|
159
|
+
@client.response_handler(response)
|
160
|
+
end
|
161
|
+
|
162
|
+
private
|
163
|
+
|
164
|
+
# Converts Date, Time, or String objects to iso8601 string
|
165
|
+
def convert_time(t)
|
166
|
+
case t
|
167
|
+
when nil then nil
|
168
|
+
when Date then t.to_time.utc.iso8601(3)
|
169
|
+
when Time then t.utc.iso8601(3)
|
170
|
+
when String then Time.parse(t).utc.iso8601(3)
|
171
|
+
else raise "Invalid time format '#{t.class}'. Valid options are Time, Date, or String"
|
172
|
+
end
|
173
|
+
rescue StandardError => e
|
174
|
+
raise "Failed to parse time value '#{t}'. #{e.message}"
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
@@ -0,0 +1,88 @@
|
|
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
|
10
|
+
# specific language governing permissions and limitations under the License.
|
11
|
+
|
12
|
+
require_relative 'resource'
|
13
|
+
|
14
|
+
module OneviewSDK
|
15
|
+
module API200
|
16
|
+
# Rack resource implementation
|
17
|
+
class Rack < Resource
|
18
|
+
BASE_URI = '/rest/racks'.freeze
|
19
|
+
UNIQUE_IDENTIFIERS = %w(name uri serialNumber).freeze
|
20
|
+
|
21
|
+
# Add the resource on OneView using the current data
|
22
|
+
# @note Calls the refresh method to set additional data
|
23
|
+
# @raise [OneviewSDK::IncompleteResource] if the client is not set
|
24
|
+
# @raise [StandardError] if the resource creation fails
|
25
|
+
# @return [OneviewSDK::Rack] self
|
26
|
+
alias add create
|
27
|
+
|
28
|
+
# Remove resource from OneView
|
29
|
+
# @return [true] if resource was removed successfully
|
30
|
+
alias remove delete
|
31
|
+
|
32
|
+
# Create a resource object, associate it with a client, and set its properties.
|
33
|
+
# @param [OneviewSDK::Client] client The client object for the OneView appliance
|
34
|
+
# @param [Hash] params The options for this resource (key-value pairs)
|
35
|
+
# @param [Integer] api_ver The api version to use when interracting with this resource.
|
36
|
+
def initialize(client, params = {}, api_ver = nil)
|
37
|
+
super
|
38
|
+
# Default values:
|
39
|
+
@data['rackMounts'] ||= []
|
40
|
+
end
|
41
|
+
|
42
|
+
# Method is not available
|
43
|
+
# @raise [OneviewSDK::MethodUnavailable] method is not available
|
44
|
+
def create
|
45
|
+
unavailable_method
|
46
|
+
end
|
47
|
+
|
48
|
+
# Method is not available
|
49
|
+
# @raise [OneviewSDK::MethodUnavailable] method is not available
|
50
|
+
def delete
|
51
|
+
unavailable_method
|
52
|
+
end
|
53
|
+
|
54
|
+
# Adds the rack resource with specified options
|
55
|
+
# @param [OneviewSDK::Resource] resource Resource to be added
|
56
|
+
# @param [String] options rack options
|
57
|
+
def add_rack_resource(resource, options = {})
|
58
|
+
rack_resource_options = {}
|
59
|
+
# Write values to hash and transform any symbol to string
|
60
|
+
options.each { |key, val| rack_resource_options[key.to_s] = val }
|
61
|
+
|
62
|
+
# Verify if the rack resource exists in the rack, if not init add it
|
63
|
+
rack_resource = @data['rackMounts'].find { |resource_from_rack| resource_from_rack['mountUri'] == resource['uri'] }
|
64
|
+
if rack_resource
|
65
|
+
rack_resource_options.each { |key, val| rack_resource[key] = val }
|
66
|
+
else
|
67
|
+
# Set default values if not given
|
68
|
+
rack_resource_options['mountUri'] = resource['uri']
|
69
|
+
rack_resource_options['location'] = 'CenterFront' unless rack_resource_options['location']
|
70
|
+
@data['rackMounts'] << rack_resource_options
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
# Remove resources from the rack
|
75
|
+
# @param [OneviewSDK::Resource] resource Resource to be removed from rack
|
76
|
+
def remove_rack_resource(resource)
|
77
|
+
@data['rackMounts'].reject! { |rack_resource| rack_resource['mountUri'] == resource['uri'] }
|
78
|
+
end
|
79
|
+
|
80
|
+
# Gets topology information for the rack
|
81
|
+
# @return [Hash] Environmental analysis
|
82
|
+
def get_device_topology
|
83
|
+
response = @client.rest_get(@data['uri'] + '/deviceTopology')
|
84
|
+
@client.response_handler(response)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,18 @@
|
|
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
|
+
module OneviewSDK
|
13
|
+
module API200
|
14
|
+
# Base Resource implementation for API200 resources
|
15
|
+
class Resource < OneviewSDK::Resource
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,92 @@
|
|
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
|
+
# SAN manager resource implementation
|
17
|
+
class SANManager < Resource
|
18
|
+
BASE_URI = '/rest/fc-sans/device-managers'.freeze
|
19
|
+
PROVIDERS_URI = '/rest/fc-sans/providers'.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'] = 'FCDeviceManagerV2'
|
33
|
+
end
|
34
|
+
|
35
|
+
# Adds the resource on OneView using the current data
|
36
|
+
# @return [OneviewSDK::SANManager] self
|
37
|
+
def add
|
38
|
+
ensure_client
|
39
|
+
raise 'providerDisplayName' unless @data['providerDisplayName']
|
40
|
+
@data['providerUri'] = get_provider_uri
|
41
|
+
response = @client.rest_post(@data['providerUri'] + '/device-managers', { 'body' => @data }, @api_version)
|
42
|
+
body = @client.response_handler(response)
|
43
|
+
set_all(body)
|
44
|
+
self
|
45
|
+
end
|
46
|
+
|
47
|
+
# Method is not available
|
48
|
+
# @raise [OneviewSDK::MethodUnavailable] method is not available
|
49
|
+
def create
|
50
|
+
unavailable_method
|
51
|
+
end
|
52
|
+
|
53
|
+
# Method is not available
|
54
|
+
# @raise [OneviewSDK::MethodUnavailable] method is not available
|
55
|
+
def delete
|
56
|
+
unavailable_method
|
57
|
+
end
|
58
|
+
|
59
|
+
# Refreshes the san manager state or change connection information
|
60
|
+
# @param [Hash] options
|
61
|
+
def update(options)
|
62
|
+
ensure_client && ensure_uri
|
63
|
+
response = @client.rest_put(@data['uri'], 'body' => options)
|
64
|
+
new_data = @client.response_handler(response)
|
65
|
+
set_all(new_data)
|
66
|
+
end
|
67
|
+
|
68
|
+
# Retrieves the default connection information for a specific provider
|
69
|
+
# @param [OneviewSDK::Client] client The client object for the OneView appliance
|
70
|
+
# @param [String] provider_name Providers name
|
71
|
+
# @return [Hash] A hash with default connectionInfo information
|
72
|
+
def self.get_default_connection_info(client, provider_name)
|
73
|
+
response = client.rest_get(PROVIDERS_URI)
|
74
|
+
providers = client.response_handler(response)['members']
|
75
|
+
desired_provider = providers.find { |provider| provider['displayName'] == provider_name || provider['name'] == provider_name }
|
76
|
+
desired_provider['defaultConnectionInfo']
|
77
|
+
end
|
78
|
+
|
79
|
+
private
|
80
|
+
|
81
|
+
# Gets the provider uri
|
82
|
+
# @return [String] provider uri
|
83
|
+
def get_provider_uri
|
84
|
+
return @data['providerUri'] if @data['providerUri']
|
85
|
+
response = @client.rest_get(PROVIDERS_URI)
|
86
|
+
providers = @client.response_handler(response)['members']
|
87
|
+
desired_provider = providers.find { |provider| provider['displayName'] == @data['providerDisplayName'] }
|
88
|
+
desired_provider['uri']
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|