Class: OneviewSDK::LIGUplinkSet

Inherits:
Resource
  • Object
show all
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

Instance Method Summary collapse

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.

Parameters:



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

Specify one uplink passing the VC Bay and the port to be attached.

Parameters:

  • bay (Fixnum)

    number to identify the VC

  • port (String)

    to attach the uplink. Allowed D1..D16 and X1..X10



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

Parameters:

  • value (String)

    Notapplicable, Tagged, Tunnel, Unknown, Untagged. Must exist if networkType is ‘Ethernet’, otherwise shouldn’t.



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

Parameters:

  • value (String)

    FibreChannel, Ethernet



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