Class: OneviewSDK::API500::C7000::StorageSystem

Inherits:
OneviewSDK::API300::C7000::StorageSystem show all
Defined in:
lib/oneview-sdk/resource/api500/c7000/storage_system.rb

Overview

Storage System resource implementation for API500 C7000

Direct Known Subclasses

Synergy::StorageSystem

Constant Summary collapse

UNIQUE_IDENTIFIERS =
%w(name uri hostname).freeze

Constants inherited from OneviewSDK::API200::StorageSystem

OneviewSDK::API200::StorageSystem::BASE_URI

Constants inherited from Resource

Resource::BASE_URI, Resource::DEFAULT_REQUEST_HEADER

Instance Attribute Summary

Attributes inherited from Resource

#api_version, #client, #data, #logger

Instance Method Summary collapse

Methods inherited from OneviewSDK::API200::StorageSystem

#create, #delete, get_host_types, #get_storage_pools, #like?

Methods inherited from Resource

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

Constructor Details

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

Create a resource object, associate it with a client, and set its properties.



26
27
28
29
30
31
# 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

Instance Method Details

#addOneviewSDK::StorageSystem

Note:

Calls the refresh method to set additional data

Adds the resource to OneView using the current data



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/oneview-sdk/resource/api500/c7000/storage_system.rb', line 48

def add
  ensure_client
  temp_old_data = JSON.load(@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?Boolean

Checks if the resource already exists

Raises:



95
96
97
98
# 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_portsObject

Method is unavailable

Raises:



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

def get_managed_ports(*)
  unavailable_method
end

#get_reachable_ports(networks = []) ⇒ Array

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



129
130
131
132
133
134
135
136
137
# 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_templatesArray

Gets a list of storage templates.



141
142
143
144
# 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

#removetrue

Delete resource from OneView



85
86
87
88
89
90
# 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_refreshObject

Refreshes a storage system



147
148
149
150
# File 'lib/oneview-sdk/resource/api500/c7000/storage_system.rb', line 147

def request_refresh
  @data['requestingRefresh'] = true
  update
end

#retrieve!Boolean

Note:

one of the UNIQUE_IDENTIFIERS, deviceSpecificAttributes or deviceSpecificAttributes must be specified in the resource

Retrieves the resource details based on this resource’s unique identifiers

Raises:



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/oneview-sdk/resource/api500/c7000/storage_system.rb', line 105

def retrieve!
  data_temp = JSON.load(@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_stateObject

Method is unavailable

Raises:



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

def set_refresh_state(*)
  unavailable_method
end

#update(attributes = {}) ⇒ Resource

Set data and save to OneView

Raises:



75
76
77
78
79
80
81
# 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