Class: RSpecSystem::Node

Inherits:
Object
  • Object
show all
Includes:
InternalHelpers
Defined in:
lib/rspec-system/node.rb

Overview

This class represents a node in a nodeset

Class Method Summary collapse

Instance Method Summary collapse

Methods included from InternalHelpers

#custom_prefabs_path, #rspec_destroy, #rspec_system_config, #rspec_system_node_set, #rspec_system_tmp, #rspec_virtual_env, #start_nodes, #stop_nodes

Constructor Details

#initialize(options) ⇒ Node

Create a new node object.

Parameters:

  • options (Hash)

    options for new node

Options Hash (options):

  • :name (String)

    name of node. Mandatory.

  • :prefab (String)

    prefab setting. Mandatory.

  • :options (String)

    options setting. Optional.

  • :nodeset (RSpecSystem::NodeSet)

    the parent nodeset for this node. Mandatory.

  • :custom_prefabs_path (String)

    path of custom prefabs yaml file. Optional.



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/rspec-system/node.rb', line 36

def initialize(options)
  @name = options[:name]
  prefab = options[:prefab]
  @options = options[:options]
  @nodeset = options[:nodeset]
  @custom_prefabs_path = options[:custom_prefabs_path]

  if prefab.nil?
    # TODO: do not support not prefabs yet
    raise "No prefab defined, bailing"
  else
    @prefab = RSpecSystem::Prefab.prefab(prefab, custom_prefabs_path)
    @facts = @prefab.facts
    @provider_specifics = @prefab.provider_specifics
  end
end

Class Method Details

.node_from_yaml(nodeset, k, v, custom_prefabs_path) ⇒ RSpecSystem::Node

Static helper for generating a node direct from the hash returned by the nodeset YAML file.

Parameters:

  • nodeset (RSpecSystem::Node)

    nodeset that this node belongs to

  • k (String)

    name of node

  • v (Hash<String,String>)

    hash configuration as given from the nodeset yaml file

  • custom_prefabs_path (String)

    path of custom prefabs yaml file

Returns:



16
17
18
19
20
21
22
23
24
# File 'lib/rspec-system/node.rb', line 16

def self.node_from_yaml(nodeset, k, v, custom_prefabs_path)
  RSpecSystem::Node.new(
    :nodeset => nodeset,
    :custom_prefabs_path => custom_prefabs_path,
    :name => k,
    :prefab => v['prefab'],
    :options => v['options']
  )
end

Instance Method Details

#factsHash

Retreives facts from the nodeset definition or prefab.

Returns:

  • (Hash)

    returns a hash of facter facts defined for this node



77
78
79
# File 'lib/rspec-system/node.rb', line 77

def facts
  @facts
end

#inspectString

Return name when inspected

Returns:

  • (String)

    name of node



105
106
107
# File 'lib/rspec-system/node.rb', line 105

def inspect
  name
end

#nameString

Returns the name of the node as specified in the nodeset file.

Returns:

  • (String)

    name of node



56
57
58
# File 'lib/rspec-system/node.rb', line 56

def name
  @name
end

#nodesetRSpecSystem::NodeSet

Returns the nodeset this node belongs in.

Returns:



84
85
86
# File 'lib/rspec-system/node.rb', line 84

def nodeset
  @nodeset
end

#optionsHash

Returns the custom object for this node (if any).

Returns:

  • (Hash)

    the options object used to customize the node



70
71
72
# File 'lib/rspec-system/node.rb', line 70

def options
  @options
end

#prefabRSpecSystem::Prefab

Returns the prefab object for this node (if any).

Returns:



63
64
65
# File 'lib/rspec-system/node.rb', line 63

def prefab
  @prefab
end

#provider_specificsHash

Return provider specific settings

Returns:

  • (Hash)

    provider specific settings



91
92
93
# File 'lib/rspec-system/node.rb', line 91

def provider_specifics
  @provider_specifics
end

#to_sString

Return name when stringified

Returns:

  • (String)

    name of node



98
99
100
# File 'lib/rspec-system/node.rb', line 98

def to_s
  name
end