class OneviewSDK::API200::StorageSystem

Storage system resource implementation

Constants

BASE_URI
UNIQUE_IDENTIFIERS

Public Class Methods

get_host_types(client) click to toggle source

Gets the host types for the storage system resource @param [OneviewSDK::Client] client The client object for the OneView appliance @return [String] response body

# File lib/oneview-sdk/resource/api200/storage_system.rb, line 132
def self.get_host_types(client)
  response = client.rest_get(BASE_URI + '/host-types')
  client.response_handler(response)
end
new(client, params = {}, api_ver = nil) click to toggle source

Create a resource object, associate it with a client, and set its properties. @param [OneviewSDK::Client] client The client object for the OneView appliance @param [Hash] params The options for this resource (key-value pairs) @param [Integer] api_ver The api version to use when interracting with this resource.

Calls superclass method OneviewSDK::Resource::new
# File lib/oneview-sdk/resource/api200/storage_system.rb, line 29
def initialize(client, params = {}, api_ver = nil)
  super
  # Default values:
  @data['type'] ||= 'StorageSystemV3'
end

Public Instance Methods

add() click to toggle source

Adds the resource to OneView using the current data @note Calls the refresh method to set additional data @return [OneviewSDK::StorageSystem] self

# File lib/oneview-sdk/resource/api200/storage_system.rb, line 56
def add
  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
create(*) click to toggle source

Method is not available @raise [OneviewSDK::MethodUnavailable] method is not available

# File lib/oneview-sdk/resource/api200/storage_system.rb, line 37
def create(*)
  unavailable_method
end
create!(*) click to toggle source

Method is not available @raise [OneviewSDK::MethodUnavailable] method is not available

# File lib/oneview-sdk/resource/api200/storage_system.rb, line 43
def create!(*)
  unavailable_method
end
delete(*) click to toggle source

Method is not available @raise [OneviewSDK::MethodUnavailable] method is not available

# File lib/oneview-sdk/resource/api200/storage_system.rb, line 49
def delete(*)
  unavailable_method
end
Also aliased as: remove
exists?() click to toggle source

Checks if the resource already exists @note one of the UNIQUE_IDENTIFIERS or credentials must be specified in the resource @return [Boolean] Whether or not resource exists @raise [OneviewSDK::IncompleteResource] if required attributes are not filled

Calls superclass method OneviewSDK::Resource#exists?
# File lib/oneview-sdk/resource/api200/storage_system.rb, line 72
def exists?
  ip_hostname = self['credentials'][:ip_hostname] || self['credentials']['ip_hostname'] rescue nil
  return true if ip_hostname && self.class.find_by(@client, credentials: { ip_hostname: ip_hostname }).size == 1
  super
rescue IncompleteResource => e
  raise e unless ip_hostname
  false
end
get_managed_ports(port = nil) click to toggle source

Lists all managed target ports for the specified storage system, or only the one specified @param [String] port Target port

# File lib/oneview-sdk/resource/api200/storage_system.rb, line 145
def get_managed_ports(port = nil)
  uri = @data['uri']
  uri += port.nil? ? '/managedPorts' : "/managedPorts/#{port}"
  self.class.find_with_pagination(@client, uri)
end
get_storage_pools() click to toggle source

Lists the storage pools

# File lib/oneview-sdk/resource/api200/storage_system.rb, line 138
def get_storage_pools
  self.class.find_with_pagination(@client, @data['uri'] + '/storage-pools')
end
like?(other) click to toggle source

Check the equality of the data for the other resource with this resource. @note Does not check the client, logger, or api_version if another resource is passed in @param [Hash, Resource] other resource or hash to compare the key-value pairs with @example Compare to hash @note Does not check the password in credentials @example myResource.like?(credentials: { username: 'admin', password: 'secret' })

myResource = OneviewSDK::Resource.new(client, { name: 'res1', description: 'example'}, 200)
myResource.like?(description: '') # returns false
myResource.like?(name: 'res1') # returns true

@return [Boolean] Whether or not the two objects are alike

Calls superclass method OneviewSDK::Resource#like?
# File lib/oneview-sdk/resource/api200/storage_system.rb, line 110
def like?(other)
  if other.is_a? Hash
    other_copy = Marshal.load(Marshal.dump(other))
  else
    other_copy = other.dup
    other_copy.data = Marshal.load(Marshal.dump(other.data))
  end

  if other_copy['credentials']
    other_copy['credentials'].delete('password') rescue nil
    other_copy['credentials'].delete(:password) rescue nil
  elsif other_copy[:credentials]
    other_copy[:credentials].delete('password') rescue nil
    other_copy[:credentials].delete(:password) rescue nil
  end

  super(other_copy)
end
remove(*)

Remove resource from OneView @return [true] if resource was removed successfully

Alias for: delete
retrieve!() click to toggle source

Retrieves the resource details based on this resource's name or URI. @note one of the UNIQUE_IDENTIFIERS or credentials must be specified in the resource @return [Boolean] Whether or not retrieve was successful @raise [OneviewSDK::IncompleteResource] if required attributes are not filled

Calls superclass method OneviewSDK::Resource#retrieve!
# File lib/oneview-sdk/resource/api200/storage_system.rb, line 85
def retrieve!
  ip_hostname = self['credentials'][:ip_hostname] || self['credentials']['ip_hostname'] rescue nil
  if ip_hostname
    results = self.class.find_by(@client, credentials: { ip_hostname: ip_hostname })
    if results.size == 1
      set_all(results[0].data)
      return true
    end
  end
  super
rescue IncompleteResource => e
  raise e unless ip_hostname
  false
end
set_refresh_state(state) click to toggle source

Refreshes a storage system @param [String] state NotRefreshing, RefreshFailed, RefreshPending, Refreshing

# File lib/oneview-sdk/resource/api200/storage_system.rb, line 153
def set_refresh_state(state)
  @data['refreshState'] = state
  update
end