Class: Shared::Instance Abstract

Inherits:
StateResource show all
Includes:
Deletable
Defined in:
lib/vas/shared/instance.rb

Overview

This class is abstract.

A collection of instances

Instance Attribute Summary collapse

Attributes included from Deletable

#collection

Attributes inherited from Resource

#location, #security

Instance Method Summary collapse

Methods included from Deletable

#delete

Methods inherited from StateResource

#state

Constructor Details

#initialize(location, client, group_class, installation_class, live_configurations_class, pending_configurations_class, node_instance_class, node_instance_type) ⇒ Instance

Returns a new instance of Instance.



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/vas/shared/instance.rb', line 28

def initialize(location, client,
    group_class,
    installation_class,
    live_configurations_class,
    pending_configurations_class,
    node_instance_class,
    node_instance_type)

  super(location, client)

  @live_configurations_location = Util::LinkUtils.get_link_href(details, 'live-configurations')
  @pending_configurations_location = Util::LinkUtils.get_link_href(details, 'pending-configurations')
  @group_location = Util::LinkUtils.get_link_href(details, 'group')

  @group_class = group_class
  @installation_class = installation_class
  @node_instance_class = node_instance_class
  @live_configurations_class = live_configurations_class
  @pending_configurations_class = pending_configurations_class
  @node_instance_type = node_instance_type

  @name = details['name']
end

Instance Attribute Details

#nameString (readonly)

Returns the instance’s name.

Returns:

  • (String)

    the instance’s name



25
26
27
# File 'lib/vas/shared/instance.rb', line 25

def name
  @name
end

Instance Method Details

#groupGroup

Returns the group that contains this instance.

Returns:

  • (Group)

    the group that contains this instance



73
74
75
# File 'lib/vas/shared/instance.rb', line 73

def group
  @group ||= @group_class.new(@group_location, client)
end

#installationInstallation

Returns the installation that this instance is using.

Returns:

  • (Installation)

    the installation that this instance is using



63
64
65
# File 'lib/vas/shared/instance.rb', line 63

def installation
  @installation ||= @installation_class.new(@installation_location, client)
end

#live_configurationsObject

Returns the instance’s live configurations.

Returns:

  • the instance’s live configurations



78
79
80
# File 'lib/vas/shared/instance.rb', line 78

def live_configurations
  @live_configurations ||= @live_configurations_class.new(@live_configurations_location, client)
end

#node_instancesNodeInstance[]

Returns the instance’s individual node instances.

Returns:

  • (NodeInstance[])

    the instance’s individual node instances



68
69
70
# File 'lib/vas/shared/instance.rb', line 68

def node_instances
  @node_instances ||= create_resources_from_links(@node_instance_type, @node_instance_class)
end

#pending_configurationsObject

Returns the instance’s pending configurations.

Returns:

  • the instance’s pending configurations



83
84
85
# File 'lib/vas/shared/instance.rb', line 83

def pending_configurations
  @pending_configurations ||= @pending_configurations_class.new(@pending_configurations_location, client)
end

#reloadvoid

This method returns an undefined value.

Reloads the instance’s details from the server



55
56
57
58
59
60
# File 'lib/vas/shared/instance.rb', line 55

def reload
  super
  @installation_location = Util::LinkUtils.get_link_href(details, 'installation')
  @installation = nil
  @node_instances = nil
end

#start(serial = false) ⇒ Object

Starts the instance

Parameters:

  • serial (Boolean) (defaults to: false)

    true if the starting of the individual instances represented by this group instance should happen serially, false if they should happen in parallel



91
92
93
# File 'lib/vas/shared/instance.rb', line 91

def start(serial = false)
  client.post(@state_location, { :status => 'STARTED', :serial => serial })
end

#stop(serial = false) ⇒ Object

Stops the instance

Parameters:

  • serial (Boolean) (defaults to: false)

    true if the stoping of the individual instances represented by this group instance should happen serially, false if they should happen in parallel



99
100
101
# File 'lib/vas/shared/instance.rb', line 99

def stop(serial = false)
  client.post(@state_location, { :status => 'STOPPED', :serial => serial })
end

#to_sString

Returns a string representation of the instance.

Returns:

  • (String)

    a string representation of the instance



104
105
106
# File 'lib/vas/shared/instance.rb', line 104

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