Class: NodeSpec::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/nodespec/node.rb

Defined Under Namespace

Classes: BadNodeNameError

Constant Summary collapse

WORKING_DIR =
'.nodespec'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node_name, options = nil) ⇒ Node

Returns a new instance of Node.



10
11
12
13
14
15
16
# File 'lib/nodespec/node.rb', line 10

def initialize(node_name, options = nil)
  @name = validate(node_name)
  opts = (options || {}).dup
  @os = opts.delete('os')
  adapter_name = opts.delete('adapter')
  @communicator = CommunicationAdapters.get_communicator(@name, adapter_name, opts)
end

Instance Attribute Details

#communicatorObject (readonly)

Returns the value of attribute communicator.



8
9
10
# File 'lib/nodespec/node.rb', line 8

def communicator
  @communicator
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/nodespec/node.rb', line 8

def name
  @name
end

#osObject (readonly)

Returns the value of attribute os.



8
9
10
# File 'lib/nodespec/node.rb', line 8

def os
  @os
end

Instance Method Details

#create_temp_directory(path) ⇒ Object



30
31
32
33
# File 'lib/nodespec/node.rb', line 30

def create_temp_directory(path)
  path = path[1..-1] if path.start_with?('/')
  create_directory("#{backend_proxy.temp_directory}/#{path}")
end

#execute(command) ⇒ Object



35
36
37
# File 'lib/nodespec/node.rb', line 35

def execute(command)
  backend_proxy.execute(command)
end