Class: OneviewSDK::API200::UplinkSet

Inherits:
Resource show all
Defined in:
lib/oneview-sdk/resource/api200/uplink_set.rb

Overview

Uplink set resource implementation

Constant Summary collapse

BASE_URI =
'/rest/uplink-sets'.freeze

Constants inherited from Resource

Resource::UNIQUE_IDENTIFIERS

Instance Attribute Summary

Attributes inherited from Resource

#api_version, #client, #data, #logger

Instance Method Summary collapse

Methods inherited from Resource

#==, #[], #[]=, build_query, #create, #create!, #delete, #each, #eql?, #exists?, find_by, from_file, get_all, #like?, #refresh, #retrieve!, #schema, schema, #set, #set_all, #to_file, #update

Constructor Details

#initialize(client, params = {}, api_ver = nil) ⇒ UplinkSet

Create a resource object, associate it with a client, and set its properties.

Parameters:

  • client (OneviewSDK::Client)

    The client object for the OneView appliance

  • params (Hash) (defaults to: {})

    The options for this resource (key-value pairs)

  • api_ver (Integer) (defaults to: nil)

    The api version to use when interracting with this resource.


24
25
26
27
28
29
30
31
32
33
# File 'lib/oneview-sdk/resource/api200/uplink_set.rb', line 24

def initialize(client, params = {}, api_ver = nil)
  super
  # Default values
  @data['fcNetworkUris'] ||= []
  @data['fcoeNetworkUris'] ||= []
  @data['networkUris'] ||= []
  @data['portConfigInfos'] ||= []
  @data['primaryPortLocation'] = nil
  @data['type'] ||= 'uplink-setV3'
end

Instance Method Details

#add_fcnetwork(network) ⇒ Object

Adds an fc network to the uplink set

Parameters:

  • network (OneviewSDK::FCNetwork, Hash)

    must accept hash syntax

Raises:


68
69
70
71
72
# File 'lib/oneview-sdk/resource/api200/uplink_set.rb', line 68

def add_fcnetwork(network)
  uri = network[:uri] || network['uri']
  raise IncompleteResource, 'Must set network uri attribute' unless uri
  @data['fcNetworkUris'].push(uri)
end

#add_fcoenetwork(network) ⇒ Object

Adds an fcoe network to the uplink set

Parameters:

  • network (OneviewSDK::FCoENetwork, Hash)

    must accept hash syntax

Raises:


76
77
78
79
80
# File 'lib/oneview-sdk/resource/api200/uplink_set.rb', line 76

def add_fcoenetwork(network)
  uri = network[:uri] || network['uri']
  raise IncompleteResource, 'Must set network uri attribute' unless uri
  @data['fcoeNetworkUris'].push(uri)
end

#add_network(network) ⇒ Object

Adds an ethernet network to the uplink set

Parameters:

  • network (OneviewSDK::EthernetNetwork, Hash)

Raises:


60
61
62
63
64
# File 'lib/oneview-sdk/resource/api200/uplink_set.rb', line 60

def add_network(network)
  uri = network[:uri] || network['uri']
  raise IncompleteResource, 'Must set network uri attribute' unless uri
  @data['networkUris'].push(uri)
end

#add_port_config(portUri, speed, locationEntries) ⇒ Object

Adds the portConfigInfos to the array

Parameters:

  • portUri (String)
  • speed (String)
  • locationEntries (Hash)

39
40
41
42
43
44
45
46
47
48
# File 'lib/oneview-sdk/resource/api200/uplink_set.rb', line 39

def add_port_config(portUri, speed, locationEntries)
  entry = {
    'portUri' => portUri,
    'desiredSpeed' => speed,
    'location' => {
      'locationEntries' => locationEntries
    }
  }
  @data['portConfigInfos'] << entry
end

#get_unassigned_portsArray

Gets the unassigned uplink ports

Returns:

  • (Array)

    List of unassigned uplink-ports


84
85
86
87
88
89
# File 'lib/oneview-sdk/resource/api200/uplink_set.rb', line 84

def get_unassigned_ports
  ensure_client && ensure_uri
  response = @client.rest_post(BASE_URI + '/unassignedUplinkPorts', { 'body' => @data }, @api_version)
  result = @client.response_handler(response)
  result['members']
end

#set_logical_interconnect(logical_interconnect) ⇒ Object

Sets the logical interconnect uri

Parameters:

  • logical_interconnect (OneviewSDK::LogicalInterconnect, Hash)

Raises:


52
53
54
55
56
# File 'lib/oneview-sdk/resource/api200/uplink_set.rb', line 52

def set_logical_interconnect(logical_interconnect)
  uri = logical_interconnect[:uri] || logical_interconnect['uri']
  raise IncompleteResource, 'Invalid object' unless uri
  @data['logicalInterconnectUri'] = uri
end