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
@@ -0,0 +1,203 @@
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 'time'
13
+ require 'date'
14
+ require_relative 'resource'
15
+
16
+ module OneviewSDK
17
+ module API200
18
+ # Enclosure resource implementation
19
+ class Enclosure < Resource
20
+ BASE_URI = '/rest/enclosures'.freeze
21
+ UNIQUE_IDENTIFIERS = %w(name uri serialNumber activeOaPreferredIP standbyOaPreferredIP).freeze
22
+
23
+ # Remove resource from OneView
24
+ # @return [true] if resource was removed successfully
25
+ alias remove delete
26
+
27
+ # Create a resource object, associate it with a client, and set its properties.
28
+ # @param [OneviewSDK::Client] client The client object for the OneView appliance
29
+ # @param [Hash] params The options for this resource (key-value pairs)
30
+ # @param [Integer] api_ver The api version to use when interracting with this resource.
31
+ def initialize(client, params = {}, api_ver = nil)
32
+ super
33
+ # Default values:
34
+ @data['type'] ||= 'EnclosureV200'
35
+ end
36
+
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
+ # Claim/configure the enclosure and its components to the appliance
51
+ # @note Calls the refresh method to set additional data
52
+ # @return [OneviewSDK::Enclosure] self
53
+ def add
54
+ ensure_client
55
+ required_attributes = %w(enclosureGroupUri hostname username password licensingIntent)
56
+ required_attributes.each { |k| raise IncompleteResource, "Missing required attribute: '#{k}'" unless @data.key?(k) }
57
+
58
+ optional_attrs = %w(enclosureUri firmwareBaselineUri force forceInstallFirmware state unmanagedEnclosure updateFirmwareOn)
59
+ temp_data = @data.select { |k, _v| required_attributes.include?(k) || optional_attrs.include?(k) }
60
+ response = @client.rest_post(self.class::BASE_URI, { 'body' => temp_data }, @api_version)
61
+ new_data = @client.response_handler(response)
62
+ old_name = @data.select { |k, _v| %w(name rackName).include?(k) } # Save name (if given)
63
+ %w(username password hostname).each { |k| @data.delete(k) } # These are no longer needed
64
+ set_all(new_data)
65
+ set_all(old_name)
66
+ update
67
+ self
68
+ end
69
+
70
+ # Overrides the update operation because only the name and rackName can be updated (and it uses PATCH).
71
+ # @param [Hash] attributes attributes to be updated
72
+ # @return [OneviewSDK::Enclosure] self
73
+ def update(attributes = {})
74
+ set_all(attributes)
75
+ ensure_client && ensure_uri
76
+ cur_state = self.class.find_by(@client, uri: @data['uri']).first
77
+ unless cur_state[:name] == @data['name']
78
+ temp_data = [{ op: 'replace', path: '/name', value: @data['name'] }]
79
+ response = @client.rest_patch(@data['uri'], { 'body' => temp_data }, @api_version)
80
+ @client.response_handler(response)
81
+ end
82
+ unless cur_state[:rackName] == @data['rackName']
83
+ temp_data = [{ op: 'replace', path: '/rackName', value: @data['rackName'] }]
84
+ response = @client.rest_patch(@data['uri'], { 'body' => temp_data }, @api_version)
85
+ @client.response_handler(response)
86
+ end
87
+ self
88
+ end
89
+
90
+ # Reapplies the enclosure configuration
91
+ def configuration
92
+ ensure_client && ensure_uri
93
+ response = @client.rest_put(@data['uri'] + '/configuration', {}, @api_version)
94
+ new_data = @client.response_handler(response)
95
+ set_all(new_data)
96
+ end
97
+
98
+
99
+ # Refreshes the enclosure along with all of its components
100
+ # @param [String] state NotRefreshing, RefreshFailed, RefreshPending, Refreshing
101
+ # @param [Hash] options Optional force fields for refreshing the enclosure
102
+ def set_refresh_state(state, options = {})
103
+ ensure_client && ensure_uri
104
+ s = state.to_s rescue state
105
+ requestBody = {
106
+ 'body' => {
107
+ refreshState: s,
108
+ refreshForceOptions: options
109
+ }
110
+ }
111
+ response = @client.rest_put(@data['uri'] + '/refreshState', requestBody, @api_version)
112
+ new_data = @client.response_handler(response)
113
+ set_all(new_data)
114
+ end
115
+
116
+ # Gets the enclosure script content
117
+ # @return [String] Script content
118
+ def script
119
+ ensure_client && ensure_uri
120
+ response = @client.rest_get(@data['uri'] + '/script', @api_version)
121
+ @client.response_handler(response)
122
+ end
123
+
124
+ # Gets the enclosure settings that describe the environmental configuration
125
+ # @return [Hash] The enclosure envirnomental configuration
126
+ def environmental_configuration
127
+ ensure_client && ensure_uri
128
+ response = @client.rest_get(@data['uri'] + '/environmentalConfiguration', @api_version)
129
+ @client.response_handler(response)
130
+ end
131
+
132
+ # Sets the calibrated max power of an unmanaged or unsupported enclosure
133
+ # @param [String] power The calibrated maximum power of the resource
134
+ def set_environmental_configuration(power)
135
+ ensure_client && ensure_uri
136
+ response = @client.rest_put(@data['uri'] + '/environmentalConfiguration', 'body' => { calibratedMaxPower: power })
137
+ @client.response_handler(response)
138
+ end
139
+
140
+ # Retrieves historical utilization
141
+ # @param [Hash] queryParameters query parameters (ie :startDate, :endDate, :fields, :view, etc.)
142
+ # @option queryParameters [Array] :fields
143
+ # @option queryParameters [Time, Date, String] :startDate
144
+ # @option queryParameters [Time, Date, String] :endDate
145
+ def utilization(queryParameters = {})
146
+ ensure_client && ensure_uri
147
+ uri = "#{@data['uri']}/utilization?"
148
+
149
+ queryParameters[:endDate] = convert_time(queryParameters[:endDate])
150
+ queryParameters[:startDate] = convert_time(queryParameters[:startDate])
151
+
152
+ queryParameters.each do |key, value|
153
+ next if value.nil?
154
+ uri += case key.to_sym
155
+ when :fields
156
+ "fields=#{value.join(',')}"
157
+ when :startDate, :endDate
158
+ "filter=#{key}=#{value}"
159
+ else
160
+ "#{key}=#{value}"
161
+ end
162
+ uri += '&'
163
+ end
164
+ uri.chop! # Get rid of trailing '&' or '?'
165
+ response = @client.rest_get(uri, @api_version)
166
+ @client.response_handler(response)
167
+ end
168
+
169
+ # Updates specific attributes of a given enclosure resource
170
+ # @param [String] operation operation to be performed
171
+ # @param [String] path path
172
+ # @param [String] value value
173
+ def patch(operation, path, value)
174
+ ensure_client && ensure_uri
175
+ response = @client.rest_patch(@data['uri'], { 'body' => [{ op: operation, path: path, value: value }] }, @api_version)
176
+ @client.response_handler(response)
177
+ end
178
+
179
+ # Associates an enclosure group to the enclosure
180
+ # @param [OneviewSDK<Resource>] eg Enclosure Group associated
181
+ def set_enclosure_group(eg)
182
+ eg.retrieve! unless eg['uri']
183
+ @data['enclosureGroupUri'] = eg['uri']
184
+ end
185
+
186
+ private
187
+
188
+ # Converts Date, Time, or String objects to iso8601 string
189
+ # @raise [InvalidResource] if time is not formatted correctly
190
+ def convert_time(t)
191
+ case t
192
+ when nil then nil
193
+ when Date then t.to_time.utc.iso8601(3)
194
+ when Time then t.utc.iso8601(3)
195
+ when String then Time.parse(t).utc.iso8601(3)
196
+ else raise InvalidResource, "Invalid time format '#{t.class}'. Valid options are Time, Date, or String"
197
+ end
198
+ rescue StandardError => e
199
+ raise InvalidResource, "Failed to parse time value '#{t}'. #{e.message}"
200
+ end
201
+ end
202
+ end
203
+ end
@@ -0,0 +1,86 @@
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
+ # Enclosure group resource implementation
17
+ class EnclosureGroup < Resource
18
+ BASE_URI = '/rest/enclosure-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['type'] ||= 'EnclosureGroupV200'
28
+ @data['interconnectBayMappingCount'] ||= 8
29
+ create_interconnect_bay_mapping unless @data['interconnectBayMappings']
30
+ end
31
+
32
+ # Get the script executed by enclosures in this enclosure group
33
+ # @return [String] The script for this enclosure group
34
+ def get_script
35
+ ensure_client && ensure_uri
36
+ response = @client.rest_get(@data['uri'] + '/script', @api_version)
37
+ @client.response_handler(response)
38
+ end
39
+
40
+ # Changes the script executed by the enclosures in this enclosure group
41
+ # @param [String] body The script to be executed
42
+ # @return true if set successfully
43
+ def set_script(body)
44
+ ensure_client && ensure_uri
45
+ response = @client.rest_put(@data['uri'] + '/script', { 'body' => body }, @api_version)
46
+ @client.response_handler(response)
47
+ true
48
+ end
49
+
50
+ # Adds the logical interconnect group
51
+ # @param [OneviewSDK::LogicalInterconnectGroup] lig Logical Interconnect Group
52
+ def add_logical_interconnect_group(lig)
53
+ lig.retrieve! unless lig['uri']
54
+ lig['interconnectMapTemplate']['interconnectMapEntryTemplates'].each do |entry|
55
+ entry['logicalLocation']['locationEntries'].each do |location|
56
+ add_lig_to_bay(location['relativeValue'], lig) if location['type'] == 'Bay' && entry['permittedInterconnectTypeUri']
57
+ end
58
+ end
59
+ end
60
+
61
+ # Creates the interconnect bay mapping
62
+ def create_interconnect_bay_mapping
63
+ @data['interconnectBayMappings'] = []
64
+ 1.upto(@data['interconnectBayMappingCount']) do |bay_number|
65
+ entry = {
66
+ 'interconnectBay' => bay_number,
67
+ 'logicalInterconnectGroupUri' => nil
68
+ }
69
+ @data['interconnectBayMappings'] << entry
70
+ end
71
+ end
72
+
73
+ private
74
+
75
+ # Add logical interconnect group to bay
76
+ # @param [Integer] bay Bay number
77
+ # @param [OneviewSDK::LogicalInterconnectGroup] lig Logical Interconnect Group
78
+ def add_lig_to_bay(bay, lig)
79
+ @data['interconnectBayMappings'].each do |location|
80
+ return location['logicalInterconnectGroupUri'] = lig['uri'] if location['interconnectBay'] == bay
81
+ end
82
+ end
83
+
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,60 @@
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
+ # Ethernet network resource implementation
17
+ class EthernetNetwork < Resource
18
+ BASE_URI = '/rest/ethernet-networks'.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['ethernetNetworkType'] ||= 'Tagged'
28
+ @data['type'] ||= 'ethernet-networkV3'
29
+ end
30
+
31
+ # Bulk create the ethernet networks
32
+ # @param [OneviewSDK::Client] client The client object for the OneView appliance
33
+ # @param [Hash] options information necessary to create networks
34
+ # @return [Array] list of ethernet networks created
35
+ def self.bulk_create(client, options)
36
+ range = options[:vlanIdRange].split('-').map(&:to_i)
37
+ options[:type] = 'bulk-ethernet-network'
38
+ response = client.rest_post(BASE_URI + '/bulk', { 'body' => options }, client.api_version)
39
+ client.response_handler(response)
40
+ network_names = []
41
+ range[0].upto(range[1]) { |i| network_names << "#{options[:namePrefix]}_#{i}" }
42
+ OneviewSDK::EthernetNetwork.get_all(client).select { |network| network_names.include?(network['name']) }
43
+ end
44
+
45
+ # Gets the associated profiles
46
+ def get_associated_profiles
47
+ ensure_client && ensure_uri
48
+ response = @client.rest_get("#{@data['uri']}/associatedProfiles", @api_version)
49
+ response.body
50
+ end
51
+
52
+ # Gets the associated uplink groups
53
+ def get_associated_uplink_groups
54
+ ensure_client && ensure_uri
55
+ response = @client.rest_get("#{@data['uri']}/associatedUplinkGroups", @api_version)
56
+ response.body
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,45 @@
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
+ # Fabric resource implementation
17
+ class Fabric < Resource
18
+ BASE_URI = '/rest/fabrics'.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
+ # Method is not available
39
+ # @raise [OneviewSDK::MethodUnavailable] method is not available
40
+ def refresh
41
+ unavailable_method
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,34 @@
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
+ # FC network resource implementation
17
+ class FCNetwork < Resource
18
+ BASE_URI = '/rest/fc-networks'.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['autoLoginRedistribution'] ||= false
28
+ @data['type'] ||= 'fc-networkV2'
29
+ @data['linkStabilityTime'] ||= 30
30
+ @data['fabricType'] ||= 'FabricAttach'
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,32 @@
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
+ # FCoE network resource implementation
17
+ class FCoENetwork < Resource
18
+ BASE_URI = '/rest/fcoe-networks'.freeze
19
+
20
+ # Create a resource object, associate it with a client, and set its properties.
21
+ # @param [OneviewSDK::Client] client The client object for the OneView appliance
22
+ # @param [Hash] params The options for this resource (key-value pairs)
23
+ # @param [Integer] api_ver The api version to use when interracting with this resource.
24
+ def initialize(client, params = {}, api_ver = nil)
25
+ super
26
+ # Default values:
27
+ @data['connectionTemplateUri'] ||= nil
28
+ @data['type'] ||= 'fcoe-network'
29
+ end
30
+ end
31
+ end
32
+ end