Class: OneviewSDK::API200::NetworkSet

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

Overview

Network set resource implementation

Direct Known Subclasses

OneviewSDK::API300::C7000::NetworkSet

Constant Summary collapse

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

Constants inherited from Resource

Resource::DEFAULT_REQUEST_HEADER, Resource::UNIQUE_IDENTIFIERS

Instance Attribute Summary

Attributes inherited from Resource

#api_version, #client, #data, #logger

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

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

Constructor Details

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

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
# File 'lib/oneview-sdk/resource/api200/network_set.rb', line 24

def initialize(client, params = {}, api_ver = nil)
  super
  # Default values:
  @data['connectionTemplateUri'] ||= nil
  @data['nativeNetworkUri'] ||= nil
  @data['networkUris'] ||= []
  @data['type'] ||= 'network-set'
end

Class Method Details

.get_without_ethernet(client) ⇒ Array

Lists network sets excluding ethernet networks

Parameters:

Returns:

  • (Array)

    List of network sets



55
56
57
58
# File 'lib/oneview-sdk/resource/api200/network_set.rb', line 55

def self.get_without_ethernet(client)
  response = client.rest_get(BASE_URI + '/withoutEthernet')
  client.response_handler(response)
end

Instance Method Details

#add_ethernet_network(ethernet_network) ⇒ Object

Adds an ethernet network to the network set

Parameters:

  • ethernet_network (OneviewSDK::EthernetNetwork)

    Ethernet Network



42
43
44
# File 'lib/oneview-sdk/resource/api200/network_set.rb', line 42

def add_ethernet_network(ethernet_network)
  @data['networkUris'] << ethernet_network['uri'] unless @data['networkUris'].include?(ethernet_network['uri'])
end

#get_without_ethernetOneviewSDK::NetworkSet

Lists network set excluding ethernet networks

Returns:

  • (OneviewSDK::NetworkSet)

    Network set



62
63
64
65
# File 'lib/oneview-sdk/resource/api200/network_set.rb', line 62

def get_without_ethernet
  response = @client.rest_get(@data['uri'] + '/withoutEthernet')
  @client.response_handler(response)
end

#remove_ethernet_network(ethernet_network) ⇒ Object

Removes an ethernet network from the network set

Parameters:

  • ethernet_network (OneviewSDK::EthernetNetwork)

    Ethernet Network



48
49
50
# File 'lib/oneview-sdk/resource/api200/network_set.rb', line 48

def remove_ethernet_network(ethernet_network)
  @data['networkUris'].delete(ethernet_network['uri']) if @data['networkUris'].include?(ethernet_network['uri'])
end

#set_native_network(ethernet_network) ⇒ Object

Sets the native network for the network set

Parameters:

  • ethernet_network (OneviewSDK::EthernetNetwork)

    Ethernet Network



35
36
37
38
# File 'lib/oneview-sdk/resource/api200/network_set.rb', line 35

def set_native_network(ethernet_network)
  @data['nativeNetworkUri'] = ethernet_network['uri']
  @data['networkUris'] << ethernet_network['uri'] unless @data['networkUris'].include?(ethernet_network['uri'])
end