Class: OneviewSDK::LogicalEnclosure

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

Overview

Logical enclosure resource implementation

Validates collapse

VALID_FABRIC_TYPES =
%w(DirectAttach FabricAttach).freeze

Constant Summary collapse

BASE_URI =
'/rest/logical-enclosures'.freeze

Instance Attribute Summary

Attributes inherited from Resource

#api_version, #client, #data, #logger

Validates collapse

Instance Method Summary collapse

Methods inherited from Resource

#==, #[], #[]=, #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) ⇒ LogicalEnclosure

Returns a new instance of LogicalEnclosure.



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

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

Instance Method Details

#get_scriptString

Get the configuration script

Returns:

  • (String)

    script

Raises:

  • (RuntimeError)

    if the client is not set

  • (RuntimeError)

    if the uri is not set

  • (RuntimeError)

    if retrieving fails



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

def get_script
  ensure_client && ensure_uri
  response = @client.rest_get("#{@data['uri']}/script", @api_version)
  response.body
end

#reconfigureLogicalEnclosure

Reapplies the appliance’s configuration on enclosures

Returns:

Raises:

  • (RuntimeError)

    if the client is not set

  • (RuntimeError)

    if the uri is not set

  • (RuntimeError)

    if the reapply fails



29
30
31
32
33
34
# File 'lib/oneview-sdk/resource/logical_enclosure.rb', line 29

def reconfigure
  ensure_client && ensure_uri
  response = @client.rest_put("#{@data['uri']}/configuration", {}, @api_version)
  @client.response_handler(response)
  self
end

#set_script(script) ⇒ Resource

Updates the configuration script for the logical enclosure

Returns:

Raises:

  • (RuntimeError)

    if the client is not set

  • (RuntimeError)

    if the uri is not set

  • (RuntimeError)

    if the reapply fails



64
65
66
67
68
69
# File 'lib/oneview-sdk/resource/logical_enclosure.rb', line 64

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

#support_dump(options) ⇒ Resource

Generates a support dump for the logical enclosure

Returns:

Raises:

  • (RuntimeError)

    if the client is not set

  • (RuntimeError)

    if the uri is not set

  • (RuntimeError)

    if the process fails when generating the support dump



76
77
78
79
80
81
# File 'lib/oneview-sdk/resource/logical_enclosure.rb', line 76

def support_dump(options)
  ensure_client && ensure_uri
  response = @client.rest_post("#{@data['uri']}/support-dumps", { 'body' => options }, @api_version)
  @client.wait_for(response.header['location'])
  self
end

#update_from_groupResource

Makes this logical enclosure consistent with the enclosure group

Returns:

Raises:

  • (RuntimeError)

    if the client is not set

  • (RuntimeError)

    if the uri is not set

  • (RuntimeError)

    if the process fails



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

def update_from_group
  ensure_client && ensure_uri
  response = @client.rest_put("#{@data['uri']}/updateFromGroup", {}, @api_version)
  @client.response_handler(response)
  self
end

#validate_fabricType(value) ⇒ Object

Validate fabricType

Parameters:

  • value (String)

    DirectAttach, FabricAttach

Raises:

  • (RuntimeError)

    if value is not ‘DirectAttach’ or ‘FabricAttach’



18
19
20
# File 'lib/oneview-sdk/resource/logical_enclosure.rb', line 18

def validate_fabricType(value)
  fail 'Invalid fabric type' unless VALID_FABRIC_TYPES.include?(value)
end