-
Notifications
You must be signed in to change notification settings - Fork 16
/
uplink_set.rb
91 lines (77 loc) · 3.45 KB
/
uplink_set.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# (C) Copyright 2020 Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.
require_relative '../_client' # Gives access to @client and @logical_interconnect_name
# Example: Create/Update/Delete an uplink set
# NOTE: This will create a uplink set named 'UplinkSet Example', then update it with network, then delete it.
# NOTE 2: Dependencies: Enclosure, EthernetNetwork, LogicalInterconnectGroup, LogicalInterconnect, Interconnect.
# NOTE 3: To add an ethernet network, the interconnect must support ethernet network.
#
# Supported APIs:
# - 200, 300, 500, 600, 800, 1000, 1200, 1600, 1800
# Supported variants:
# - C7000 and Synergy for all api versions
# Resource Class used in this sample
uplink_set_class = OneviewSDK.resource_named('UplinkSet', @client.api_version)
ethernet_class = OneviewSDK.resource_named('EthernetNetwork', @client.api_version)
li_class = OneviewSDK.resource_named('LogicalInterconnect', @client.api_version)
interconnect_class = OneviewSDK.resource_named('Interconnect', @client.api_version)
ethernet = ethernet_class.get_all(@client).first
logical_interconnect = li_class.find_by(@client, name: @logical_interconnect_name).first
interconnect = interconnect_class.find_by(@client, logicalInterconnectUri: logical_interconnect['uri']).first
port = interconnect['ports'].select { |item| item['portType'] == 'Uplink' && item['portStatus'] == 'Unlinked' }.first
options = {
nativeNetworkUri: nil,
reachability: 'Reachable',
manualLoginRedistributionState: 'NotSupported',
connectionMode: 'Auto',
lacpTimer: 'Short',
networkType: 'Ethernet',
ethernetNetworkType: 'Tagged',
description: nil,
name: 'UplinkSet Example'
}
uplink = uplink_set_class.new(@client, options)
uplink.set_logical_interconnect(logical_interconnect)
puts "\nCreating UplinkSet ..."
uplink.create
puts "\nUplinkSet '#{uplink['uri']}' created successfully!"
puts "\nUpdating the port config"
uplink.add_port_config(
port['uri'],
'Auto',
[
{ value: port['bayNumber'], type: 'Bay' },
{ value: interconnect['enclosureUri'], type: 'Enclosure' },
{ value: port['portName'], type: 'Port' }
]
)
uplink.update
uplink.retrieve!
puts "\nPort config updated successfully. \nPort config: #{uplink['portConfigInfos']}"
puts "\nClean up the port config"
uplink['portConfigInfos'].clear
uplink.update
uplink.retrieve!
puts "\nClean up done. \nPort config: #{uplink['portConfigInfos']}"
# To add fc network and fcoe networks use respectively add_fcnetwork and add_fcoenetwork
puts "\nUpdating UplinkSet (adding network '#{ethernet['uri']}') ..."
uplink.add_network(ethernet)
uplink.update
uplink.retrieve!
puts "\nUplinkSet updated successfully! \nNetworks: #{uplink['networkUris']}"
puts "\nRemoving the network added..."
uplink['networkUris'].delete(ethernet['uri'])
uplink.update
uplink.retrieve!
puts "\nNetwork removed successfully! \nNetworks: #{uplink['networkUris']}"
puts "\nDeleting UplinkSet ..."
uplink.delete
puts "\nUplinkSet deleted successfully!" unless uplink.retrieve!