Class: Fleetctl::RemoteTempfile

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

Class Method Summary collapse

Class Method Details

.open(local_file) {|remote_path| ... } ⇒ Object

Yields:

  • (remote_path)


4
5
6
7
8
9
# File 'lib/fleetctl/remote_tempfile.rb', line 4

def open(local_file)
  remote_path = File.join(Fleetctl.options.remote_temp_dir, File.basename(local_file.path))
  Net::SCP.upload!(Fleetctl.options.fleet_host, Fleetctl.options.fleet_user, local_file.path, remote_path, :ssh => Fleetctl.options.ssh_options)
  yield(remote_path)
  Net::SSH.start(Fleetctl.options.fleet_host, Fleetctl.options.fleet_user, Fleetctl.options.ssh_options) { |ssh| ssh.exec!("rm #{remote_path}") }
end