Class: OneviewSDK::StorageSystem

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

Overview

Storage system resource implementation

Constant Summary collapse

BASE_URI =
'/rest/storage-systems'.freeze

Instance Attribute Summary

Attributes inherited from Resource

#api_version, #client, #data, #logger

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

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

Constructor Details

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

Returns a new instance of StorageSystem.



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

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

Class Method Details

.get_host_types(client) ⇒ String

Get host types for storage system resource

Parameters:

  • client (Client)

    client handle REST calls to OV instance

Returns:

  • (String)

    response body



39
40
41
42
# File 'lib/oneview-sdk/resource/storage_system.rb', line 39

def self.get_host_types(client)
  response = client.rest_get(BASE_URI + '/host-types')
  response.body
end

Instance Method Details

#createObject



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/oneview-sdk/resource/storage_system.rb', line 12

def create
  ensure_client
  task = @client.rest_post(self.class::BASE_URI, { 'body' => self['credentials'] }, @api_version)
  temp = @data.clone
  task = @client.wait_for(task['uri'] || task['location'])
  @data['uri'] = task['associatedResource']['resourceUri']
  refresh
  temp.delete('credentials')
  update(temp)
  self
end

#get_managed_ports(port = nil) ⇒ Object

List of all managed target ports for the specified storage system or only the one specified

Parameters:

  • port (String) (defaults to: nil)

    Target port



53
54
55
56
57
58
59
60
# File 'lib/oneview-sdk/resource/storage_system.rb', line 53

def get_managed_ports(port = nil)
  response = if port.nil?
               @client.rest_get("#{@data['uri']}/managedPorts")
             else
               @client.rest_get("#{@data['uri']}/managedPorts/#{port}")
             end
  response.body
end

#get_storage_poolsObject

List of storage pools



45
46
47
48
# File 'lib/oneview-sdk/resource/storage_system.rb', line 45

def get_storage_pools
  response = @client.rest_get(@data['uri'] + '/storage-pools')
  response.body
end

#retrieve!Object



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/oneview-sdk/resource/storage_system.rb', line 24

def retrieve!
  if @data['name']
    super
  else
    ip_hostname = self['credentials'][:ip_hostname] || self['credentials']['ip_hostname']
    results = self.class.find_by(@client, credentials: { ip_hostname: ip_hostname })
    return false unless results.size == 1
    set_all(results[0].data)
    true
  end
end