Class: OneviewSDK::API500::C7000::StoragePool

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

Overview

Storage pool resource implementation for API500 C7000

Constant Summary collapse

BASE_URI =
'/rest/storage-pools'.freeze
UNIQUE_IDENTIFIERS =
%w[uri].freeze

Constants inherited from Resource

Resource::DEFAULT_REQUEST_HEADER

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, #deep_merge!, #each, #eql?, find_by, find_with_pagination, from_file, get_all, get_all_with_query, #like?, #refresh, #schema, schema, #set, #set_all, #to_file, #update

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.



26
27
28
29
30
# File 'lib/oneview-sdk/resource/api500/c7000/storage_pool.rb', line 26

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

Class Method Details

.reachable(client, networks = []) ⇒ Array<OneviewSDK::StoragePool>

Gets the storage pools that are connected on the specified networks based on the storage system port’s expected network connectivity.

Parameters:

  • client (OneviewSDK::Client)

    The client object for the OneView appliance

  • networks (Array<Resource>) (defaults to: [])

    The list of networks with URI to be used as a filter

Returns:

  • (Array<OneviewSDK::StoragePool>)

    the list of storage pools



78
79
80
81
82
83
84
85
# File 'lib/oneview-sdk/resource/api500/c7000/storage_pool.rb', line 78

def self.reachable(client, networks = [])
  uri = self::BASE_URI + '/reachable-storage-pools'
  unless networks.empty?
    network_uris = networks.map { |item| item['uri'] }
    uri += "?networks='#{network_uris.join(',')}'"
  end
  find_with_pagination(client, uri)
end

Instance Method Details

#createObject

Method is not available

Raises:



34
35
36
# File 'lib/oneview-sdk/resource/api500/c7000/storage_pool.rb', line 34

def create(*)
  unavailable_method
end

#create!Object

Method is not available

Raises:



40
41
42
# File 'lib/oneview-sdk/resource/api500/c7000/storage_pool.rb', line 40

def create!(*)
  unavailable_method
end

#deleteObject

Method is not available

Raises:



46
47
48
# File 'lib/oneview-sdk/resource/api500/c7000/storage_pool.rb', line 46

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



69
70
71
72
# File 'lib/oneview-sdk/resource/api500/c7000/storage_pool.rb', line 69

def exists?
  temp = self.class.new(@client, data)
  temp.retrieve!
end

#manage(be_managed) ⇒ Object

Note:

Storage Pool that belongs to Storage System with family StoreVirtual can’t be changed to unmanaged

To manage/unmanage a storage pool

Parameters:

  • be_managed (Boolean)

    Set true to manage or false to unmanage



90
91
92
93
94
95
96
97
# File 'lib/oneview-sdk/resource/api500/c7000/storage_pool.rb', line 90

def manage(be_managed)
  if !be_managed && self['family'] == 'StoreVirtual'
    raise ArgumentError, 'Attempting to unmanage a StoreVirtual pool is not allowed'
  end
  self['isManaged'] = be_managed
  update
  refresh
end

#request_refreshObject

To request a refresh of a storage pool



100
101
102
103
104
# File 'lib/oneview-sdk/resource/api500/c7000/storage_pool.rb', line 100

def request_refresh
  self['requestingRefresh'] = true
  update
  refresh
end

#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



53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/oneview-sdk/resource/api500/c7000/storage_pool.rb', line 53

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

#set_storage_system(storage_system) ⇒ Object

Sets the storage system

Parameters:

  • storage_system (OneviewSDK::StorageSystem)

Raises:



109
110
111
112
# File 'lib/oneview-sdk/resource/api500/c7000/storage_pool.rb', line 109

def set_storage_system(storage_system)
  raise 'Storage System could not be found!' unless storage_system.retrieve!
  set('storageSystemUri', storage_system['uri'])
end