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
Constants inherited from Resource
Resource::DEFAULT_REQUEST_HEADER
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.
-
#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, #deep_merge!, #each, #eql?, find_by, find_with_pagination, from_file, get_all, get_all_with_query, #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
132 133 134 135 |
# 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 |
Instance Method Details
#add ⇒ OneviewSDK::StorageSystem
Calls the refresh method to set additional data
Adds the resource to OneView using the current data
56 57 58 59 60 61 62 63 64 65 66 |
# 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 ⇒ Object
Method is not available
37 38 39 |
# File 'lib/oneview-sdk/resource/api200/storage_system.rb', line 37 def create(*) unavailable_method end |
#create! ⇒ Object
Method is not available
43 44 45 |
# File 'lib/oneview-sdk/resource/api200/storage_system.rb', line 43 def create!(*) unavailable_method end |
#delete ⇒ Object
Method is not available
49 50 51 |
# File 'lib/oneview-sdk/resource/api200/storage_system.rb', line 49 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
72 73 74 75 76 77 78 79 |
# 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) ⇒ Object
Lists all managed target ports for the specified storage system, or only the one specified
145 146 147 148 149 |
# 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 ⇒ Object
Lists the storage pools
138 139 140 |
# 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) ⇒ 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.
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# 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 ⇒ 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.
85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# 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) ⇒ Object
Refreshes a storage system
153 154 155 156 |
# File 'lib/oneview-sdk/resource/api200/storage_system.rb', line 153 def set_refresh_state(state) @data['refreshState'] = state update end |