Class: TcServer::Instances

Inherits:
Shared::MutableCollection show all
Defined in:
lib/vas/tc_server/instances.rb

Overview

Used to enumerate, create, and delete tc Server instances.

Instance Attribute Summary

Attributes inherited from Shared::Resource

#location, #security

Instance Method Summary collapse

Methods inherited from Shared::MutableCollection

#create_image

Methods inherited from Shared::Collection

#each, #reload

Constructor Details

#initialize(location, client) ⇒ Instances

Returns a new instance of Instances.



23
24
25
# File 'lib/vas/tc_server/instances.rb', line 23

def initialize(location, client)
  super(location, client, "group-instances", Instance)
end

Instance Method Details

#create(installation, name, options = {}) ⇒ Instance

Creates a new instance

Parameters:

  • installation (Installation)

    the installation to be used by the instance

  • name (String)

    the name of the instance

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

    optional configuration

Options Hash (options):

  • :properties (Hash)

    configuration properties that customise the instance

  • :runtime_version (String)

    the version of the runtime to be used by the instance. Must be one of the runtime_versions available in the installation. Defaults to the latest version that is available in the installation

  • :templates (Template[])

    the templates to use when creating the instance

  • :layout (String)

    the layout to use when creating the instance. Valid values are COMBINED and SEPARATE. Defaults to SEPARATE

Returns:



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/vas/tc_server/instances.rb', line 42

def create(installation, name, options = {})
  payload = { :installation => installation.location, :name => name }
  
  if options.has_key?(:properties)
    payload[:properties] = options[:properties]
  end
  
  if options.has_key?(:runtime_version)
    payload['runtime-version'] = options[:runtime_version]
  end
  
  if options.has_key?(:templates)
    template_locations = []
    options[:templates].each { |template| template_locations << template.location }
    payload[:templates] = template_locations
  end
  
  if options.has_key?(:layout)
    payload[:layout] = options[:layout]
  end

  super(payload, 'group-instance')
end