Class: OneviewSDK::API200::LogicalInterconnect

Inherits:
Resource show all
Includes:
ResourceHelper::ConfigurationOperation
Defined in:
lib/oneview-sdk/resource/api200/logical_interconnect.rb

Overview

Logical interconnect resource implementation

Constant Summary collapse

BASE_URI =
'/rest/logical-interconnects'.freeze
LOCATION_URI =
'/rest/logical-interconnects/locations/interconnects'.freeze

Constants inherited from Resource

Resource::DEFAULT_REQUEST_HEADER, Resource::UNIQUE_IDENTIFIERS

Instance Attribute Summary

Attributes inherited from Resource

#api_version, #client, #data, #logger

Instance Method Summary collapse

Methods included from ResourceHelper::ConfigurationOperation

#configuration

Methods inherited from Resource

#==, #[], #[]=, build_query, #create!, #deep_merge!, #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) ⇒ LogicalInterconnect

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.



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

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

Instance Method Details

#add_snmp_trap_destination(trap_destination, trap_format = 'SNMPv1', community_string = 'public', trap_options = {}) ⇒ Object

It will add one trap destination to the Logical Interconnect SNMP configuration

Parameters:

  • trap_format (String) (defaults to: 'SNMPv1')

    SNMP version for this trap destination, ‘’SNMPv1’‘ or `’SNMPv2’‘ or `’SNMPv3’‘

  • trap_destination (String)

    The trap destination IP address or host name

  • community_string (String) (defaults to: 'public')

    The Authentication string for the trap destination

  • trap_options (Hash) (defaults to: {})

    Hash with the options of the trap. Create it using generate_trap_options method



214
215
216
217
218
219
# File 'lib/oneview-sdk/resource/api200/logical_interconnect.rb', line 214

def add_snmp_trap_destination(trap_destination, trap_format = 'SNMPv1', community_string = 'public', trap_options = {})
  trap_options['communityString'] = community_string
  trap_options['trapDestination'] = trap_destination
  trap_options['trapFormat'] = trap_format
  @data['snmpConfiguration']['trapDestinations'].push(trap_options)
end

#complianceObject

Returns logical interconnects to a consistent state. The current logical interconnect state is compared to the associated logical interconnect group.

Returns:

  • returns the updated object



134
135
136
137
138
139
# File 'lib/oneview-sdk/resource/api200/logical_interconnect.rb', line 134

def compliance
  ensure_client && ensure_uri
  response = @client.rest_put(@data['uri'] + '/compliance', {}, @api_version)
  body = client.response_handler(response)
  set_all(body)
end

#create(bay_number, enclosure) ⇒ Object

Creates an Interconnect in the desired bay in a specified enclosure WARN: It does not create the LOGICAL INTERCONNECT itself. It will fail if no interconnect is already present on the specified position

Parameters:

  • bay_number (Fixnum)

    Number of the bay to put the interconnect

  • enclosure (OneviewSDK::Resource)

    Enclosure to insert the interconnect



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/oneview-sdk/resource/api200/logical_interconnect.rb', line 39

def create(bay_number, enclosure)
  enclosure.ensure_uri
  entry = {
    'locationEntries' => [
      { 'value' => bay_number, 'type' => 'Bay' },
      { 'value' => enclosure['uri'], 'type' => 'Enclosure' }
    ]
  }
  response = @client.rest_post(self.class::LOCATION_URI, { 'body' => entry }, @api_version)
  @client.response_handler(response)
end

#delete(bay_number, enclosure) ⇒ OneviewSDK::LogicalInterconnect

Deletes an INTERCONNECT WARN: This will not delete the LOGICAL INTERCONNECT itself, and may cause inconsistency between the enclosure and LIG

Parameters:

  • bay_number (Fixnum)

    The bay number to locate the logical interconnect

  • enclosure (OneviewSDK::Enclosure)

    Enclosure to remove the logical interconnect

Returns:

  • (OneviewSDK::LogicalInterconnect)

    self



56
57
58
59
60
61
62
# File 'lib/oneview-sdk/resource/api200/logical_interconnect.rb', line 56

def delete(bay_number, enclosure)
  enclosure.ensure_uri
  delete_uri = self.class::LOCATION_URI + "?location=Enclosure:#{enclosure['uri']},Bay:#{bay_number}"
  response = @client.rest_delete(delete_uri, {}, @api_version)
  @client.response_handler(response)
  self
end

#firmware_update(command, firmware_driver, firmware_options) ⇒ Object

Update firmware

Parameters:

  • command (String)
  • firmware_driver (OneviewSDK::FirmwareDriver)
  • firmware_options (Hash)

Raises:



253
254
255
256
257
258
259
260
261
262
263
264
# File 'lib/oneview-sdk/resource/api200/logical_interconnect.rb', line 253

