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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +50 -0
- data/README.md +61 -15
- data/Rakefile +39 -1
- data/lib/oneview-sdk.rb +38 -3
- data/lib/oneview-sdk/cli.rb +85 -30
- data/lib/oneview-sdk/client.rb +21 -18
- data/lib/oneview-sdk/config_loader.rb +1 -1
- data/lib/oneview-sdk/resource.rb +44 -36
- data/lib/oneview-sdk/resource/api200.rb +34 -0
- data/lib/oneview-sdk/resource/api200/connection_template.rb +52 -0
- data/lib/oneview-sdk/resource/api200/datacenter.rb +81 -0
- data/lib/oneview-sdk/resource/api200/enclosure.rb +203 -0
- data/lib/oneview-sdk/resource/api200/enclosure_group.rb +86 -0
- data/lib/oneview-sdk/resource/api200/ethernet_network.rb +60 -0
- data/lib/oneview-sdk/resource/api200/fabric.rb +45 -0
- data/lib/oneview-sdk/resource/api200/fc_network.rb +34 -0
- data/lib/oneview-sdk/resource/api200/fcoe_network.rb +32 -0
- data/lib/oneview-sdk/resource/api200/firmware_bundle.rb +56 -0
- data/lib/oneview-sdk/resource/{fcoe_network.rb → api200/firmware_driver.rb} +21 -12
- data/lib/oneview-sdk/resource/api200/interconnect.rb +112 -0
- data/lib/oneview-sdk/resource/api200/lig_uplink_set.rb +84 -0
- data/lib/oneview-sdk/resource/api200/logical_downlink.rb +57 -0
- data/lib/oneview-sdk/resource/api200/logical_enclosure.rb +88 -0
- data/lib/oneview-sdk/resource/api200/logical_interconnect.rb +251 -0
- data/lib/oneview-sdk/resource/api200/logical_interconnect_group.rb +116 -0
- data/lib/oneview-sdk/resource/api200/logical_switch.rb +188 -0
- data/lib/oneview-sdk/resource/api200/logical_switch_group.rb +70 -0
- data/lib/oneview-sdk/resource/api200/managed_san.rb +83 -0
- data/lib/oneview-sdk/resource/api200/network_set.rb +68 -0
- data/lib/oneview-sdk/resource/api200/power_device.rb +178 -0
- data/lib/oneview-sdk/resource/api200/rack.rb +88 -0
- data/lib/oneview-sdk/resource/api200/resource.rb +18 -0
- data/lib/oneview-sdk/resource/api200/san_manager.rb +92 -0
- data/lib/oneview-sdk/resource/api200/server_hardware.rb +244 -0
- data/lib/oneview-sdk/resource/api200/server_hardware_type.rb +61 -0
- data/lib/oneview-sdk/resource/api200/server_profile.rb +385 -0
- data/lib/oneview-sdk/resource/api200/server_profile_template.rb +217 -0
- data/lib/oneview-sdk/resource/api200/storage_pool.rb +92 -0
- data/lib/oneview-sdk/resource/api200/storage_system.rb +157 -0
- data/lib/oneview-sdk/resource/api200/switch.rb +91 -0
- data/lib/oneview-sdk/resource/api200/unmanaged_device.rb +59 -0
- data/lib/oneview-sdk/resource/api200/uplink_set.rb +83 -0
- data/lib/oneview-sdk/resource/api200/volume.rb +192 -0
- data/lib/oneview-sdk/resource/api200/volume_attachment.rb +83 -0
- data/lib/oneview-sdk/resource/api200/volume_snapshot.rb +50 -0
- data/lib/oneview-sdk/resource/api200/volume_template.rb +99 -0
- data/lib/oneview-sdk/resource/api300.rb +66 -0
- data/lib/oneview-sdk/resource/api300/c7000.rb +27 -0
- data/lib/oneview-sdk/resource/api300/c7000/connection_template.rb +30 -0
- data/lib/oneview-sdk/resource/api300/c7000/datacenter.rb +22 -0
- data/lib/oneview-sdk/resource/api300/c7000/enclosure.rb +48 -0
- data/lib/oneview-sdk/resource/api300/c7000/enclosure_group.rb +37 -0
- data/lib/oneview-sdk/resource/api300/c7000/ethernet_network.rb +35 -0
- data/lib/oneview-sdk/resource/api300/c7000/fabric.rb +22 -0
- data/lib/oneview-sdk/resource/api300/c7000/fc_network.rb +37 -0
- data/lib/oneview-sdk/resource/api300/c7000/fcoe_network.rb +35 -0
- data/lib/oneview-sdk/resource/api300/c7000/firmware_bundle.rb +21 -0
- data/lib/oneview-sdk/resource/api300/c7000/firmware_driver.rb +22 -0
- data/lib/oneview-sdk/resource/api300/c7000/interconnect.rb +21 -0
- data/lib/oneview-sdk/resource/api300/c7000/lig_uplink_set.rb +21 -0
- data/lib/oneview-sdk/resource/api300/c7000/logical_downlink.rb +34 -0
- data/lib/oneview-sdk/resource/api300/c7000/logical_enclosure.rb +35 -0
- data/lib/oneview-sdk/resource/api300/c7000/logical_interconnect.rb +21 -0
- data/lib/oneview-sdk/resource/api300/c7000/logical_interconnect_group.rb +33 -0
- data/lib/oneview-sdk/resource/api300/c7000/logical_switch.rb +51 -0
- data/lib/oneview-sdk/resource/api300/c7000/logical_switch_group.rb +33 -0
- data/lib/oneview-sdk/resource/api300/c7000/managed_san.rb +36 -0
- data/lib/oneview-sdk/resource/api300/c7000/network_set.rb +37 -0
- data/lib/oneview-sdk/resource/api300/c7000/power_device.rb +21 -0
- data/lib/oneview-sdk/resource/api300/c7000/rack.rb +22 -0
- data/lib/oneview-sdk/resource/api300/c7000/resource.rb +21 -0
- data/lib/oneview-sdk/resource/api300/c7000/san_manager.rb +22 -0
- data/lib/oneview-sdk/resource/api300/c7000/server_hardware.rb +93 -0
- data/lib/oneview-sdk/resource/api300/c7000/server_hardware_type.rb +21 -0
- data/lib/oneview-sdk/resource/api300/c7000/server_profile.rb +33 -0
- data/lib/oneview-sdk/resource/api300/c7000/server_profile_template.rb +50 -0
- data/lib/oneview-sdk/resource/api300/c7000/storage_pool.rb +29 -0
- data/lib/oneview-sdk/resource/api300/c7000/storage_system.rb +21 -0
- data/lib/oneview-sdk/resource/api300/c7000/switch.rb +31 -0
- data/lib/oneview-sdk/resource/api300/c7000/unmanaged_device.rb +21 -0
- data/lib/oneview-sdk/resource/api300/c7000/uplink_set.rb +21 -0
- data/lib/oneview-sdk/resource/api300/c7000/volume.rb +22 -0
- data/lib/oneview-sdk/resource/api300/c7000/volume_attachment.rb +21 -0
- data/lib/oneview-sdk/resource/api300/c7000/volume_snapshot.rb +21 -0
- data/lib/oneview-sdk/resource/api300/c7000/volume_template.rb +32 -0
- data/lib/oneview-sdk/resource/api300/synergy.rb +27 -0
- data/lib/oneview-sdk/resource/api300/synergy/connection_template.rb +30 -0
- data/lib/oneview-sdk/resource/api300/synergy/datacenter.rb +22 -0
- data/lib/oneview-sdk/resource/api300/synergy/drive_enclosure.rb +71 -0
- data/lib/oneview-sdk/resource/api300/synergy/enclosure.rb +110 -0
- data/lib/oneview-sdk/resource/api300/synergy/enclosure_group.rb +43 -0
- data/lib/oneview-sdk/resource/api300/synergy/ethernet_network.rb +35 -0
- data/lib/oneview-sdk/resource/api300/synergy/fabric.rb +46 -0
- data/lib/oneview-sdk/resource/api300/synergy/fc_network.rb +37 -0
- data/lib/oneview-sdk/resource/api300/synergy/fcoe_network.rb +35 -0
- data/lib/oneview-sdk/resource/api300/synergy/firmware_bundle.rb +21 -0
- data/lib/oneview-sdk/resource/api300/synergy/firmware_driver.rb +22 -0
- data/lib/oneview-sdk/resource/api300/synergy/interconnect.rb +43 -0
- data/lib/oneview-sdk/resource/api300/synergy/lig_uplink_set.rb +21 -0
- data/lib/oneview-sdk/resource/api300/synergy/logical_downlink.rb +34 -0
- data/lib/oneview-sdk/resource/api300/synergy/logical_enclosure.rb +59 -0
- data/lib/oneview-sdk/resource/api300/synergy/logical_interconnect.rb +21 -0
- data/lib/oneview-sdk/resource/api300/synergy/logical_interconnect_group.rb +119 -0
- data/lib/oneview-sdk/resource/api300/synergy/logical_switch.rb +33 -0
- data/lib/oneview-sdk/resource/api300/synergy/logical_switch_group.rb +45 -0
- data/lib/oneview-sdk/resource/{firmware_driver.rb → api300/synergy/managed_san.rb} +7 -17
- data/lib/oneview-sdk/resource/api300/synergy/network_set.rb +37 -0
- data/lib/oneview-sdk/resource/api300/synergy/power_device.rb +21 -0
- data/lib/oneview-sdk/resource/api300/synergy/rack.rb +22 -0
- data/lib/oneview-sdk/resource/api300/synergy/resource.rb +21 -0
- data/lib/oneview-sdk/resource/api300/synergy/san_manager.rb +22 -0
- data/lib/oneview-sdk/resource/api300/synergy/sas_interconnect.rb +87 -0
- data/lib/oneview-sdk/resource/api300/synergy/sas_logical_interconnect.rb +110 -0
- data/lib/oneview-sdk/resource/api300/synergy/sas_logical_interconnect_group.rb +87 -0
- data/lib/oneview-sdk/resource/api300/synergy/server_hardware.rb +30 -0
- data/lib/oneview-sdk/resource/api300/synergy/server_hardware_type.rb +21 -0
- data/lib/oneview-sdk/resource/api300/synergy/server_profile.rb +78 -0
- data/lib/oneview-sdk/resource/api300/synergy/server_profile_template.rb +34 -0
- data/lib/oneview-sdk/resource/api300/synergy/storage_pool.rb +22 -0
- data/lib/oneview-sdk/resource/api300/synergy/storage_system.rb +21 -0
- data/lib/oneview-sdk/resource/api300/synergy/switch.rb +37 -0
- data/lib/oneview-sdk/resource/api300/synergy/unmanaged_device.rb +21 -0
- data/lib/oneview-sdk/resource/api300/synergy/uplink_set.rb +21 -0
- data/lib/oneview-sdk/resource/api300/synergy/volume.rb +22 -0
- data/lib/oneview-sdk/resource/api300/synergy/volume_attachment.rb +21 -0
- data/lib/oneview-sdk/resource/api300/synergy/volume_snapshot.rb +21 -0
- data/lib/oneview-sdk/resource/api300/synergy/volume_template.rb +32 -0
- data/lib/oneview-sdk/rest.rb +7 -10
- data/lib/oneview-sdk/ssl_helper.rb +3 -3
- data/lib/oneview-sdk/version.rb +1 -1
- data/oneview-sdk.gemspec +5 -5
- metadata +126 -47
- data/.gitattributes +0 -2
- data/.gitignore +0 -29
- data/.rubocop.yml +0 -80
- data/.travis.yml +0 -12
- data/lib/oneview-sdk/resource/connection_template.rb +0 -48
- data/lib/oneview-sdk/resource/datacenter.rb +0 -77
- data/lib/oneview-sdk/resource/enclosure.rb +0 -191
- data/lib/oneview-sdk/resource/enclosure_group.rb +0 -82
- data/lib/oneview-sdk/resource/ethernet_network.rb +0 -56
- data/lib/oneview-sdk/resource/fabric.rb +0 -41
- data/lib/oneview-sdk/resource/fc_network.rb +0 -30
- data/lib/oneview-sdk/resource/firmware_bundle.rb +0 -50
- data/lib/oneview-sdk/resource/interconnect.rb +0 -107
- data/lib/oneview-sdk/resource/lig_uplink_set.rb +0 -80
- data/lib/oneview-sdk/resource/logical_downlink.rb +0 -53
- data/lib/oneview-sdk/resource/logical_enclosure.rb +0 -86
- data/lib/oneview-sdk/resource/logical_interconnect.rb +0 -247
- data/lib/oneview-sdk/resource/logical_interconnect_group.rb +0 -112
- data/lib/oneview-sdk/resource/logical_switch.rb +0 -184
- data/lib/oneview-sdk/resource/logical_switch_group.rb +0 -66
- data/lib/oneview-sdk/resource/managed_san.rb +0 -79
- data/lib/oneview-sdk/resource/network_set.rb +0 -64
- data/lib/oneview-sdk/resource/power_device.rb +0 -174
- data/lib/oneview-sdk/resource/rack.rb +0 -83
- data/lib/oneview-sdk/resource/san_manager.rb +0 -88
- data/lib/oneview-sdk/resource/server_hardware.rb +0 -209
- data/lib/oneview-sdk/resource/server_hardware_type.rb +0 -58
- data/lib/oneview-sdk/resource/server_profile.rb +0 -380
- data/lib/oneview-sdk/resource/server_profile_template.rb +0 -213
- data/lib/oneview-sdk/resource/storage_pool.rb +0 -63
- data/lib/oneview-sdk/resource/storage_system.rb +0 -113
- data/lib/oneview-sdk/resource/switch.rb +0 -86
- data/lib/oneview-sdk/resource/unmanaged_device.rb +0 -55
- data/lib/oneview-sdk/resource/uplink_set.rb +0 -79
- data/lib/oneview-sdk/resource/volume.rb +0 -188
- data/lib/oneview-sdk/resource/volume_attachment.rb +0 -79
- data/lib/oneview-sdk/resource/volume_snapshot.rb +0 -46
- data/lib/oneview-sdk/resource/volume_template.rb +0 -95
@@ -0,0 +1,116 @@
|
|
1
|
+
# (C) Copyright 2016 Hewlett Packard Enterprise Development LP
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# You may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
6
|
+
#
|
7
|
+
# Unless required by applicable law or agreed to in writing, software distributed
|
8
|
+
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
9
|
+
# CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
|
10
|
+
# language governing permissions and limitations under the License.
|
11
|
+
|
12
|
+
require_relative 'resource'
|
13
|
+
|
14
|
+
module OneviewSDK
|
15
|
+
module API200
|
16
|
+
# Logical interconnect group resource implementation
|
17
|
+
class LogicalInterconnectGroup < Resource
|
18
|
+
BASE_URI = '/rest/logical-interconnect-groups'.freeze
|
19
|
+
|
20
|
+
attr_reader :bay_count
|
21
|
+
|
22
|
+
# Create a resource object, associate it with a client, and set its properties.
|
23
|
+
# @param [OneviewSDK::Client] client The client object for the OneView appliance
|
24
|
+
# @param [Hash] params The options for this resource (key-value pairs)
|
25
|
+
# @param [Integer] api_ver The api version to use when interracting with this resource.
|
26
|
+
def initialize(client, params = {}, api_ver = nil)
|
27
|
+
super
|
28
|
+
# Default values:
|
29
|
+
@data['enclosureType'] ||= 'C7000'
|
30
|
+
@data['state'] ||= 'Active'
|
31
|
+
@data['uplinkSets'] ||= []
|
32
|
+
@data['type'] ||= 'logical-interconnect-groupV3'
|
33
|
+
@data['interconnectMapTemplate'] ||= {}
|
34
|
+
@data['interconnectMapTemplate']['interconnectMapEntryTemplates'] ||= []
|
35
|
+
|
36
|
+
# User friendly values:
|
37
|
+
@bay_count = 8
|
38
|
+
|
39
|
+
# Create all entries if empty
|
40
|
+
parse_interconnect_map_template if @data['interconnectMapTemplate']['interconnectMapEntryTemplates'] == []
|
41
|
+
end
|
42
|
+
|
43
|
+
# Adds an interconnect
|
44
|
+
# @param [Fixnum] bay Bay number
|
45
|
+
# @param [String] type Interconnect type
|
46
|
+
# @raise [StandardError] if a invalid type is given then raises an error
|
47
|
+
def add_interconnect(bay, type)
|
48
|
+
@data['interconnectMapTemplate']['interconnectMapEntryTemplates'].each do |entry|
|
49
|
+
entry['logicalLocation']['locationEntries'].each do |location|
|
50
|
+
if location['type'] == 'Bay' && location['relativeValue'] == bay
|
51
|
+
entry['permittedInterconnectTypeUri'] = OneviewSDK::Interconnect.get_type(@client, type)['uri']
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
rescue StandardError
|
56
|
+
list = OneviewSDK::Interconnect.get_types(@client).map { |t| t['name'] }
|
57
|
+
raise "Interconnect type #{type} not found! Supported types: #{list}"
|
58
|
+
end
|
59
|
+
|
60
|
+
# Adds an uplink set
|
61
|
+
# @param [OneviewSDK::LIGUplinkSet] uplink_set
|
62
|
+
def add_uplink_set(uplink_set)
|
63
|
+
@data['uplinkSets'] << uplink_set.data
|
64
|
+
end
|
65
|
+
|
66
|
+
# Get the logical interconnect group default settings
|
67
|
+
# @return [Hash] The logical interconnect group settings
|
68
|
+
def get_default_settings
|
69
|
+
get_uri = self.class::BASE_URI + '/defaultSettings'
|
70
|
+
response = @client.rest_get(get_uri, @api_version)
|
71
|
+
@client.response_handler(response)
|
72
|
+
end
|
73
|
+
|
74
|
+
# Gets the logical interconnect group settings
|
75
|
+
# @return [Hash] The logical interconnect group settings
|
76
|
+
def get_settings
|
77
|
+
get_uri = @data['uri'] + '/settings'
|
78
|
+
response = @client.rest_get(get_uri, @api_version)
|
79
|
+
@client.response_handler(response)
|
80
|
+
end
|
81
|
+
|
82
|
+
# Saves the current data attributes to the Logical Interconnect Group
|
83
|
+
# @param [Hash] attributes attributes to be updated
|
84
|
+
# @return Updated instance of the Logical Interconnect Group
|
85
|
+
def update(attributes = {})
|
86
|
+
set_all(attributes)
|
87
|
+
update_options = {
|
88
|
+
'If-Match' => @data.delete('eTag'),
|
89
|
+
'Body' => @data
|
90
|
+
}
|
91
|
+
response = @client.rest_put(@data['uri'], update_options, @api_version)
|
92
|
+
body = @client.response_handler(response)
|
93
|
+
set_all(body)
|
94
|
+
end
|
95
|
+
|
96
|
+
private
|
97
|
+
|
98
|
+
# Parse interconnect map template structure
|
99
|
+
def parse_interconnect_map_template
|
100
|
+
1.upto(@bay_count) do |bay_number|
|
101
|
+
entry = {
|
102
|
+
'logicalDownlinkUri' => nil,
|
103
|
+
'logicalLocation' => {
|
104
|
+
'locationEntries' => [
|
105
|
+
{ 'relativeValue' => bay_number, 'type' => 'Bay' },
|
106
|
+
{ 'relativeValue' => 1, 'type' => 'Enclosure' }
|
107
|
+
]
|
108
|
+
},
|
109
|
+
'permittedInterconnectTypeUri' => nil
|
110
|
+
}
|
111
|
+
@data['interconnectMapTemplate']['interconnectMapEntryTemplates'] << entry
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
@@ -0,0 +1,188 @@
|
|
1
|
+
# (C) Copyright 2016 Hewlett Packard Enterprise Development LP
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# You may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
6
|
+
#
|
7
|
+
# Unless required by applicable law or agreed to in writing, software distributed
|
8
|
+
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
9
|
+
# CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
|
10
|
+
# language governing permissions and limitations under the License.
|
11
|
+
|
12
|
+
require_relative 'resource'
|
13
|
+
|
14
|
+
module OneviewSDK
|
15
|
+
module API200
|
16
|
+
# Logical switch resource implementation
|
17
|
+
class LogicalSwitch < Resource
|
18
|
+
BASE_URI = '/rest/logical-switches'.freeze
|
19
|
+
|
20
|
+
attr_accessor :logical_switch_credentials
|
21
|
+
|
22
|
+
# Create a resource object, associate it with a client, and set its properties.
|
23
|
+
# @param [OneviewSDK::Client] client The client object for the OneView appliance
|
24
|
+
# @param [Hash] params The options for this resource (key-value pairs)
|
25
|
+
# @param [Integer] api_ver The api version to use when interracting with this resource.
|
26
|
+
def initialize(client, params = {}, api_ver = nil)
|
27
|
+
super
|
28
|
+
# Default values
|
29
|
+
@data['type'] ||= 'logical-switch'
|
30
|
+
@logical_switch_credentials = {}
|
31
|
+
end
|
32
|
+
|
33
|
+
# Create method
|
34
|
+
# @raise [OneviewSDK::IncompleteResource] if the client is not set
|
35
|
+
# @raise [StandardError] if the resource creation fails
|
36
|
+
# @return [OneviewSDK::LogicalSwitch] self
|
37
|
+
def create
|
38
|
+
ensure_client
|
39
|
+
request_body = {}
|
40
|
+
request_body['logicalSwitchCredentials'] = generate_logical_switch_credentials
|
41
|
+
request_body['logicalSwitch'] = @data.clone
|
42
|
+
request_body['logicalSwitch']['switchCredentialConfiguration'] = generate_logical_switch_credential_configuration
|
43
|
+
response = @client.rest_post(self.class::BASE_URI, { 'body' => request_body }, @api_version)
|
44
|
+
body = @client.response_handler(response)
|
45
|
+
set_all(body)
|
46
|
+
self
|
47
|
+
end
|
48
|
+
|
49
|
+
# Updates this object using the data that exists on OneView
|
50
|
+
# @note Will overwrite any data that differs from OneView
|
51
|
+
# @return [Resource] self
|
52
|
+
def refresh
|
53
|
+
response = @client.rest_put(@data['uri'] + '/refresh')
|
54
|
+
@client.response_handler(response)
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
# @!group Credentials
|
59
|
+
CredentialsSSH = Struct.new(:user, :password)
|
60
|
+
|
61
|
+
CredentialsSNMPV1 = Struct.new(:port, :community_string, :version) do
|
62
|
+
# @return [String] Returns SNMPv1
|
63
|
+
def version
|
64
|
+
'SNMPv1'
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
CredentialsSNMPV3 = Struct.new(:port, :user, :auth_protocol, :auth_password, :privacy_protocol, :privacy_password, :version) do
|
69
|
+
# @return [String] Returns SNMPv3
|
70
|
+
def version
|
71
|
+
'SNMPv3'
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# Sets switch credentials
|
76
|
+
# @param [String] host IP address or host name
|
77
|
+
# @param [CredentialsSSH] ssh_credentials SSH credentials
|
78
|
+
# @param [CredentialsSNMP] snmp_credentials SNMP credentials
|
79
|
+
# @return [Array] An Array containing the SSH and SNMP credentials
|
80
|
+
def set_switch_credentials(host, ssh_credentials, snmp_credentials)
|
81
|
+
raise TypeError, 'Use struct<OneviewSDK::LogicalSwitch::CredentialsSSH>' if ssh_credentials.class != OneviewSDK::LogicalSwitch::CredentialsSSH
|
82
|
+
raise TypeError, 'Use struct<OneviewSDK::LogicalSwitch::CredentialsSNMP>' unless snmp_credentials.respond_to?('version')
|
83
|
+
raise TypeError, 'Use struct<OneviewSDK::LogicalSwitch::CredentialsSNMP>' if snmp_credentials.version != 'SNMPv1' &&
|
84
|
+
snmp_credentials.version != 'SNMPv3'
|
85
|
+
@logical_switch_credentials[host] = [ssh_credentials.clone, snmp_credentials.clone]
|
86
|
+
@logical_switch_credentials[host]
|
87
|
+
end
|
88
|
+
|
89
|
+
# @!endgroup
|
90
|
+
|
91
|
+
|
92
|
+
# Sets the logical switch group
|
93
|
+
# @param [OneviewSDK::logicalSwitchGroup] logical_switch_group Logical switch group
|
94
|
+
def set_logical_switch_group(logical_switch_group)
|
95
|
+
@data['logicalSwitchGroupUri'] = logical_switch_group['uri']
|
96
|
+
end
|
97
|
+
|
98
|
+
private
|
99
|
+
|
100
|
+
# Generates the logical switch credentials for POST and PUT requests
|
101
|
+
# @return [Array] List of connection properties for each logical switch
|
102
|
+
def generate_logical_switch_credentials
|
103
|
+
credentials = []
|
104
|
+
@logical_switch_credentials.each do |_, switch|
|
105
|
+
switch_credentials = []
|
106
|
+
switch_credentials << {
|
107
|
+
'valueFormat' => 'Unknown',
|
108
|
+
'propertyName' => 'SshBasicAuthCredentialUser',
|
109
|
+
'valueType' => 'String',
|
110
|
+
'value' => switch[0].user
|
111
|
+
}
|
112
|
+
|
113
|
+
switch_credentials << {
|
114
|
+
'valueFormat' => 'SecuritySensitive',
|
115
|
+
'propertyName' => 'SshBasicAuthCredentialPassword',
|
116
|
+
'valueType' => 'String',
|
117
|
+
'value' => switch[0].password
|
118
|
+
}
|
119
|
+
|
120
|
+
if switch[1].version == 'SNMPv3'
|
121
|
+
switch_credentials << {
|
122
|
+
'valueFormat' => 'SecuritySensitive',
|
123
|
+
'propertyName' => 'SnmpV3AuthorizationPassword',
|
124
|
+
'valueType' => 'String',
|
125
|
+
'value' => switch[1].auth_password
|
126
|
+
}
|
127
|
+
|
128
|
+
switch_credentials << {
|
129
|
+
'valueFormat' => 'Unknown',
|
130
|
+
'propertyName' => 'SnmpV3User',
|
131
|
+
'valueType' => 'String',
|
132
|
+
'value' => switch[1].user
|
133
|
+
}
|
134
|
+
|
135
|
+
if switch[1].privacy_password
|
136
|
+
switch_credentials << {
|
137
|
+
'valueFormat' => 'SecuritySensitive',
|
138
|
+
'propertyName' => 'SnmpV3PrivacyPassword',
|
139
|
+
'valueType' => 'String',
|
140
|
+
'value' => switch[1].privacy_password
|
141
|
+
}
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
credentials << { 'connectionProperties' => switch_credentials }
|
146
|
+
end
|
147
|
+
credentials
|
148
|
+
end
|
149
|
+
|
150
|
+
# Generates the logical switch credential configuration for POST and PUT requests
|
151
|
+
# @return [Array] List of logical switch credential configuration for each switch
|
152
|
+
def generate_logical_switch_credential_configuration
|
153
|
+
configuration = []
|
154
|
+
@logical_switch_credentials.each do |host, switch|
|
155
|
+
switch_configuration = {
|
156
|
+
'snmpPort' => switch[1].port,
|
157
|
+
'snmpV3Configuration' => nil,
|
158
|
+
'snmpV1Configuration' => nil,
|
159
|
+
'logicalSwitchManagementHost' => host,
|
160
|
+
'snmpVersion' => switch[1].version
|
161
|
+
}
|
162
|
+
|
163
|
+
if switch[1].version == 'SNMPv3'
|
164
|
+
switch_configuration['snmpV1Configuration'] = nil
|
165
|
+
switch_configuration['snmpV3Configuration'] = {
|
166
|
+
'authorizationProtocol' => switch[1].auth_protocol
|
167
|
+
}
|
168
|
+
|
169
|
+
if switch[1].privacy_protocol
|
170
|
+
switch_configuration['snmpV3Configuration']['securityLevel'] = 'AuthPrivacy'
|
171
|
+
switch_configuration['snmpV3Configuration']['privacyProtocol'] = switch[1].privacy_protocol
|
172
|
+
else
|
173
|
+
switch_configuration['snmpV3Configuration']['securityLevel'] = 'Auth'
|
174
|
+
end
|
175
|
+
|
176
|
+
elsif switch[1].version == 'SNMPv1'
|
177
|
+
switch_configuration['snmpV3Configuration'] = nil
|
178
|
+
switch_configuration['snmpV1Configuration'] = {
|
179
|
+
'communityString' => switch[1].community_string
|
180
|
+
}
|
181
|
+
end
|
182
|
+
configuration << switch_configuration
|
183
|
+
end
|
184
|
+
configuration
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# (C) Copyright 2016 Hewlett Packard Enterprise Development LP
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# You may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
6
|
+
#
|
7
|
+
# Unless required by applicable law or agreed to in writing, software distributed
|
8
|
+
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
9
|
+
# CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
|
10
|
+
# language governing permissions and limitations under the License.
|
11
|
+
|
12
|
+
require_relative 'resource'
|
13
|
+
|
14
|
+
module OneviewSDK
|
15
|
+
module API200
|
16
|
+
# Logical switch group resource implementation
|
17
|
+
class LogicalSwitchGroup < Resource
|
18
|
+
BASE_URI = '/rest/logical-switch-groups'.freeze
|
19
|
+
|
20
|
+
# Create a resource object, associate it with a client, and set its properties.
|
21
|
+
# @param [OneviewSDK::Client] client The client object for the OneView appliance
|
22
|
+
# @param [Hash] params The options for this resource (key-value pairs)
|
23
|
+
# @param [Integer] api_ver The api version to use when interracting with this resource.
|
24
|
+
def initialize(client, params = {}, api_ver = nil)
|
25
|
+
super
|
26
|
+
# Default values:
|
27
|
+
@data['category'] ||= 'logical-switch-groups'
|
28
|
+
@data['state'] ||= 'Active'
|
29
|
+
@data['type'] ||= 'logical-switch-group'
|
30
|
+
@data['switchMapTemplate'] ||= {}
|
31
|
+
end
|
32
|
+
|
33
|
+
# Define how the switches will be grouped, setting the number and the type of the switches
|
34
|
+
# @param [Fixnum] number_of_switches The number of the switch inside the group [1,2]
|
35
|
+
# @param [String] type Switch type name
|
36
|
+
# @raise [StandardError]
|
37
|
+
def set_grouping_parameters(number_of_switches, type)
|
38
|
+
@data['switchMapTemplate']['switchMapEntryTemplates'] = []
|
39
|
+
parse_switch_map_template(number_of_switches)
|
40
|
+
switch_type_uri = OneviewSDK::Switch.get_type(@client, type)['uri']
|
41
|
+
@data['switchMapTemplate']['switchMapEntryTemplates'].each do |entry|
|
42
|
+
entry['logicalLocation']['locationEntries'].each do |location|
|
43
|
+
entry['permittedSwitchTypeUri'] = switch_type_uri if location['type'] == 'StackingMemberId'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
rescue StandardError
|
47
|
+
list = OneviewSDK::Switch.get_types(@client).map { |t| t['name'] }
|
48
|
+
raise "Switch type #{type} not found! Supported types: #{list}"
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
# Parse switch map template structure
|
54
|
+
# @param [Integer] number_of_switches number of switches
|
55
|
+
def parse_switch_map_template(number_of_switches)
|
56
|
+
1.upto(number_of_switches) do |stacking_member_id|
|
57
|
+
entry = {
|
58
|
+
'logicalLocation' => {
|
59
|
+
'locationEntries' => [
|
60
|
+
{ 'relativeValue' => stacking_member_id, 'type' => 'StackingMemberId' }
|
61
|
+
]
|
62
|
+
},
|
63
|
+
'permittedSwitchTypeUri' => nil
|
64
|
+
}
|
65
|
+
@data['switchMapTemplate']['switchMapEntryTemplates'] << entry
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
# (C) Copyright 2016 Hewlett Packard Enterprise Development LP
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# You may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
6
|
+
#
|
7
|
+
# Unless required by applicable law or agreed to in writing, software distributed
|
8
|
+
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
9
|
+
# CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
|
10
|
+
# language governing permissions and limitations under the License.
|
11
|
+
|
12
|
+
require_relative 'resource'
|
13
|
+
|
14
|
+
module OneviewSDK
|
15
|
+
module API200
|
16
|
+
# Managed SAN resource implementation
|
17
|
+
class ManagedSAN < Resource
|
18
|
+
BASE_URI = '/rest/fc-sans/managed-sans'.freeze
|
19
|
+
|
20
|
+
# Method is not available
|
21
|
+
# @raise [OneviewSDK::MethodUnavailable] method is not available
|
22
|
+
def create
|
23
|
+
unavailable_method
|
24
|
+
end
|
25
|
+
|
26
|
+
# Method is not available
|
27
|
+
# @raise [OneviewSDK::MethodUnavailable] method is not available
|
28
|
+
def delete
|
29
|
+
unavailable_method
|
30
|
+
end
|
31
|
+
|
32
|
+
# Method is not available
|
33
|
+
# @raise [OneviewSDK::MethodUnavailable] method is not available
|
34
|
+
def update
|
35
|
+
unavailable_method
|
36
|
+
end
|
37
|
+
|
38
|
+
# Retrieves a list of endpoints
|
39
|
+
# @return [Array] List of endpoints
|
40
|
+
def get_endpoints
|
41
|
+
response = @client.rest_get(@data['uri'] + '/endpoints')
|
42
|
+
@client.response_handler(response)['members']
|
43
|
+
end
|
44
|
+
|
45
|
+
# Set refresh state for managed SAN
|
46
|
+
# @param [String] state Desired refresh state
|
47
|
+
def set_refresh_state(state)
|
48
|
+
response = @client.rest_put(@data['uri'], 'body' => { refreshState: state })
|
49
|
+
@client.response_handler(response)
|
50
|
+
end
|
51
|
+
|
52
|
+
# Set public attributes
|
53
|
+
# @param [Hash] attributes Public attributes
|
54
|
+
# @option attributes [String] :name
|
55
|
+
# @option attributes [String] :value
|
56
|
+
# @option attributes [String] :valueType
|
57
|
+
# @option attributes [String] :valueFormat
|
58
|
+
def set_public_attributes(attributes)
|
59
|
+
response = @client.rest_put(@data['uri'], 'body' => { publicAttributes: attributes })
|
60
|
+
@client.response_handler(response)
|
61
|
+
end
|
62
|
+
|
63
|
+
# Set public attributes
|
64
|
+
# @param [Hash] policy SAN policy
|
65
|
+
# @option attributes [String] :zoningPolicy
|
66
|
+
# @option attributes [String] :zoneNameFormat
|
67
|
+
# @option attributes [String] :enableAliasing
|
68
|
+
# @option attributes [String] :initiatorNameFormat
|
69
|
+
# @option attributes [String] :targetNameFormat
|
70
|
+
# @option attributes [String] :targetGroupNameFormat
|
71
|
+
def set_san_policy(policy)
|
72
|
+
response = @client.rest_put(@data['uri'], 'body' => { sanPolicy: policy })
|
73
|
+
@client.response_handler(response)
|
74
|
+
end
|
75
|
+
|
76
|
+
# Creates unexpected zoning report for a SAN
|
77
|
+
def get_zoning_report
|
78
|
+
response = @client.rest_post(@data['uri'] + '/issues', 'body' => {})
|
79
|
+
@client.response_handler(response)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|