class OneviewSDK::API500::C7000::StorageSystem

Storage System resource implementation for API500 C7000

Constants

UNIQUE_IDENTIFIERS

deviceSpecificAttributes and deviceSpecificAttributes are supported too

Public Class Methods

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::API200::StorageSystem::new
# File lib/oneview-sdk/resource/api500/c7000/storage_system.rb, line 26
def initialize(client, params = {}, api_ver = nil)
  # Default values:
  @data ||= {}
  @data['type'] ||= 'StorageSystemV4'
  super
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/api500/c7000/storage_system.rb, line 48
def add
  ensure_client
  temp_old_data = JSON.parse(@data.to_json)
  credentials = temp_old_data['credentials'] || {}
  request_body = {
    'family'   => @data['family'],
    'hostname' => @data['hostname'],
    'username' => @data.delete('username') || credentials['username'],
    'password' => @data.delete('password') || credentials['password']
  }
  response = @client.rest_post(self.class::BASE_URI, { 'body' => request_body }, @api_version)
  response_body = @client.response_handler(response)
  set_all(response_body)

  managed_domain = temp_old_data['deviceSpecificAttributes']['managedDomain'] rescue nil
  if self['family'] == 'StoreServ' && managed_domain
    deep_merge!(temp_old_data)
    update
  end
  self
end
exists?() click to toggle source

Checks if the resource already exists @return [Boolean] Whether or not resource exists @raise [OneviewSDK::IncompleteResource] if required attributes are not filled

# File lib/oneview-sdk/resource/api500/c7000/storage_system.rb, line 95
def exists?
  temp_item = self.class.new(@client, @data.clone)
  temp_item.retrieve!
end
get_managed_ports(*) click to toggle source

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

# File lib/oneview-sdk/resource/api500/c7000/storage_system.rb, line 35
def get_managed_ports(*)
  unavailable_method
end
get_reachable_ports(networks = []) click to toggle source

Gets the storage ports that are connected on the specified networks based on the storage system port's expected network connectivity @param [Array] network Array of networks @return [Array] Array of reachable storage port

# File lib/oneview-sdk/resource/api500/c7000/storage_system.rb, line 129
def get_reachable_ports(networks = [])
  ensure_client && ensure_uri
  uri = @data['uri'] + '/reachable-ports'
  unless networks.empty?
    network_uris = ensure_and_get_uris(networks)
    uri += "?networks='#{network_uris.join(',')}'"
  end
  self.class.find_with_pagination(@client, uri)
end
get_templates() click to toggle source

Gets a list of storage templates. @return [Array] Array of Storage Template

# File lib/oneview-sdk/resource/api500/c7000/storage_system.rb, line 141
def get_templates
  ensure_client && ensure_uri
  self.class.find_with_pagination(@client, @data['uri'] + '/templates')
end
remove() click to toggle source

Delete resource from OneView @return [true] if resource was deleted successfully

# File lib/oneview-sdk/resource/api500/c7000/storage_system.rb, line 85
def remove
  ensure_client && ensure_uri
  response = @client.rest_delete(@data['uri'], { 'If-Match' => @data['eTag'] }, @api_version)
  @client.response_handler(response)
  true
end
request_refresh() click to toggle source

Refreshes a storage system

# File lib/oneview-sdk/resource/api500/c7000/storage_system.rb, line 147
def request_refresh
  @data['requestingRefresh'] = true
  update
end
retrieve!() click to toggle source

Retrieves the resource details based on this resource's unique identifiers @note one of the UNIQUE_IDENTIFIERS, deviceSpecificAttributes or deviceSpecificAttributes

must be specified in the resource

@return [Boolean] Whether or not retrieve was successful @raise [OneviewSDK::IncompleteResource] if required attributes are not filled

# File lib/oneview-sdk/resource/api500/c7000/storage_system.rb, line 105
def retrieve!
  data_temp = JSON.parse(@data.to_json)
  serial_number = data_temp['deviceSpecificAttributes']['serialNumber'] rescue nil
  wwn = data_temp['deviceSpecificAttributes']['wwn'] rescue nil

  proc_retrieve_temp = proc do |identifier|
    results = self.class.find_by(@client, identifier)
    if results.size == 1
      set_all(results.first.data)
      return true
    end
  end
  proc_retrieve_temp.call('deviceSpecificAttributes' => { 'serialNumber' => serial_number }) if serial_number
  proc_retrieve_temp.call('deviceSpecificAttributes' => { 'wwn' => wwn }) if wwn

  super
rescue IncompleteResource => e
  raise e unless serial_number || wwn
  false
end
set_refresh_state(*) click to toggle source

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

# File lib/oneview-sdk/resource/api500/c7000/storage_system.rb, line 41
def set_refresh_state(*)
  unavailable_method
end
update(attributes = {}) click to toggle source

Set data and save to OneView @param [Hash] attributes The attributes to add/change for this resource (key-value pairs) @raise [OneviewSDK::IncompleteResource] if the client or uri is not set @raise [StandardError] if the resource save fails @return [Resource] self

# File lib/oneview-sdk/resource/api500/c7000/storage_system.rb, line 75
def update(attributes = {})
  set_all(attributes)
  ensure_client && ensure_uri
  response = @client.rest_put(@data['uri'] + '/?force=true', { 'body' => @data }, @api_version)
  @client.response_handler(response)
  self
end