class OneviewSDK::API200::VolumeTemplate

Volume template resource implementation

Constants

BASE_URI
DEFAULT_REQUEST_HEADER

Public Class Methods

new(client, params = {}, api_ver = nil) click to toggle source

Create the client object, establishes connection, and set up the logging and api version. @param [OneviewSDK::Client] client The client object for the OneView appliance @param [Hash] params The options for this resource (key-value pairs) @param [Integer] api_ver The api version to use when interracting with this resource. Defaults to client.api_version if exists, or OneviewSDK::Client::DEFAULT_API_VERSION. Defaults type to StorageVolumeTemplate when API version is 120 Defaults type to StorageVolumeTemplateV3 when API version is 200

Calls superclass method OneviewSDK::Resource::new
# File lib/oneview-sdk/resource/api200/volume_template.rb, line 28
def initialize(client, params = {}, api_ver = nil)
  super
  # Default values:
  @data['provisioning'] ||= {}
  @data['type'] ||= 'StorageVolumeTemplateV3'
end

Public Instance Methods

create(header = {}) click to toggle source

Create the resource on OneView using the current data @note Calls refresh method to set additional data @param [Hash] header The header options for the request (key-value pairs) @raise [OneviewSDK::IncompleteResource] if the client is not set @raise [StandardError] if the resource creation fails @return [Resource] self

Calls superclass method OneviewSDK::Resource#create
# File lib/oneview-sdk/resource/api200/volume_template.rb, line 41
def create(header = {})
  super(DEFAULT_REQUEST_HEADER.merge(header))
end
delete(header = {}) click to toggle source

Deletes the volume template from OneView @param [Hash] header The header options for the request (key-value pairs) @return [TrueClass] if the volume template was deleted successfully

Calls superclass method OneviewSDK::Resource#delete
# File lib/oneview-sdk/resource/api200/volume_template.rb, line 48
def delete(header = {})
  super(DEFAULT_REQUEST_HEADER.merge(header))
end
get_connectable_volume_templates(attributes = {}) click to toggle source

Gets the connectable volume templates by its attributes @param [Hash] attributes Hash containing the attributes name and value

# File lib/oneview-sdk/resource/api200/volume_template.rb, line 91
def get_connectable_volume_templates(attributes = {})
  OneviewSDK::Resource.find_by(@client, attributes, BASE_URI + '/connectable-volume-templates')
end
set_provisioning(shareable, provisionType, capacity, storage_pool) click to toggle source

Sets the storage pool @param [Boolean] shareable @param [String] provisionType 'Thin' or 'Full' @param [String] capacity (in bytes) @param [OneviewSDK::StoragePool] storage_pool

# File lib/oneview-sdk/resource/api200/volume_template.rb, line 67
def set_provisioning(shareable, provisionType, capacity, storage_pool)
  @data['provisioning']['shareable'] = shareable
  @data['provisioning']['provisionType'] = provisionType
  @data['provisioning']['capacity'] = capacity
  storage_pool.retrieve! unless storage_pool['uri']
  @data['provisioning']['storagePoolUri'] = storage_pool['uri']
end
set_snapshot_pool(storage_pool) click to toggle source

Sets the snapshot pool @param [OneviewSDK::StoragePool] storage_pool Storage Pool to generate the template

# File lib/oneview-sdk/resource/api200/volume_template.rb, line 84
def set_snapshot_pool(storage_pool)
  storage_pool.retrieve! unless storage_pool['uri']
  @data['snapshotPoolUri'] = storage_pool['uri']
end
set_storage_system(storage_system) click to toggle source

Sets the storage system @param [OneviewSDK::StorageSystem] storage_system Storage System to be used to create the template

# File lib/oneview-sdk/resource/api200/volume_template.rb, line 77
def set_storage_system(storage_system)
  storage_system.retrieve! unless storage_system['uri']
  @data['storageSystemUri'] = storage_system['uri']
end
update(attributes = {}) click to toggle source

Updates the volume template from OneView @return [Resource] self

# File lib/oneview-sdk/resource/api200/volume_template.rb, line 54
def update(attributes = {})
  set_all(attributes)
  ensure_client && ensure_uri
  response = @client.rest_put(@data['uri'], { 'Accept-Language' => 'en_US', 'body' => @data }, @api_version)
  @client.response_handler(response)
  self
end