Class: OneviewSDK::LIGUplinkSet
- Defined in:
- lib/oneview-sdk/resource/lig_uplink_set.rb
Overview
Uplink Sets resource implementation to be used in Logical interconnect groups
Validates collapse
- VALID_NETWORK_TYPES =
%w(FibreChannel Ethernet).freeze
- VALID_ETHERNET_NETWORK_TYPES =
%w(NotApplicable Tagged Tunnel Unknown Untagged).freeze
Constant Summary collapse
- BASE_URI =
'/rest/logical-interconnect-groups'.freeze
Instance Attribute Summary
Attributes inherited from Resource
#api_version, #client, #data, #logger
Validates collapse
-
#validate_ethernetNetworkType(value) ⇒ Object
Validate ethernetNetworkType request.
-
#validate_networkType(value) ⇒ Object
Validate ethernetNetworkType request.
Instance Method Summary collapse
-
#add_network(network) ⇒ Object
Add existing network to the network list.
-
#add_uplink(bay, port) ⇒ Object
Specify one uplink passing the VC Bay and the port to be attached.
-
#initialize(client, params = {}, api_ver = nil) ⇒ LIGUplinkSet
constructor
A new instance of LIGUplinkSet.
-
#sets(networkTypefirst) ⇒ Object
Set all params.
Methods inherited from Resource
#==, #[], #[]=, #create, #create!, #delete, #each, #eql?, #exists?, find_by, from_file, get_all, #like?, #refresh, #retrieve!, #schema, schema, #set, #to_file, #update
Constructor Details
#initialize(client, params = {}, api_ver = nil) ⇒ LIGUplinkSet
Returns a new instance of LIGUplinkSet.
6 7 8 9 10 11 12 13 |
# File 'lib/oneview-sdk/resource/lig_uplink_set.rb', line 6 def initialize(client, params = {}, api_ver = nil) super # Default values: @data['logicalPortConfigInfos'] ||= [] @data['lacpTimer'] ||= 'Short' @data['mode'] ||= 'Auto' @data['networkUris'] ||= [] end |
Instance Method Details
#add_network(network) ⇒ Object
Add existing network to the network list. Ethernet and FibreChannel networks are allowed.
38 39 40 41 |
# File 'lib/oneview-sdk/resource/lig_uplink_set.rb', line 38 def add_network(network) fail 'Resource not retrieved from server' unless network['uri'] @data['networkUris'] << network['uri'] end |
#add_uplink(bay, port) ⇒ Object
Specify one uplink passing the VC Bay and the port to be attached.
46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/oneview-sdk/resource/lig_uplink_set.rb', line 46 def add_uplink(bay, port) entry = { 'desiredSpeed' => 'Auto', 'logicalLocation' => { 'locationEntries' => [ { 'relativeValue' => bay, 'type' => 'Bay' }, { 'relativeValue' => 1, 'type' => 'Enclosure' }, { 'relativeValue' => relative_value_of(port), 'type' => 'Port' } ] } } @data['logicalPortConfigInfos'] << entry end |
#sets(networkTypefirst) ⇒ Object
Set all params
62 63 64 65 66 67 68 |
# File 'lib/oneview-sdk/resource/lig_uplink_set.rb', line 62 def set_all(params = {}) params = params.data if params.class <= Resource params = Hash[params.map { |(k, v)| [k.to_s, v] }] network_type = params.delete('networkType') params.each { |key, value| set(key.to_s, value) } set('networkType', network_type) if network_type end |
#validate_ethernetNetworkType(value) ⇒ Object
Validate ethernetNetworkType request
29 30 31 |
# File 'lib/oneview-sdk/resource/lig_uplink_set.rb', line 29 def validate_ethernetNetworkType(value) fail 'Invalid ethernetNetworkType' unless VALID_ETHERNET_NETWORK_TYPES.include?(value) end |
#validate_networkType(value) ⇒ Object
Validate ethernetNetworkType request
20 21 22 23 24 |
# File 'lib/oneview-sdk/resource/lig_uplink_set.rb', line 20 def validate_networkType(value) fail 'Invalid network type' unless VALID_NETWORK_TYPES.include?(value) fail 'Attribute missing' if value == 'Ethernet' && !@data['ethernetNetworkType'] fail 'Attribute not supported' if value == 'FibreChannel' && @data['ethernetNetworkType'] end |