Class: OneviewSDK::StorageSystem
- Defined in:
- lib/oneview-sdk/resource/storage_system.rb
Overview
Storage system resource implementation
Constant Summary collapse
- BASE_URI =
'/rest/storage-systems'.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.
-
#remove ⇒ true
Remove resource from OneView.
-
#retrieve! ⇒ Boolean
Retrieves the resource details based on this resource’s name or URI.
Methods inherited from Resource
#==, #[], #[]=, build_query, #create!, #each, #eql?, find_by, from_file, get_all, #like?, #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.
25 26 27 28 29 |
# File 'lib/oneview-sdk/resource/storage_system.rb', line 25 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
90 91 92 93 |
# File 'lib/oneview-sdk/resource/storage_system.rb', line 90 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
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/oneview-sdk/resource/storage_system.rb', line 46 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
33 34 35 |
# File 'lib/oneview-sdk/resource/storage_system.rb', line 33 def create unavailable_method end |
#delete ⇒ Object
Method is not available
39 40 41 |
# File 'lib/oneview-sdk/resource/storage_system.rb', line 39 def delete unavailable_method end |
#exists? ⇒ Boolean
name,uri or ip_hostname must be specified inside resource
Checks if the resource already exists
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/oneview-sdk/resource/storage_system.rb', line 61 def exists? ip_hostname = self['credentials'][:ip_hostname] || self['credentials']['ip_hostname'] if self['credentials'] return true if @data['name'] && self.class.find_by(@client, name: @data['name']).size == 1 return true if @data['uri'] && self.class.find_by(@client, uri: @data['uri']).size == 1 return true if ip_hostname && self.class.find_by(@client, credentials: { ip_hostname: ip_hostname }).size == 1 unless @data['name'] || @data['uri'] || ip_hostname fail IncompleteResource, 'Must set resource name, uri or ip_hostname before trying to retrieve!' end false end |
#get_managed_ports(port = nil) ⇒ Object
Lists all managed target ports for the specified storage system, or only the one specified
104 105 106 107 108 109 110 111 |
# File 'lib/oneview-sdk/resource/storage_system.rb', line 104 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
96 97 98 99 |
# File 'lib/oneview-sdk/resource/storage_system.rb', line 96 def get_storage_pools response = @client.rest_get(@data['uri'] + '/storage-pools') response.body end |
#remove ⇒ true
Remove resource from OneView
19 |
# File 'lib/oneview-sdk/resource/storage_system.rb', line 19 alias remove delete |
#retrieve! ⇒ Boolean
Name,URI or ip_hostname must be specified inside resource
Retrieves the resource details based on this resource’s name or URI.
76 77 78 79 80 81 82 83 84 85 |
# File 'lib/oneview-sdk/resource/storage_system.rb', line 76 def retrieve! ip_hostname = self['credentials'][:ip_hostname] || self['credentials']['ip_hostname'] if self['credentials'] return super if @data['name'] || @data['uri'] fail IncompleteResource, 'Must set resource name, uri or ip_hostname before trying to retrieve!' unless ip_hostname results = self.class.find_by(@client, credentials: { ip_hostname: ip_hostname }) return false unless results.size == 1 set_all(results[0].data) true end |