Class: OneviewSDK::API200::Switch

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

Overview

Switch resource implementation

Direct Known Subclasses

OneviewSDK::API300::C7000::Switch

Constant Summary collapse

BASE_URI =
'/rest/switches'.freeze
TYPE_URI =
'/rest/switch-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, #initialize, #like?, #retrieve!, schema, #schema, #set, #set_all, #to_file

Constructor Details

This class inherits a constructor from OneviewSDK::Resource

Class Method Details

.get_type(client, name) ⇒ Array

Retrieves the switch type with the name

Parameters:

  • client (OneviewSDK::Client)

    The client object for the OneView appliance

  • name (String)

    Switch type name

Returns:

  • (Array)

    Switch type


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

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

.get_types(client) ⇒ Array

Retrieves the switch types

Parameters:

Returns:

  • (Array)

    All the Switch types


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

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:


28
29
30
# File 'lib/oneview-sdk/resource/api200/switch.rb', line 28

def create(*)
  unavailable_method
end

#deleteObject

Method is not available

Raises:


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

def delete(*)
  unavailable_method
end

#environmental_configurationHash

Get settings that describe the environmental configuration

Returns:

  • (Hash)

    Configuration parameters


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

def environmental_configuration
  ensure_client && ensure_uri
  response = @client.rest_get(@data['uri'] + '/environmentalConfiguration', @api_version)
  @client.response_handler(response)
end

#refreshObject

Method is not available

Raises:


40
41
42
# File 'lib/oneview-sdk/resource/api200/switch.rb', line 40

def refresh(*)
  unavailable_method
end

#removetrue

Remove resource from OneView

Returns:

  • (true)

    if resource was removed successfully


24
# File 'lib/oneview-sdk/resource/api200/switch.rb', line 24

alias remove delete

#statistics(port_name = nil, subport_number = nil) ⇒ Hash

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

Parameters:

  • port_name (String) (defaults to: nil)

    port to retrieve statistics

  • subport_number (String) (defaults to: nil)

    subport to retrieve statistics

Returns:

  • (Hash)

    Switch statistics


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

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

#updateObject

Method is not available

Raises:


34
35
36
# File 'lib/oneview-sdk/resource/api200/switch.rb', line 34

def update(*)
  unavailable_method
end