Class: OneviewSDK::Interconnect

Inherits:
Resource
  • Object
show all
Defined in:
lib/oneview-sdk/resource/interconnect.rb

Overview

Interconnect resource implementation

Constant Summary collapse

BASE_URI =
'/rest/interconnects'.freeze
TYPE_URI =
'/rest/interconnect-types'.freeze

Instance Attribute Summary

Attributes inherited from Resource

#api_version, #client, #data, #logger

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

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

Constructor Details

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

Returns a new instance of Interconnect.



7
8
9
# File 'lib/oneview-sdk/resource/interconnect.rb', line 7

def initialize(client, params = {}, api_ver = nil)
  super
end

Class Method Details

.get_type(client, name) ⇒ Array

Retrieve interconnect ype with name

Parameters:

  • client (Client)

    http client

  • name (String)

    Interconnect type name

Returns:

  • (Array)

    Interconnect type



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

def self.get_type(client, name)
  results = get_types(client)
  results.find { |interconnect_type| interconnect_type['name'] == name }
end

.get_types(client) ⇒ Object

Retrieve interconnect types

Parameters:

  • client (Client)

    http client



25
26
27
28
29
# File 'lib/oneview-sdk/resource/interconnect.rb', line 25

def self.get_types(client)
  response = client.rest_get(TYPE_URI)
  response = client.response_handler(response)
  response['members']
end

Instance Method Details

#createObject



11
12
13
# File 'lib/oneview-sdk/resource/interconnect.rb', line 11

def create
  unavailable_method
end

#deleteObject



19
20
21
# File 'lib/oneview-sdk/resource/interconnect.rb', line 19

def delete
  unavailable_method
end

#name_serversObject

Retrieve named servers for this interconnect



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

def name_servers
  response = @client.rest_get(@data['uri'] + '/nameServers')
  response.body
end

#reset_port_protectionObject

Triggers a reset of port protection



72
73
74
75
# File 'lib/oneview-sdk/resource/interconnect.rb', line 72

def reset_port_protection
  response = @client.rest_put(@data['uri'] + '/resetportprotection')
  @client.response_handler(response)
end

#statistics(portName = nil, subportNumber = nil) ⇒ Object

Get statistics for an interconnect, for the specified port or subport

Parameters:

  • portName (String) (defaults to: nil)

    port to retrieve statistics

  • subportNumber (String) (defaults to: nil)

    subport to retrieve statistics



61
62
63
64
65
66
67
68
69
# File 'lib/oneview-sdk/resource/interconnect.rb', line 61

def statistics(portName = nil, subportNumber = nil)
  uri = if subportNumber.nil?
          "#{@data['uri']}/statistics/#{portName}"
        else
          "#{@data['uri']}/statistics/#{portName}/subport/#{subportNumber}"
        end
  response = @client.rest_get(uri)
  response.body
end

#updateObject



15
16
17
# File 'lib/oneview-sdk/resource/interconnect.rb', line 15

def update
  unavailable_method
end

#update_attribute(operation, path, value) ⇒ Object

Update specific attributes of a given interconnect resource

Parameters:

  • operation (String)

    operation to be performed

  • path (String)

    path

  • value (String)

    value



81
82
83
84
# File 'lib/oneview-sdk/resource/interconnect.rb', line 81

def update_attribute(operation, path, value)
  response = @client.rest_patch(@data['uri'], 'body' => [{ op: operation, path: path, value: value }])
  @client.response_handler(response)
end

#update_port(portName, attributes) ⇒ Object

Updates an interconnect port

Parameters:

  • portName (String)

    port name

  • attributes (Hash)

    hash with attributes and values to be changed



49
50
51
52
53
54
55
56
# File 'lib/oneview-sdk/resource/interconnect.rb', line 49

def update_port(portName, attributes)
  @data['ports'].each do |port|
    next unless port['name'] == portName
    attributes.each { |key, value| port[key.to_s] = value }
    response = @client.rest_put(@data['uri'] + '/ports', 'body' => port)
    @client.response_handler(response)
  end
end