class OneviewSDK::API500::C7000::VolumeTemplate

Volume Template resource implementation for API500 C7000

Constants

BASE_URI

Public Class Methods

get_reachable_volume_templates(client, networks = [], attributes = {}) click to toggle source

Gets the storage templates that are connected on the specified networks based on the storage system port's expected network connectivity. @param [OneviewSDK::Client] client The client object for the OneView appliance @param [Array] networks Set of networks to filter the storage templates connected @param [Hash] attributes Hash containing the attributes name and value to filter storage templates @return [Array] the collection of volume templates

# 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

Public Instance Methods

delete(header = {}) click to toggle source

Delete resource from OneView @param [Hash] header The header options for the request (key-value pairs) @return [true] if resource was deleted successfully

Calls superclass method OneviewSDK::Resource#delete
# 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_systems() click to toggle source

Retrieves a collection of all storage systems that is applicable to this storage volume template @raise [OneviewSDK::IncompleteResource] if the client or the URI is not set @return [Array] collection of Storage Systems

# 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) click to toggle source

Gets the value of property @param [String] property The property to get value @raise [OneviewSDK::IncompleteResource] if the rootTemplateUri or properties are not set @return [Object] the default value of property

# 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) click to toggle source

Sets the “locked” property of property passed to true or false @param [String] property The property for change value @param [Boolean] locked The value to set to “locked” property. Default: true. @raise [OneviewSDK::IncompleteResource] if the rootTemplateUri or properties are not set

# 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) click to toggle source

Verify if property is locked @param [String] property The property @raise [OneviewSDK::IncompleteResource] if the rootTemplateUri or properties are not set @return [Boolean] true if property is locked or false if not

# 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) click to toggle source

Sets the value of property @param [String] property The property for change value @param [Object] value The new value of property @raise [OneviewSDK::IncompleteResource] if the rootTemplateUri or properties are not set

# 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) click to toggle source

Sets the root template @param [VolumeTemplate] root_template The Volume Template resource

# 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) click to toggle source

Sets the “locked” property of property passed to false @param [String] property The property for change value @raise [OneviewSDK::IncompleteResource] if the rootTemplateUri or properties are not set

# File lib/oneview-sdk/resource/api500/c7000/volume_template.rb, line 47
def unlock(property)
  lock(property, false)
end

Private Instance Methods

verify_if_root_template_is_set!() click to toggle source

Verify if rootTemplateUri or properties are set @raise [OneviewSDK::IncompleteResource] if the rootTemplateUri or properties were set set before

# File lib/oneview-sdk/resource/api500/c7000/volume_template.rb, line 105
def verify_if_root_template_is_set!
  raise IncompleteResource, 'Must set a valid root template' if self['rootTemplateUri'].nil? || self['properties'].nil?
end