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

#delete

Methods inherited from Shared::Collection

#each

Constructor Details

#initialize(location, client) ⇒ Instances

:nodoc:



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

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

Instance Method Details

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

Creates a new instance named name, using the Installation installation. Creation can be customized using options.

Recognized options are:

properties

A hash of properties

runtime_version

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 available version.

templates

An array of templates to use when creating the instance. Each Template must be present in the Installation.

layout

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



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

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
  
  Instance.new(client.post(location, payload, "group-instance"), client)
end