Class: OsCtl::Lib::Exporter::Tar

Inherits:
Base
  • Object
show all
Includes:
Utils::Log, Utils::System
Defined in:
lib/libosctl/exporter/tar.rb

Overview

Handles dumping containers into tar archives

The container's rootfs is stored as a compressed tar archive.

Constant Summary

Constants inherited from Base

Base::DIR_MODE, Base::FILE_MODE

Instance Attribute Summary

Attributes inherited from Base

#base_snap, #ct, #datasets, #opts, #tar

Instance Method Summary collapse

Methods included from Utils::System

#repeat_on_failure, #syscmd, #zfs

Methods included from Utils::Log

included

Methods inherited from Base

#add_file_from_disk, #close, #dump_configs, #dump_metadata, #dump_user_hook_scripts, #initialize

Constructor Details

This class inherits a constructor from OsCtl::Lib::Exporter::Base

Instance Method Details

#formatObject



22
23
24
# File 'lib/libosctl/exporter/tar.rb', line 22

def format
  :tar
end

#pack_rootfsObject



11
12
13
14
15
16
17
18
19
20
# File 'lib/libosctl/exporter/tar.rb', line 11

def pack_rootfs
  tar.mkdir('rootfs', DIR_MODE)
  tar.add_file('rootfs/base.tar.gz', FILE_MODE) do |tf|
    IO.popen("exec tar -cz -C #{ct.rootfs} .") do |io|
      tf.write(io.read(16*1024)) until io.eof?
    end

    fail "tar failed with exit status #{$?.exitstatus}" if $?.exitstatus != 0
  end
end