oneview-sdk 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -0
- data/CHANGELOG.md +81 -2
- data/README.md +118 -113
- data/Rakefile +11 -0
- data/lib/oneview-sdk/cli.rb +21 -15
- data/lib/oneview-sdk/client.rb +34 -21
- data/lib/oneview-sdk/config_loader.rb +12 -1
- data/lib/oneview-sdk/exceptions.rb +55 -0
- data/lib/oneview-sdk/resource/connection_template.rb +48 -0
- data/lib/oneview-sdk/resource/datacenter.rb +77 -0
- data/lib/oneview-sdk/resource/enclosure.rb +46 -24
- data/lib/oneview-sdk/resource/enclosure_group.rb +20 -36
- data/lib/oneview-sdk/resource/ethernet_network.rb +19 -23
- data/lib/oneview-sdk/resource/fabric.rb +41 -0
- data/lib/oneview-sdk/resource/fc_network.rb +15 -16
- data/lib/oneview-sdk/resource/fcoe_network.rb +15 -12
- data/lib/oneview-sdk/resource/firmware_bundle.rb +23 -24
- data/lib/oneview-sdk/resource/firmware_driver.rb +21 -9
- data/lib/oneview-sdk/resource/interconnect.rb +29 -9
- data/lib/oneview-sdk/resource/lig_uplink_set.rb +22 -28
- data/lib/oneview-sdk/resource/logical_downlink.rb +53 -0
- data/lib/oneview-sdk/resource/logical_enclosure.rb +35 -33
- data/lib/oneview-sdk/resource/logical_interconnect.rb +29 -65
- data/lib/oneview-sdk/resource/logical_interconnect_group.rb +26 -6
- data/lib/oneview-sdk/resource/logical_switch.rb +184 -0
- data/lib/oneview-sdk/resource/logical_switch_group.rb +66 -0
- data/lib/oneview-sdk/resource/managed_san.rb +79 -0
- data/lib/oneview-sdk/resource/network_set.rb +64 -0
- data/lib/oneview-sdk/resource/power_device.rb +174 -0
- data/lib/oneview-sdk/resource/rack.rb +83 -0
- data/lib/oneview-sdk/resource/san_manager.rb +88 -0
- data/lib/oneview-sdk/resource/server_hardware.rb +139 -18
- data/lib/oneview-sdk/resource/server_hardware_type.rb +32 -1
- data/lib/oneview-sdk/resource/server_profile.rb +352 -9
- data/lib/oneview-sdk/resource/server_profile_template.rb +193 -4
- data/lib/oneview-sdk/resource/storage_pool.rb +42 -20
- data/lib/oneview-sdk/resource/storage_system.rb +64 -14
- data/lib/oneview-sdk/resource/switch.rb +86 -0
- data/lib/oneview-sdk/resource/unmanaged_device.rb +55 -0
- data/lib/oneview-sdk/resource/uplink_set.rb +24 -64
- data/lib/oneview-sdk/resource/volume.rb +29 -29
- data/lib/oneview-sdk/resource/volume_attachment.rb +79 -0
- data/lib/oneview-sdk/resource/volume_snapshot.rb +20 -1
- data/lib/oneview-sdk/resource/volume_template.rb +22 -33
- data/lib/oneview-sdk/resource.rb +66 -28
- data/lib/oneview-sdk/rest.rb +69 -24
- data/lib/oneview-sdk/ssl_helper.rb +20 -9
- data/lib/oneview-sdk/version.rb +12 -1
- data/lib/oneview-sdk.rb +12 -0
- data/oneview-sdk.gemspec +11 -0
- metadata +17 -2
@@ -1,41 +1,63 @@
|
|
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
|
+
|
1
12
|
module OneviewSDK
|
2
13
|
# Storage pool resource implementation
|
3
14
|
class StoragePool < Resource
|
4
15
|
BASE_URI = '/rest/storage-pools'.freeze
|
5
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.
|
6
32
|
def initialize(client, params = {}, api_ver = nil)
|
7
33
|
super
|
8
34
|
# Default values:
|
9
35
|
@data['type'] ||= 'StoragePoolV2'
|
10
36
|
end
|
11
37
|
|
12
|
-
#
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
# @param [String] value NotRefreshing, RefreshFailed, RefreshPending, Refreshing
|
17
|
-
def validate_refreshState(value)
|
18
|
-
fail 'Invalid refresh state' unless VALID_REFRESH_STATES.include?(value)
|
19
|
-
end
|
20
|
-
|
21
|
-
VALID_STATUSES = %w(OK Disabled Warning Critical Unknown).freeze
|
22
|
-
# Validate status
|
23
|
-
# @param [String] value OK, Disabled, Warning, Critical, Unknown
|
24
|
-
def validate_status(value)
|
25
|
-
fail 'Invalid status' unless VALID_STATUSES.include?(value)
|
38
|
+
# Method is not available
|
39
|
+
# @raise [OneviewSDK::MethodUnavailable] method is not available
|
40
|
+
def create
|
41
|
+
unavailable_method
|
26
42
|
end
|
27
43
|
|
28
|
-
#
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
def set_storage_system(storage_system)
|
33
|
-
set('storageSystemUri', storage_system['uri'])
|
44
|
+
# Method is not available
|
45
|
+
# @raise [OneviewSDK::MethodUnavailable] method is not available
|
46
|
+
def delete
|
47
|
+
unavailable_method
|
34
48
|
end
|
35
49
|
|
50
|
+
# Method is not available
|
51
|
+
# @raise [OneviewSDK::MethodUnavailable] method is not available
|
36
52
|
def update
|
37
53
|
unavailable_method
|
38
54
|
end
|
39
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
|
40
62
|
end
|
41
63
|
end
|
@@ -1,15 +1,49 @@
|
|
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
|
+
|
1
12
|
module OneviewSDK
|
2
13
|
# Storage system resource implementation
|
3
14
|
class StorageSystem < Resource
|
4
15
|
BASE_URI = '/rest/storage-systems'.freeze
|
5
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.
|
6
25
|
def initialize(client, params = {}, api_ver = nil)
|
7
26
|
super
|
8
27
|
# Default values:
|
9
28
|
@data['type'] ||= 'StorageSystemV3'
|
10
29
|
end
|
11
30
|
|
31
|
+
# Method is not available
|
32
|
+
# @raise [OneviewSDK::MethodUnavailable] method is not available
|
12
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
|
13
47
|
ensure_client
|
14
48
|
task = @client.rest_post(self.class::BASE_URI, { 'body' => self['credentials'] }, @api_version)
|
15
49
|
temp = @data.clone
|
@@ -21,33 +55,50 @@ module OneviewSDK
|
|
21
55
|
self
|
22
56
|
end
|
23
57
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
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!'
|
33
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
|
34
85
|
end
|
35
86
|
|
36
|
-
#
|
37
|
-
# @param [Client] client client
|
87
|
+
# Gets the host types for the storage system resource
|
88
|
+
# @param [OneviewSDK::Client] client The client object for the OneView appliance
|
38
89
|
# @return [String] response body
|
39
90
|
def self.get_host_types(client)
|
40
91
|
response = client.rest_get(BASE_URI + '/host-types')
|
41
92
|
response.body
|
42
93
|
end
|
43
94
|
|
44
|
-
#
|
95
|
+
# Lists the storage pools
|
45
96
|
def get_storage_pools
|
46
97
|
response = @client.rest_get(@data['uri'] + '/storage-pools')
|
47
98
|
response.body
|
48
99
|
end
|
49
100
|
|
50
|
-
#
|
101
|
+
# Lists all managed target ports for the specified storage system,
|
51
102
|
# or only the one specified
|
52
103
|
# @param [String] port Target port
|
53
104
|
def get_managed_ports(port = nil)
|
@@ -58,6 +109,5 @@ module OneviewSDK
|
|
58
109
|
end
|
59
110
|
response.body
|
60
111
|
end
|
61
|
-
|
62
112
|
end
|
63
113
|
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
|
+
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
|
@@ -0,0 +1,55 @@
|
|
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,8 +1,23 @@
|
|
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
|
+
|
1
12
|
module OneviewSDK
|
2
13
|
# Uplink set resource implementation
|
3
14
|
class UplinkSet < Resource
|
4
15
|
BASE_URI = '/rest/uplink-sets'.freeze
|
5
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.
|
6
21
|
def initialize(client, params = {}, api_ver = nil)
|
7
22
|
super
|
8
23
|
# Default values
|
@@ -14,61 +29,7 @@ module OneviewSDK
|
|
14
29
|
@data['type'] ||= 'uplink-setV3'
|
15
30
|
end
|
16
31
|
|
17
|
-
#
|
18
|
-
|
19
|
-
VALID_ETHERNET_NETWORK_TYPES = %w(NotApplicable Tagged Tunnel Unknown Untagged).freeze
|
20
|
-
# Validate ethernetNetworkType
|
21
|
-
# @param [String] value NotApplicable, Tagged, Tunnel, Unknown, Untagged
|
22
|
-
def validate_ethernetNetworkType(value)
|
23
|
-
fail 'Invalid ethernet network type' unless VALID_ETHERNET_NETWORK_TYPES.include?(value)
|
24
|
-
end
|
25
|
-
|
26
|
-
VALID_LACP_TIMERS = %w(Short Long).freeze
|
27
|
-
# Validate lacpTimer
|
28
|
-
# @param [String] value Short, Long
|
29
|
-
def validate_lacpTimer(value)
|
30
|
-
return if value.to_s.empty?
|
31
|
-
fail 'Invalid lacp timer' unless %w(Short Long).include?(value)
|
32
|
-
end
|
33
|
-
|
34
|
-
VALID_MANUAL_LOGIN_REDISTRIBUTION_STATES = %w(Distributed Distributing DistributionFailed NotSupported Supported).freeze
|
35
|
-
# Validate manualLoginRedistributionState
|
36
|
-
# @param [String] value Distributed, Distributing, DistributionFailed, NotSupported, Supported
|
37
|
-
def validate_manualLoginRedistributionState(value)
|
38
|
-
fail 'Invalid manual login redistribution state' unless VALID_MANUAL_LOGIN_REDISTRIBUTION_STATES.include?(value)
|
39
|
-
end
|
40
|
-
|
41
|
-
VALID_NETWORK_TYPES = %w(Ethernet FibreChannel).freeze
|
42
|
-
# Validate networkType
|
43
|
-
# @param [String] value Ethernet, FibreChannel
|
44
|
-
def validate_networkType(value)
|
45
|
-
fail 'Invalid network type' unless VALID_NETWORK_TYPES.include?(value)
|
46
|
-
end
|
47
|
-
|
48
|
-
VALID_LOCATION_ENTRIES_TYPES = %w(Bay Enclosure Ip Password Port StackingDomainId StackingMemberId UserId).freeze
|
49
|
-
# Validate locationEntriesType
|
50
|
-
# @param [String] value Bay Enclosure Ip Password Port StackingDomainId StackingMemberId UserId
|
51
|
-
def validate_locationEntriesType(value)
|
52
|
-
fail 'Invalid location entry type' unless VALID_LOCATION_ENTRIES_TYPES.include?(value)
|
53
|
-
end
|
54
|
-
|
55
|
-
VALID_REACHABILITIES = ['NotReachable', 'Reachable', 'RedundantlyReachable', 'Unknown', nil].freeze
|
56
|
-
# Validate ethernetNetworkType request
|
57
|
-
# @param [String] value NotReachable Reachable RedundantlyReachable Unknown
|
58
|
-
def validate_reachability(value)
|
59
|
-
fail 'Invalid reachability' unless VALID_REACHABILITIES.include?(value)
|
60
|
-
end
|
61
|
-
|
62
|
-
VALID_STATUSES = %w(OK Disabled Warning Critical Unknown).freeze
|
63
|
-
# Validate ethernetNetworkType request
|
64
|
-
# @param [String] value OK Disabled Warning Critical Unknown
|
65
|
-
def validate_status(value)
|
66
|
-
fail 'Invalid status' unless VALID_STATUSES.include?(value)
|
67
|
-
end
|
68
|
-
|
69
|
-
# @!endgroup
|
70
|
-
|
71
|
-
# Add portConfigInfos to the array
|
32
|
+
# Adds the portConfigInfos to the array
|
72
33
|
# @param [String] portUri
|
73
34
|
# @param [String] speed
|
74
35
|
# @param [Hash] locationEntries
|
@@ -83,37 +44,36 @@ module OneviewSDK
|
|
83
44
|
@data['portConfigInfos'] << entry
|
84
45
|
end
|
85
46
|
|
86
|
-
#
|
47
|
+
# Sets the logical interconnect uri
|
87
48
|
# @param [OneviewSDK::LogicalInterconnect, Hash] logical_interconnect
|
88
49
|
def set_logical_interconnect(logical_interconnect)
|
89
50
|
uri = logical_interconnect[:uri] || logical_interconnect['uri']
|
90
|
-
fail 'Invalid object' unless uri
|
51
|
+
fail IncompleteResource, 'Invalid object' unless uri
|
91
52
|
@data['logicalInterconnectUri'] = uri
|
92
53
|
end
|
93
54
|
|
94
|
-
#
|
55
|
+
# Adds an ethernet network to the uplink set
|
95
56
|
# @param [OneviewSDK::EthernetNetwork, Hash] network
|
96
57
|
def add_network(network)
|
97
58
|
uri = network[:uri] || network['uri']
|
98
|
-
fail '
|
59
|
+
fail IncompleteResource, 'Must set network uri attribute' unless uri
|
99
60
|
@data['networkUris'].push(uri)
|
100
61
|
end
|
101
62
|
|
102
|
-
#
|
63
|
+
# Adds an fc network to the uplink set
|
103
64
|
# @param [OneviewSDK::FCNetwork, Hash] network must accept hash syntax
|
104
65
|
def add_fcnetwork(network)
|
105
66
|
uri = network[:uri] || network['uri']
|
106
|
-
fail '
|
67
|
+
fail IncompleteResource, 'Must set network uri attribute' unless uri
|
107
68
|
@data['fcNetworkUris'].push(uri)
|
108
69
|
end
|
109
70
|
|
110
|
-
#
|
71
|
+
# Adds an fcoe network to the uplink set
|
111
72
|
# @param [OneviewSDK::FCoENetwork, Hash] network must accept hash syntax
|
112
73
|
def add_fcoenetwork(network)
|
113
74
|
uri = network[:uri] || network['uri']
|
114
|
-
fail '
|
75
|
+
fail IncompleteResource, 'Must set network uri attribute' unless uri
|
115
76
|
@data['fcoeNetworkUris'].push(uri)
|
116
77
|
end
|
117
|
-
|
118
78
|
end
|
119
79
|
end
|
@@ -1,19 +1,19 @@
|
|
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
|
+
|
1
12
|
module OneviewSDK
|
2
13
|
# Volume resource implementation
|
3
14
|
class Volume < Resource
|
4
15
|
BASE_URI = '/rest/storage-volumes'.freeze
|
5
16
|
|
6
|
-
# @!group Validates
|
7
|
-
|
8
|
-
VALID_PROVISION_TYPES = %w(Thin Full).freeze
|
9
|
-
# Validate the type of provisioning
|
10
|
-
# @param [String] value Must be Thin or Full
|
11
|
-
def validate_provisionType(value)
|
12
|
-
fail 'Invalid provision type' unless VALID_PROVISION_TYPES.include?(value)
|
13
|
-
end
|
14
|
-
|
15
|
-
# @!endgroup
|
16
|
-
|
17
17
|
# It's possible to create the volume in 6 different ways:
|
18
18
|
# 1) Common = Storage System + Storage Pool
|
19
19
|
# 2) Template = Storage Volume Template
|
@@ -22,10 +22,10 @@ module OneviewSDK
|
|
22
22
|
# 5) Management by name = Storage System + Storage System Volume Name
|
23
23
|
# 6) Snapshot = Snapshot Pool + Storage Pool + Snapshot
|
24
24
|
|
25
|
-
#
|
26
|
-
# @note
|
27
|
-
# @raise [
|
28
|
-
# @raise [
|
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
29
|
# @return [Resource] self
|
30
30
|
def create
|
31
31
|
ensure_client
|
@@ -36,7 +36,7 @@ module OneviewSDK
|
|
36
36
|
self
|
37
37
|
end
|
38
38
|
|
39
|
-
#
|
39
|
+
# Deletes the resource from OneView or from Oneview and storage system
|
40
40
|
# @param [Symbol] flag Delete storage system from Oneview only or in storage system as well
|
41
41
|
# @return [true] if resource was deleted successfully
|
42
42
|
def delete(flag = :all)
|
@@ -49,7 +49,7 @@ module OneviewSDK
|
|
49
49
|
response = @client.rest_api(:delete, @data['uri'], {}, @api_version)
|
50
50
|
@client.response_handler(response)
|
51
51
|
else
|
52
|
-
fail 'Invalid flag value, use :oneview or :all'
|
52
|
+
fail InvalidResource, 'Invalid flag value, use :oneview or :all'
|
53
53
|
end
|
54
54
|
true
|
55
55
|
end
|
@@ -65,10 +65,11 @@ module OneviewSDK
|
|
65
65
|
# @param [OneviewSDK::StoragePool] storage_pool Storage pool
|
66
66
|
def set_storage_pool(storage_pool)
|
67
67
|
assure_uri(storage_pool)
|
68
|
-
|
68
|
+
self['provisioningParameters'] ||= {}
|
69
|
+
self['provisioningParameters']['storagePoolUri'] = storage_pool['uri']
|
69
70
|
end
|
70
71
|
|
71
|
-
# Adds storage volume template to the volume
|
72
|
+
# Adds the storage volume template to the volume
|
72
73
|
# @param [OneviewSDK::VolumeTemplate] storage_volume_template Storage Volume Template
|
73
74
|
def set_storage_volume_template(storage_volume_template)
|
74
75
|
assure_uri(storage_volume_template)
|
@@ -82,7 +83,7 @@ module OneviewSDK
|
|
82
83
|
set('snapshotPoolUri', storage_pool['uri'])
|
83
84
|
end
|
84
85
|
|
85
|
-
#
|
86
|
+
# Creates a snapshot of the volume
|
86
87
|
# @param [String, OneviewSDK::VolumeSnapshot] snapshot String or OneviewSDK::VolumeSnapshot object
|
87
88
|
# @param [String] description Provide a description
|
88
89
|
# @return [true] if snapshot was created successfully
|
@@ -104,7 +105,7 @@ module OneviewSDK
|
|
104
105
|
true
|
105
106
|
end
|
106
107
|
|
107
|
-
#
|
108
|
+
# Deletes a snapshot of the volume
|
108
109
|
# @param [String] name snapshot name
|
109
110
|
# @return [true] if snapshot was created successfully
|
110
111
|
def delete_snapshot(name)
|
@@ -114,7 +115,7 @@ module OneviewSDK
|
|
114
115
|
true
|
115
116
|
end
|
116
117
|
|
117
|
-
#
|
118
|
+
# Retrieves a snapshot by name
|
118
119
|
# @param [String] name
|
119
120
|
# @return [Hash] snapshot data
|
120
121
|
def get_snapshot(name)
|
@@ -124,7 +125,7 @@ module OneviewSDK
|
|
124
125
|
end
|
125
126
|
end
|
126
127
|
|
127
|
-
#
|
128
|
+
# Gets all the snapshots of this volume
|
128
129
|
# @return [Array] Array of snapshots
|
129
130
|
def get_snapshots
|
130
131
|
ensure_uri && ensure_client
|
@@ -143,8 +144,8 @@ module OneviewSDK
|
|
143
144
|
results
|
144
145
|
end
|
145
146
|
|
146
|
-
#
|
147
|
-
# @param [Client] client The client object for the appliance
|
147
|
+
# Gets all the attachable volumes managed by the appliance
|
148
|
+
# @param [OneviewSDK::Client] client The client object for the OneView appliance
|
148
149
|
# @return [Array<OneviewSDK::Volume>] Array of volumes
|
149
150
|
def self.get_attachable_volumes(client)
|
150
151
|
results = []
|
@@ -161,14 +162,14 @@ module OneviewSDK
|
|
161
162
|
end
|
162
163
|
|
163
164
|
# Gets the list of extra managed storage volume paths
|
164
|
-
# @param [OneviewSDK::Client] client
|
165
|
+
# @param [OneviewSDK::Client] client The client object for the OneView appliance
|
165
166
|
# @return response
|
166
167
|
def self.get_extra_managed_volume_paths(client)
|
167
168
|
response = client.rest_get(BASE_URI + '/repair?alertFixType=ExtraManagedStorageVolumePaths')
|
168
169
|
client.response_handler(response)
|
169
170
|
end
|
170
171
|
|
171
|
-
# Removes extra presentation from volume
|
172
|
+
# Removes extra presentation from the volume
|
172
173
|
# @return response
|
173
174
|
def repair
|
174
175
|
response = client.rest_post(BASE_URI + '/repair', 'body' => { resourceUri: @data['uri'], type: 'ExtraManagedStorageVolumePaths' })
|
@@ -181,8 +182,7 @@ module OneviewSDK
|
|
181
182
|
# If not, first it tries to retrieve, and then verify for its existence
|
182
183
|
def assure_uri(resource)
|
183
184
|
resource.retrieve! unless resource['uri']
|
184
|
-
fail "#{resource.class}: #{resource['name']} not found" unless resource['uri']
|
185
|
+
fail IncompleteResource, "#{resource.class}: #{resource['name']} not found" unless resource['uri']
|
185
186
|
end
|
186
|
-
|
187
187
|
end
|
188
188
|
end
|