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.

  • :nodeset (RSpecSystem::NodeSet)

    the parent nodeset for this node. Mandatory.

  • :custom_prefabs_path (String)

    path of custom prefabs yaml file. Optional.



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

def initialize(options)
  @name = options[:name]
  prefab = options[:prefab]
  @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
# 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']
  )
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



67
68
69
# File 'lib/rspec-system/node.rb', line 67

def facts
  @facts
end

#inspectString

Return name when inspected

Returns:

  • (String)

    name of node



95
96
97
# File 'lib/rspec-system/node.rb', line 95

def inspect
  name
end

#nameString

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

Returns:

  • (String)

    name of node



53
54
55
# File 'lib/rspec-system/node.rb', line 53

def name
  @name
end

#nodesetRSpecSystem::NodeSet

Returns the nodeset this node belongs in.

Returns:



74
75
76
# File 'lib/rspec-system/node.rb', line 74

def nodeset
  @nodeset
end

#prefabRSpecSystem::Prefab

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

Returns:



60
61
62
# File 'lib/rspec-system/node.rb', line 60

def prefab
  @prefab
end

#provider_specificsHash

Return provider specific settings

Returns:

  • (Hash)

    provider specific settings



81
82
83
# File 'lib/rspec-system/node.rb', line 81

def provider_specifics
  @provider_specifics
end

#to_sString

Return name when stringified

Returns:

  • (String)

    name of node



88
89
90
# File 'lib/rspec-system/node.rb', line 88

def to_s
  name
end