Class: OneviewSDK::API500::C7000::Volume

Inherits:
OneviewSDK::API300::C7000::Volume show all
Defined in:
lib/oneview-sdk/resource/api500/c7000/volume.rb

Overview

Volume resource implementation on API500 C7000

Direct Known Subclasses

Synergy::Volume

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

Instance Method Summary collapse

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

Note:

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.

Parameters:

  • client (OneviewSDK::Client)

    The client object for the OneView appliance.

  • storage_system (OneviewSDK::StorageSystem)

    The storage system in which the volume exists to be managed.

  • volume_name (String)

    The name of the volume on the actual storage system.

  • is_shareable (Boolean) (defaults to: false)

    Describes if the volume is shareable or private.

  • options (Hash) (defaults to: {})

    The options to create a volume.

Options Hash (options):

  • :name (String)

    The name for new volume.

  • :description (String)

    The description for new volume.

Returns:

  • (OneviewSDK::Volume)

    The volume imported.

Raises:



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, options = {})
  raise IncompleteResource, 'Storage system not found!' unless storage_system.retrieve!
  data = options.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

#createResource

Note:

properties and templateUri parameters are required for creation, but not afterwards; after creation, they will be removed.

Creates the volume

Returns:

Raises:



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

Note:

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.

Parameters:

  • snapshot_name (String)

    The snapshot name.

  • properties (Hash)

    Storage Pool to use for snapshots.

  • volume_template (OneviewSDK::VolumeTemplate) (defaults to: nil)

    The Volume Template resource.

  • is_permanent (Boolean) (defaults to: true)

    If true, indicates that the volume will persist when the profile using this volume is deleted.

Options Hash (properties):

  • :provisioningType (String)

    The provision type. Values: Full or Thin.

  • :name (String)

    The name for new volume.

  • :isShareable (String)

    Indicates whether or not the volume can be shared by multiple profiles.

Returns:

  • (OneviewSDK::Volume)

    The volume created.

Raises:



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

Parameters:

  • flag (Symbol) (defaults to: :all)

    Delete storage system from Oneview only or in storage system as well. Flags: :all = removes the volume from oneview and storage system. :oneview = removes from oneview only.

Returns:

  • (true)

    if resource was deleted successfully.

Raises:



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

Parameters:

  • storage_pool (OneviewSDK::StoragePool)

    Storage Pool to use for snapshots.



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

Parameters:

  • storage_pool (OneviewSDK::StoragePool)

    Storage pool.



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_systemObject

Method is not available

Raises:



22
23
24
# File 'lib/oneview-sdk/resource/api500/c7000/volume.rb', line 22

def set_storage_system(*)
  unavailable_method
end