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