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,63 +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
- # Storage pool resource implementation
14
- class StoragePool < Resource
15
- BASE_URI = '/rest/storage-pools'.freeze
16
-
17
- # Add the resource on OneView using the current data
18
- # @note Calls the refresh method to set additional data
19
- # @raise [OneviewSDK::IncompleteResource] if the client is not set
20
- # @raise [StandardError] if the resource creation fails
21
- # @return [OneviewSDK::StoragePool] self
22
- alias add create
23
-
24
- # Remove resource from OneView
25
- # @return [true] if resource was removed successfully
26
- alias remove delete
27
-
28
- # Create a resource object, associate it with a client, and set its properties.
29
- # @param [OneviewSDK::Client] client The client object for the OneView appliance
30
- # @param [Hash] params The options for this resource (key-value pairs)
31
- # @param [Integer] api_ver The api version to use when interracting with this resource.
32
- def initialize(client, params = {}, api_ver = nil)
33
- super
34
- # Default values:
35
- @data['type'] ||= 'StoragePoolV2'
36
- end
37
-
38
- # Method is not available
39
- # @raise [OneviewSDK::MethodUnavailable] method is not available
40
- def create
41
- unavailable_method
42
- end
43
-
44
- # Method is not available
45
- # @raise [OneviewSDK::MethodUnavailable] method is not available
46
- def delete
47
- unavailable_method
48
- end
49
-
50
- # Method is not available
51
- # @raise [OneviewSDK::MethodUnavailable] method is not available
52
- def update
53
- unavailable_method
54
- end
55
-
56
- # Sets the storage system
57
- # @param [OneviewSDK::StorageSystem] storage_system
58
- def set_storage_system(storage_system)
59
- fail IncompleteResource, 'Please set the storage system\'s uri attribute!' unless storage_system['uri']
60
- set('storageSystemUri', storage_system['uri'])
61
- end
62
- end
63
- end
@@ -1,113 +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
- # Storage system resource implementation
14
- class StorageSystem < Resource
15
- BASE_URI = '/rest/storage-systems'.freeze
16
-
17
- # Remove resource from OneView
18
- # @return [true] if resource was removed successfully
19
- alias remove delete
20
-
21
- # Create a resource object, associate it with a client, and set its properties.
22
- # @param [OneviewSDK::Client] client The client object for the OneView appliance
23
- # @param [Hash] params The options for this resource (key-value pairs)
24
- # @param [Integer] api_ver The api version to use when interracting with this resource.
25
- def initialize(client, params = {}, api_ver = nil)
26
- super
27
- # Default values:
28
- @data['type'] ||= 'StorageSystemV3'
29
- end
30
-
31
- # Method is not available
32
- # @raise [OneviewSDK::MethodUnavailable] method is not available
33
- def create
34
- unavailable_method
35
- end
36
-
37
- # Method is not available
38
- # @raise [OneviewSDK::MethodUnavailable] method is not available
39
- def delete
40
- unavailable_method
41
- end
42
-
43
- # Adds the resource to OneView using the current data
44
- # @note Calls the refresh method to set additional data
45
- # @return [OneviewSDK::StorageSystem] self
46
- def add
47
- ensure_client
48
- task = @client.rest_post(self.class::BASE_URI, { 'body' => self['credentials'] }, @api_version)
49
- temp = @data.clone
50
- task = @client.wait_for(task['uri'] || task['location'])
51
- @data['uri'] = task['associatedResource']['resourceUri']
52
- refresh
53
- temp.delete('credentials')
54
- update(temp)
55
- self
56
- end
57
-
58
- # Checks if the resource already exists
59
- # @note name,uri or ip_hostname must be specified inside resource
60
- # @return [Boolean] Whether or not resource exists
61
- def exists?
62
- ip_hostname = self['credentials'][:ip_hostname] || self['credentials']['ip_hostname'] if self['credentials']
63
- return true if @data['name'] && self.class.find_by(@client, name: @data['name']).size == 1
64
- return true if @data['uri'] && self.class.find_by(@client, uri: @data['uri']).size == 1
65
- return true if ip_hostname && self.class.find_by(@client, credentials: { ip_hostname: ip_hostname }).size == 1
66
- unless @data['name'] || @data['uri'] || ip_hostname
67
- fail IncompleteResource, 'Must set resource name, uri or ip_hostname before trying to retrieve!'
68
- end
69
- false
70
- end
71
-
72
- # Retrieves the resource details based on this resource's name or URI.
73
- # @note Name,URI or ip_hostname must be specified inside resource
74
- # @return [Boolean] Whether or not retrieve was successful
75
- # @raise [OneviewSDK::IncompleteResource] if attributes are not filled
76
- def retrieve!
77
- ip_hostname = self['credentials'][:ip_hostname] || self['credentials']['ip_hostname'] if self['credentials']
78
- return super if @data['name'] || @data['uri']
79
-
80
- fail IncompleteResource, 'Must set resource name, uri or ip_hostname before trying to retrieve!' unless ip_hostname
81
- results = self.class.find_by(@client, credentials: { ip_hostname: ip_hostname })
82
- return false unless results.size == 1
83
- set_all(results[0].data)
84
- true
85
- end
86
-
87
- # Gets the host types for the storage system resource
88
- # @param [OneviewSDK::Client] client The client object for the OneView appliance
89
- # @return [String] response body
90
- def self.get_host_types(client)
91
- response = client.rest_get(BASE_URI + '/host-types')
92
- response.body
93
- end
94
-
95
- # Lists the storage pools
96
- def get_storage_pools
97
- response = @client.rest_get(@data['uri'] + '/storage-pools')
98
- response.body
99
- end
100
-
101
- # Lists all managed target ports for the specified storage system,
102
- # or only the one specified
103
- # @param [String] port Target port
104
- def get_managed_ports(port = nil)
105
- response = if port.nil?
106
- @client.rest_get("#{@data['uri']}/managedPorts")
107
- else
108
- @client.rest_get("#{@data['uri']}/managedPorts/#{port}")
109
- end
110
- response.body
111
- end
112
- end
113
- 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
- # Switch resource implementation
14
- class Switch < Resource
15
- BASE_URI = '/rest/switches'.freeze
16
- TYPE_URI = '/rest/switch-types'.freeze
17
-
18
- # Remove resource from OneView
19
- # @return [true] if resource was removed successfully
20
- alias remove delete
21
-
22
- # Method is not available
23
- # @raise [OneviewSDK::MethodUnavailable] method is not available
24
- def create
25
- unavailable_method
26
- end
27
-
28
- # Method is not available
29
- # @raise [OneviewSDK::MethodUnavailable] method is not available
30
- def update
31
- unavailable_method
32
- end
33
-
34
- # Method is not available
35
- # @raise [OneviewSDK::MethodUnavailable] method is not available
36
- def refresh
37
- unavailable_method
38
- end
39
-
40
- # Method is not available
41
- # @raise [OneviewSDK::MethodUnavailable] method is not available
42
- def delete
43
- unavailable_method
44
- end
45
-
46
- # Retrieves the switch types
47
- # @param [OneviewSDK::Client] client The client object for the OneView appliance
48
- # @return [Array] All the Switch types
49
- def self.get_types(client)
50
- response = client.rest_get(TYPE_URI)
51
- response = client.response_handler(response)
52
- response['members']
53
- end
54
-
55
- # Retrieves the switch type with the name
56
- # @param [OneviewSDK::Client] client The client object for the OneView appliance
57
- # @param [String] name Switch type name
58
- # @return [Array] Switch type
59
- def self.get_type(client, name)
60
- results = get_types(client)
61
- results.find { |switch_type| switch_type['name'] == name }
62
- end
63
-
64
- # Get statistics for an interconnect, for the specified port or subport
65
- # @param [String] port_name port to retrieve statistics
66
- # @param [String] subport_number subport to retrieve statistics
67
- # @return [Hash] Switch statistics
68
- def statistics(port_name = nil, subport_number = nil)
69
- uri = if subport_number
70
- "#{@data['uri']}/statistics/#{port_name}/subport/#{subport_number}"
71
- else
72
- "#{@data['uri']}/statistics/#{port_name}"
73
- end
74
- response = @client.rest_get(uri)
75
- response.body
76
- end
77
-
78
- # Get settings that describe the environmental configuration
79
- # @return [Hash] Configuration parameters
80
- def environmental_configuration
81
- ensure_client && ensure_uri
82
- response = @client.rest_get(@data['uri'] + '/environmentalConfiguration', @api_version)
83
- @client.response_handler(response)
84
- end
85
- end
86
- end
@@ -1,55 +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
- # Storage system resource implementation
14
- class UnmanagedDevice < Resource
15
- BASE_URI = '/rest/unmanaged-devices'.freeze
16
-
17
- # Add the resource on OneView using the current data
18
- # @note Calls the refresh method to set additional data
19
- # @raise [OneviewSDK::IncompleteResource] if the client is not set
20
- # @raise [StandardError] if the resource creation fails
21
- # @return [OneviewSDK::UnmanagedDevice] self
22
- alias add create
23
-
24
- # Remove resource from OneView
25
- # @return [true] if resource was removed successfully
26
- alias remove delete
27
-
28
- # Method is not available
29
- # @raise [OneviewSDK::MethodUnavailable] method is not available
30
- def create
31
- unavailable_method
32
- end
33
-
34
- # Method is not available
35
- # @raise [OneviewSDK::MethodUnavailable] method is not available
36
- def delete
37
- unavailable_method
38
- end
39
-
40
- # Gets a list of unmanaged devices
41
- # @param [OneviewSDK::Client] client The client object for the OneView appliance
42
- # @return [Array] list of unmanaged devices
43
- def self.get_devices(client)
44
- response = client.rest_get(BASE_URI)
45
- client.response_handler(response)['members']
46
- end
47
-
48
- # Get settings that describe the environmental configuration
49
- def environmental_configuration
50
- ensure_client && ensure_uri
51
- response = @client.rest_get(@data['uri'] + '/environmentalConfiguration')
52
- @client.response_handler(response)
53
- end
54
- end
55
- end
@@ -1,79 +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 set resource implementation
14
- class UplinkSet < Resource
15
- BASE_URI = '/rest/uplink-sets'.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['fcNetworkUris'] ||= []
25
- @data['fcoeNetworkUris'] ||= []
26
- @data['networkUris'] ||= []
27
- @data['portConfigInfos'] ||= []
28
- @data['primaryPortLocation'] = nil
29
- @data['type'] ||= 'uplink-setV3'
30
- end
31
-
32
- # Adds the portConfigInfos to the array
33
- # @param [String] portUri
34
- # @param [String] speed
35
- # @param [Hash] locationEntries
36
- def add_port_config(portUri, speed, locationEntries)
37
- entry = {
38
- 'portUri' => portUri,
39
- 'desiredSpeed' => speed,
40
- 'location' => {
41
- 'locationEntries' => locationEntries
42
- }
43
- }
44
- @data['portConfigInfos'] << entry
45
- end
46
-
47
- # Sets the logical interconnect uri
48
- # @param [OneviewSDK::LogicalInterconnect, Hash] logical_interconnect
49
- def set_logical_interconnect(logical_interconnect)
50
- uri = logical_interconnect[:uri] || logical_interconnect['uri']
51
- fail IncompleteResource, 'Invalid object' unless uri
52
- @data['logicalInterconnectUri'] = uri
53
- end
54
-
55
- # Adds an ethernet network to the uplink set
56
- # @param [OneviewSDK::EthernetNetwork, Hash] network
57
- def add_network(network)
58
- uri = network[:uri] || network['uri']
59
- fail IncompleteResource, 'Must set network uri attribute' unless uri
60
- @data['networkUris'].push(uri)
61
- end
62
-
63
- # Adds an fc network to the uplink set
64
- # @param [OneviewSDK::FCNetwork, Hash] network must accept hash syntax
65
- def add_fcnetwork(network)
66
- uri = network[:uri] || network['uri']
67
- fail IncompleteResource, 'Must set network uri attribute' unless uri
68
- @data['fcNetworkUris'].push(uri)
69
- end
70
-
71
- # Adds an fcoe network to the uplink set
72
- # @param [OneviewSDK::FCoENetwork, Hash] network must accept hash syntax
73
- def add_fcoenetwork(network)
74
- uri = network[:uri] || network['uri']
75
- fail IncompleteResource, 'Must set network uri attribute' unless uri
76
- @data['fcoeNetworkUris'].push(uri)
77
- end
78
- end
79
- end
@@ -1,188 +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
- # Volume resource implementation
14
- class Volume < Resource
15
- BASE_URI = '/rest/storage-volumes'.freeze
16
-
17
- # It's possible to create the volume in 6 different ways:
18
- # 1) Common = Storage System + Storage Pool
19
- # 2) Template = Storage Volume Template
20
- # 3) Common with snapshots = Storage System + Storage Pool + Snapshot Pool
21
- # 4) Management = Storage System + wwn
22
- # 5) Management by name = Storage System + Storage System Volume Name
23
- # 6) Snapshot = Snapshot Pool + Storage Pool + Snapshot
24
-
25
- # Creates the volume
26
- # @note provisioning parameters are required for creation, but not afterwards; after creation, they will be removed.
27
- # @raise [OneviewSDK::IncompleteResource] if the client is not set
28
- # @raise [StandardError] if the resource creation fails
29
- # @return [Resource] self
30
- def create
31
- ensure_client
32
- response = @client.rest_post(self.class::BASE_URI, { 'body' => @data }, @api_version)
33
- body = @client.response_handler(response)
34
- set_all(body)
35
- @data.delete('provisioningParameters')
36
- self
37
- end
38
-
39
- # Deletes the resource from OneView or from Oneview and storage system
40
- # @param [Symbol] flag Delete storage system from Oneview only or in storage system as well
41
- # @return [true] if resource was deleted successfully
42
- def delete(flag = :all)
43
- ensure_client && ensure_uri
44
- case flag
45
- when :oneview
46
- response = @client.rest_api(:delete, @data['uri'], { 'exportOnly' => true }, @api_version)
47
- @client.response_handler(response)
48
- when :all
49
- response = @client.rest_api(:delete, @data['uri'], {}, @api_version)
50
- @client.response_handler(response)
51
- else
52
- fail InvalidResource, 'Invalid flag value, use :oneview or :all'
53
- end
54
- true
55
- end
56
-
57
- # Sets the storage system to the volume
58
- # @param [OneviewSDK::StorageSystem] storage_system Storage System
59
- def set_storage_system(storage_system)
60
- assure_uri(storage_system)
61
- set('storageSystemUri', storage_system['uri'])
62
- end
63
-
64
- # Sets the storage pool to the volume
65
- # @param [OneviewSDK::StoragePool] storage_pool Storage pool
66
- def set_storage_pool(storage_pool)
67
- assure_uri(storage_pool)
68
- self['provisioningParameters'] ||= {}
69
- self['provisioningParameters']['storagePoolUri'] = storage_pool['uri']
70
- end
71
-
72
- # Adds the storage volume template to the volume
73
- # @param [OneviewSDK::VolumeTemplate] storage_volume_template Storage Volume Template
74
- def set_storage_volume_template(storage_volume_template)
75
- assure_uri(storage_volume_template)
76
- set('templateUri', storage_volume_template['uri'])
77
- end
78
-
79
- # Sets the snapshot pool to the volume
80
- # @param [OneviewSDK::StoragePool] storage_pool Storage Pool to use for snapshots
81
- def set_snapshot_pool(storage_pool)
82
- assure_uri(storage_pool)
83
- set('snapshotPoolUri', storage_pool['uri'])
84
- end
85
-
86
- # Creates a snapshot of the volume
87
- # @param [String, OneviewSDK::VolumeSnapshot] snapshot String or OneviewSDK::VolumeSnapshot object
88
- # @param [String] description Provide a description
89
- # @return [true] if snapshot was created successfully
90
- def create_snapshot(snapshot, description = nil)
91
- ensure_uri && ensure_client
92
- if snapshot.is_a?(OneviewSDK::Resource) || snapshot.is_a?(Hash)
93
- name = snapshot[:name] || snapshot['name']
94
- description ||= snapshot[:description] || snapshot['description']
95
- else
96
- name = snapshot
97
- end
98
- data = {
99
- type: 'Snapshot',
100
- description: description,
101
- name: name
102
- }
103
- response = @client.rest_post("#{@data['uri']}/snapshots", { 'body' => data }, @api_version)
104
- @client.response_handler(response)
105
- true
106
- end
107
-
108
- # Deletes a snapshot of the volume
109
- # @param [String] name snapshot name
110
- # @return [true] if snapshot was created successfully
111
- def delete_snapshot(name)
112
- result = get_snapshot(name)
113
- response = @client.rest_api(:delete, result['uri'], {}, @api_version)
114
- @client.response_handler(response)
115
- true
116
- end
117
-
118
- # Retrieves a snapshot by name
119
- # @param [String] name
120
- # @return [Hash] snapshot data
121
- def get_snapshot(name)
122
- results = get_snapshots
123
- results.each do |snapshot|
124
- return snapshot if snapshot['name'] == name
125
- end
126
- end
127
-
128
- # Gets all the snapshots of this volume
129
- # @return [Array] Array of snapshots
130
- def get_snapshots
131
- ensure_uri && ensure_client
132
- results = []
133
- uri = "#{@data['uri']}/snapshots"
134
- loop do
135
- response = @client.rest_get(uri, @api_version)
136
- body = @client.response_handler(response)
137
- members = body['members']
138
- members.each do |member|
139
- results.push(member)
140
- end
141
- break unless body['nextPageUri']
142
- uri = body['nextPageUri']
143
- end
144
- results
145
- end
146
-
147
- # Gets all the attachable volumes managed by the appliance
148
- # @param [OneviewSDK::Client] client The client object for the OneView appliance
149
- # @return [Array<OneviewSDK::Volume>] Array of volumes
150
- def self.get_attachable_volumes(client)
151
- results = []
152
- uri = "#{BASE_URI}/attachable-volumes"
153
- loop do
154
- response = client.rest_get(uri)
155
- body = client.response_handler(response)
156
- members = body['members']
157
- members.each { |member| results.push(OneviewSDK::Volume.new(client, member)) }
158
- break unless body['nextPageUri']
159
- uri = body['nextPageUri']
160
- end
161
- results
162
- end
163
-
164
- # Gets the list of extra managed storage volume paths
165
- # @param [OneviewSDK::Client] client The client object for the OneView appliance
166
- # @return response
167
- def self.get_extra_managed_volume_paths(client)
168
- response = client.rest_get(BASE_URI + '/repair?alertFixType=ExtraManagedStorageVolumePaths')
169
- client.response_handler(response)
170
- end
171
-
172
- # Removes extra presentation from the volume
173
- # @return response
174
- def repair
175
- response = client.rest_post(BASE_URI + '/repair', 'body' => { resourceUri: @data['uri'], type: 'ExtraManagedStorageVolumePaths' })
176
- client.response_handler(response)
177
- end
178
-
179
- private
180
-
181
- # Verify if the resource has a URI
182
- # If not, first it tries to retrieve, and then verify for its existence
183
- def assure_uri(resource)
184
- resource.retrieve! unless resource['uri']
185
- fail IncompleteResource, "#{resource.class}: #{resource['name']} not found" unless resource['uri']
186
- end
187
- end
188
- end