oneview-sdk 2.2.1 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -0,0 +1,56 @@
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 'net/http/post/multipart'
13
+
14
+ module OneviewSDK
15
+ module API200
16
+ # Firmware bundle resource implementation
17
+ class FirmwareBundle
18
+ BASE_URI = '/rest/firmware-bundles'.freeze
19
+ READ_TIMEOUT = 300 # in seconds, 5 minutes
20
+
21
+ # Uploads a firmware bundle file
22
+ # @param [OneviewSDK::Client] client The client object for the OneView appliance
23
+ # @param [String] file_path
24
+ # @param [Integer] timeout The number of seconds to wait for completing the request
25
+ # @return [OneviewSDK::FirmwareDriver] if the upload was sucessful, return a FirmwareDriver object
26
+ def self.add(client, file_path, timeout = READ_TIMEOUT)
27
+ raise NotFound, "ERROR: File '#{file_path}' not found!" unless File.file?(file_path)
28
+ options = {}
29
+ options['Content-Type'] = 'multipart/form-data'
30
+ options['X-Api-Version'] = client.api_version.to_s
31
+ options['auth'] = client.token
32
+ options['uploadfilename'] = File.basename(file_path)
33
+ url = URI.parse(URI.escape("#{client.url}#{BASE_URI}"))
34
+
35
+ File.open(file_path) do |file|
36
+ req = Net::HTTP::Post::Multipart.new(
37
+ url.path,
38
+ { 'file' => UploadIO.new(file, 'application/octet-stream', File.basename(file_path)) },
39
+ options
40
+ )
41
+
42
+ http_request = Net::HTTP.new(url.host, url.port)
43
+ http_request.use_ssl = true
44
+ http_request.verify_mode = OpenSSL::SSL::VERIFY_NONE
45
+ http_request.read_timeout = timeout
46
+
47
+ http_request.start do |http|
48
+ response = http.request(req)
49
+ data = client.response_handler(response)
50
+ return OneviewSDK::FirmwareDriver.new(client, data)
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -9,20 +9,29 @@
9
9
  # CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
10
10
  # language governing permissions and limitations under the License.
11
11
 
12
+ require_relative 'resource'
13
+
12
14
  module OneviewSDK
13
- # FCoE network resource implementation
14
- class FCoENetwork < Resource
15
- BASE_URI = '/rest/fcoe-networks'.freeze
15
+ module API200
16
+ # Firmware driver resource implementation
17
+ class FirmwareDriver < Resource
18
+ BASE_URI = '/rest/firmware-drivers'.freeze
19
+
20
+ # Remove resource from OneView
21
+ # @return [true] if resource was removed successfully
22
+ alias remove delete
23
+
24
+ # Method is not available
25
+ # @raise [OneviewSDK::MethodUnavailable] method is not available
26
+ def delete
27
+ unavailable_method
28
+ end
16
29
 
17
- # Create a resource object, associate it with a client, and set its properties.
18
- # @param [OneviewSDK::Client] client The client object for the OneView appliance
19
- # @param [Hash] params The options for this resource (key-value pairs)
20
- # @param [Integer] api_ver The api version to use when interracting with this resource.
21
- def initialize(client, params = {}, api_ver = nil)
22
- super
23
- # Default values:
24
- @data['connectionTemplateUri'] ||= nil
25
- @data['type'] ||= 'fcoe-network'
30
+ # Method is not available
31
+ # @raise [OneviewSDK::MethodUnavailable] method is not available
32
+ def update
33
+ unavailable_method
34
+ end
26
35
  end
27
36
  end
28
37
  end