def firmware_update(command, firmware_driver, firmware_options)
  ensure_client && ensure_uri
  firmware_options['command'] = command
  firmware_options['sppUri'] =  firmware_driver['uri']
  firmware_options['sppName'] = firmware_driver['name']
  update_json = {
    'If-Match' => '*',
    'body' => firmware_options
  }
  response = @client.rest_put(@data['uri'] + '/firmware', update_json)
  @client.response_handler(response)
end

#generate_trap_options(enet_trap_categories = [], fc_trap_categories = [], vcm_trap_categories = [], trap_severities = []) ⇒ Hash

Generates trap options to be used in add_snmp_trap_destination method

Parameters:

  • enet_trap_categories (Array) (defaults to: [])

    Filter the traps for this trap destination by the list of configured Ethernet traps can contain, ‘’Other’‘ or `’PortStatus’‘ or `’PortThresholds’‘

  • fc_trap_categories (Array) (defaults to: [])

    Filter the traps for this trap destination by the list of configured Fibre Channel traps can contain, ‘’Other’‘ or `’PortStatus’‘

  • vcm_trap_categories (Array) (defaults to: [])

    Filter the traps for this trap destination by the list of configured VCM trap, ‘’Legacy’‘

  • trap_severities (Array) (defaults to: [])

    Filter the traps for this trap destination by the list of configured severities can contain, ‘’Critical’‘ or `’Info’‘ or `’Major’‘ or `’Minor’‘ or `’Normal’‘ or `’Unknown’‘ or `’Warning’‘

Returns:

  • (Hash)

    Contains all trap options for one SNMP destination



230
231
232
233
234
235
236
237
238
# File 'lib/oneview-sdk/resource/api200/logical_interconnect.rb', line 230

def generate_trap_options(enet_trap_categories = [], fc_trap_categories = [], vcm_trap_categories = [], trap_severities = [])
  options = {
    'enetTrapCategories' => enet_trap_categories,
    'vcmTrapCategories' => vcm_trap_categories,
    'fcTrapCategories' => fc_trap_categories,
    'trapSeverities' => trap_severities
  }
  options
end

#get_firmwareHash

Gets the installed firmware for a logical interconnect.

Returns:

  • (Hash)

    Contains all firmware information



242
243
244
245
246
# File 'lib/oneview-sdk/resource/api200/logical_interconnect.rb', line 242

def get_firmware
  ensure_client && ensure_uri
  response = @client.rest_get(@data['uri'] + '/firmware')
  @client.response_handler(response)
end

Gets a collection of uplink ports from the member interconnects which are eligible for assignment to an analyzer port.

Returns:

  • (Hash)

    Hash of uplink ports eligibles for assignment to an analyzer port



144
145
146
147
148
149
150
# File 'lib/oneview-sdk/resource/api200/logical_interconnect.rb', line 144

def get_unassigned_uplink_ports_for_port_monitor
  ensure_client && ensure_uri
  response = @client.rest_get("#{@data['uri']}/unassignedUplinkPortsForPortMonitor")
  @client.response_handler(response)
  body = @client.response_handler(response)
  body['members']
end

#list_vlan_networksOneviewSDK::Resource

Lists internal networks on the logical interconnect

Returns:



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/oneview-sdk/resource/api200/logical_interconnect.rb', line 80

def list_vlan_networks
  ensure_client && ensure_uri
  results = OneviewSDK::Resource.find_by(@client, {}, @data['uri'] + '/internalVlans')
  internal_networks = []
  variant = self.class.name.split('::').at(-2)
  results.each do |vlan|
    net = if vlan['generalNetworkUri'].include? 'ethernet-network'
            OneviewSDK.resource_named('EthernetNetwork', @client.api_version, variant).new(@client, uri: vlan['generalNetworkUri'])
          elsif vlan['generalNetworkUri'].include? 'fc-network'
            OneviewSDK.resource_named('FCNetwork', @client.api_version, variant).new(@client, uri: vlan['generalNetworkUri'])
          else
            OneviewSDK.resource_named('FCoENetwork', @client.api_version, variant).new(@client, uri: vlan['generalNetworkUri'])
          end
    net.retrieve!
    internal_networks.push(net)
  end
  internal_networks
end

#update_ethernet_settingsObject

Note:

The attribute is defined inside the instance of the Logical Interconnect

Updates ethernet settings of the logical interconnect

Returns:

  • Updated instance of the Logical Interconnect

Raises:



102
103
104
105
106
107
108
109
110
111
112
# File 'lib/oneview-sdk/resource/api200/logical_interconnect.rb', line 102

def update_ethernet_settings
  ensure_client && ensure_uri
  raise IncompleteResource, 'Please retrieve the Logical Interconnect before trying to update' unless @data['ethernetSettings']
  update_options = {
    'If-Match' =>  @data['ethernetSettings'].delete('eTag'),
    'body' => @data['ethernetSettings']
  }
  response = @client.rest_put(@data['uri'] + '/ethernetSettings', update_options, @api_version)
  body = @client.response_handler(response)
  set_all(body)
end

#update_internal_networks(*networks) ⇒ Object

Updates internal networks on the logical interconnect

Parameters:

  • networks (OneviewSDK::EthernetNetworks)

    List of networks to update the Logical Interconnect



66
67
68
69
70
71
72
73
74
75
76
# File 'lib/oneview-sdk/resource/api200/logical_interconnect.rb', line 66

def update_internal_networks(*networks)
  uris = []
  return @client.response_handler(@client.rest_put(@data['uri'] + '/internalNetworks', 'body' => [])) unless networks
  networks.each do |net|
    net.retrieve! unless net['uri']
    uris.push(net['uri'])
  end
  response = @client.rest_put(@data['uri'] + '/internalNetworks', 'body' => uris)
  body = @client.response_handler(response)
  set_all(body)
end

#update_port_monitorObject

Note:

The attribute is defined inside the instance of the Logical Interconnect

Updates port monitor settings of the Logical Interconnect

Returns:

  • Updated instance of the Logical Interconnect

Raises:



155
156
157
158
159
160
161
162
163
164
# File 'lib/oneview-sdk/resource/api200/logical_interconnect.rb', line 155

def update_port_monitor
  raise IncompleteResource, 'Please retrieve the Logical Interconnect before trying to update' unless @data['portMonitor']
  update_options = {
    'If-Match' =>  @data['portMonitor'].delete('eTag'),
    'body' => @data['portMonitor']
  }
  response = @client.rest_put("#{@data['uri']}/port-monitor", update_options, @api_version)
  body = @client.response_handler(response)
  set_all(body)
end

#update_qos_configurationObject

Note:

The attribute is defined inside the instance of the Logical Interconnect

Updates QoS aggregated configuration of the Logical Interconnect

Returns:

  • Updated instance of the Logical Interconnect

Raises:



169
170
171
172
173
174
175
176
177
178
# File 'lib/oneview-sdk/resource/api200/logical_interconnect.rb', line 169

def update_qos_configuration
  raise IncompleteResource, 'Please retrieve the Logical Interconnect before trying to update' unless @data['qosConfiguration']
  update_options = {
    'If-Match' =>  @data['qosConfiguration'].delete('eTag'),
    'body' => @data['qosConfiguration']
  }
  response = @client.rest_put(@data['uri'] + '/qos-aggregated-configuration', update_options, @api_version)
  body = @client.response_handler(response)
  set_all(body)
end

#update_settings(options = {}) ⇒ Object

Updates settings of the logical interconnect

Parameters:

  • options (defaults to: {})

    Options to update the Logical Interconnect

Returns:

  • Updated instance of the Logical Interconnect



117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/oneview-sdk/resource/api200/logical_interconnect.rb', line 117

def update_settings(options = {})
  ensure_client && ensure_uri
  options['type'] ||= 'InterconnectSettingsV3'
  options['ethernetSettings'] ||= {}
  options['ethernetSettings']['type'] ||= 'EthernetInterconnectSettingsV3'
  update_options = {
    'If-Match' =>  @data['eTag'],
    'body' => options
  }
  response = @client.rest_put(@data['uri'] + '/settings', update_options, @api_version)
  body = @client.response_handler(response)
  set_all(body)
end

#update_snmp_configurationObject

Note:

The attribute is defined inside the instance of the Logical Interconnect. Use helper methods to add the trap destination values: #add_snmp_trap_destination and #generate_trap_options

Updates snmp configuration of the Logical Interconnect

Returns:

  • Updated instance of the Logical Interconnect

Raises:



198
199
200
201
202
203
204
205
206
207
# File 'lib/oneview-sdk/resource/api200/logical_interconnect.rb', line 198

def update_snmp_configuration
  raise IncompleteResource, 'Please retrieve the Logical Interconnect before trying to update' unless @data['snmpConfiguration']
  update_options = {
    'If-Match' =>  @data['snmpConfiguration'].delete('eTag'),
    'body' => @data['snmpConfiguration']
  }
  response = @client.rest_put(@data['uri'] + '/snmp-configuration', update_options, @api_version)
  body = @client.response_handler(response)
  set_all(body)
end

#update_telemetry_configurationObject

Note:

The attribute is defined inside the instance of the Logical Interconnect

Updates telemetry configuration of the Logical Interconnect

Returns:

  • Updated instance of the Logical Interconnect

Raises:



183
184
185
186
187
188
189
190
191
192
# File 'lib/oneview-sdk/resource/api200/logical_interconnect.rb', line 183

def update_telemetry_configuration
  raise IncompleteResource, 'Please retrieve the Logical Interconnect before trying to update' unless @data['telemetryConfiguration']
  update_options = {
    'If-Match' =>  @data['telemetryConfiguration'].delete('eTag'),
    'body' => @data['telemetryConfiguration']
  }
  response = @client.rest_put(@data['telemetryConfiguration']['uri'], update_options, @api_version)
  body = @client.response_handler(response)
  set_all(body)
end