class DbDumper::RemoteMachine::SshAgent

Wrapper around Net::SSH, Net:SCP

Attributes

block[R]
config[R]
ssh[R]

Public Class Methods

new(config, &block) click to toggle source
# File lib/db_dumper/remote_machine/ssh_agent.rb, line 9
def initialize(config, &block)
  @config       = config
  @block        = block
  @ssh          = Net::SSH.start(*credentials)
end

Public Instance Methods

download!(remote_source, local_dest, options = {}) click to toggle source
# File lib/db_dumper/remote_machine/ssh_agent.rb, line 20
def download!(remote_source, local_dest, options = {})
  log("DOWNLOADING from #{ssh_machine_name}:#{remote_source} to #{local_dest}")
  log ssh.scp.download!(remote_source, local_dest, options)
end
exec!(command) click to toggle source
# File lib/db_dumper/remote_machine/ssh_agent.rb, line 15
def exec!(command)
  log("EXECUTING on #{ssh_machine_name}: #{command}")
  log ssh.exec!(command)
end
upload!(local_source, remote_dest, options = {}) click to toggle source
# File lib/db_dumper/remote_machine/ssh_agent.rb, line 25
def upload!(local_source, remote_dest, options = {})
  log("uploading from #{ssh_machine_name}:#{local_source} to #{remote_dest}")
  log ssh.scp.upload!(local_source, remote_dest, options)
end

Private Instance Methods

credentials() click to toggle source
# File lib/db_dumper/remote_machine/ssh_agent.rb, line 32
def credentials
  [
    ssh_user.host,
    ssh_user.name,
    keys:       ssh_user.ssh_keys,
    passphrase: ssh_user.passphrase
  ]
end
log(message) click to toggle source
# File lib/db_dumper/remote_machine/ssh_agent.rb, line 49
def log(message)
  config.log(message)
end
ssh_machine_name() click to toggle source
# File lib/db_dumper/remote_machine/ssh_agent.rb, line 45
def ssh_machine_name
  "#{ssh_user.name}@#{ssh_user.host}"
end
ssh_user() click to toggle source
# File lib/db_dumper/remote_machine/ssh_agent.rb, line 41
def ssh_user
  @ssh_user ||= config.ssh_user
end