Class: Shared::NodeConfiguration Abstract

Inherits:
Resource
  • Object
show all
Defined in:
lib/vas/shared/node_configuration.rb

Overview

This class is abstract.

A configuration file in a node instance

Instance Attribute Summary collapse

Attributes inherited from Resource

#location, #security

Instance Method Summary collapse

Constructor Details

#initialize(location, client, instance_type, instance_class, group_configuration_class) ⇒ NodeConfiguration

Returns a new instance of NodeConfiguration.



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/vas/shared/node_configuration.rb', line 29

def initialize(location, client, instance_type, instance_class, group_configuration_class)
  super(location, client)

  @instance_class = instance_class
  @group_configuration_class = group_configuration_class

  @instance_location = Util::LinkUtils.get_link_href(details, instance_type)
  @group_configuration_location = Util::LinkUtils.get_link_href(details, 'group-live-configuration')
  @content_location = Util::LinkUtils.get_link_href(details, 'content')

  @path = details['path']
end

Instance Attribute Details

#pathString (readonly)

Returns the configuration’s path.

Returns:

  • (String)

    the configuration’s path



23
24
25
# File 'lib/vas/shared/node_configuration.rb', line 23

def path
  @path
end

#sizeInteger (readonly)

Returns the configuration’s size.

Returns:

  • (Integer)

    the configuration’s size



26
27
28
# File 'lib/vas/shared/node_configuration.rb', line 26

def size
  @size
end

Instance Method Details

#content {|chunk| ... } ⇒ void

This method returns an undefined value.

Retrieves the configuration’s content and passes it to the block

Yields:

  • (chunk)

    a chunk of the configuration’s content



54
55
56
# File 'lib/vas/shared/node_configuration.rb', line 54

def content(&block)
  client.get_stream(@content_location, &block)
end

#group_configurationLiveConfiguration

Returns the node configuration’s group configuration.

Returns:



59
60
61
# File 'lib/vas/shared/node_configuration.rb', line 59

def group_configuration
  @group_configuration ||= @group_configuration_class.new(@group_configuration_location, client)
end

#instanceNodeInstance

Returns the node instance that owns the configuration.

Returns:

  • (NodeInstance)

    the node instance that owns the configuration



64
65
66
# File 'lib/vas/shared/node_configuration.rb', line 64

def instance
  @instance ||= @instance_class.new(@instance_location, client)
end

#reloadvoid

This method returns an undefined value.

Reloads the configuration’s details from the server



44
45
46
47
# File 'lib/vas/shared/node_configuration.rb', line 44

def reload
  super
  @size = details['size']
end

#to_sString

Returns a string representation of the configuration.

Returns:

  • (String)

    a string representation of the configuration



69
70
71
# File 'lib/vas/shared/node_configuration.rb', line 69

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