Class: OneviewSDK::API200::VolumeTemplate
- Defined in:
- lib/oneview-sdk/resource/api200/volume_template.rb
Overview
Volume template resource implementation
Direct Known Subclasses
OneviewSDK::API300::C7000::VolumeTemplate, OneviewSDK::API300::Synergy::VolumeTemplate
Constant Summary collapse
- BASE_URI =
'/rest/storage-volume-templates'.freeze
- DEFAULT_REQUEST_HEADER =
{ 'Accept-Language' => 'en_US' }.freeze
Constants inherited from Resource
Instance Attribute Summary
Attributes inherited from Resource
#api_version, #client, #data, #logger
Instance Method Summary collapse
-
#create(header = {}) ⇒ Resource
Create the resource on OneView using the current data.
-
#delete(header = {}) ⇒ TrueClass
Deletes the volume template from OneView.
-
#get_connectable_volume_templates(attributes = {}) ⇒ Object
Gets the connectable volume templates by its attributes.
-
#initialize(client, params = {}, api_ver = nil) ⇒ VolumeTemplate
constructor
Create the client object, establishes connection, and set up the logging and api version.
-
#set_provisioning(shareable, provisionType, capacity, storage_pool) ⇒ Object
Sets the storage pool.
-
#set_snapshot_pool(storage_pool) ⇒ Object
Sets the snapshot pool.
-
#set_storage_system(storage_system) ⇒ Object
Sets the storage system.
-
#update(attributes = {}) ⇒ Resource
Updates the volume template from OneView.
Methods inherited from Resource
#==, #[], #[]=, build_query, #create!, #deep_merge!, #each, #eql?, #exists?, find_by, find_with_pagination, from_file, get_all, get_all_with_query, #like?, #refresh, #retrieve!, #schema, schema, #set, #set_all, #to_file
Constructor Details
#initialize(client, params = {}, api_ver = nil) ⇒ VolumeTemplate
Create the client object, establishes connection, and set up the logging and api version. 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
28 29 30 31 32 33 |
# 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 |
Instance Method Details
#create(header = {}) ⇒ Resource
Calls refresh method to set additional data
Create the resource on OneView using the current data
41 42 43 |
# File 'lib/oneview-sdk/resource/api200/volume_template.rb', line 41 def create(header = {}) super(DEFAULT_REQUEST_HEADER.merge(header)) end |
#delete(header = {}) ⇒ TrueClass
Deletes the volume template from OneView
48 49 50 |
# 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 = {}) ⇒ Object
Gets the connectable volume templates by its attributes
91 92 93 |
# 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) ⇒ Object
Sets the storage pool
67 68 69 70 71 72 73 |
# 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) ⇒ Object
Sets the snapshot pool
84 85 86 87 |
# 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) ⇒ Object
Sets the storage system
77 78 79 80 |
# 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 = {}) ⇒ Resource
Updates the volume template from OneView
54 55 56 57 58 59 60 |
# 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 |