Class: OneviewSDK::API500::C7000::VolumeTemplate

Inherits:
Resource show all
Defined in:
lib/oneview-sdk/resource/api500/c7000/volume_template.rb

Overview

Volume Template resource implementation for API500 C7000

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

#==, #[], #[]=, build_query, #create, #create!, #deep_merge!, #each, #eql?, #exists?, find_by, find_with_pagination, from_file, get_all, get_all_with_query, #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

.get_reachable_volume_templates(client, networks = [], attributes = {}) ⇒ Array

Gets the storage templates that are connected on the specified networks based on the storage system port’s expected network connectivity.

Parameters:

  • client (OneviewSDK::Client)

    The client object for the OneView appliance

  • networks (Array) (defaults to: [])

    Set of networks to filter the storage templates connected

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

    Hash containing the attributes name and value to filter storage templates

Returns:

  • (Array)

    the collection of volume templates



92
93
94
95
96
97
98
99
# File 'lib/oneview-sdk/resource/api500/c7000/volume_template.rb', line 92

def self.get_reachable_volume_templates(client, networks = [], attributes = {})
  uri = self::BASE_URI + '/reachable-volume-templates'
  unless networks.empty?
    network_uris = networks.map { |item| item['uri'] }
    uri += "?networks='#{network_uris.join(',')}'"
  end
  find_by(client, attributes, uri)
end

Instance Method Details

#delete(header = {}) ⇒ true

Delete resource from OneView

Parameters:

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

    The header options for the request (key-value pairs)

Returns:

  • (true)

    if resource was deleted successfully



24
25
26
# File 'lib/oneview-sdk/resource/api500/c7000/volume_template.rb', line 24

def delete(header = {})
  super(DEFAULT_REQUEST_HEADER.merge(header).merge('If-Match' => @data['eTag']))
end

#get_compatible_systemsArray

Retrieves a collection of all storage systems that is applicable to this storage volume template

Returns:

  • (Array)

    collection of Storage Systems

Raises:



82
83
84
85
# File 'lib/oneview-sdk/resource/api500/c7000/volume_template.rb', line 82

def get_compatible_systems
  ensure_client && ensure_uri
  self.class.find_with_pagination(@client, self['compatibleStorageSystemsUri'])
end

#get_default_value(property) ⇒ Object

Gets the value of property

Parameters:

  • property (String)

    The property to get value

Returns:

  • (Object)

    the default value of property

Raises:



74
75
76
77
# File 'lib/oneview-sdk/resource/api500/c7000/volume_template.rb', line 74

def get_default_value(property)
  verify_if_root_template_is_set!
  self['properties'][property.to_s]['default']
end

#lock(property, locked = true) ⇒ Object

Sets the “locked” property of property passed to true or false

Parameters:

  • property (String)

    The property for change value

  • locked (Boolean) (defaults to: true)

    The value to set to “locked” property. Default: true.

Raises:



39
40
41
42
# File 'lib/oneview-sdk/resource/api500/c7000/volume_template.rb', line 39

def lock(property, locked = true)
  verify_if_root_template_is_set!
  self['properties'][property.to_s]['meta']['locked'] = locked
end

#locked?(property) ⇒ Boolean

Verify if property is locked

Parameters:

  • property (String)

    The property

Returns:

  • (Boolean)

    true if property is locked or false if not

Raises:



55
56
57
58
# File 'lib/oneview-sdk/resource/api500/c7000/volume_template.rb', line 55

def locked?(property)
  verify_if_root_template_is_set!
  self['properties'][property.to_s]['meta']['locked']
end

#set_default_value(property, value) ⇒ Object

Sets the value of property

Parameters:

  • property (String)

    The property for change value

  • value (Object)

    The new value of property

Raises:



64
65
66
67
68
# File 'lib/oneview-sdk/resource/api500/c7000/volume_template.rb', line 64

def set_default_value(property, value)
  verify_if_root_template_is_set!
  value = value['uri'] if value.is_a?(Resource)
  self['properties'][property.to_s]['default'] = value
end

#set_root_template(root_template) ⇒ Object

Sets the root template

Parameters:



30
31
32
33
# File 'lib/oneview-sdk/resource/api500/c7000/volume_template.rb', line 30

def set_root_template(root_template)
  self['properties'] = root_template['properties'].clone
  self['rootTemplateUri'] = root_template['uri']
end

#unlock(property) ⇒ Object

Sets the “locked” property of property passed to false

Parameters:

  • property (String)

    The property for change value

Raises:



47
48
49
# File 'lib/oneview-sdk/resource/api500/c7000/volume_template.rb', line 47

def unlock(property)
  lock(property, false)
end