Class: Skewer::Node

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

Overview

responsible for talking to remote machines

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeNode

Returns a new instance of Node.



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/node.rb', line 6

def initialize
  @address = nil
  @username = nil
  @password = nil
  @pubkey = nil
  @ssh = Fog::SSH::Real.new(
    @address,
    @username,
    {:password => @password}
  )
  install_pubkey(@ssh, @pubkey)
end

Instance Attribute Details

#usernameObject (readonly)

Returns the value of attribute username.



4
5
6
# File 'lib/node.rb', line 4

def username
  @username
end

Instance Method Details

#destroyObject



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

def destroy
end

#dns_nameObject



24
25
26
# File 'lib/node.rb', line 24

def dns_name
  @address
end

#install_pubkey(ssh, key) ⇒ Object



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

def install_pubkey(ssh, key)
  key_file = File.read(key).gsub("\n",'')
  ssh(['mkdir -p .ssh', 'chmod 0700 .ssh',"echo #{key_file} > .ssh/authorized_keys"])
end

#ssh(commands) ⇒ Object



34
35
36
37
38
39
40
41
# File 'lib/node.rb', line 34

def ssh(commands)
  results = @ssh.run(commands)
  if results.is_a?(Array)
    results.each {|result| Skewer.logger.debug result.stdout }
  else
    Skewer.logger.debug results.stdout
  end
end

#wait_for(*blk) ⇒ Object



28
29
# File 'lib/node.rb', line 28

def wait_for(*blk)
end