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,37 +1,36 @@
|
|
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
|
# Firmware bundle resource implementation
|
3
14
|
class FirmwareBundle
|
4
15
|
BASE_URI = '/rest/firmware-bundles'.freeze
|
5
|
-
BOUNDARY = '
|
16
|
+
BOUNDARY = '----011000010111000001101001'.freeze
|
6
17
|
|
7
|
-
#
|
8
|
-
# @param [OneviewSDK::Client] client
|
18
|
+
# Uploads a firmware bundle file
|
19
|
+
# @param [OneviewSDK::Client] client The client object for the OneView appliance
|
9
20
|
# @param [String] file_path
|
10
21
|
# @return [OneviewSDK::FirmwareDriver] if the upload was sucessful, return a FirmwareDriver object
|
11
|
-
def self.
|
12
|
-
fail "ERROR: File '#{file_path}' not found!" unless File.file?(file_path)
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
body
|
20
|
-
body << "Content-Disposition: form-data; name=\"file\"; filename=\"#{File.basename(file_path)}\"\r\n"
|
21
|
-
body << "Content-Type: #{type}\r\n\r\n"
|
22
|
-
body << File.read(file_path)
|
23
|
-
body << "\r\n--#{BOUNDARY}--"
|
24
|
-
|
25
|
-
options = {
|
26
|
-
'Content-Type' => "multipart/form-data; boundary=#{BOUNDARY}",
|
27
|
-
'uploadfilename' => File.basename(file_path),
|
28
|
-
'body' => body
|
29
|
-
}
|
30
|
-
|
22
|
+
def self.add(client, file_path)
|
23
|
+
fail NotFound, "ERROR: File '#{file_path}' not found!" unless File.file?(file_path)
|
24
|
+
options = {}
|
25
|
+
options['Content-Type'] = "multipart/form-data; boundary=#{BOUNDARY}"
|
26
|
+
options['uploadfilename'] = File.basename(file_path)
|
27
|
+
options['body'] = "--#{BOUNDARY}\r\n"
|
28
|
+
options['body'] << "Content-Disposition: form-data; name=\"file\"; filename=\"#{File.basename(file_path)}\"\r\n"
|
29
|
+
options['body'] << "Content-Type: application/octet-stream; Content-Transfer-Encoding: binary\r\n\r\n"
|
30
|
+
options['body'] << "#{IO.binread(file_path)}\r\n--#{BOUNDARY}--"
|
31
31
|
response = client.rest_post(BASE_URI, options)
|
32
32
|
data = client.response_handler(response)
|
33
33
|
OneviewSDK::FirmwareDriver.new(client, data)
|
34
34
|
end
|
35
|
-
|
36
35
|
end
|
37
36
|
end
|
@@ -1,21 +1,33 @@
|
|
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
|
# Firmware driver resource implementation
|
3
14
|
class FirmwareDriver < Resource
|
4
15
|
BASE_URI = '/rest/firmware-drivers'.freeze
|
5
16
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
@data['type'] ||= 'firmware-baselines'
|
10
|
-
end
|
17
|
+
# Remove resource from OneView
|
18
|
+
# @return [true] if resource was removed successfully
|
19
|
+
alias remove delete
|
11
20
|
|
12
|
-
|
13
|
-
|
21
|
+
# Method is not available
|
22
|
+
# @raise [OneviewSDK::MethodUnavailable] method is not available
|
23
|
+
def delete
|
24
|
+
unavailable_method
|
14
25
|
end
|
15
26
|
|
27
|
+
# Method is not available
|
28
|
+
# @raise [OneviewSDK::MethodUnavailable] method is not available
|
16
29
|
def update
|
17
|
-
|
30
|
+
unavailable_method
|
18
31
|
end
|
19
|
-
|
20
32
|
end
|
21
33
|
end
|
@@ -1,35 +1,56 @@
|
|
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
|
# Interconnect resource implementation
|
3
14
|
class Interconnect < Resource
|
4
15
|
BASE_URI = '/rest/interconnects'.freeze
|
5
16
|
TYPE_URI = '/rest/interconnect-types'.freeze
|
6
17
|
|
18
|
+
# Create a resource object, associate it with a client, and set its properties.
|
19
|
+
# @param [OneviewSDK::Client] client The client object for the OneView appliance
|
20
|
+
# @param [Hash] params The options for this resource (key-value pairs)
|
21
|
+
# @param [Integer] api_ver The api version to use when interracting with this resource.
|
7
22
|
def initialize(client, params = {}, api_ver = nil)
|
8
23
|
super
|
9
24
|
end
|
10
25
|
|
26
|
+
# Method is not available
|
27
|
+
# @raise [OneviewSDK::MethodUnavailable] method is not available
|
11
28
|
def create
|
12
29
|
unavailable_method
|
13
30
|
end
|
14
31
|
|
32
|
+
# Method is not available
|
33
|
+
# @raise [OneviewSDK::MethodUnavailable] method is not available
|
15
34
|
def update
|
16
35
|
unavailable_method
|
17
36
|
end
|
18
37
|
|
38
|
+
# Method is not available
|
39
|
+
# @raise [OneviewSDK::MethodUnavailable] method is not available
|
19
40
|
def delete
|
20
41
|
unavailable_method
|
21
42
|
end
|
22
43
|
|
23
|
-
#
|
24
|
-
# @param [Client] client
|
44
|
+
# Retrieves interconnect types
|
45
|
+
# @param [OneviewSDK::Client] client The client object for the OneView appliance
|
25
46
|
def self.get_types(client)
|
26
47
|
response = client.rest_get(TYPE_URI)
|
27
48
|
response = client.response_handler(response)
|
28
49
|
response['members']
|
29
50
|
end
|
30
51
|
|
31
|
-
#
|
32
|
-
# @param [Client] client
|
52
|
+
# Retrieves the interconnect type with name
|
53
|
+
# @param [OneviewSDK::Client] client The client object for the OneView appliance
|
33
54
|
# @param [String] name Interconnect type name
|
34
55
|
# @return [Array] Interconnect type
|
35
56
|
def self.get_type(client, name)
|
@@ -37,7 +58,7 @@ module OneviewSDK
|
|
37
58
|
results.find { |interconnect_type| interconnect_type['name'] == name }
|
38
59
|
end
|
39
60
|
|
40
|
-
#
|
61
|
+
# Retrieves the named servers for this interconnect
|
41
62
|
def name_servers
|
42
63
|
response = @client.rest_get(@data['uri'] + '/nameServers')
|
43
64
|
response.body
|
@@ -68,20 +89,19 @@ module OneviewSDK
|
|
68
89
|
response.body
|
69
90
|
end
|
70
91
|
|
71
|
-
# Triggers
|
92
|
+
# Triggers the reset port protection action
|
72
93
|
def reset_port_protection
|
73
94
|
response = @client.rest_put(@data['uri'] + '/resetportprotection')
|
74
95
|
@client.response_handler(response)
|
75
96
|
end
|
76
97
|
|
77
|
-
#
|
98
|
+
# Updates specific attributes for a given interconnect resource
|
78
99
|
# @param [String] operation operation to be performed
|
79
100
|
# @param [String] path path
|
80
101
|
# @param [String] value value
|
81
|
-
def
|
102
|
+
def patch(operation, path, value)
|
82
103
|
response = @client.rest_patch(@data['uri'], 'body' => [{ op: operation, path: path, value: value }])
|
83
104
|
@client.response_handler(response)
|
84
105
|
end
|
85
|
-
|
86
106
|
end
|
87
107
|
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
|
-
# Uplink
|
13
|
+
# Uplink sets resource implementation to be used in logical interconnect groups
|
3
14
|
class LIGUplinkSet < Resource
|
4
15
|
BASE_URI = '/rest/logical-interconnect-groups'.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:
|
@@ -12,35 +27,15 @@ module OneviewSDK
|
|
12
27
|
@data['networkUris'] ||= []
|
13
28
|
end
|
14
29
|
|
15
|
-
#
|
16
|
-
|
17
|
-
VALID_NETWORK_TYPES = %w(FibreChannel Ethernet).freeze
|
18
|
-
# Validate ethernetNetworkType request
|
19
|
-
# @param [String] value FibreChannel, Ethernet
|
20
|
-
def validate_networkType(value)
|
21
|
-
fail 'Invalid network type' unless VALID_NETWORK_TYPES.include?(value)
|
22
|
-
fail 'Attribute missing' if value == 'Ethernet' && !@data['ethernetNetworkType']
|
23
|
-
fail 'Attribute not supported' if value == 'FibreChannel' && @data['ethernetNetworkType']
|
24
|
-
end
|
25
|
-
|
26
|
-
VALID_ETHERNET_NETWORK_TYPES = %w(NotApplicable Tagged Tunnel Unknown Untagged).freeze
|
27
|
-
# Validate ethernetNetworkType request
|
28
|
-
# @param [String] value Notapplicable, Tagged, Tunnel, Unknown, Untagged. Must exist if networkType is 'Ethernet', otherwise shouldn't.
|
29
|
-
def validate_ethernetNetworkType(value)
|
30
|
-
fail 'Invalid ethernetNetworkType' unless VALID_ETHERNET_NETWORK_TYPES.include?(value)
|
31
|
-
end
|
32
|
-
|
33
|
-
# @!endgroup
|
34
|
-
|
35
|
-
# Add existing network to the network list.
|
30
|
+
# Add an existing network to the network list.
|
36
31
|
# Ethernet and FibreChannel networks are allowed.
|
37
|
-
# @param [OneviewSDK::Resource] network resource to be added to the list
|
32
|
+
# @param [OneviewSDK::Resource] network The resource to be added to the list
|
38
33
|
def add_network(network)
|
39
|
-
|
34
|
+
network.retrieve! unless network['uri']
|
40
35
|
@data['networkUris'] << network['uri']
|
41
36
|
end
|
42
37
|
|
43
|
-
# Specify one uplink passing the
|
38
|
+
# Specify one uplink passing the virtual connect bay and the port to be attached.
|
44
39
|
# @param [Fixnum] bay number to identify the VC
|
45
40
|
# @param [String] port to attach the uplink. Allowed D1..D16 and X1..X10
|
46
41
|
def add_uplink(bay, port)
|
@@ -57,7 +52,7 @@ module OneviewSDK
|
|
57
52
|
@data['logicalPortConfigInfos'] << entry
|
58
53
|
end
|
59
54
|
|
60
|
-
#
|
55
|
+
# Sets all params
|
61
56
|
# @overload sets networkType first
|
62
57
|
def set_all(params = {})
|
63
58
|
params = params.data if params.class <= Resource
|
@@ -77,10 +72,9 @@ module OneviewSDK
|
|
77
72
|
offset = case identifier
|
78
73
|
when 'D' then 0
|
79
74
|
when 'X' then 16
|
80
|
-
else fail "Port not supported: #{identifier} type not found"
|
75
|
+
else fail InvalidResource, "Port not supported: #{identifier} type not found"
|
81
76
|
end
|
82
77
|
port.to_i + offset
|
83
78
|
end
|
84
|
-
|
85
79
|
end
|
86
80
|
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# (C) Copyright 2016 Hewlett Packard Enterprise Development LP
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# You may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
6
|
+
#
|
7
|
+
# Unless required by applicable law or agreed to in writing, software distributed
|
8
|
+
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
9
|
+
# CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
|
10
|
+
# language governing permissions and limitations under the License.
|
11
|
+
|
12
|
+
module OneviewSDK
|
13
|
+
# Logical downlink resource implementation
|
14
|
+
class LogicalDownlink < Resource
|
15
|
+
BASE_URI = '/rest/logical-downlinks'.freeze
|
16
|
+
|
17
|
+
# Method is not available
|
18
|
+
# @raise [OneviewSDK::MethodUnavailable] method is not available
|
19
|
+
def create
|
20
|
+
unavailable_method
|
21
|
+
end
|
22
|
+
|
23
|
+
# Method is not available
|
24
|
+
# @raise [OneviewSDK::MethodUnavailable] method is not available
|
25
|
+
def update
|
26
|
+
unavailable_method
|
27
|
+
end
|
28
|
+
|
29
|
+
# Method is not available
|
30
|
+
# @raise [OneviewSDK::MethodUnavailable] method is not available
|
31
|
+
def delete
|
32
|
+
unavailable_method
|
33
|
+
end
|
34
|
+
|
35
|
+
# Gets a list of logical downlinks, excluding any existing ethernet network
|
36
|
+
# @param [OneviewSDK::Client] client The client object for the OneView appliance
|
37
|
+
# @return [Array<OneviewSDK::LogicalDownlink] Logical downlink array
|
38
|
+
def self.get_without_ethernet(client)
|
39
|
+
result = []
|
40
|
+
response = client.rest_get(BASE_URI + '/withoutEthernet')
|
41
|
+
members = client.response_handler(response)['members']
|
42
|
+
members.each { |member| result << new(client, member) }
|
43
|
+
result
|
44
|
+
end
|
45
|
+
|
46
|
+
# Gets a logical downlink, excluding any existing ethernet network
|
47
|
+
# @return [OneviewSDK::LogicalDownlink] Logical downlink array
|
48
|
+
def get_without_ethernet
|
49
|
+
response = @client.rest_get(@data['uri'] + '/withoutEthernet')
|
50
|
+
OneviewSDK::LogicalDownlink.new(@client, @client.response_handler(response))
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -1,31 +1,34 @@
|
|
1
|
+
# (C) Copyright 2016 Hewlett Packard Enterprise Development LP
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# You may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
6
|
+
#
|
7
|
+
# Unless required by applicable law or agreed to in writing, software distributed
|
8
|
+
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
9
|
+
# CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
|
10
|
+
# language governing permissions and limitations under the License.
|
11
|
+
|
1
12
|
module OneviewSDK
|
2
13
|
# Logical enclosure resource implementation
|
3
14
|
class LogicalEnclosure < Resource
|
4
15
|
BASE_URI = '/rest/logical-enclosures'.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
|
9
24
|
@data['type'] ||= 'LogicalEnclosure'
|
10
25
|
end
|
11
26
|
|
12
|
-
#
|
13
|
-
|
14
|
-
|
15
|
-
#
|
16
|
-
# @
|
17
|
-
# @raise [RuntimeError] if value is not 'DirectAttach' or 'FabricAttach'
|
18
|
-
def validate_fabricType(value)
|
19
|
-
fail 'Invalid fabric type' unless VALID_FABRIC_TYPES.include?(value)
|
20
|
-
end
|
21
|
-
|
22
|
-
# @!endgroup
|
23
|
-
|
24
|
-
# Reapplies the appliance's configuration on enclosures
|
25
|
-
# @raise [RuntimeError] if the client is not set
|
26
|
-
# @raise [RuntimeError] if the uri is not set
|
27
|
-
# @raise [RuntimeError] if the reapply fails
|
28
|
-
# @return [LogicalEnclosure] self
|
27
|
+
# Reapplies the appliance's configuration on the enclosures
|
28
|
+
# @raise [OneviewSDK::IncompleteResource] if the client is not set
|
29
|
+
# @raise [OneviewSDK::IncompleteResource] if the uri is not set
|
30
|
+
# @raise [StandardError] if the reapply fails
|
31
|
+
# @return [OneviewSDK::LogicalEnclosure] self
|
29
32
|
def reconfigure
|
30
33
|
ensure_client && ensure_uri
|
31
34
|
response = @client.rest_put("#{@data['uri']}/configuration", {}, @api_version)
|
@@ -34,10 +37,10 @@ module OneviewSDK
|
|
34
37
|
end
|
35
38
|
|
36
39
|
# Makes this logical enclosure consistent with the enclosure group
|
37
|
-
# @raise [
|
38
|
-
# @raise [
|
39
|
-
# @raise [
|
40
|
-
# @return [
|
40
|
+
# @raise [OneviewSDK::IncompleteResource] if the client is not set
|
41
|
+
# @raise [OneviewSDK::IncompleteResource] if the uri is not set
|
42
|
+
# @raise [StandardError] if the process fails
|
43
|
+
# @return [OneviewSDK::LogicalEnclosure] self
|
41
44
|
def update_from_group
|
42
45
|
ensure_client && ensure_uri
|
43
46
|
response = @client.rest_put("#{@data['uri']}/updateFromGroup", {}, @api_version)
|
@@ -46,9 +49,9 @@ module OneviewSDK
|
|
46
49
|
end
|
47
50
|
|
48
51
|
# Get the configuration script
|
49
|
-
# @raise [
|
50
|
-
# @raise [
|
51
|
-
# @raise [
|
52
|
+
# @raise [OneviewSDK::IncompleteResource] if the client is not set
|
53
|
+
# @raise [OneviewSDK::IncompleteResource] if the uri is not set
|
54
|
+
# @raise [StandardError] if retrieving fails
|
52
55
|
# @return [String] script
|
53
56
|
def get_script
|
54
57
|
ensure_client && ensure_uri
|
@@ -57,10 +60,10 @@ module OneviewSDK
|
|
57
60
|
end
|
58
61
|
|
59
62
|
# Updates the configuration script for the logical enclosure
|
60
|
-
# @raise [
|
61
|
-
# @raise [
|
62
|
-
# @raise [
|
63
|
-
# @return [
|
63
|
+
# @raise [OneviewSDK::IncompleteResource] if the client is not set
|
64
|
+
# @raise [OneviewSDK::IncompleteResource] if the uri is not set
|
65
|
+
# @raise [StandardError] if the reapply fails
|
66
|
+
# @return [OneviewSDK::LogicalEnclosure] self
|
64
67
|
def set_script(script)
|
65
68
|
ensure_client && ensure_uri
|
66
69
|
response = @client.rest_put("#{@data['uri']}/script", { 'body' => script }, @api_version)
|
@@ -69,16 +72,15 @@ module OneviewSDK
|
|
69
72
|
end
|
70
73
|
|
71
74
|
# Generates a support dump for the logical enclosure
|
72
|
-
# @raise [
|
73
|
-
# @raise [
|
74
|
-
# @raise [
|
75
|
-
# @return [
|
75
|
+
# @raise [OneviewSDK::IncompleteResource] if the client is not set
|
76
|
+
# @raise [OneviewSDK::IncompleteResource] if the uri is not set
|
77
|
+
# @raise [StandardError] if the process fails when generating the support dump
|
78
|
+
# @return [OneviewSDK::LogicalEnclosure] self
|
76
79
|
def support_dump(options)
|
77
80
|
ensure_client && ensure_uri
|
78
81
|
response = @client.rest_post("#{@data['uri']}/support-dumps", { 'body' => options }, @api_version)
|
79
82
|
@client.wait_for(response.header['location'])
|
80
83
|
self
|
81
84
|
end
|
82
|
-
|
83
85
|
end
|
84
86
|
end
|
@@ -1,57 +1,21 @@
|
|
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
|
# Logical interconnect resource implementation
|
3
14
|
class LogicalInterconnect < Resource
|
4
15
|
BASE_URI = '/rest/logical-interconnects'.freeze
|
5
16
|
LOCATION_URI = '/rest/logical-interconnects/locations/interconnects'.freeze
|
6
17
|
|
7
|
-
#
|
8
|
-
|
9
|
-
# Validate ethernet trap categories
|
10
|
-
VALID_ENET_TRAP_CATEGORIES = %w(Other PortStatus PortThresholds).freeze
|
11
|
-
def validate_enet_trap_categories(enet_trap_categories)
|
12
|
-
enet_trap_categories.uniq!
|
13
|
-
enet_trap_categories.each do |cat|
|
14
|
-
fail "Ethernet Trap Category #{cat} is not one of the allowed values: #{VALID_ENET_TRAP_CATEGORIES}" unless
|
15
|
-
VALID_ENET_TRAP_CATEGORIES.include?(cat)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
# Validate fc trap categories
|
20
|
-
VALID_FC_TRAP_CATEGORIES = %w(Other PortStatus).freeze
|
21
|
-
def validate_fc_trap_categories(fc_trap_categories)
|
22
|
-
fc_trap_categories.uniq!
|
23
|
-
fc_trap_categories.each do |cat|
|
24
|
-
fail "FC Trap Category #{cat} is not one of the allowed values: #{VALID_FC_TRAP_CATEGORIES}" unless VALID_FC_TRAP_CATEGORIES.include?(cat)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
# Validate vcm trap categories
|
29
|
-
VALID_VCM_TRAP_CATEGORIES = %w(Legacy).freeze
|
30
|
-
def validate_vcm_trap_categories(vcm_trap_categories)
|
31
|
-
vcm_trap_categories.uniq!
|
32
|
-
vcm_trap_categories.each do |cat|
|
33
|
-
fail "VCM Trap Category #{cat} is not one of the allowed values: #{VALID_VCM_TRAP_CATEGORIES}" unless VALID_VCM_TRAP_CATEGORIES.include?(cat)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
# Validate trap severities
|
38
|
-
VALID_TRAP_SEVERITIES = %w(Critical Info Major Minor Normal Unknown Warning).freeze
|
39
|
-
def validate_trap_severities(trap_severities)
|
40
|
-
trap_severities.uniq!
|
41
|
-
trap_severities.each do |cat|
|
42
|
-
fail "Trap Severities #{cat} is not one of the allowed values: #{VALID_TRAP_SEVERITIES}" unless VALID_TRAP_SEVERITIES.include?(cat)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
# Validate snmp trap format
|
47
|
-
VALID_TRAP_FORMATS = %w(SNMPv1 SNMPv2 SNMPv3).freeze
|
48
|
-
def validate_trap_format(trap_format)
|
49
|
-
fail "Trap Format #{trap_format} is not one of the allowed values: #{VALID_TRAP_FORMATS}" unless VALID_TRAP_FORMATS.include?(trap_format)
|
50
|
-
end
|
51
|
-
|
52
|
-
# @!endgroup
|
53
|
-
|
54
|
-
# Create an Interconnect in the desired Bay in a specified enclosure
|
18
|
+
# Creates an Interconnect in the desired bay in a specified enclosure
|
55
19
|
# WARN: It does not create the LOGICAL INTERCONNECT itself.
|
56
20
|
# It will fail if no interconnect is already present on the specified position
|
57
21
|
# @param [Fixnum] bay_number Number of the bay to put the interconnect
|
@@ -69,9 +33,10 @@ module OneviewSDK
|
|
69
33
|
end
|
70
34
|
|
71
35
|
# Deletes an INTERCONNECT
|
72
|
-
# WARN: This
|
73
|
-
# @param [Fixnum] bay_number
|
74
|
-
# @param [OneviewSDK::
|
36
|
+
# WARN: This will not delete the LOGICAL INTERCONNECT itself, and may cause inconsistency between the enclosure and LIG
|
37
|
+
# @param [Fixnum] bay_number The bay number to locate the logical interconnect
|
38
|
+
# @param [OneviewSDK::Enclosure] enclosure Enclosure to remove the logical interconnect
|
39
|
+
# @return [OneviewSDK::LogicalInterconnect] self
|
75
40
|
def delete(bay_number, enclosure)
|
76
41
|
enclosure.ensure_uri
|
77
42
|
delete_uri = self.class::LOCATION_URI + "?location=Enclosure:#{enclosure['uri']},Bay:#{bay_number}"
|
@@ -114,12 +79,12 @@ module OneviewSDK
|
|
114
79
|
internal_networks
|
115
80
|
end
|
116
81
|
|
117
|
-
# Updates ethernet settings of the
|
82
|
+
# Updates ethernet settings of the logical interconnect
|
118
83
|
# @note The attribute is defined inside the instance of the Logical Interconnect
|
119
84
|
# @return Updated instance of the Logical Interconnect
|
120
85
|
def update_ethernet_settings
|
121
86
|
ensure_client && ensure_uri
|
122
|
-
fail 'Please retrieve the Logical Interconnect before trying to update' unless @data['ethernetSettings']
|
87
|
+
fail IncompleteResource, 'Please retrieve the Logical Interconnect before trying to update' unless @data['ethernetSettings']
|
123
88
|
update_options = {
|
124
89
|
'If-Match' => @data['ethernetSettings'].delete('eTag'),
|
125
90
|
'body' => @data['ethernetSettings']
|
@@ -129,7 +94,7 @@ module OneviewSDK
|
|
129
94
|
set_all(body)
|
130
95
|
end
|
131
96
|
|
132
|
-
# Updates settings of the
|
97
|
+
# Updates settings of the logical interconnect
|
133
98
|
# @param options Options to update the Logical Interconnect
|
134
99
|
# @return Updated instance of the Logical Interconnect
|
135
100
|
def update_settings(options = {})
|
@@ -169,7 +134,7 @@ module OneviewSDK
|
|
169
134
|
# @note The attribute is defined inside the instance of the Logical Interconnect
|
170
135
|
# @return Updated instance of the Logical Interconnect
|
171
136
|
def update_port_monitor
|
172
|
-
fail 'Please retrieve the Logical Interconnect before trying to update' unless @data['portMonitor']
|
137
|
+
fail IncompleteResource, 'Please retrieve the Logical Interconnect before trying to update' unless @data['portMonitor']
|
173
138
|
update_options = {
|
174
139
|
'If-Match' => @data['portMonitor'].delete('eTag'),
|
175
140
|
'body' => @data['portMonitor']
|
@@ -183,7 +148,7 @@ module OneviewSDK
|
|
183
148
|
# @note The attribute is defined inside the instance of the Logical Interconnect
|
184
149
|
# @return Updated instance of the Logical Interconnect
|
185
150
|
def update_qos_configuration
|
186
|
-
fail 'Please retrieve the Logical Interconnect before trying to update' unless @data['qosConfiguration']
|
151
|
+
fail IncompleteResource, 'Please retrieve the Logical Interconnect before trying to update' unless @data['qosConfiguration']
|
187
152
|
update_options = {
|
188
153
|
'If-Match' => @data['qosConfiguration'].delete('eTag'),
|
189
154
|
'body' => @data['qosConfiguration']
|
@@ -197,7 +162,7 @@ module OneviewSDK
|
|
197
162
|
# @note The attribute is defined inside the instance of the Logical Interconnect
|
198
163
|
# @return Updated instance of the Logical Interconnect
|
199
164
|
def update_telemetry_configuration
|
200
|
-
fail 'Please retrieve the Logical Interconnect before trying to update' unless @data['telemetryConfiguration']
|
165
|
+
fail IncompleteResource, 'Please retrieve the Logical Interconnect before trying to update' unless @data['telemetryConfiguration']
|
201
166
|
update_options = {
|
202
167
|
'If-Match' => @data['telemetryConfiguration'].delete('eTag'),
|
203
168
|
'body' => @data['telemetryConfiguration']
|
@@ -212,7 +177,7 @@ module OneviewSDK
|
|
212
177
|
# Use helper methods to add the trap destination values: #add_snmp_trap_destination and #generate_trap_options
|
213
178
|
# @return Updated instance of the Logical Interconnect
|
214
179
|
def update_snmp_configuration
|
215
|
-
fail 'Please retrieve the Logical Interconnect before trying to update' unless @data['snmpConfiguration']
|
180
|
+
fail IncompleteResource, 'Please retrieve the Logical Interconnect before trying to update' unless @data['snmpConfiguration']
|
216
181
|
update_options = {
|
217
182
|
'If-Match' => @data['snmpConfiguration'].delete('eTag'),
|
218
183
|
'body' => @data['snmpConfiguration']
|
@@ -225,10 +190,9 @@ module OneviewSDK
|
|
225
190
|
# It will add one trap destination to the Logical Interconnect SNMP configuration
|
226
191
|
# @param trap_format [String] SNMP version for this trap destination, `'SNMPv1'` or `'SNMPv2'` or `'SNMPv3'`
|
227
192
|
# @param trap_destination [String] The trap destination IP address or host name
|
228
|
-
# @param community_string [String] Authentication string for the trap destination
|
193
|
+
# @param community_string [String] The Authentication string for the trap destination
|
229
194
|
# @param trap_options [Hash] Hash with the options of the trap. Create it using generate_trap_options method
|
230
195
|
def add_snmp_trap_destination(trap_destination, trap_format = 'SNMPv1', community_string = 'public', trap_options = {})
|
231
|
-
validate_trap_format(trap_format)
|
232
196
|
trap_options['communityString'] = community_string
|
233
197
|
trap_options['trapDestination'] = trap_destination
|
234
198
|
trap_options['trapFormat'] = trap_format
|
@@ -245,10 +209,6 @@ module OneviewSDK
|
|
245
209
|
# can contain, `'Critical'` or `'Info'` or `'Major'` or `'Minor'` or `'Normal'` or `'Unknown'` or `'Warning'`
|
246
210
|
# @return [Hash] Contains all trap options for one SNMP destination
|
247
211
|
def generate_trap_options(enet_trap_categories = [], fc_trap_categories = [], vcm_trap_categories = [], trap_severities = [])
|
248
|
-
validate_enet_trap_categories(enet_trap_categories)
|
249
|
-
validate_fc_trap_categories(fc_trap_categories)
|
250
|
-
validate_vcm_trap_categories(vcm_trap_categories)
|
251
|
-
validate_trap_severities(trap_severities)
|
252
212
|
options = {
|
253
213
|
'enetTrapCategories' => enet_trap_categories,
|
254
214
|
'vcmTrapCategories' => vcm_trap_categories,
|
@@ -266,6 +226,11 @@ module OneviewSDK
|
|
266
226
|
@client.response_handler(response)
|
267
227
|
end
|
268
228
|
|
229
|
+
# Update firmware
|
230
|
+
# @param [String] command
|
231
|
+
# @param [OneviewSDK::FirmwareDriver] firmware_driver
|
232
|
+
# @param [Hash] firmware_options
|
233
|
+
# @raise [OneviewSDK::IncompleteResource] if the client or uri is not set
|
269
234
|
def firmware_update(command, firmware_driver, firmware_options)
|
270
235
|
ensure_client && ensure_uri
|
271
236
|
firmware_options['command'] = command
|
@@ -278,6 +243,5 @@ module OneviewSDK
|
|
278
243
|
response = @client.rest_put(@data['uri'] + '/firmware', update_json)
|
279
244
|
@client.response_handler(response)
|
280
245
|
end
|
281
|
-
|
282
246
|
end
|
283
247
|
end
|