Class: RSpecSystem::Node

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

Overview

This class represents a node in a nodeset

Class Method Summary collapse

Instance Method Summary collapse

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.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/rspec-system/node.rb', line 26

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

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

Class Method Details

.node_from_yaml(nodeset, k, v) ⇒ 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

Returns:



11
12
13
14
15
16
17
# File 'lib/rspec-system/node.rb', line 11

def self.node_from_yaml(nodeset, k, v)
  RSpecSystem::Node.new(
    :nodeset => nodeset,
    :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



58
59
60
# File 'lib/rspec-system/node.rb', line 58

def facts
  @facts
end

#nameString

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

Returns:

  • (String)

    name of node



44
45
46
# File 'lib/rspec-system/node.rb', line 44

def name
  @name
end

#nodesetRSpecSystem::NodeSet

Returns the nodeset this node belongs in.

Returns:



65
66
67
# File 'lib/rspec-system/node.rb', line 65

def nodeset
  @nodeset
end

#prefabRSpecSystem::Prefab

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

Returns:



51
52
53
# File 'lib/rspec-system/node.rb', line 51

def prefab
  @prefab
end

#provider_specificsHash

Return provider specific settings

Returns:

  • (Hash)

    provider specific settings



72
73
74
# File 'lib/rspec-system/node.rb', line 72

def provider_specifics
  @provider_specifics
end