Class: OneviewSDK::API200::EthernetNetwork

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

Overview

Ethernet network resource implementation

Constant Summary collapse

BASE_URI =
'/rest/ethernet-networks'.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) ⇒ EthernetNetwork

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

def initialize(client, params = {}, api_ver = nil)
  super
  # Default values:
  @data['ethernetNetworkType'] ||= 'Tagged'
  @data['type'] ||= 'ethernet-networkV3'
end

Class Method Details

.bulk_create(client, options) ⇒ Array

Bulk create the ethernet networks

Parameters:

  • client (OneviewSDK::Client)

    The client object for the OneView appliance

  • options (Hash)

    information necessary to create networks

Returns:

  • (Array)

    list of ethernet networks created



35
36
37
38
39
40
41
42
43
# File 'lib/oneview-sdk/resource/api200/ethernet_network.rb', line 35

def self.bulk_create(client, options)
  range = options[:vlanIdRange].split('-').map(&:to_i)
  options[:type] = 'bulk-ethernet-network'
  response = client.rest_post(BASE_URI + '/bulk', { 'body' => options }, client.api_version)
  client.response_handler(response)
  network_names = []
  range[0].upto(range[1]) { |i| network_names << "#{options[:namePrefix]}_#{i}" }
  OneviewSDK::EthernetNetwork.get_all(client).select { |network| network_names.include?(network['name']) }
end

Instance Method Details

#get_associated_profilesObject

Gets the associated profiles



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

def get_associated_profiles
  ensure_client && ensure_uri
  response = @client.rest_get("#{@data['uri']}/associatedProfiles", {}, @api_version)
  response.body
end

Gets the associated uplink groups



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

def get_associated_uplink_groups
  ensure_client && ensure_uri
  response = @client.rest_get("#{@data['uri']}/associatedUplinkGroups", {}, @api_version)
  response.body
end