Class: OneviewSDK::API500::C7000::Volume
- Inherits:
-
OneviewSDK::API300::C7000::Volume
- Object
- Resource
- OneviewSDK::API200::Volume
- OneviewSDK::API300::C7000::Volume
- OneviewSDK::API500::C7000::Volume
- Defined in:
- lib/oneview-sdk/resource/api500/c7000/volume.rb
Overview
Volume resource implementation on API500 C7000
Direct Known Subclasses
Constant Summary
Constants inherited from OneviewSDK::API200::Volume
OneviewSDK::API200::Volume::BASE_URI
Constants inherited from Resource
Resource::BASE_URI, Resource::DEFAULT_REQUEST_HEADER, Resource::UNIQUE_IDENTIFIERS
Instance Attribute Summary
Attributes inherited from Resource
#api_version, #client, #data, #logger
Class Method Summary collapse
-
.add(client, storage_system, volume_name, is_shareable = false, options = {}) ⇒ OneviewSDK::Volume
deprecated
Deprecated.
Use #add instead.
Instance Method Summary collapse
-
#add ⇒ OneviewSDK::Volume
Initiates a process to import a volume (created external to OneView) for management by the appliance.
-
#create ⇒ Resource
Creates the volume.
-
#create_from_snapshot(snapshot_name, properties, volume_template = nil, is_permanent = true) ⇒ OneviewSDK::Volume
Creates a new volume on the storage system from a snapshot of a volume.
-
#delete(flag = :all) ⇒ true
Deletes the resource from OneView or from Oneview and storage system.
-
#exists? ⇒ Boolean
Check if a resource exists.
-
#retrieve! ⇒ Boolean
Retrieve resource details based on this resource’s name or URI.
-
#set_snapshot_pool(storage_pool) ⇒ Object
Sets the snapshot pool to the volume.
-
#set_storage_pool(storage_pool) ⇒ Object
Sets the storage pool to the volume.
-
#set_storage_system ⇒ Object
Method is not available.
-
#update(attributes = {}) ⇒ OneviewSDK::Volume
Update resource attributes.
Methods inherited from OneviewSDK::API200::Volume
#create_snapshot, #delete_snapshot, get_attachable_volumes, get_extra_managed_volume_paths, #get_snapshot, #get_snapshots, #repair, #set_storage_volume_template
Methods inherited from Resource
#==, #[], #[]=, build_query, #create!, #deep_merge!, #each, #eql?, find_by, find_with_pagination, from_file, get_all, #initialize, #like?, #refresh, #schema, schema, #set, #set_all, #to_file
Constructor Details
This class inherits a constructor from OneviewSDK::Resource
Class Method Details
.add(client, storage_system, volume_name, is_shareable = false, options = {}) ⇒ OneviewSDK::Volume
Use #add instead.
Volumes can be added only on the storage system and storage pools managed by the appliance.
Initiates a process to import a volume (created external to OneView) for management by the appliance.
138 139 140 141 142 143 |
# File 'lib/oneview-sdk/resource/api500/c7000/volume.rb', line 138 def self.add(client, storage_system, volume_name, is_shareable = false, = {}) raise IncompleteResource, 'Storage system not found!' unless storage_system.retrieve! data = .merge('storageSystemUri' => storage_system['uri'], 'deviceVolumeName' => volume_name, 'isShareable' => is_shareable) response = client.rest_post("#{BASE_URI}/from-existing", { 'body' => data }, client.api_version) new(client, client.response_handler(response)) end |
Instance Method Details
#add ⇒ OneviewSDK::Volume
Volumes can be added only on the storage system and storage pools managed by the appliance.
Initiates a process to import a volume (created external to OneView) for management by the appliance.
149 150 151 152 153 154 155 156 157 |
# File 'lib/oneview-sdk/resource/api500/c7000/volume.rb', line 149 def add ensure_client required_attributes = %w(deviceVolumeName isShareable storageSystemUri) required_attributes.each { |k| raise IncompleteResource, "Missing required attribute: '#{k}'" unless @data.key?(k) || @data.key?(k.to_sym) } @data['name'] ||= @data['deviceVolumeName'] response = @client.rest_post("#{BASE_URI}/from-existing", { 'body' => @data }, @api_version) set_all(client.response_handler(response)) self end |
#create ⇒ Resource
properties and templateUri parameters are required for creation, but not afterwards; after creation, they will be removed.
Creates the volume
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/oneview-sdk/resource/api500/c7000/volume.rb', line 31 def create properties = Hash[@data['properties'].map { |k, v| [k.to_sym, v] }] family = properties[:dataProtectionLevel].nil? ? 'StoreServ' : 'StoreVirtual' template_data = { isRoot: true, family: family } @data['templateUri'] = get_volume_template_uri(template_data) unless @data['templateUri'] OneviewSDK::Resource.instance_method(:create).bind(self).call @data.delete('properties') @data.delete('templateUri') self end |
#create_from_snapshot(snapshot_name, properties, volume_template = nil, is_permanent = true) ⇒ OneviewSDK::Volume
Volumes can only be created on storage pools managed by the appliance.
Creates a new volume on the storage system from a snapshot of a volume.
102 103 104 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/volume.rb', line 102 def create_from_snapshot(snapshot_name, properties, volume_template = nil, is_permanent = true) snapshot = get_snapshot(snapshot_name) raise IncompleteResource, 'Snapshot not found!' unless snapshot storage_pool_uri = nil volume_template_uri = if volume_template.nil? storage_pool_uri = @data['storagePoolUri'] get_volume_template_uri(isRoot: true, family: 'StoreServ') else raise IncompleteResource, 'Volume Template not found!' unless volume_template.retrieve! storage_pool_uri = volume_template['storagePoolUri'] volume_template['uri'] end data = { 'properties' => properties.merge('storagePool' => storage_pool_uri, 'snapshotPool' => storage_pool_uri), 'snapshotUri' => snapshot['uri'], 'templateUri' => volume_template_uri, 'isPermanent' => is_permanent } response = @client.rest_post("#{BASE_URI}/from-snapshot", { 'body' => data }, @api_version) self.class.new(@client, client.response_handler(response)) end |
#delete(flag = :all) ⇒ true
Deletes the resource from OneView or from Oneview and storage system
59 60 61 62 63 64 65 66 67 |
# File 'lib/oneview-sdk/resource/api500/c7000/volume.rb', line 59 def delete(flag = :all) ensure_client && ensure_uri raise InvalidResource, 'Invalid flag value, use :oneview or :all' unless flag == :oneview || flag == :all uri = @data['uri'] uri << '?suppressDeviceUpdates=true' if flag == :oneview response = @client.rest_delete(uri, 'If-Match' => @data['eTag']) @client.response_handler(response) true end |
#exists? ⇒ Boolean
one of the UNIQUE_IDENTIFIERS, e.g. name or uri or properties, must be specified in the resource
Check if a resource exists
173 174 175 176 |
# File 'lib/oneview-sdk/resource/api500/c7000/volume.rb', line 173 def exists? return super unless @data['properties'] find_by_name_in_properties.size == 1 end |
#retrieve! ⇒ Boolean
one of the UNIQUE_IDENTIFIERS, e.g. name or uri or properties, must be specified in the resource
Retrieve resource details based on this resource’s name or URI.
162 163 164 165 166 167 168 |
# File 'lib/oneview-sdk/resource/api500/c7000/volume.rb', line 162 def retrieve! return super unless @data['properties'] results = find_by_name_in_properties return false unless results.size == 1 set_all(results.first.data) true end |
#set_snapshot_pool(storage_pool) ⇒ Object
Sets the snapshot pool to the volume
80 81 82 83 84 85 86 87 88 89 |
# File 'lib/oneview-sdk/resource/api500/c7000/volume.rb', line 80 def set_snapshot_pool(storage_pool) assure_uri(storage_pool) if @data['uri'] @data['deviceSpecificAttributes'] ||= {} @data['deviceSpecificAttributes']['snapshotPoolUri'] = storage_pool['uri'] else @data['properties'] ||= {} @data['properties']['snapshotPool'] = storage_pool['uri'] end end |
#set_storage_pool(storage_pool) ⇒ Object
The storagePoolUri attribute should not be set in the updated. Once created, this attribute is read only.
Sets the storage pool to the volume
72 73 74 75 76 |
# File 'lib/oneview-sdk/resource/api500/c7000/volume.rb', line 72 def set_storage_pool(storage_pool) assure_uri(storage_pool) @data['properties'] ||= {} @data['properties']['storagePool'] = storage_pool['uri'] end |
#set_storage_system ⇒ Object
Method is not available
22 23 24 |
# File 'lib/oneview-sdk/resource/api500/c7000/volume.rb', line 22 def set_storage_system(*) unavailable_method end |
#update(attributes = {}) ⇒ OneviewSDK::Volume
Update resource attributes
49 50 51 52 |
# File 'lib/oneview-sdk/resource/api500/c7000/volume.rb', line 49 def update(attributes = {}) @data.delete('properties') OneviewSDK::Resource.instance_method(:update).bind(self).call(attributes) end |