lib/testlab/container/io.rb in testlab-1.16.0 vs lib/testlab/container/io.rb in testlab-1.16.1
- old
+ new
@@ -41,12 +41,13 @@
end
when :get, :put then
elapsed = (Time.now - @start_time)
current_size = (args[1] + args[2].length)
+ message = ((action == :get) ? 'downloading from' : 'uploading to')
- transfer_message(%(uploading to node:), args[0].local, current_size, @total_size, elapsed)
+ transfer_message(%(#{message} node:), args[0].local, current_size, @total_size, elapsed)
when :finish
@ui.stdout.puts
@total_size = 0
@@ -71,11 +72,12 @@
do_provisioner_callbacks(self, :export, @ui)
# Ensure the container is stopped before we attempt to export it.
self.down
- self.lxc.attach(%(-- /bin/bash -c 'apt-get clean'))
+ self.lxc.execute(%(/bin/bash -c 'apt-get -y autoremove'))
+ self.lxc.execute(%(/bin/bash -c 'apt-get -y clean'))
export_tempfile = Tempfile.new('export')
remote_filename = File.basename(export_tempfile.path.dup)
export_tempfile.close!
@@ -83,27 +85,27 @@
local_file ||= File.join(Dir.pwd, "#{self.id}.sc")
local_file = File.expand_path(local_file)
root_fs_path = self.lxc.fs_root.split(File::SEPARATOR).last
please_wait(:ui => @ui, :message => format_object_action(self, 'Compress', :cyan)) do
- self.node.bootstrap(<<-EOF)
-du -sh #{self.lxc.container_root}
-cd #{self.lxc.container_root}
-find #{root_fs_path} -depth -print0 | cpio -o0 | pbzip2 -#{compression} -vfczm#{PBZIP2_MEMORY} > #{remote_file}
-chown ${SUDO_USER}:${SUDO_USER} #{remote_file}
-ls -lah #{remote_file}
-EOF
+ self.node.bootstrap(<<-EOSCRIPT)
+ du -sh #{self.lxc.container_root}
+ cd #{self.lxc.container_root}
+ find #{root_fs_path} -depth -print0 | cpio -o0 | pbzip2 -#{compression} -vfczm#{PBZIP2_MEMORY} > #{remote_file}
+ chown ${SUDO_USER}:${SUDO_USER} #{remote_file}
+ ls -lah #{remote_file}
+ EOSCRIPT
end
File.exists?(local_file) and FileUtils.rm_f(local_file)
@total_size = self.node.ssh.sftp.stat!(remote_file).size
self.node.download(remote_file, local_file, :on_progress => method(:progress_callback), :read_size => READ_SIZE, :use_scp => true)
- self.node.bootstrap(<<-EOF)
-rm -fv #{remote_file}
-EOF
+ self.node.bootstrap(<<-EOSCRIPT)
+ rm -fv #{remote_file}
+ EOSCRIPT
@ui.stdout.puts(format_message("Your shipping container is now exported and available at '#{local_file}'!".green.bold))
true
end