Skip to content

Instantly share code, notes, and snippets.

@dalen
Created February 6, 2014 23:32
Show Gist options
  • Save dalen/8854722 to your computer and use it in GitHub Desktop.
Save dalen/8854722 to your computer and use it in GitHub Desktop.
# Transfer files to a host in the NodeSet.
def rcp(opts)
dest = opts[:d].name
source = opts[:sp]
dest_path = opts[:dp]
fqdn = RSpec.configuration.rs_storage[:nodes][dest][:fqdn]
user = RSpec.configuration.rs_storage[:nodes][dest][:user]
# Grab a remote path for temp transfer
tmpdest = tmppath
cmd = "rsync -rl '#{source}' #{user}@#{fqdn}:#{tmpdest}"
output << " #{cmd}\n"
system(cmd)
# Now we move the file into their final destination
if File.directory? source
result = shell(:n => opts[:d], :c => "mv -f #{File.join(tmpdest, File.basename(source))} #{dest_path}")
else
result = shell(:n => opts[:d], :c => "mv -f #{tmpdest} #{dest_path}")
end
result[:exit_code] == 0
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment