Class: OneviewSDK::API200::Interconnect

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

Overview

Interconnect resource implementation

Constant Summary collapse

BASE_URI =
'/rest/interconnects'.freeze
TYPE_URI =
'/rest/interconnect-types'.freeze
UNIQUE_IDENTIFIERS =
%w(name uri serialNumber).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

#==, #[], #[]=, build_query, #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

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.



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

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

Class Method Details

.get_type(client, name) ⇒ Array

Retrieves the interconnect type with name

Parameters:

  • client (OneviewSDK::Client)

    The client object for the OneView appliance

  • name (String)

    Interconnect type name

Returns:

  • (Array)

    Interconnect type



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

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

.get_types(client) ⇒ Object

Retrieves interconnect types

Parameters:



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

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

Instance Method Details

#createObject

Method is not available

Raises:



32
33
34
# File 'lib/oneview-sdk/resource/api200/interconnect.rb', line 32

def create
  unavailable_method
end

#deleteObject

Method is not available

Raises:



44
45
46
# File 'lib/oneview-sdk/resource/api200/interconnect.rb', line 44

def delete
  unavailable_method
end

#name_serversObject

Retrieves the named servers for this interconnect



66
67
68
69
# File 'lib/oneview-sdk/resource/api200/interconnect.rb', line 66

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

#patch(operation, path, value) ⇒ Object

Updates specific attributes for a given interconnect resource

Parameters:

  • operation (String)

    operation to be performed

  • path (String)

    path

  • value (String)

    value



106
107
108
109
# File 'lib/oneview-sdk/resource/api200/interconnect.rb', line 106

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

#reset_port_protectionObject

Triggers the reset port protection action



97
98
99
100
# File 'lib/oneview-sdk/resource/api200/interconnect.rb', line 97

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



86
87
88
89
90
91
92
93
94
# File 'lib/oneview-sdk/resource/api200/interconnect.rb', line 86

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

Method is not available

Raises:



38
39
40
# File 'lib/oneview-sdk/resource/api200/interconnect.rb', line 38

def update
  unavailable_method
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



74
75
76
77
78
79
80
81
# File 'lib/oneview-sdk/resource/api200/interconnect.rb', line 74

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