Class: OneviewSDK::API200::EnclosureGroup

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

Overview

Enclosure group resource implementation

Constant Summary collapse

BASE_URI =
'/rest/enclosure-groups'.freeze

Constants inherited from Resource

Resource::UNIQUE_IDENTIFIERS

Instance Attribute Summary

Attributes inherited from Resource

#api_version, #client, #data, #logger

Instance Method Summary collapse

Methods inherited from Resource

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

Constructor Details

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

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

def initialize(client, params = {}, api_ver = nil)
  super
  # Default values:
  @data['type'] ||= 'EnclosureGroupV200'
  @data['interconnectBayMappingCount'] ||= 8
  create_interconnect_bay_mapping unless @data['interconnectBayMappings']
end

Instance Method Details

#add_logical_interconnect_group(lig) ⇒ OneviewSDK::EnclosureGroup

Adds the logical interconnect group

Parameters:

  • lig (OneviewSDK::LogicalInterconnectGroup)

    Logical Interconnect Group

Returns:

  • (OneviewSDK::EnclosureGroup)

    self

Raises:


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

def add_logical_interconnect_group(lig)
  lig.retrieve! unless lig['uri']
  raise(NotFound, "The logical interconnect group #{lig['name']} was not found.") unless lig['uri']
  lig['interconnectMapTemplate']['interconnectMapEntryTemplates'].each do |entry|
    entry['logicalLocation']['locationEntries'].each do |location|
      add_lig_to_bay(location['relativeValue'], lig) if location['type'] == 'Bay' && entry['permittedInterconnectTypeUri']
    end
  end
  self
end

#create_interconnect_bay_mappingOneviewSDK::EnclosureGroup

Creates the interconnect bay mapping

Returns:

  • (OneviewSDK::EnclosureGroup)

    self


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

def create_interconnect_bay_mapping
  @data['interconnectBayMappings'] = []
  1.upto(@data['interconnectBayMappingCount']) do |bay_number|
    entry = {
      'interconnectBay' => bay_number,
      'logicalInterconnectGroupUri' => nil
    }
    @data['interconnectBayMappings'] << entry
  end
  self
end

#get_scriptString

Get the script executed by enclosures in this enclosure group

Returns:

  • (String)

    The script for this enclosure group


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

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

#set_script(body) ⇒ Object

Changes the script executed by the enclosures in this enclosure group

Parameters:

  • body (String)

    The script to be executed

Returns:

  • true if set successfully


43
44
45
46
47
48
# File 'lib/oneview-sdk/resource/api200/enclosure_group.rb', line 43

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