Class: DbDumper::RemoteMachine::SshAgent

Inherits:
Object
  • Object
show all
Defined in:
lib/db_dumper/remote_machine/ssh_agent.rb

Overview

Wrapper around Net::SSH, Net:SCP

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, &block) ⇒ SshAgent

Returns a new instance of SshAgent.



9
10
11
12
13
# 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

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



7
8
9
# File 'lib/db_dumper/remote_machine/ssh_agent.rb', line 7

def block
  @block
end

#configObject (readonly)

Returns the value of attribute config.



6
7
8
# File 'lib/db_dumper/remote_machine/ssh_agent.rb', line 6

def config
  @config
end

#sshObject (readonly)

Returns the value of attribute ssh.



7
8
9
# File 'lib/db_dumper/remote_machine/ssh_agent.rb', line 7

def ssh
  @ssh
end

Instance Method Details

#download!(remote_source, local_dest, options = {}) ⇒ Object



20
21
22
23
# 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) ⇒ Object



15
16
17
18
# 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 = {}) ⇒ Object



25
26
27
28
# 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