Class: OneviewSDK::API200::StorageSystem
- Defined in:
- lib/oneview-sdk/resource/api200/storage_system.rb
Overview
Storage system resource implementation
Direct Known Subclasses
OneviewSDK::API300::C7000::StorageSystem, OneviewSDK::API300::Synergy::StorageSystem
Constant Summary collapse
- BASE_URI =
'/rest/storage-systems'.freeze
- UNIQUE_IDENTIFIERS =
credentials is supported too
%w(name uri serialNumber wwn).freeze
Instance Attribute Summary
Attributes inherited from Resource
#api_version, #client, #data, #logger
Class Method Summary collapse
-
.get_host_types(client) ⇒ String
Gets the host types for the storage system resource.
Instance Method Summary collapse
-
#add ⇒ OneviewSDK::StorageSystem
Adds the resource to OneView using the current data.
-
#create ⇒ Object
Method is not available.
-
#delete ⇒ Object
Method is not available.
-
#exists? ⇒ Boolean
Checks if the resource already exists.
-
#get_managed_ports(port = nil) ⇒ Object
Lists all managed target ports for the specified storage system, or only the one specified.
-
#get_storage_pools ⇒ Object
Lists the storage pools.
-
#initialize(client, params = {}, api_ver = nil) ⇒ StorageSystem
constructor
Create a resource object, associate it with a client, and set its properties.
-
#like?(other) ⇒ Boolean
Check the equality of the data for the other resource with this resource.
-
#remove ⇒ true
Remove resource from OneView.
-
#retrieve! ⇒ Boolean
Retrieves the resource details based on this resource’s name or URI.
-
#set_refresh_state(state) ⇒ Object
Refreshes a storage system.
Methods inherited from Resource
#==, #[], #[]=, build_query, #create!, #each, #eql?, find_by, from_file, get_all, #refresh, #schema, schema, #set, #set_all, #to_file, #update
Constructor Details
#initialize(client, params = {}, api_ver = nil) ⇒ StorageSystem
Create a resource object, associate it with a client, and set its properties.
29 30 31 32 33 |
# 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 |
Class Method Details
.get_host_types(client) ⇒ String
Gets the host types for the storage system resource
126 127 128 129 |
# File 'lib/oneview-sdk/resource/api200/storage_system.rb', line 126 def self.get_host_types(client) response = client.rest_get(BASE_URI + '/host-types') response.body end |
Instance Method Details
#add ⇒ OneviewSDK::StorageSystem
Calls the refresh method to set additional data
Adds the resource to OneView using the current data
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/oneview-sdk/resource/api200/storage_system.rb', line 50 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 ⇒ Object
Method is not available
37 38 39 |
# File 'lib/oneview-sdk/resource/api200/storage_system.rb', line 37 def create(*) unavailable_method end |
#delete ⇒ Object
Method is not available
43 44 45 |
# File 'lib/oneview-sdk/resource/api200/storage_system.rb', line 43 def delete(*) unavailable_method end |
#exists? ⇒ Boolean
one of the UNIQUE_IDENTIFIERS or credentials must be specified in the resource
Checks if the resource already exists
66 67 68 69 70 71 72 73 |
# File 'lib/oneview-sdk/resource/api200/storage_system.rb', line 66 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) ⇒ Object
Lists all managed target ports for the specified storage system, or only the one specified
140 141 142 143 144 145 146 147 |
# File 'lib/oneview-sdk/resource/api200/storage_system.rb', line 140 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_pools ⇒ Object
Lists the storage pools
132 133 134 135 |
# File 'lib/oneview-sdk/resource/api200/storage_system.rb', line 132 def get_storage_pools response = @client.rest_get(@data['uri'] + '/storage-pools') response.body end |
#like?(other) ⇒ Boolean
Does not check the client, logger, or api_version if another resource is passed in
Does not check the password in credentials
Check the equality of the data for the other resource with this resource.
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/oneview-sdk/resource/api200/storage_system.rb', line 104 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 ⇒ true
Remove resource from OneView
23 |
# File 'lib/oneview-sdk/resource/api200/storage_system.rb', line 23 alias remove delete |
#retrieve! ⇒ Boolean
one of the UNIQUE_IDENTIFIERS or credentials must be specified in the resource
Retrieves the resource details based on this resource’s name or URI.
79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/oneview-sdk/resource/api200/storage_system.rb', line 79 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) ⇒ Object
Refreshes a storage system
151 152 153 154 |
# File 'lib/oneview-sdk/resource/api200/storage_system.rb', line 151 def set_refresh_state(state) @data['refreshState'] = state update end |