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.
Files changed (171) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +50 -0
  3. data/README.md +61 -15
  4. data/Rakefile +39 -1
  5. data/lib/oneview-sdk.rb +38 -3
  6. data/lib/oneview-sdk/cli.rb +85 -30
  7. data/lib/oneview-sdk/client.rb +21 -18
  8. data/lib/oneview-sdk/config_loader.rb +1 -1
  9. data/lib/oneview-sdk/resource.rb +44 -36
  10. data/lib/oneview-sdk/resource/api200.rb +34 -0
  11. data/lib/oneview-sdk/resource/api200/connection_template.rb +52 -0
  12. data/lib/oneview-sdk/resource/api200/datacenter.rb +81 -0
  13. data/lib/oneview-sdk/resource/api200/enclosure.rb +203 -0
  14. data/lib/oneview-sdk/resource/api200/enclosure_group.rb +86 -0
  15. data/lib/oneview-sdk/resource/api200/ethernet_network.rb +60 -0
  16. data/lib/oneview-sdk/resource/api200/fabric.rb +45 -0
  17. data/lib/oneview-sdk/resource/api200/fc_network.rb +34 -0
  18. data/lib/oneview-sdk/resource/api200/fcoe_network.rb +32 -0
  19. data/lib/oneview-sdk/resource/api200/firmware_bundle.rb +56 -0
  20. data/lib/oneview-sdk/resource/{fcoe_network.rb → api200/firmware_driver.rb} +21 -12
  21. data/lib/oneview-sdk/resource/api200/interconnect.rb +112 -0
  22. data/lib/oneview-sdk/resource/api200/lig_uplink_set.rb +84 -0
  23. data/lib/oneview-sdk/resource/api200/logical_downlink.rb +57 -0
  24. data/lib/oneview-sdk/resource/api200/logical_enclosure.rb +88 -0
  25. data/lib/oneview-sdk/resource/api200/logical_interconnect.rb +251 -0
  26. data/lib/oneview-sdk/resource/api200/logical_interconnect_group.rb +116 -0
  27. data/lib/oneview-sdk/resource/api200/logical_switch.rb +188 -0
  28. data/lib/oneview-sdk/resource/api200/logical_switch_group.rb +70 -0
  29. data/lib/oneview-sdk/resource/api200/managed_san.rb +83 -0
  30. data/lib/oneview-sdk/resource/api200/network_set.rb +68 -0
  31. data/lib/oneview-sdk/resource/api200/power_device.rb +178 -0
  32. data/lib/oneview-sdk/resource/api200/rack.rb +88 -0
  33. data/lib/oneview-sdk/resource/api200/resource.rb +18 -0
  34. data/lib/oneview-sdk/resource/api200/san_manager.rb +92 -0
  35. data/lib/oneview-sdk/resource/api200/server_hardware.rb +244 -0
  36. data/lib/oneview-sdk/resource/api200/server_hardware_type.rb +61 -0
  37. data/lib/oneview-sdk/resource/api200/server_profile.rb +385 -0
  38. data/lib/oneview-sdk/resource/api200/server_profile_template.rb +217 -0
  39. data/lib/oneview-sdk/resource/api200/storage_pool.rb +92 -0
  40. data/lib/oneview-sdk/resource/api200/storage_system.rb +157 -0
  41. data/lib/oneview-sdk/resource/api200/switch.rb +91 -0
  42. data/lib/oneview-sdk/resource/api200/unmanaged_device.rb +59 -0
  43. data/lib/oneview-sdk/resource/api200/uplink_set.rb +83 -0
  44. data/lib/oneview-sdk/resource/api200/volume.rb +192 -0
  45. data/lib/oneview-sdk/resource/api200/volume_attachment.rb +83 -0
  46. data/lib/oneview-sdk/resource/api200/volume_snapshot.rb +50 -0
  47. data/lib/oneview-sdk/resource/api200/volume_template.rb +99 -0
  48. data/lib/oneview-sdk/resource/api300.rb +66 -0
  49. data/lib/oneview-sdk/resource/api300/c7000.rb +27 -0
  50. data/lib/oneview-sdk/resource/api300/c7000/connection_template.rb +30 -0
  51. data/lib/oneview-sdk/resource/api300/c7000/datacenter.rb +22 -0
  52. data/lib/oneview-sdk/resource/api300/c7000/enclosure.rb +48 -0
  53. data/lib/oneview-sdk/resource/api300/c7000/enclosure_group.rb +37 -0
  54. data/lib/oneview-sdk/resource/api300/c7000/ethernet_network.rb +35 -0
  55. data/lib/oneview-sdk/resource/api300/c7000/fabric.rb +22 -0
  56. data/lib/oneview-sdk/resource/api300/c7000/fc_network.rb +37 -0
  57. data/lib/oneview-sdk/resource/api300/c7000/fcoe_network.rb +35 -0
  58. data/lib/oneview-sdk/resource/api300/c7000/firmware_bundle.rb +21 -0
  59. data/lib/oneview-sdk/resource/api300/c7000/firmware_driver.rb +22 -0
  60. data/lib/oneview-sdk/resource/api300/c7000/interconnect.rb +21 -0
  61. data/lib/oneview-sdk/resource/api300/c7000/lig_uplink_set.rb +21 -0
  62. data/lib/oneview-sdk/resource/api300/c7000/logical_downlink.rb +34 -0
  63. data/lib/oneview-sdk/resource/api300/c7000/logical_enclosure.rb +35 -0
  64. data/lib/oneview-sdk/resource/api300/c7000/logical_interconnect.rb +21 -0
  65. data/lib/oneview-sdk/resource/api300/c7000/logical_interconnect_group.rb +33 -0
  66. data/lib/oneview-sdk/resource/api300/c7000/logical_switch.rb +51 -0
  67. data/lib/oneview-sdk/resource/api300/c7000/logical_switch_group.rb +33 -0
  68. data/lib/oneview-sdk/resource/api300/c7000/managed_san.rb +36 -0
  69. data/lib/oneview-sdk/resource/api300/c7000/network_set.rb +37 -0
  70. data/lib/oneview-sdk/resource/api300/c7000/power_device.rb +21 -0
  71. data/lib/oneview-sdk/resource/api300/c7000/rack.rb +22 -0
  72. data/lib/oneview-sdk/resource/api300/c7000/resource.rb +21 -0
  73. data/lib/oneview-sdk/resource/api300/c7000/san_manager.rb +22 -0
  74. data/lib/oneview-sdk/resource/api300/c7000/server_hardware.rb +93 -0
  75. data/lib/oneview-sdk/resource/api300/c7000/server_hardware_type.rb +21 -0
  76. data/lib/oneview-sdk/resource/api300/c7000/server_profile.rb +33 -0
  77. data/lib/oneview-sdk/resource/api300/c7000/server_profile_template.rb +50 -0
  78. data/lib/oneview-sdk/resource/api300/c7000/storage_pool.rb +29 -0
  79. data/lib/oneview-sdk/resource/api300/c7000/storage_system.rb +21 -0
  80. data/lib/oneview-sdk/resource/api300/c7000/switch.rb +31 -0
  81. data/lib/oneview-sdk/resource/api300/c7000/unmanaged_device.rb +21 -0
  82. data/lib/oneview-sdk/resource/api300/c7000/uplink_set.rb +21 -0
  83. data/lib/oneview-sdk/resource/api300/c7000/volume.rb +22 -0
  84. data/lib/oneview-sdk/resource/api300/c7000/volume_attachment.rb +21 -0
  85. data/lib/oneview-sdk/resource/api300/c7000/volume_snapshot.rb +21 -0
  86. data/lib/oneview-sdk/resource/api300/c7000/volume_template.rb +32 -0
  87. data/lib/oneview-sdk/resource/api300/synergy.rb +27 -0
  88. data/lib/oneview-sdk/resource/api300/synergy/connection_template.rb +30 -0
  89. data/lib/oneview-sdk/resource/api300/synergy/datacenter.rb +22 -0
  90. data/lib/oneview-sdk/resource/api300/synergy/drive_enclosure.rb +71 -0
  91. data/lib/oneview-sdk/resource/api300/synergy/enclosure.rb +110 -0
  92. data/lib/oneview-sdk/resource/api300/synergy/enclosure_group.rb +43 -0
  93. data/lib/oneview-sdk/resource/api300/synergy/ethernet_network.rb +35 -0
  94. data/lib/oneview-sdk/resource/api300/synergy/fabric.rb +46 -0
  95. data/lib/oneview-sdk/resource/api300/synergy/fc_network.rb +37 -0
  96. data/lib/oneview-sdk/resource/api300/synergy/fcoe_network.rb +35 -0
  97. data/lib/oneview-sdk/resource/api300/synergy/firmware_bundle.rb +21 -0
  98. data/lib/oneview-sdk/resource/api300/synergy/firmware_driver.rb +22 -0
  99. data/lib/oneview-sdk/resource/api300/synergy/interconnect.rb +43 -0
  100. data/lib/oneview-sdk/resource/api300/synergy/lig_uplink_set.rb +21 -0
  101. data/lib/oneview-sdk/resource/api300/synergy/logical_downlink.rb +34 -0
  102. data/lib/oneview-sdk/resource/api300/synergy/logical_enclosure.rb +59 -0
  103. data/lib/oneview-sdk/resource/api300/synergy/logical_interconnect.rb +21 -0
  104. data/lib/oneview-sdk/resource/api300/synergy/logical_interconnect_group.rb +119 -0
  105. data/lib/oneview-sdk/resource/api300/synergy/logical_switch.rb +33 -0
  106. data/lib/oneview-sdk/resource/api300/synergy/logical_switch_group.rb +45 -0
  107. data/lib/oneview-sdk/resource/{firmware_driver.rb → api300/synergy/managed_san.rb} +7 -17
  108. data/lib/oneview-sdk/resource/api300/synergy/network_set.rb +37 -0
  109. data/lib/oneview-sdk/resource/api300/synergy/power_device.rb +21 -0
  110. data/lib/oneview-sdk/resource/api300/synergy/rack.rb +22 -0
  111. data/lib/oneview-sdk/resource/api300/synergy/resource.rb +21 -0
  112. data/lib/oneview-sdk/resource/api300/synergy/san_manager.rb +22 -0
  113. data/lib/oneview-sdk/resource/api300/synergy/sas_interconnect.rb +87 -0
  114. data/lib/oneview-sdk/resource/api300/synergy/sas_logical_interconnect.rb +110 -0
  115. data/lib/oneview-sdk/resource/api300/synergy/sas_logical_interconnect_group.rb +87 -0
  116. data/lib/oneview-sdk/resource/api300/synergy/server_hardware.rb +30 -0
  117. data/lib/oneview-sdk/resource/api300/synergy/server_hardware_type.rb +21 -0
  118. data/lib/oneview-sdk/resource/api300/synergy/server_profile.rb +78 -0
  119. data/lib/oneview-sdk/resource/api300/synergy/server_profile_template.rb +34 -0
  120. data/lib/oneview-sdk/resource/api300/synergy/storage_pool.rb +22 -0
  121. data/lib/oneview-sdk/resource/api300/synergy/storage_system.rb +21 -0
  122. data/lib/oneview-sdk/resource/api300/synergy/switch.rb +37 -0
  123. data/lib/oneview-sdk/resource/api300/synergy/unmanaged_device.rb +21 -0
  124. data/lib/oneview-sdk/resource/api300/synergy/uplink_set.rb +21 -0
  125. data/lib/oneview-sdk/resource/api300/synergy/volume.rb +22 -0
  126. data/lib/oneview-sdk/resource/api300/synergy/volume_attachment.rb +21 -0
  127. data/lib/oneview-sdk/resource/api300/synergy/volume_snapshot.rb +21 -0
  128. data/lib/oneview-sdk/resource/api300/synergy/volume_template.rb +32 -0
  129. data/lib/oneview-sdk/rest.rb +7 -10
  130. data/lib/oneview-sdk/ssl_helper.rb +3 -3
  131. data/lib/oneview-sdk/version.rb +1 -1
  132. data/oneview-sdk.gemspec +5 -5
  133. metadata +126 -47
  134. data/.gitattributes +0 -2
  135. data/.gitignore +0 -29
  136. data/.rubocop.yml +0 -80
  137. data/.travis.yml +0 -12
  138. data/lib/oneview-sdk/resource/connection_template.rb +0 -48
  139. data/lib/oneview-sdk/resource/datacenter.rb +0 -77
  140. data/lib/oneview-sdk/resource/enclosure.rb +0 -191
  141. data/lib/oneview-sdk/resource/enclosure_group.rb +0 -82
  142. data/lib/oneview-sdk/resource/ethernet_network.rb +0 -56
  143. data/lib/oneview-sdk/resource/fabric.rb +0 -41
  144. data/lib/oneview-sdk/resource/fc_network.rb +0 -30
  145. data/lib/oneview-sdk/resource/firmware_bundle.rb +0 -50
  146. data/lib/oneview-sdk/resource/interconnect.rb +0 -107
  147. data/lib/oneview-sdk/resource/lig_uplink_set.rb +0 -80
  148. data/lib/oneview-sdk/resource/logical_downlink.rb +0 -53
  149. data/lib/oneview-sdk/resource/logical_enclosure.rb +0 -86
  150. data/lib/oneview-sdk/resource/logical_interconnect.rb +0 -247
  151. data/lib/oneview-sdk/resource/logical_interconnect_group.rb +0 -112
  152. data/lib/oneview-sdk/resource/logical_switch.rb +0 -184
  153. data/lib/oneview-sdk/resource/logical_switch_group.rb +0 -66
  154. data/lib/oneview-sdk/resource/managed_san.rb +0 -79
  155. data/lib/oneview-sdk/resource/network_set.rb +0 -64
  156. data/lib/oneview-sdk/resource/power_device.rb +0 -174
  157. data/lib/oneview-sdk/resource/rack.rb +0 -83
  158. data/lib/oneview-sdk/resource/san_manager.rb +0 -88
  159. data/lib/oneview-sdk/resource/server_hardware.rb +0 -209
  160. data/lib/oneview-sdk/resource/server_hardware_type.rb +0 -58
  161. data/lib/oneview-sdk/resource/server_profile.rb +0 -380
  162. data/lib/oneview-sdk/resource/server_profile_template.rb +0 -213
  163. data/lib/oneview-sdk/resource/storage_pool.rb +0 -63
  164. data/lib/oneview-sdk/resource/storage_system.rb +0 -113
  165. data/lib/oneview-sdk/resource/switch.rb +0 -86
  166. data/lib/oneview-sdk/resource/unmanaged_device.rb +0 -55
  167. data/lib/oneview-sdk/resource/uplink_set.rb +0 -79
  168. data/lib/oneview-sdk/resource/volume.rb +0 -188
  169. data/lib/oneview-sdk/resource/volume_attachment.rb +0 -79
  170. data/lib/oneview-sdk/resource/volume_snapshot.rb +0 -46
  171. data/lib/oneview-sdk/resource/volume_template.rb +0 -95
