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
Constants inherited from Resource
Resource::DEFAULT_REQUEST_HEADER, Resource::UNIQUE_IDENTIFIERS
Instance Attribute Summary
Attributes inherited from Resource
#api_version, #client, #data, #logger
Instance Method Summary collapse
-
#create ⇒ Resource
Create the resource on OneView using the current data.
-
#delete ⇒ 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, #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
27 28 29 30 31 32 |
# File 'lib/oneview-sdk/resource/api200/volume_template.rb', line 27 def initialize(client, params = {}, api_ver = nil) super # Default values: @data['provisioning'] ||= {} @data['type'] ||= 'StorageVolumeTemplateV3' end |
Instance Method Details
#create ⇒ Resource
Calls refresh method to set additional data
Create the resource on OneView using the current data
39 40 41 42 43 44 |
# File 'lib/oneview-sdk/resource/api200/volume_template.rb', line 39 def create ensure_client response = @client.rest_post(self.class::BASE_URI, { 'Accept-Language' => 'en_US', 'body' => @data }, @api_version) body = @client.response_handler(response) set_all(body) end |
#delete ⇒ TrueClass
Deletes the volume template from OneView
48 49 50 51 52 53 |
# File 'lib/oneview-sdk/resource/api200/volume_template.rb', line 48 def delete ensure_client && ensure_uri response = @client.rest_delete(@data['uri'], { 'Accept-Language' => 'en_US' }, @api_version) @client.response_handler(response) true end |
#get_connectable_volume_templates(attributes = {}) ⇒ Object
Gets the connectable volume templates by its attributes
94 95 96 |
# File 'lib/oneview-sdk/resource/api200/volume_template.rb', line 94 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
70 71 72 73 74 75 76 |
# File 'lib/oneview-sdk/resource/api200/volume_template.rb', line 70 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
87 88 89 90 |
# File 'lib/oneview-sdk/resource/api200/volume_template.rb', line 87 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
80 81 82 83 |
# File 'lib/oneview-sdk/resource/api200/volume_template.rb', line 80 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
57 58 59 60 61 62 63 |
# File 'lib/oneview-sdk/resource/api200/volume_template.rb', line 57 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 |