class Gusteau::Server
Attributes
chef[R]
host[R]
password[R]
port[R]
user[R]
Public Class Methods
new(config)
click to toggle source
# File lib/gusteau/server.rb, line 12 def initialize(config) @host = config['host'] @port = config['port'] || 22 @user = config['user'] || 'root' @password = config['password'] @chef = Gusteau::Chef.new(self, config['platform']) end
Public Instance Methods
run(*cmds)
click to toggle source
# File lib/gusteau/server.rb, line 34 def run(*cmds) cmds.each do |cmd| log("%{host}> #{prepared_cmd cmd}", :host => host) do unless send_command(cmd) log_error("%{host}> #{prepared_cmd cmd}", :host => host) raise end end end true end
ssh()
click to toggle source
# File lib/gusteau/server.rb, line 46 def ssh ssh_expect = File.expand_path("../../../bin/gusteau_ssh_expect", __FILE__) Kernel.system "#{ssh_expect} #{@user}@#{@host} #{@port} #{@password}" end
to_s()
click to toggle source
# File lib/gusteau/server.rb, line 20 def to_s "#{user}@#{host}#{" -p #{port}" unless port == 22}" end
upload(files_and_dirs, dest_dir, opts={})
click to toggle source
# File lib/gusteau/server.rb, line 24 def upload(files_and_dirs, dest_dir, opts={}) log "#uploading #{files_and_dirs.join(' ')} to #{@host}:#{dest_dir}" do files = [] Find.find(*files_and_dirs) do |f| files << f unless(opts[:exclude] && f.include?(opts[:exclude])) end send_files(files, dest_dir, opts[:strip_c]) end end