Class: OneviewSDK::API200::StoragePool

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

Overview

Storage pool resource implementation

Constant Summary collapse

BASE_URI =
'/rest/storage-pools'.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!, #each, #eql?, find_by, from_file, get_all, #like?, #refresh, schema, #schema, #set, #set_all, #to_file

Constructor Details

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

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.


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

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

Instance Method Details

#addOneviewSDK::StoragePool

Note:

Calls the refresh method to set additional data

Add the resource on OneView using the current data

Returns:

  • (OneviewSDK::StoragePool)

    self

Raises:


25
# File 'lib/oneview-sdk/resource/api200/storage_pool.rb', line 25

alias add create

#createObject

Method is not available

Raises:


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

def create(*)
  unavailable_method
end

#deleteObject

Method is not available

Raises:


49
50
51
# File 'lib/oneview-sdk/resource/api200/storage_pool.rb', line 49

def delete(*)
  unavailable_method
end

#exists?Boolean

Note:

name or uri must be specified inside resource

Check if a resource exists

Returns:

  • (Boolean)

    Whether or not resource exists

Raises:


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

def exists?
  raise IncompleteResource, 'Must set resource name or uri before trying to exists?' unless @data['name'] || @data['uri']
  raise IncompleteResource, 'Must set resource storageSystemUri before trying to exists?' unless @data['storageSystemUri']
  return true if @data['name'] && self.class.find_by(@client, name: @data['name'], storageSystemUri: @data['storageSystemUri']).size == 1
  return true if @data['uri']  && self.class.find_by(@client, uri:  @data['uri'], storageSystemUri: @data['storageSystemUri']).size == 1
  false
end

#removetrue

Remove resource from OneView

Returns:

  • (true)

    if resource was removed successfully


29
# File 'lib/oneview-sdk/resource/api200/storage_pool.rb', line 29

alias remove delete

#retrieve!Boolean

Note:

Name or URI must be specified inside the resource

Retrieve resource details based on this resource's name or URI.

Returns:

  • (Boolean)

    Whether or not retrieve was successful

Raises:


62
63
64
65
66
67
68
69
70
71
# File 'lib/oneview-sdk/resource/api200/storage_pool.rb', line 62

def retrieve!
  raise IncompleteResource, 'Must set resource name or uri before trying to retrieve!' unless @data['name'] || @data['uri']
  raise IncompleteResource, 'Must set resource storageSystemUri before trying to retrieve!' unless @data['storageSystemUri']
  results = self.class.find_by(@client, name: @data['name'], storageSystemUri: @data['storageSystemUri']) if @data['name']
  results = self.class.find_by(@client, uri:  @data['uri'], storageSystemUri: @data['storageSystemUri']) if @data['uri'] &&
    (!results || results.empty?)
  return false unless results.size == 1
  set_all(results[0].data)
  true
end

#set_storage_system(storage_system) ⇒ Object

Sets the storage system

Parameters:

  • storage_system (OneviewSDK::StorageSystem)

Raises:


86
87
88
89
# File 'lib/oneview-sdk/resource/api200/storage_pool.rb', line 86

def set_storage_system(storage_system)
  raise IncompleteResource, 'Please set the storage system\'s uri attribute!' unless storage_system['uri']
  set('storageSystemUri', storage_system['uri'])
end

#updateObject

Method is not available

Raises:


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

def update(*)
  unavailable_method
end