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
Initiates a process to import a volume (created external to OneView) for management by the appliance.
Instance Method Summary collapse
-
#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.
-
#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.
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?, #exists?, find_by, find_with_pagination, from_file, get_all, #initialize, #like?, #refresh, #retrieve!, #schema, schema, #set, #set_all, #to_file, #update
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
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.
123 124 125 126 127 128 |
# File 'lib/oneview-sdk/resource/api500/c7000/volume.rb', line 123 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
#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.
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/oneview-sdk/resource/api500/c7000/volume.rb', line 88 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
51 52 53 54 55 56 57 58 59 |
# File 'lib/oneview-sdk/resource/api500/c7000/volume.rb', line 51 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 |
#set_snapshot_pool(storage_pool) ⇒ Object
Sets the snapshot pool to the volume
71 72 73 74 75 |
# File 'lib/oneview-sdk/resource/api500/c7000/volume.rb', line 71 def set_snapshot_pool(storage_pool) assure_uri(storage_pool) @data['properties'] ||= {} @data['properties']['snapshotPool'] = storage_pool['uri'] end |
#set_storage_pool(storage_pool) ⇒ Object
Sets the storage pool to the volume
63 64 65 66 67 |
# File 'lib/oneview-sdk/resource/api500/c7000/volume.rb', line 63 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 |