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(header = {}) ⇒ 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, header = {}) ⇒ true
Deletes the resource from OneView or from Oneview and storage system.
-
#exists?(header = {}) ⇒ Boolean
Check if a resource exists.
-
#retrieve!(header = {}) ⇒ 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!, #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, get_all_with_query, #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.
140 141 142 143 144 145 |
# File 'lib/oneview-sdk/resource/api500/c7000/volume.rb', line 140 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.
151 152 153 154 155 156 157 158 159 |
# File 'lib/oneview-sdk/resource/api500/c7000/volume.rb', line 151 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(header = {}) ⇒ Resource
properties and templateUri parameters are required for creation, but not afterwards; after creation, they will be removed.
Creates the volume
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/oneview-sdk/resource/api500/c7000/volume.rb', line 32 def create(header = {}) 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(DEFAULT_REQUEST_HEADER.merge(header)) @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.
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/oneview-sdk/resource/api500/c7000/volume.rb', line 104 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, header = {}) ⇒ true
Deletes the resource from OneView or from Oneview and storage system
61 62 63 64 65 66 67 68 69 |
# File 'lib/oneview-sdk/resource/api500/c7000/volume.rb', line 61 def delete(flag = :all, header = {}) ensure_client && ensure_uri raise InvalidResource, 'Invalid flag value, use :oneview or :all' unless %i[oneview all].include?(flag) uri = @data['uri'] uri << '?suppressDeviceUpdates=true' if flag == :oneview response = @client.rest_delete(uri, DEFAULT_REQUEST_HEADER.merge(header).merge('If-Match' => @data['eTag'])) @client.response_handler(response) true end |
#exists?(header = {}) ⇒ Boolean
one of the UNIQUE_IDENTIFIERS, e.g. name or uri or properties, must be specified in the resource
Check if a resource exists
178 179 180 181 182 |
# File 'lib/oneview-sdk/resource/api500/c7000/volume.rb', line 178 def exists?(header = {}) header = DEFAULT_REQUEST_HEADER.merge(header) return super(header) unless @data['properties'] find_by_name_in_properties(header).size == 1 end |
#retrieve!(header = {}) ⇒ 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.
165 166 167 168 169 170 171 172 |
# File 'lib/oneview-sdk/resource/api500/c7000/volume.rb', line 165 def retrieve!(header = {}) header = DEFAULT_REQUEST_HEADER.merge(header) return super(header) unless @data['properties'] results = find_by_name_in_properties(header) 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
82 83 84 85 86 87 88 89 90 91 |
# File 'lib/oneview-sdk/resource/api500/c7000/volume.rb', line 82 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
74 75 76 77 78 |
# File 'lib/oneview-sdk/resource/api500/c7000/volume.rb', line 74 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
50 51 52 53 |
# File 'lib/oneview-sdk/resource/api500/c7000/volume.rb', line 50 def update(attributes = {}) @data.delete('properties') OneviewSDK::Resource.instance_method(:update).bind(self).call(attributes) end |