Class: TcServer::Instance

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

Overview

A tc Server instance

Instance Attribute Summary collapse

Attributes inherited from Shared::Instance

#name

Attributes included from Shared::Deletable

#collection

Attributes inherited from Shared::Resource

#location, #security

Instance Method Summary collapse

Methods inherited from Shared::Instance

#group, #installation, #live_configurations, #node_instances, #pending_configurations, #start, #stop

Methods included from Shared::Deletable

#delete

Methods inherited from Shared::StateResource

#start, #state, #stop

Constructor Details

#initialize(location, client) ⇒ Instance

Returns a new instance of Instance.



81
82
83
84
85
# File 'lib/vas/tc_server/instances.rb', line 81

def initialize(location, client)
  super(location, client, Group, Installation, LiveConfigurations, PendingConfigurations, NodeInstance, 'node-instance')

  @layout = details['layout']
end

Instance Attribute Details

#layoutString (readonly)

Returns the instance’s layout.

Returns:

  • (String)

    the instance’s layout



72
73
74
# File 'lib/vas/tc_server/instances.rb', line 72

def layout
  @layout
end

#runtime_versionString (readonly)

Returns the version of runtime used by the instance.

Returns:

  • (String)

    the version of runtime used by the instance



75
76
77
# File 'lib/vas/tc_server/instances.rb', line 75

def runtime_version
  @runtime_version
end

#servicesHash (readonly)

Returns the instance’s services.

Returns:

  • (Hash)

    the instance’s services



78
79
80
# File 'lib/vas/tc_server/instances.rb', line 78

def services
  @services
end

Instance Method Details

#applicationsApplications

Returns the instance’s applications.

Returns:



96
97
98
# File 'lib/vas/tc_server/instances.rb', line 96

def applications
  @applications ||= Applications.new(Util::LinkUtils.get_link_href(details, 'group-applications'), client)
end

#reloadvoid

This method returns an undefined value.

Reloads the instance’s details from the server



89
90
91
92
93
# File 'lib/vas/tc_server/instances.rb', line 89

def reload
  super
  @runtime_version = details['runtime-version']
  @services = details['services']
end

#to_sString

Returns a string representation of the instance.

Returns:

  • (String)

    a string representation of the instance



116
117
118
# File 'lib/vas/tc_server/instances.rb', line 116

def to_s
  "#<#{self.class} name='#{name}' layout='#@layout' runtime_version='#@runtime_version' services='#@services'>"
end

#update(installation, runtime_version = nil) ⇒ void

This method returns an undefined value.

Updates the installation and, optionally, the runtime_version used by the instance

Parameters:

  • installation (Installation)

    the installation to be used by the instance

  • runtime_version (String) (defaults to: nil)

    the version of the runtime to be used by the instance



106
107
108
109
110
111
112
113
# File 'lib/vas/tc_server/instances.rb', line 106

def update(installation, runtime_version = nil)
  payload = { :installation => installation.location }
  if runtime_version
    payload['runtime-version'] = runtime_version
  end
  client.post(location, payload)
  reload
end