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.



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

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, @os, adapter_name, opts)
end

Instance Attribute Details

#communicatorObject (readonly)

Returns the value of attribute communicator.



10
11
12
# File 'lib/nodespec/node.rb', line 10

def communicator
  @communicator
end

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/nodespec/node.rb', line 10

def name
  @name
end

#osObject (readonly)

Returns the value of attribute os.



10
11
12
# File 'lib/nodespec/node.rb', line 10

def os
  @os
end

Instance Method Details

#backendObject



20
21
22
# File 'lib/nodespec/node.rb', line 20

def backend
  @communicator.backend
end

#create_temp_directory(path) ⇒ Object



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

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

#execute(command) ⇒ Object



41
42
43
# File 'lib/nodespec/node.rb', line 41

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