@@ -1,174 +0,0 @@
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
- # Power device resource implementation
14
- class PowerDevice < Resource
15
- BASE_URI = '/rest/power-devices'.freeze
16
-
17
- # Add the resource on OneView using the current data
18
- # @note Calls the refresh method to set additional data
19
- # @raise [OneviewSDK::IncompleteResource] if the client is not set
20
- # @raise [StandardError] if the resource creation fails
21
- # @return [OneviewSDK::PowerDevice] self
22
- alias add create
23
-
24
- # Remove resource from OneView
25
- # @return [true] if resource was removed successfully
26
- alias remove delete
27
-
28
- # Create a resource object, associate it with a client, and set its properties.
29
- # @param [OneviewSDK::Client] client The client object for the OneView appliance
30
- # @param [Hash] params The options for this resource (key-value pairs)
31
- # @param [Integer] api_ver The api version to use when interracting with this resource.
32
- def initialize(client, params = {}, api_ver = nil)
33
- super
34
- # Default values
35
- @data['deviceType'] ||= 'BranchCircuit'
36
- @data['phaseType'] ||= 'Unknown'
37
- @data['powerConnections'] ||= []
38
- end
39
-
40
- # Method is not available
41
- # @raise [OneviewSDK::MethodUnavailable] method is not available
42
- def create
43
- unavailable_method
44
- end
45
-
46
- # Method is not available
47
- # @raise [OneviewSDK::MethodUnavailable] method is not available
48
- def delete
49
- unavailable_method
50
- end
51
-
52
- # Adds an iPDU and bring all components under management by discovery of its management modules
53
- # @param [OneviewSDK::Client] client The client object for the OneView appliance
54
- # @param [Hash] options options for the iPDU
55
- # @return [OneviewSDK::PowerDevice] The iPDU power device created in OneView
56
- def self.discover(client, options)
57
- options['force'] ||= options[:force] || false
58
- response = client.rest_post(BASE_URI + '/discover', 'body' => options)
59
- power_device_info = client.response_handler(response)
60
- new(client, power_device_info)
61
- end
62
-
63
- # Retrieves the list of power devices given an iPDU hostname
64
- # @param [OneviewSDK::Client] client The client object for the OneView appliance
65
- # @param [String] hostname The iPDU hostname
66
- # @return [Array] array of OneviewSDK::PowerDevice
67
- def self.get_ipdu_devices(client, hostname)
68
- find_by(client, managedBy: { hostName: hostname })
69
- end
70
-
71
- # Gets the power state of a power device
72
- # @return [String] Power state
73
- def get_power_state
74
- response = @client.rest_get(@data['uri'] + '/powerState')
75
- response.body
76
- end
77
-
78
- # Adds a power connection
79
- # @param [OneviewSDK::Resource] resource
80
- # @param [Integer] connection connection number
81
- def add_connection(resource, connection)
82
- @data['powerConnections'] << {
83
- 'connectionUri' => resource['uri'],
84
- 'deviceConnection' => connection,
85
- 'sourceConnection' => connection
86
- }
87
- end
88
-
89
- # Removes the power connection
90
- # @param [OneviewSDK::Resource] resource
91
- # @param [Integer] connection connection number
92
- def remove_connection(resource, connection)
93
- @data['powerConnections'].reject! do |conn|
94
- conn['connectionUri'] == resource['uri'] && conn['deviceConnection'] == connection
95
- end
96
- end
97
-
98
- # Sets the power state of the power delivery device
99
- # @param [String] state On|Off
100
- def set_power_state(state)
101
- response = @client.rest_put(@data['uri'] + '/powerState', 'body' => { powerState: state })
102
- @client.response_handler(response)
103
- end
104
-
105
- # Refreshes a power delivery device
106
- # @param [Hash] options
107
- # @option options [String] :refreshState
108
- # @option options [String] :username
109
- # @option options [String] :password
110
- def set_refresh_state(options)
111
- response = @client.rest_put(@data['uri'] + '/refreshState', 'body' => options)
112
- @client.response_handler(response)
113
- end
114
-
115
- # Retrieves the unit identification state of the specified power outlet
116
- # @return [String] Uid state
117
- def get_uid_state
118
- response = @client.rest_get(@data['uri'] + '/uidState')
119
- response.body
120
- end
121
-
122
- # Sets the unit identification light state of the power delivery device
123
- # @param [String] state On|Off
124
- def set_uid_state(state)
125
- response = @client.rest_put(@data['uri'] + '/uidState', 'body' => { uidState: state })
126
- @client.response_handler(response)
127
- end
128
-
129
- # Retrieves historical utilization
130
- # @param [Hash] queryParameters query parameters (ie :startDate, :endDate, :fields, :view, etc.)
131
- # @option queryParameters [Array] :fields
132
- # @option queryParameters [Time, Date, String] :startDate
133
- # @option queryParameters [Time, Date, String] :endDate
134
- # @return [Hash] Utilization data
135
- def utilization(queryParameters = {})
136
- ensure_client && ensure_uri
137
- uri = "#{@data['uri']}/utilization?"
138
-
139
- queryParameters[:endDate] = convert_time(queryParameters[:endDate])
140
- queryParameters[:startDate] = convert_time(queryParameters[:startDate])
141
-
142
- queryParameters.each do |key, value|
143
- next if value.nil?
144
- uri += case key.to_sym
145
- when :fields
146
- "fields=#{value.join(',')}"
147
- when :startDate, :endDate
148
- "filter=#{key}=#{value}"
149
- else
150
- "#{key}=#{value}"
151
- end
152
- uri += '&'
153
- end
154
- uri.chop! # Get rid of trailing '&' or '?'
155
- response = @client.rest_get(uri, @api_version)
156
- @client.response_handler(response)
157
- end
158
-
159
- private
160
-
161
- # Converts Date, Time, or String objects to iso8601 string
162
- def convert_time(t)
163
- case t
164
- when nil then nil
165
- when Date then t.to_time.utc.iso8601(3)
166
- when Time then t.utc.iso8601(3)
167
- when String then Time.parse(t).utc.iso8601(3)
168
- else fail "Invalid time format '#{t.class}'. Valid options are Time, Date, or String"
169
- end
170
- rescue StandardError => e
171
- raise "Failed to parse time value '#{t}'. #{e.message}"
172
- end
173
- end
174
- end
@@ -1,83 +0,0 @@
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
- module OneviewSDK
13
- # Rack resource implementation
14
- class Rack < Resource
15
- BASE_URI = '/rest/racks'.freeze
16
-
17
- # Add the resource on OneView using the current data
18
- # @note Calls the refresh method to set additional data
19
- # @raise [OneviewSDK::IncompleteResource] if the client is not set
20
- # @raise [StandardError] if the resource creation fails
21
- # @return [OneviewSDK::Rack] self
22
- alias add create
23
-
24
- # Remove resource from OneView
25
- # @return [true] if resource was removed successfully
26
- alias remove delete
27
-
28
- # Create a resource object, associate it with a client, and set its properties.
29
- # @param [OneviewSDK::Client] client The client object for the OneView appliance
30
- # @param [Hash] params The options for this resource (key-value pairs)
31
- # @param [Integer] api_ver The api version to use when interracting with this resource.
32
- def initialize(client, params = {}, api_ver = nil)
33
- super
34
- # Default values:
35
- @data['rackMounts'] ||= []
36
- end
37
-
38
- # Method is not available
39
- # @raise [OneviewSDK::MethodUnavailable] method is not available
40
- def create
41
- unavailable_method
42
- end
43
-
44
- # Method is not available
45
- # @raise [OneviewSDK::MethodUnavailable] method is not available
46
- def delete
47
- unavailable_method
48
- end
49
-
50
- # Adds the rack resource with specified options
51
- # @param [OneviewSDK::Resource] resource Resource to be added
52
- # @param [String] options rack options
53
- def add_rack_resource(resource, options = {})
54
- rack_resource_options = {}
55
- # Write values to hash and transform any symbol to string
56
- options.each { |key, val| rack_resource_options[key.to_s] = val }
57
-
58
- # Verify if the rack resource exists in the rack, if not init add it
59
- rack_resource = @data['rackMounts'].find { |resource_from_rack| resource_from_rack['mountUri'] == resource['uri'] }
60
- if rack_resource
61
- rack_resource_options.each { |key, val| rack_resource[key] = val }
62
- else
63
- # Set default values if not given
64
- rack_resource_options['mountUri'] = resource['uri']
65
- rack_resource_options['location'] = 'CenterFront' unless rack_resource_options['location']
66
- @data['rackMounts'] << rack_resource_options
67
- end
68
- end
69
-
70
- # Remove resources from the rack
71
- # @param [OneviewSDK::Resource] resource Resource to be removed from rack
72
- def remove_rack_resource(resource)
73
- @data['rackMounts'].reject! { |rack_resource| rack_resource['mountUri'] == resource['uri'] }
74
- end
75
-
76
- # Gets topology information for the rack
77
- # @return [Hash] Environmental analysis
78
- def get_device_topology
79
- response = @client.rest_get(@data['uri'] + '/deviceTopology')
80
- @client.response_handler(response)
81
- end
82
- end
83
- end
@@ -1,88 +0,0 @@
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
- # SAN manager resource implementation
14
- class SANManager < Resource
15
- BASE_URI = '/rest/fc-sans/device-managers'.freeze
16
- PROVIDERS_URI = '/rest/fc-sans/providers'.freeze
17
-
18
- # Remove resource from OneView
19
- # @return [true] if resource was removed successfully
20
- alias remove delete
21
-
22
- # Create a resource object, associate it with a client, and set its properties.
23
- # @param [OneviewSDK::Client] client The client object for the OneView appliance
24
- # @param [Hash] params The options for this resource (key-value pairs)
25
- # @param [Integer] api_ver The api version to use when interracting with this resource.
26
- def initialize(client, params = {}, api_ver = nil)
27
- super
28
- # Default values:
29
- @data['type'] = 'FCDeviceManagerV2'
30
- end
31
-
32
- # Adds the resource on OneView using the current data
33
- # @return [OneviewSDK::SANManager] self
34
- def add
35
- ensure_client
36
- fail 'providerDisplayName' unless @data['providerDisplayName']
37
- @data['providerUri'] = get_provider_uri
38
- response = @client.rest_post(@data['providerUri'] + '/device-managers', { 'body' => @data }, @api_version)
39
- body = @client.response_handler(response)
40
- set_all(body)
41
- self
42
- end
43
-
44
- # Method is not available
45
- # @raise [OneviewSDK::MethodUnavailable] method is not available
46
- def create
47
- unavailable_method
48
- end
49
-
50
- # Method is not available
51
- # @raise [OneviewSDK::MethodUnavailable] method is not available
52
- def delete
53
- unavailable_method
54
- end
55
-
56
- # Refreshes the san manager state or change connection information
57
- # @param [Hash] options
58
- def update(options)
59
- ensure_client && ensure_uri
60
- response = @client.rest_put(@data['uri'], 'body' => options)
61
- new_data = @client.response_handler(response)
62
- set_all(new_data)
63
- end
64
-
65
- # Retrieves the default connection information for a specific provider
66
- # @param [OneviewSDK::Client] client The client object for the OneView appliance
67
- # @param [String] provider_name Providers name
68
- # @return [Hash] A hash with default connectionInfo information
69
- def self.get_default_connection_info(client, provider_name)
70
- response = client.rest_get(PROVIDERS_URI)
71
- providers = client.response_handler(response)['members']
72
- desired_provider = providers.find { |provider| provider['displayName'] == provider_name || provider['name'] == provider_name }
73
- desired_provider['defaultConnectionInfo']
74
- end
75
-
76
- private
77
-
78
- # Gets the provider uri
79
- # @return [String] provider uri
80
- def get_provider_uri
81
- return @data['providerUri'] if @data['providerUri']
82
- response = @client.rest_get(PROVIDERS_URI)
83
- providers = @client.response_handler(response)['members']
84
- desired_provider = providers.find { |provider| provider['displayName'] == @data['providerDisplayName'] }
85
- desired_provider['uri']
86
- end
87
- end
88
- end
@@ -1,209 +0,0 @@
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
- # Server hardware resource implementation
14
- class ServerHardware < Resource
15
- BASE_URI = '/rest/server-hardware'.freeze
16
-
17
- # Remove resource from OneView
18
- # @return [true] if resource was removed successfully
19
- alias remove delete
20
-
21
- # Create a resource object, associate it with a client, and set its properties.
22
- # @param [OneviewSDK::Client] client The client object for the OneView appliance
23
- # @param [Hash] params The options for this resource (key-value pairs)
24
- # @param [Integer] api_ver The api version to use when interracting with this resource.
25
- def initialize(client, params = {}, api_ver = nil)
26
- super
27
- # Default values
28
- @data['type'] ||= 'server-hardware-4'
29
- end
30
-
31
- # Method is not available
32
- # @raise [OneviewSDK::MethodUnavailable] method is not available
33
- def create
34
- unavailable_method
35
- end
36
-
37
- # Method is not available
38
- # @raise [OneviewSDK::MethodUnavailable] method is not available
39
- def delete
40
- unavailable_method
41
- end
42
-
43
- # Adds the resource on OneView using the current data
44
- # @raise [OneviewSDK::IncompleteResource] if the client is not set or required attributes are missing
45
- # @return [OneviewSDK::ServerHardware] self
46
- def add
47
- ensure_client
48
- required_attributes = %w(hostname username password licensingIntent)
49
- required_attributes.each { |k| fail IncompleteResource, "Missing required attribute: '#{k}'" unless @data.key?(k) }
50
-
51
- optional_attrs = %w(configurationState force restore)
52
- temp_data = @data.select { |k, _v| required_attributes.include?(k) || optional_attrs.include?(k) }
53
- response = @client.rest_post(self.class::BASE_URI, { 'body' => temp_data }, @api_version)
54
- body = @client.response_handler(response)
55
- set_all(body)
56
- %w(username password hostname).each { |k| @data.delete(k) } # These are no longer needed
57
- self
58
- end
59
-
60
- # Method is not available
61
- # @raise [OneviewSDK::MethodUnavailable] method is not available
62
- def update(*)
63
- unavailable_method
64
- end
65
-
66
- # Power on the server hardware
67
- # @param [Boolean] force Use 'PressAndHold' action?
68
- # @return [Boolean] Returns whether or not the server was powered on
69
- def power_on(force = false)
70
- set_power_state('on', force)
71
- end
72
-
73
- # Power off the server hardware
74
- # @param [Boolean] force Use 'PressAndHold' action?
75
- # @return [Boolean] Returns whether or not the server was powered off
76
- def power_off(force = false)
77
- set_power_state('off', force)
78
- end
79
-
80
- # Gets a list of BIOS/UEFI values on the physical server
81
- # @return [Hash] List with BIOS/UEFI settings
82
- def get_bios
83
- response = @client.rest_get(@data['uri'] + '/bios')
84
- @client.response_handler(response)
85
- end
86
-
87
- # Gets a url to the iLO web interface
88
- # @return [Hash] url
89
- def get_ilo_sso_url
90
- response = @client.rest_get(@data['uri'] + '/iloSsoUrl')
91
- @client.response_handler(response)
92
- end
93
-
94
- # Gets a Single Sign-On session for the Java Applet console
95
- # @return [Hash] url
96
- def get_java_remote_sso_url
97
- response = @client.rest_get(@data['uri'] + '/javaRemoteConsoleUrl')
98
- @client.response_handler(response)
99
- end
100
-
101
- # Gets a url to the iLO web interface
102
- # @return [Hash] url
103
- def get_remote_console_url
104
- response = @client.rest_get(@data['uri'] + '/remoteConsoleUrl')
105
- @client.response_handler(response)
106
- end
107
-
108
- # Refreshes the enclosure along with all of its components
109
- # @param [String] state NotRefreshing, RefreshFailed, RefreshPending, Refreshing
110
- # @param [Hash] options Optional force fields for refreshing the enclosure
111
- def set_refresh_state(state, options = {})
112
- ensure_client && ensure_uri
113
- s = state.to_s rescue state
114
- requestBody = {
115
- 'body' => {
116
- refreshState: s
117
- }
118
- }
119
- requestBody['body'].merge(options)
120
- response = @client.rest_put(@data['uri'] + '/refreshState', requestBody, @api_version)
121
- new_data = @client.response_handler(response)
122
- set_all(new_data)
123
- end
124
-
125
- # Updates the iLO firmware on a physical server to a minimum iLO firmware required by OneView
126
- def update_ilo_firmware
127
- response = @client.rest_put(@data['uri'] + '/mpFirmwareVersion')
128
- @client.response_handler(response)
129
- end
130
-
131
- # Gets the settings that describe the environmental configuration
132
- def environmental_configuration
133
- ensure_client && ensure_uri
134
- response = @client.rest_get(@data['uri'] + '/environmentalConfiguration', @api_version)
135
- @client.response_handler(response)
136
- end
137
-
138
- # Retrieves historical utilization
139
- # @param [Hash] queryParameters query parameters (ie :startDate, :endDate, :fields, :view, etc.)
140
- # @option queryParameters [Array] :fields
141
- # @option queryParameters [Time, Date, String] :startDate
142
- # @option queryParameters [Time, Date, String] :endDate
143
- def utilization(queryParameters = {})
144
- ensure_client && ensure_uri
145
- uri = "#{@data['uri']}/utilization?"
146
-
147
- queryParameters[:endDate] = convert_time(queryParameters[:endDate])
148
- queryParameters[:startDate] = convert_time(queryParameters[:startDate])
149
-
150
- queryParameters.each do |key, value|
151
- next if value.nil?
152
- uri += case key.to_sym
153
- when :fields
154
- "fields=#{value.join(',')}"
155
- when :startDate, :endDate
156
- "filter=#{key}=#{value}"
157
- else
158
- "#{key}=#{value}"
159
- end
160
- uri += '&'
161
- end
162
- uri.chop! # Get rid of trailing '&' or '?'
163
- response = @client.rest_get(uri, @api_version)
164
- @client.response_handler(response)
165
- end
166
-
167
- private
168
-
169
- # Converts Date, Time, or String objects to iso8601 string
170
- def convert_time(t)
171
- case t
172
- when nil then nil
173
- when Date then t.to_time.utc.iso8601(3)
174
- when Time then t.utc.iso8601(3)
175
- when String then Time.parse(t).utc.iso8601(3)
176
- else fail InvalidResource, "Invalid time format '#{t.class}'. Valid options are Time, Date, or String"
177
- end
178
- rescue StandardError => e
179
- raise InvalidResource, "Failed to parse time value '#{t}'. #{e.message}"
180
- end
181
-
182
- # Set power state. Takes into consideration the current state and does the right thing
183
- def set_power_state(state, force)
184
- refresh
185
- return true if @data['powerState'].downcase == state
186
- @logger.debug "Powering #{state} server hardware '#{@data['name']}'. Current state: '#{@data['powerState']}'"
187
-
188
- action = 'PressAndHold' if force
189
- action ||= case @data['powerState'].downcase
190
- when 'poweringon', 'poweringoff' # Wait
191
- sleep 5
192
- return set_power_state(state, force)
193
- when 'resetting'
194
- if state == 'on' # Wait
195
- sleep 5
196
- return set_power_state(state, force)
197
- end
198
- 'PressAndHold'
199
- when 'unknown' then state == 'on' ? 'ColdBoot' : 'PressAndHold'
200
- else 'MomentaryPress'
201
- end
202
- options = { 'body' => { powerState: state.capitalize, powerControl: action } }
203
- response = @client.rest_put("#{@data['uri']}/powerState", options)
204
- body = @client.response_handler(response)
205
- set_all(body)
206
- true
207
- end
208
- end
209
- end