@@ -0,0 +1,112 @@
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
+ # Interconnect resource implementation
17
+ class Interconnect < Resource
18
+ BASE_URI = '/rest/interconnects'.freeze
19
+ TYPE_URI = '/rest/interconnect-types'.freeze
20
+ UNIQUE_IDENTIFIERS = %w(name uri serialNumber).freeze
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
+ end
29
+
30
+ # Method is not available
31
+ # @raise [OneviewSDK::MethodUnavailable] method is not available
32
+ def create
33
+ unavailable_method
34
+ end
35
+
36
+ # Method is not available
37
+ # @raise [OneviewSDK::MethodUnavailable] method is not available
38
+ def update
39
+ unavailable_method
40
+ end
41
+
42
+ # Method is not available
43
+ # @raise [OneviewSDK::MethodUnavailable] method is not available
44
+ def delete
45
+ unavailable_method
46
+ end
47
+
48
+ # Retrieves interconnect types
49
+ # @param [OneviewSDK::Client] client The client object for the OneView appliance
50
+ def self.get_types(client)
51
+ response = client.rest_get(TYPE_URI)
52
+ response = client.response_handler(response)
53
+ response['members']
54
+ end
55
+
56
+ # Retrieves the interconnect type with name
57
+ # @param [OneviewSDK::Client] client The client object for the OneView appliance
58
+ # @param [String] name Interconnect type name
59
+ # @return [Array] Interconnect type
60
+ def self.get_type(client, name)
61
+ results = get_types(client)
62
+ results.find { |interconnect_type| interconnect_type['name'] == name }
63
+ end
64
+
65
+ # Retrieves the named servers for this interconnect
66
+ def name_servers
67
+ response = @client.rest_get(@data['uri'] + '/nameServers')
68
+ response.body
69
+ end
70
+
71
+ # Updates an interconnect port
72
+ # @param [String] portName port name
73
+ # @param [Hash] attributes hash with attributes and values to be changed
74
+ def update_port(portName, attributes)
75
+ @data['ports'].each do |port|
76
+ next unless port['name'] == portName
77
+ attributes.each { |key, value| port[key.to_s] = value }
78
+ response = @client.rest_put(@data['uri'] + '/ports', 'body' => port)
79
+ @client.response_handler(response)
80
+ end
81
+ end
82
+
83
+ # Get statistics for an interconnect, for the specified port or subport
84
+ # @param [String] portName port to retrieve statistics
85
+ # @param [String] subportNumber subport to retrieve statistics
86
+ def statistics(portName = nil, subportNumber = nil)
87
+ uri = if subportNumber.nil?
88
+ "#{@data['uri']}/statistics/#{portName}"
89
+ else
90
+ "#{@data['uri']}/statistics/#{portName}/subport/#{subportNumber}"
91
+ end
92
+ response = @client.rest_get(uri)
93
+ response.body
94
+ end
95
+
96
+ # Triggers the reset port protection action
97
+ def reset_port_protection
98
+ response = @client.rest_put(@data['uri'] + '/resetportprotection')
99
+ @client.response_handler(response)
100
+ end
101
+
102
+ # Updates specific attributes for a given interconnect resource
103
+ # @param [String] operation operation to be performed
104
+ # @param [String] path path
105
+ # @param [String] value value
106
+ def patch(operation, path, value)
107
+ response = @client.rest_patch(@data['uri'], 'body' => [{ op: operation, path: path, value: value }])
108
+ @client.response_handler(response)
109
+ end
110
+ end
111
+ end
112
+ end
@@ -0,0 +1,84 @@
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
+ # Uplink sets resource implementation to be used in logical interconnect groups
17
+ class LIGUplinkSet < Resource
18
+ BASE_URI = '/rest/logical-interconnect-groups'.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['logicalPortConfigInfos'] ||= []
28
+ @data['lacpTimer'] ||= 'Short'
29
+ @data['mode'] ||= 'Auto'
30
+ @data['networkUris'] ||= []
31
+ end
32
+
33
+ # Add an existing network to the network list.
34
+ # Ethernet and FibreChannel networks are allowed.
35
+ # @param [OneviewSDK::Resource] network The resource to be added to the list
36
+ def add_network(network)
37
+ network.retrieve! unless network['uri']
38
+ @data['networkUris'] << network['uri']
39
+ end
40
+
41
+ # Specify one uplink passing the virtual connect bay and the port to be attached.
42
+ # @param [Fixnum] bay number to identify the VC
43
+ # @param [String] port to attach the uplink. Allowed D1..D16 and X1..X10
44
+ def add_uplink(bay, port)
45
+ entry = {
46
+ 'desiredSpeed' => 'Auto',
47
+ 'logicalLocation' => {
48
+ 'locationEntries' => [
49
+ { 'relativeValue' => bay, 'type' => 'Bay' },
50
+ { 'relativeValue' => 1, 'type' => 'Enclosure' },
51
+ { 'relativeValue' => relative_value_of(port), 'type' => 'Port' }
52
+ ]
53
+ }
54
+ }
55
+ @data['logicalPortConfigInfos'] << entry
56
+ end
57
+
58
+ # Sets all params
59
+ # @overload sets networkType first
60
+ def set_all(params = {})
61
+ params = params.data if params.class <= Resource
62
+ params = Hash[params.map { |(k, v)| [k.to_s, v] }]
63
+ network_type = params.delete('networkType')
64
+ params.each { |key, value| set(key.to_s, value) }
65
+ set('networkType', network_type) if network_type
66
+ end
67
+
68
+ private
69
+
70
+ # Relative values:
71
+ # Downlink Ports: D1 is 1, D2 is 2, ....,D15 is 15, D16 is 16;
72
+ # Uplink Ports: X1 is 17, X2 is 18, ....,X9 is 25, X10 is 26.
73
+ def relative_value_of(port)
74
+ identifier = port.slice!(0)
75
+ offset = case identifier
76
+ when 'D' then 0
77
+ when 'X' then 16
78
+ else raise InvalidResource, "Port not supported: #{identifier} type not found"
79
+ end
80
+ port.to_i + offset
81
+ end
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,57 @@
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
+ # Logical downlink resource implementation
17
+ class LogicalDownlink < Resource
18
+ BASE_URI = '/rest/logical-downlinks'.freeze
19
+
20
+ # Method is not available
21
+ # @raise [OneviewSDK::MethodUnavailable] method is not available
22
+ def create
23
+ unavailable_method
24
+ end
25
+
26
+ # Method is not available
27
+ # @raise [OneviewSDK::MethodUnavailable] method is not available
28
+ def update
29
+ unavailable_method
30
+ end
31
+
32
+ # Method is not available
33
+ # @raise [OneviewSDK::MethodUnavailable] method is not available
34
+ def delete
35
+ unavailable_method
36
+ end
37
+
38
+ # Gets a list of logical downlinks, excluding any existing ethernet network
39
+ # @param [OneviewSDK::Client] client The client object for the OneView appliance
40
+ # @return [Array<OneviewSDK::LogicalDownlink] Logical downlink array
41
+ def self.get_without_ethernet(client)
42
+ result = []
43
+ response = client.rest_get(BASE_URI + '/withoutEthernet')
44
+ members = client.response_handler(response)['members']
45
+ members.each { |member| result << new(client, member) }
46
+ result
47
+ end
48
+
49
+ # Gets a logical downlink, excluding any existing ethernet network
50
+ # @return [OneviewSDK::LogicalDownlink] Logical downlink array
51
+ def get_without_ethernet
52
+ response = @client.rest_get(@data['uri'] + '/withoutEthernet')
53
+ OneviewSDK::LogicalDownlink.new(@client, @client.response_handler(response))
54
+ end
55
+ end
56
+ end
57
+ 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 specific
10
+ # language governing permissions and limitations under the License.
11
+
12
+ require_relative 'resource'
13
+
14
+ module OneviewSDK
15
+ module API200
16
+ # Logical enclosure resource implementation
17
+ class LogicalEnclosure < Resource
18
+ BASE_URI = '/rest/logical-enclosures'.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
+ end
27
+
28
+ # Reapplies the appliance's configuration on the enclosures
29
+ # @raise [OneviewSDK::IncompleteResource] if the client is not set
30
+ # @raise [OneviewSDK::IncompleteResource] if the uri is not set
31
+ # @raise [StandardError] if the reapply fails
32
+ # @return [OneviewSDK::LogicalEnclosure] self
33
+ def reconfigure
34
+ ensure_client && ensure_uri
35
+ response = @client.rest_put("#{@data['uri']}/configuration", {}, @api_version)
36
+ @client.response_handler(response)
37
+ self
38
+ end
39
+
40
+ # Makes this logical enclosure consistent with the enclosure group
41
+ # @raise [OneviewSDK::IncompleteResource] if the client is not set
42
+ # @raise [OneviewSDK::IncompleteResource] if the uri is not set
43
+ # @raise [StandardError] if the process fails
44
+ # @return [OneviewSDK::LogicalEnclosure] self
45
+ def update_from_group
46
+ ensure_client && ensure_uri
47
+ response = @client.rest_put("#{@data['uri']}/updateFromGroup", {}, @api_version)
48
+ @client.response_handler(response)
49
+ self
50
+ end
51
+
52
+ # Get the configuration script
53
+ # @raise [OneviewSDK::IncompleteResource] if the client is not set
54
+ # @raise [OneviewSDK::IncompleteResource] if the uri is not set
55
+ # @raise [StandardError] if retrieving fails
56
+ # @return [String] script
57
+ def get_script
58
+ ensure_client && ensure_uri
59
+ response = @client.rest_get("#{@data['uri']}/script", @api_version)
60
+ response.body
61
+ end
62
+
63
+ # Updates the configuration script for the logical enclosure
64
+ # @raise [OneviewSDK::IncompleteResource] if the client is not set
65
+ # @raise [OneviewSDK::IncompleteResource] if the uri is not set
66
+ # @raise [StandardError] if the reapply fails
67
+ # @return [OneviewSDK::LogicalEnclosure] self
68
+ def set_script(script)
69
+ ensure_client && ensure_uri
70
+ response = @client.rest_put("#{@data['uri']}/script", { 'body' => script }, @api_version)
71
+ @client.response_handler(response)
72
+ self
73
+ end
74
+
75
+ # Generates a support dump for the logical enclosure
76
+ # @raise [OneviewSDK::IncompleteResource] if the client is not set
77
+ # @raise [OneviewSDK::IncompleteResource] if the uri is not set
78
+ # @raise [StandardError] if the process fails when generating the support dump
79
+ # @return [OneviewSDK::LogicalEnclosure] self
80
+ def support_dump(options)
81
+ ensure_client && ensure_uri
82
+ response = @client.rest_post("#{@data['uri']}/support-dumps", { 'body' => options }, @api_version)
83
+ @client.wait_for(response.header['location'])
84
+ self
85
+ end
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,251 @@
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
+ # Logical interconnect resource implementation
17
+ class LogicalInterconnect < Resource
18
+ BASE_URI = '/rest/logical-interconnects'.freeze
19
+ LOCATION_URI = '/rest/logical-interconnects/locations/interconnects'.freeze
20
+
21
+ # Creates an Interconnect in the desired bay in a specified enclosure
22
+ # WARN: It does not create the LOGICAL INTERCONNECT itself.
23
+ # It will fail if no interconnect is already present on the specified position
24
+ # @param [Fixnum] bay_number Number of the bay to put the interconnect
25
+ # @param [OneviewSDK::Resource] enclosure Enclosure to insert the interconnect
26
+ def create(bay_number, enclosure)
27
+ enclosure.ensure_uri
28
+ entry = {
29
+ 'locationEntries' => [
30
+ { 'value' => bay_number, 'type' => 'Bay' },
31
+ { 'value' => enclosure['uri'], 'type' => 'Enclosure' }
32
+ ]
33
+ }
34
+ response = @client.rest_post(self.class::LOCATION_URI, { 'body' => entry }, @api_version)
35
+ @client.response_handler(response)
36
+ end
37
+
38
+ # Deletes an INTERCONNECT
39
+ # WARN: This will not delete the LOGICAL INTERCONNECT itself, and may cause inconsistency between the enclosure and LIG
40
+ # @param [Fixnum] bay_number The bay number to locate the logical interconnect
41
+ # @param [OneviewSDK::Enclosure] enclosure Enclosure to remove the logical interconnect
42
+ # @return [OneviewSDK::LogicalInterconnect] self
43
+ def delete(bay_number, enclosure)
44
+ enclosure.ensure_uri
45
+ delete_uri = self.class::LOCATION_URI + "?location=Enclosure:#{enclosure['uri']},Bay:#{bay_number}"
46
+ response = @client.rest_delete(delete_uri, {}, @api_version)
47
+ @client.response_handler(response)
48
+ self
49
+ end
50
+
51
+ # Updates internal networks on the logical interconnect
52
+ # @param [OneviewSDK::EthernetNetworks] networks List of networks to update the Logical Interconnect
53
+ def update_internal_networks(*networks)
54
+ uris = []
55
+ return @client.response_handler(@client.rest_put(@data['uri'] + '/internalNetworks', 'body' => [])) unless networks
56
+ networks.each do |net|
57
+ net.retrieve! unless net['uri']
58
+ uris.push(net['uri'])
59
+ end
60
+ response = @client.rest_put(@data['uri'] + '/internalNetworks', 'body' => uris)
61
+ body = @client.response_handler(response)
62
+ set_all(body)
63
+ end
64
+
65
+ # Lists internal networks on the logical interconnect
66
+ # @return [OneviewSDK::Resource] List of networks
67
+ def list_vlan_networks
68
+ ensure_client && ensure_uri
69
+ results = OneviewSDK::Resource.find_by(@client, {}, @data['uri'] + '/internalVlans')
70
+ internal_networks = []
71
+ results.each do |vlan|
72
+ net = if vlan['generalNetworkUri'].include? 'ethernet-network'
73
+ OneviewSDK::EthernetNetwork.new(@client, uri: vlan['generalNetworkUri'])
74
+ elsif vlan['generalNetworkUri'].include? 'fc-network'
75
+ OneviewSDK::FCNetwork.new(@client, uri: vlan['generalNetworkUri'])
76
+ else
77
+ OneviewSDK::FCoENetwork.new(@client, uri: vlan['generalNetworkUri'])
78
+ end
79
+ net.retrieve!
80
+ internal_networks.push(net)
81
+ end
82
+ internal_networks
83
+ end
84
+
85
+ # Updates ethernet settings of the logical interconnect
86
+ # @note The attribute is defined inside the instance of the Logical Interconnect
87
+ # @return Updated instance of the Logical Interconnect
88
+ def update_ethernet_settings
89
+ ensure_client && ensure_uri
90
+ raise IncompleteResource, 'Please retrieve the Logical Interconnect before trying to update' unless @data['ethernetSettings']
91
+ update_options = {
92
+ 'If-Match' => @data['ethernetSettings'].delete('eTag'),
93
+ 'body' => @data['ethernetSettings']
94
+ }
95
+ response = @client.rest_put(@data['uri'] + '/ethernetSettings', update_options, @api_version)
96
+ body = @client.response_handler(response)
97
+ set_all(body)
98
+ end
99
+
100
+ # Updates settings of the logical interconnect
101
+ # @param options Options to update the Logical Interconnect
102
+ # @return Updated instance of the Logical Interconnect
103
+ def update_settings(options = {})
104
+ ensure_client && ensure_uri
105
+ options['type'] ||= 'InterconnectSettingsV3'
106
+ options['ethernetSettings'] ||= {}
107
+ options['ethernetSettings']['type'] ||= 'EthernetInterconnectSettingsV3'
108
+ update_options = {
109
+ 'If-Match' => @data['eTag'],
110
+ 'body' => options
111
+ }
112
+ response = @client.rest_put(@data['uri'] + '/settings', update_options, @api_version)
113
+ body = @client.response_handler(response)
114
+ set_all(body)
115
+ end
116
+
117
+ # Returns logical interconnects to a consistent state.
118
+ # The current logical interconnect state is compared to the associated logical interconnect group.
119
+ # @return returns the updated object
120
+ def compliance
121
+ ensure_client && ensure_uri
122
+ response = @client.rest_put(@data['uri'] + '/compliance', {}, @api_version)
123
+ body = client.response_handler(response)
124
+ set_all(body)
125
+ end
126
+
127
+ # Asynchronously applies or re-applies the logical interconnect configuration to all managed interconnects
128
+ # @return returns the updated object
129
+ def configuration
130
+ ensure_client && ensure_uri
131
+ response = @client.rest_put(@data['uri'] + '/configuration', {}, @api_version)
132
+ body = client.response_handler(response)
133
+ set_all(body)
134
+ end
135
+
136
+ # Updates port monitor settings of the Logical Interconnect
137
+ # @note The attribute is defined inside the instance of the Logical Interconnect
138
+ # @return Updated instance of the Logical Interconnect
139
+ def update_port_monitor
140
+ raise IncompleteResource, 'Please retrieve the Logical Interconnect before trying to update' unless @data['portMonitor']
141
+ update_options = {
142
+ 'If-Match' => @data['portMonitor'].delete('eTag'),
143
+ 'body' => @data['portMonitor']
144
+ }
145
+ response = @client.rest_put(@data['portMonitor']['uri'], update_options, @api_version)
146
+ body = @client.response_handler(response)
147
+ set_all(body)
148
+ end
149
+
150
+ # Updates QoS aggregated configuration of the Logical Interconnect
151
+ # @note The attribute is defined inside the instance of the Logical Interconnect
152
+ # @return Updated instance of the Logical Interconnect
153
+ def update_qos_configuration
154
+ raise IncompleteResource, 'Please retrieve the Logical Interconnect before trying to update' unless @data['qosConfiguration']
155
+ update_options = {
156
+ 'If-Match' => @data['qosConfiguration'].delete('eTag'),
157
+ 'body' => @data['qosConfiguration']
158
+ }
159
+ response = @client.rest_put(@data['uri'] + '/qos-aggregated-configuration', update_options, @api_version)
160
+ body = @client.response_handler(response)
161
+ set_all(body)
162
+ end
163
+
164
+ # Updates telemetry configuration of the Logical Interconnect
165
+ # @note The attribute is defined inside the instance of the Logical Interconnect
166
+ # @return Updated instance of the Logical Interconnect
167
+ def update_telemetry_configuration
168
+ raise IncompleteResource, 'Please retrieve the Logical Interconnect before trying to update' unless @data['telemetryConfiguration']
169
+ update_options = {
170
+ 'If-Match' => @data['telemetryConfiguration'].delete('eTag'),
171
+ 'body' => @data['telemetryConfiguration']
172
+ }
173
+ response = @client.rest_put(@data['telemetryConfiguration']['uri'], update_options, @api_version)
174
+ body = @client.response_handler(response)
175
+ set_all(body)
176
+ end
177
+
178
+ # Updates snmp configuration of the Logical Interconnect
179
+ # @note The attribute is defined inside the instance of the Logical Interconnect.
180
+ # Use helper methods to add the trap destination values: #add_snmp_trap_destination and #generate_trap_options
181
+ # @return Updated instance of the Logical Interconnect
182
+ def update_snmp_configuration
183
+ raise IncompleteResource, 'Please retrieve the Logical Interconnect before trying to update' unless @data['snmpConfiguration']
184
+ update_options = {
185
+ 'If-Match' => @data['snmpConfiguration'].delete('eTag'),
186
+ 'body' => @data['snmpConfiguration']
187
+ }
188
+ response = @client.rest_put(@data['uri'] + '/snmp-configuration', update_options, @api_version)
189
+ body = @client.response_handler(response)
190
+ set_all(body)
191
+ end
192
+
193
+ # It will add one trap destination to the Logical Interconnect SNMP configuration
194
+ # @param trap_format [String] SNMP version for this trap destination, `'SNMPv1'` or `'SNMPv2'` or `'SNMPv3'`
195
+ # @param trap_destination [String] The trap destination IP address or host name
196
+ # @param community_string [String] The Authentication string for the trap destination
197
+ # @param trap_options [Hash] Hash with the options of the trap. Create it using generate_trap_options method
198
+ def add_snmp_trap_destination(trap_destination, trap_format = 'SNMPv1', community_string = 'public', trap_options = {})
199
+ trap_options['communityString'] = community_string
200
+ trap_options['trapDestination'] = trap_destination
201
+ trap_options['trapFormat'] = trap_format
202
+ @data['snmpConfiguration']['trapDestinations'].push(trap_options)
203
+ end
204
+
205
+ # Generates trap options to be used in add_snmp_trap_destination method
206
+ # @param enet_trap_categories [Array] Filter the traps for this trap destination by the list of configured Ethernet traps
207
+ # can contain, `'Other'` or `'PortStatus'` or `'PortThresholds'`
208
+ # @param fc_trap_categories [Array] Filter the traps for this trap destination by the list of configured Fibre Channel traps
209
+ # can contain, `'Other'` or `'PortStatus'`
210
+ # @param vcm_trap_categories [Array] Filter the traps for this trap destination by the list of configured VCM trap, `'Legacy'`
211
+ # @param trap_severities [Array] Filter the traps for this trap destination by the list of configured severities
212
+ # can contain, `'Critical'` or `'Info'` or `'Major'` or `'Minor'` or `'Normal'` or `'Unknown'` or `'Warning'`
213
+ # @return [Hash] Contains all trap options for one SNMP destination
214
+ def generate_trap_options(enet_trap_categories = [], fc_trap_categories = [], vcm_trap_categories = [], trap_severities = [])
215
+ options = {
216
+ 'enetTrapCategories' => enet_trap_categories,
217
+ 'vcmTrapCategories' => vcm_trap_categories,
218
+ 'fcTrapCategories' => fc_trap_categories,
219
+ 'trapSeverities' => trap_severities
220
+ }
221
+ options
222
+ end
223
+
224
+ # Gets the installed firmware for a logical interconnect.
225
+ # @return [Hash] Contains all firmware information
226
+ def get_firmware
227
+ ensure_client && ensure_uri
228
+ response = @client.rest_get(@data['uri'] + '/firmware')
229
+ @client.response_handler(response)
230
+ end
231
+
232
+ # Update firmware
233
+ # @param [String] command
234
+ # @param [OneviewSDK::FirmwareDriver] firmware_driver
235
+ # @param [Hash] firmware_options
236
+ # @raise [OneviewSDK::IncompleteResource] if the client or uri is not set
237
+ def firmware_update(command, firmware_driver, firmware_options)
238
+ ensure_client && ensure_uri
239
+ firmware_options['command'] = command
240
+ firmware_options['sppUri'] = firmware_driver['uri']
241
+ firmware_options['sppName'] = firmware_driver['name']
242
+ update_json = {
243
+ 'If-Match' => '*',
244
+ 'body' => firmware_options
245
+ }
246
+ response = @client.rest_put(@data['uri'] + '/firmware', update_json)
247
+ @client.response_handler(response)
248
+ end
249
+ end
250
+ end
251
+ end