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,217 @@
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
+ # Server profile template resource implementation
17
+ class ServerProfileTemplate < Resource
18
+ BASE_URI = '/rest/server-profile-templates'.freeze
19
+
20
+ def initialize(client, params = {}, api_ver = nil)
21
+ super
22
+ # Default values
23
+ @data['type'] ||= 'ServerProfileTemplateV1'
24
+ end
25
+
26
+ # Sets the Server Hardware Type for the Server Profile Template
27
+ # @param [OneviewSDK::ServerHardwareType] server_hardware_type Type of the desired Server Hardware
28
+ def set_server_hardware_type(server_hardware_type)
29
+ self['serverHardwareTypeUri'] = server_hardware_type['uri'] if server_hardware_type['uri'] || server_hardware_type.retrieve!
30
+ raise "Resource #{server_hardware_type['name']} could not be found!" unless server_hardware_type['uri']
31
+ end
32
+
33
+ # Sets the enclosure group for the server profile template
34
+ # @param [OneviewSDK::EnclosureGroup] enclosure_group Enclosure Group that the Server is a member
35
+ def set_enclosure_group(enclosure_group)
36
+ self['enclosureGroupUri'] = enclosure_group['uri'] if enclosure_group['uri'] || enclosure_group.retrieve!
37
+ raise "Resource #{enclosure_group['name']} could not be found!" unless enclosure_group['uri']
38
+ end
39
+
40
+ # Sets the firmware driver for the current server profile template
41
+ # @param [OneviewSDK::FirmwareDriver] firmware Firmware Driver to be associated with the resource
42
+ # @param [Hash<String,Object>] firmware_options Firmware Driver options
43
+ # @option firmware_options [Boolean] 'manageFirmware' Indicates that the server firmware is configured using the server profile.
44
+ # Value can be 'true' or 'false'.
45
+ # @option firmware_options [Boolean] 'forceInstallFirmware' Force installation of firmware even if same or newer version is installed.
46
+ # Downgrading the firmware can result in the installation of unsupported firmware and cause server hardware to cease operation.
47
+ # Value can be 'true' or 'false'.
48
+ # @option firmware_options [String] 'firmwareInstallType' Specifies the way a Service Pack for ProLiant (SPP) is installed.
49
+ # This field is used if the 'manageFirmware' field is true.
50
+ # Values are 'FirmwareAndOSDrivers', 'FirmwareOnly', and 'FirmwareOnlyOfflineMode'.
51
+ def set_firmware_driver(firmware, firmware_options = {})
52
+ firmware_options['firmwareBaselineUri'] = firmware['uri'] if firmware['uri'] || firmware.retrieve!
53
+ self['firmware'] = firmware_options
54
+ end
55
+
56
+ # Adds a connection entry to server profile template
57
+ # @param [OneviewSDK::EthernetNetwork,OneviewSDK::FCNetwork] network Network associated with the connection
58
+ # @param [Hash<String,String>] connection_options Hash containing the configuration of the connection
59
+ # @option connection_options [Integer] 'allocatedMbps' The transmit throughput (mbps) currently allocated to
60
+ # this connection. When Fibre Channel connections are set to Auto for requested bandwidth, the value can be set to -2000
61
+ # to indicate that the actual value is unknown until OneView is able to negotiate the actual speed.
62
+ # @option connection_options [Integer] 'allocatedVFs' The number of virtual functions allocated to this connection. This value will be null.
63
+ # @option connection_options [Hash] 'boot' indicates that the server will attempt to boot from this connection.
64
+ # This object can only be specified if "boot.manageBoot" is set to 'true'
65
+ # @option connection_options [String] 'deploymentStatus' The deployment status of the connection.
66
+ # The value can be 'Undefined', 'Reserved', or 'Deployed'.
67
+ # @option connection_options [String] 'functionType' Type of function required for the connection.
68
+ # functionType cannot be modified after the connection is created.
69
+ # @option connection_options [String] 'mac' The MAC address that is currently programmed on the FlexNic.
70
+ # @option connection_options [String] 'macType' Specifies the type of MAC address to be programmed into the IO Devices.
71
+ # The value can be 'Virtual', 'Physical' or 'UserDefined'.
72
+ # @option connection_options [String] 'maximumMbps' Maximum transmit throughput (mbps) allowed on this connection.
73
+ # The value is limited by the maximum throughput of the network link and maximumBandwidth of the selected network (networkUri).
74
+ # For Fibre Channel connections, the value is limited to the same value as the allocatedMbps.
75
+ # @option connection_options [String] 'name' A string used to identify the respective connection.
76
+ # The connection name is case insensitive, limited to 63 characters and must be unique within the profile.
77
+ # @option connection_options [String] 'portId' Identifies the port (FlexNIC) used for this connection.
78
+ # @option connection_options [String] 'requestedMbps' The transmit throughput (mbps) that should be allocated to this connection.
79
+ # @option connection_options [String] 'requestedVFs' This value can be "Auto" or 0.
80
+ # @option connection_options [String] 'wwnn' The node WWN address that is currently programmed on the FlexNic.
81
+ # @option connection_options [String] 'wwpn' The port WWN address that is currently programmed on the FlexNic.
82
+ # @option connection_options [String] 'wwpnType' Specifies the type of WWN address to be porgrammed on the FlexNIC.
83
+ # The value can be 'Virtual', 'Physical' or 'UserDefined'.
84
+ def add_connection(network, connection_options = {})
85
+ self['connections'] = [] unless self['connections']
86
+ connection_options['id'] = 0 # Letting OneView treat the ID registering
87
+ connection_options['networkUri'] = network['uri'] if network['uri'] || network.retrieve!
88
+ self['connections'] << connection_options
89
+ end
90
+
91
+ # Removes a connection entry in server profile template
92
+ # @param [String] connection_name Name of the connection
93
+ # @return Returns the connection hash if found, otherwise returns nil
94
+ def remove_connection(connection_name)
95
+ desired_connection = nil
96
+ return desired_connection unless self['connections']
97
+ self['connections'].each do |con|
98
+ desired_connection = self['connections'].delete(con) if con['name'] == connection_name
99
+ end
100
+ desired_connection
101
+ end
102
+
103
+ # Adds a volume attachment entry with associated volume in server profile template
104
+ # @param [OneviewSDK::Volume] volume Volume Resource to add an attachment
105
+ # @param [Hash] attachment_options Options of the new attachment
106
+ # @option attachment_options [Fixnum] 'id' The ID of the attached storage volume. Do not use it if you want it to be created automatically.
107
+ # @option attachment_options [String] 'lun' The logical unit number.
108
+ # @option attachment_options [String] 'lunType' The logical unit number type: Auto or Manual.
109
+ # @option attachment_options [Boolean] 'permanent' Required. If true, indicates that the volume will persist when the profile is deleted.
110
+ # If false, then the volume will be deleted when the profile is deleted.
111
+ # @option attachment_options [Array] 'storagePaths' A list of host-to-target path associations.
112
+ # @return Returns the connection hash if found, otherwise returns nil
113
+ def add_volume_attachment(volume, attachment_options = {})
114
+ self['sanStorage'] ||= {}
115
+ self['sanStorage']['volumeAttachments'] ||= []
116
+ attachment_options['id'] ||= 0
117
+
118
+ volume.retrieve! unless volume['uri'] || volume['storagePoolUri'] || volume['storageSystemUri']
119
+ attachment_options['volumeUri'] = volume['uri']
120
+ attachment_options['volumeStoragePoolUri'] = volume['storagePoolUri']
121
+ attachment_options['volumeStorageSystemUri'] = volume['storageSystemUri']
122
+
123
+ self['sanStorage']['volumeAttachments'] << attachment_options
124
+ end
125
+
126
+ # Adds a volume attachment entry with new volume in Server profile template
127
+ # @param [OneviewSDK::Volume] volume Volume Resource to add an attachment
128
+ # @param [Hash] volume_options Options to create a new Volume.
129
+ # Please refer to OneviewSDK::Volume documentation for the data necessary to create a new Volume.
130
+ # @param [Hash] attachment_options Options of the new attachment
131
+ # @option attachment_options [Fixnum] 'id' The ID of the attached storage volume. Do not use it if you want it to be created automatically.
132
+ # @option attachment_options [String] 'lun' The logical unit number.
133
+ # @option attachment_options [String] 'lunType' The logical unit number type: Auto or Manual.
134
+ # @option attachment_options [Boolean] 'permanent' Required. If true, indicates that the volume will persist when the profile is deleted.
135
+ # If false, then the volume will be deleted when the profile is deleted.
136
+ # @option attachment_options [Array] 'storagePaths' A list of host-to-target path associations.
137
+ # @return Returns the connection hash if found, otherwise returns nil
138
+ def create_volume_with_attachment(storage_pool, volume_options, attachment_options = {})
139
+ self['sanStorage'] ||= {}
140
+ self['sanStorage']['volumeAttachments'] ||= []
141
+ attachment_options['id'] ||= 0
142
+ # Removing provisioningParameters and adding them to the top level hash
143
+ provision_param = volume_options.delete('provisioningParameters') || volume_options.delete(:provisioningParameters)
144
+ provision_param.each do |k, v|
145
+ volume_options[k] = v
146
+ end
147
+ # Each provisioningParameter has the prefix 'volume' attached to its name in the original options
148
+ # Also, it needs to respect the lower camel case
149
+ volume_options.each do |k, v|
150
+ attachment_options["volume#{k.to_s[0].capitalize}#{k.to_s[1, k.to_s.length - 1]}"] = v
151
+ end
152
+
153
+ attachment_options['volumeStoragePoolUri'] = storage_pool['uri'] if storage_pool['uri'] || storage_pool.retrieve!
154
+
155
+ # Since the volume is being created in this method, it needs to be nil
156
+ attachment_options['volumeUri'] = nil
157
+ attachment_options['volumeStorageSystemUri'] = nil
158
+
159
+ # volumeProvisionedCapacityBytes is not following the same pattern in Volume
160
+ attachment_options['volumeProvisionedCapacityBytes'] ||= attachment_options.delete('volumeRequestedCapacity')
161
+
162
+ # Defaults
163
+ attachment_options['permanent'] ||= true
164
+ attachment_options['lunType'] ||= 'Auto'
165
+ attachment_options['lun'] ||= nil
166
+ attachment_options['storagePaths'] ||= []
167
+
168
+ self['sanStorage']['volumeAttachments'] << attachment_options
169
+ end
170
+
171
+ # Removes a volume attachment entry in Server profile template
172
+ # @param [Fixnum] id ID number of the attachment entry
173
+ # @return Returns the volume hash if found, otherwise returns nil
174
+ def remove_volume_attachment(id)
175
+ self['sanStorage'] ||= {}
176
+ self['sanStorage']['volumeAttachments'] ||= []
177
+ return if self['sanStorage'].empty? || self['sanStorage']['volumeAttachments'].empty?
178
+
179
+ volume_attachment = nil
180
+ self['sanStorage']['volumeAttachments'].each do |entry|
181
+ volume_attachment = self['sanStorage']['volumeAttachments'].delete(entry) if entry['id'] == id
182
+ end
183
+ volume_attachment
184
+ end
185
+
186
+ # Gets the available server hardwares
187
+ # @return [Array<OneviewSDK::ServerHardware>] Array of ServerHardware resources that matches this
188
+ # profile template's server hardware type and enclosure group and who's state is 'NoProfileApplied'
189
+ def get_available_hardware
190
+ ensure_client
191
+ raise IncompleteResource, 'Must set @data[\'serverHardwareTypeUri\']' unless @data['serverHardwareTypeUri']
192
+ raise IncompleteResource, 'Must set @data[\'enclosureGroupUri\']' unless @data['enclosureGroupUri']
193
+ params = {
194
+ state: 'NoProfileApplied',
195
+ serverHardwareTypeUri: @data['serverHardwareTypeUri'],
196
+ serverGroupUri: @data['enclosureGroupUri']
197
+ }
198
+ OneviewSDK::ServerHardware.find_by(@client, params)
199
+ rescue StandardError => e
200
+ raise IncompleteResource, "Failed to get available hardware. Message: #{e.message}"
201
+ end
202
+
203
+ # Creates a ServerProfile using this template
204
+ # @param [String] name Name of new server profile
205
+ # @return [OneviewSDK::ServerProfile] New server profile from template.
206
+ # Temporary object only; call .create to actually create resource on OneView.
207
+ def new_profile(name = nil)
208
+ ensure_client && ensure_uri
209
+ response = @client.rest_get("#{@data['uri']}/new-profile")
210
+ options = @client.response_handler(response)
211
+ profile = OneviewSDK::ServerProfile.new(@client, options)
212
+ profile['name'] = name ? name : "Server_Profile_created_from_#{@data['name']}"
213
+ profile
214
+ end
215
+ end
216
+ end
217
+ end
@@ -0,0 +1,92 @@
1
+ # (C) Copyright 2016 Hewlett Packard Enterprise Development LP
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # You may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software distributed
8
+ # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
9
+ # CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
10
+ # language governing permissions and limitations under the License.
11
+
12
+ require_relative 'resource'
13
+
14
+ module OneviewSDK
15
+ module API200
16
+ # Storage pool resource implementation
17
+ class StoragePool < Resource
18
+ BASE_URI = '/rest/storage-pools'.freeze
19
+
20
+ # Add the resource on OneView using the current data
21
+ # @note Calls the refresh method to set additional data
22
+ # @raise [OneviewSDK::IncompleteResource] if the client is not set
23
+ # @raise [StandardError] if the resource creation fails
24
+ # @return [OneviewSDK::StoragePool] self
25
+ alias add create
26
+
27
+ # Remove resource from OneView
28
+ # @return [true] if resource was removed successfully
29
+ alias remove delete
30
+
31
+ # Create a resource object, associate it with a client, and set its properties.
32
+ # @param [OneviewSDK::Client] client The client object for the OneView appliance
33
+ # @param [Hash] params The options for this resource (key-value pairs)
34
+ # @param [Integer] api_ver The api version to use when interracting with this resource.
35
+ def initialize(client, params = {}, api_ver = nil)
36
+ super
37
+ # Default values:
38
+ @data['type'] ||= 'StoragePoolV2'
39
+ end
40
+
41
+ # Method is not available
42
+ # @raise [OneviewSDK::MethodUnavailable] method is not available
43
+ def create
44
+ unavailable_method
45
+ end
46
+
47
+ # Method is not available
48
+ # @raise [OneviewSDK::MethodUnavailable] method is not available
49
+ def delete
50
+ unavailable_method
51
+ end
52
+
53
+ # Method is not available
54
+ # @raise [OneviewSDK::MethodUnavailable] method is not available
55
+ def update
56
+ unavailable_method
57
+ end
58
+
59
+ # Retrieve resource details based on this resource's name or URI.
60
+ # @note Name or URI must be specified inside the resource
61
+ # @return [Boolean] Whether or not retrieve was successful
62
+ def retrieve!
63
+ raise IncompleteResource, 'Must set resource name or uri before trying to retrieve!' unless @data['name'] || @data['uri']
64
+ raise IncompleteResource, 'Must set resource storageSystemUri before trying to retrieve!' unless @data['storageSystemUri']
65
+ results = self.class.find_by(@client, name: @data['name'], storageSystemUri: @data['storageSystemUri']) if @data['name']
66
+ results = self.class.find_by(@client, uri: @data['uri'], storageSystemUri: @data['storageSystemUri']) if @data['uri'] &&
67
+ (!results || results.empty?)
68
+ return false unless results.size == 1
69
+ set_all(results[0].data)
70
+ true
71
+ end
72
+
73
+ # Check if a resource exists
74
+ # @note name or uri must be specified inside resource
75
+ # @return [Boolean] Whether or not resource exists
76
+ def exists?
77
+ raise IncompleteResource, 'Must set resource name or uri before trying to exists?' unless @data['name'] || @data['uri']
78
+ raise IncompleteResource, 'Must set resource storageSystemUri before trying to exists?' unless @data['storageSystemUri']
79
+ return true if @data['name'] && self.class.find_by(@client, name: @data['name'], storageSystemUri: @data['storageSystemUri']).size == 1
80
+ return true if @data['uri'] && self.class.find_by(@client, uri: @data['uri'], storageSystemUri: @data['storageSystemUri']).size == 1
81
+ false
82
+ end
83
+
84
+ # Sets the storage system
85
+ # @param [OneviewSDK::StorageSystem] storage_system
86
+ def set_storage_system(storage_system)
87
+ raise IncompleteResource, 'Please set the storage system\'s uri attribute!' unless storage_system['uri']
88
+ set('storageSystemUri', storage_system['uri'])
89
+ end
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,157 @@
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
+ # Storage system resource implementation
17
+ class StorageSystem < Resource
18
+ BASE_URI = '/rest/storage-systems'.freeze
19
+ UNIQUE_IDENTIFIERS = %w(name uri serialNumber wwn).freeze # credentials['ip_hostname'] is supported too
20
+
21
+ # Remove resource from OneView
22
+ # @return [true] if resource was removed successfully
23
+ alias remove delete
24
+
25
+ # Create a resource object, associate it with a client, and set its properties.
26
+ # @param [OneviewSDK::Client] client The client object for the OneView appliance
27
+ # @param [Hash] params The options for this resource (key-value pairs)
28
+ # @param [Integer] api_ver The api version to use when interracting with this resource.
29
+ def initialize(client, params = {}, api_ver = nil)
30
+ super
31
+ # Default values:
32
+ @data['type'] ||= 'StorageSystemV3'
33
+ end
34
+
35
+ # Method is not available
36
+ # @raise [OneviewSDK::MethodUnavailable] method is not available
37
+ def create
38
+ unavailable_method
39
+ end
40
+
41
+ # Method is not available
42
+ # @raise [OneviewSDK::MethodUnavailable] method is not available
43
+ def delete
44
+ unavailable_method
45
+ end
46
+
47
+ # Adds the resource to OneView using the current data
48
+ # @note Calls the refresh method to set additional data
49
+ # @return [OneviewSDK::StorageSystem] self
50
+ def add
51
+ ensure_client
52
+ task = @client.rest_post(self.class::BASE_URI, { 'body' => self['credentials'] }, @api_version)
53
+ temp = @data.clone
54
+ task = @client.wait_for(task['uri'] || task['location'])
55
+ @data['uri'] = task['associatedResource']['resourceUri']
56
+ refresh
57
+ temp.delete('credentials')
58
+ update(temp)
59
+ self
60
+ end
61
+
62
+ # Checks if the resource already exists
63
+ # @note one of the UNIQUE_IDENTIFIERS or credentials['ip_hostname'] must be specified in the resource
64
+ # @return [Boolean] Whether or not resource exists
65
+ # @raise [OneviewSDK::IncompleteResource] if required attributes are not filled
66
+ def exists?
67
+ ip_hostname = self['credentials'][:ip_hostname] || self['credentials']['ip_hostname'] rescue nil
68
+ return true if ip_hostname && self.class.find_by(@client, credentials: { ip_hostname: ip_hostname }).size == 1
69
+ super
70
+ rescue IncompleteResource => e
71
+ raise e unless ip_hostname
72
+ false
73
+ end
74
+
75
+ # Retrieves the resource details based on this resource's name or URI.
76
+ # @note one of the UNIQUE_IDENTIFIERS or credentials['ip_hostname'] must be specified in the resource
77
+ # @return [Boolean] Whether or not retrieve was successful
78
+ # @raise [OneviewSDK::IncompleteResource] if required attributes are not filled
79
+ def retrieve!
80
+ ip_hostname = self['credentials'][:ip_hostname] || self['credentials']['ip_hostname'] rescue nil
81
+ if ip_hostname
82
+ results = self.class.find_by(@client, credentials: { ip_hostname: ip_hostname })
83
+ if results.size == 1
84
+ set_all(results[0].data)
85
+ return true
86
+ end
87
+ end
88
+ super
89
+ rescue IncompleteResource => e
90
+ raise e unless ip_hostname
91
+ false
92
+ end
93
+
94
+ # Check the equality of the data for the other resource with this resource.
95
+ # @note Does not check the client, logger, or api_version if another resource is passed in
96
+ # @param [Hash, Resource] other resource or hash to compare the key-value pairs with
97
+ # @example Compare to hash
98
+ # @note Does not check the password in credentials
99
+ # @example myResource.like?(credentials: { ip_hostname: 'res1', username: 'admin', password: 'secret' })
100
+ # myResource = OneviewSDK::Resource.new(client, { name: 'res1', description: 'example'}, 200)
101
+ # myResource.like?(description: '') # returns false
102
+ # myResource.like?(name: 'res1') # returns true
103
+ # @return [Boolean] Whether or not the two objects are alike
104
+ def like?(other)
105
+ if other.is_a? Hash
106
+ other_copy = Marshal.load(Marshal.dump(other))
107
+ else
108
+ other_copy = other.dup
109
+ other_copy.data = Marshal.load(Marshal.dump(other.data))
110
+ end
111
+
112
+ if other_copy['credentials']
113
+ other_copy['credentials'].delete('password') rescue nil
114
+ other_copy['credentials'].delete(:password) rescue nil
115
+ elsif other_copy[:credentials]
116
+ other_copy[:credentials].delete('password') rescue nil
117
+ other_copy[:credentials].delete(:password) rescue nil
118
+ end
119
+
120
+ super(other_copy)
121
+ end
122
+
123
+ # Gets the host types for the storage system resource
124
+ # @param [OneviewSDK::Client] client The client object for the OneView appliance
125
+ # @return [String] response body
126
+ def self.get_host_types(client)
127
+ response = client.rest_get(BASE_URI + '/host-types')
128
+ response.body
129
+ end
130
+
131
+ # Lists the storage pools
132
+ def get_storage_pools
133
+ response = @client.rest_get(@data['uri'] + '/storage-pools')
134
+ response.body
135
+ end
136
+
137
+ # Lists all managed target ports for the specified storage system,
138
+ # or only the one specified
139
+ # @param [String] port Target port
140
+ def get_managed_ports(port = nil)
141
+ response = if port.nil?
142
+ @client.rest_get("#{@data['uri']}/managedPorts")
143
+ else
144
+ @client.rest_get("#{@data['uri']}/managedPorts/#{port}")
145
+ end
146
+ response.body
147
+ end
148
+
149
+ # Refreshes a storage system
150
+ # @param [String] state NotRefreshing, RefreshFailed, RefreshPending, Refreshing
151
+ def set_refresh_state(state)
152
+ @data['refreshState'] = state
153
+ update
154
+ end
155
+ end
156
+ end
157
+ end