diff --git a/lib/vagrant/smartos/zones/models/dataset.rb b/lib/vagrant/smartos/zones/models/dataset.rb index c12518b..b63bcbb 100644 --- a/lib/vagrant/smartos/zones/models/dataset.rb +++ b/lib/vagrant/smartos/zones/models/dataset.rb @@ -18,8 +18,8 @@ def initialize(name, zone, machine) @machine = machine end - def self.create(name, zone) - new(name, zone).create + def self.create(name, zone, machine) + new(name, zone, machine).create end def self.install(name, machine) @@ -29,17 +29,13 @@ def self.install(name, machine) def create Zones::Util::Datasets.new(machine.env).setup_smartos_directories prepare_gz - # create_dataset - # download + create_dataset + download write_manifest end def exists? - cmd = 'ls %s 2>/dev/null' % remote_filename - with_gz(cmd) do |output| - return true if output.strip == remote_filename - end - false + machine.communicate.gz_test('ls %s' % remote_filename) end def install @@ -55,7 +51,7 @@ def remote_filename private def prepare_gz - with_gz('pfexec mkdir /zones/vagrant') + with_gz('pfexec mkdir -p /zones/vagrant') with_gz('pfexec chown vagrant:vagrant /zones/vagrant') end @@ -69,7 +65,7 @@ def create_dataset zone.stop Models::Snapshot.around(zone) do |snapshot| machine.ui.info(I18n.t('vagrant.smartos.zones.commands.dataset.save')) - cmd = 'pfexec /usr/bin/bash -l -c "/usr/sbin/zfs send %s | /usr/bin/bzip2 > %s"' + cmd = 'pfexec /usr/bin/bash -l -c "/usr/sbin/zfs send %s | /usr/bin/gzip > %s"' with_gz(cmd % [snapshot.path, remote_filename]) end end @@ -92,7 +88,7 @@ def write_manifest end def filename - '%s.zfs.bz2' % name + '%s.zfs.gz' % name end def local_filename diff --git a/lib/vagrant/smartos/zones/util/datasets.rb b/lib/vagrant/smartos/zones/util/datasets.rb index 41ae173..23e8cc7 100644 --- a/lib/vagrant/smartos/zones/util/datasets.rb +++ b/lib/vagrant/smartos/zones/util/datasets.rb @@ -23,11 +23,11 @@ def setup_smartos_directories end def sha1(name) - Digest::SHA1.file(dataset_dir.join("#{name}.zfs.bz2")).hexdigest + Digest::SHA1.file(dataset_dir.join("#{name}.zfs.gz")).hexdigest end def size(name) - ::File.size(dataset_dir.join("#{name}.zfs.bz2")) + ::File.size(dataset_dir.join("#{name}.zfs.gz")) end private @@ -41,8 +41,8 @@ def home_path end def datasets - Dir[dataset_dir.join('*.zfs.bz2')].map do |f| - File.basename(f, '.zfs.bz2') + Dir[dataset_dir.join('*.zfs.gz')].map do |f| + File.basename(f, '.zfs.gz') end.sort end diff --git a/lib/vagrant/smartos/zones/util/datasets/manifest.rb b/lib/vagrant/smartos/zones/util/datasets/manifest.rb index cbb26ef..8db27fa 100644 --- a/lib/vagrant/smartos/zones/util/datasets/manifest.rb +++ b/lib/vagrant/smartos/zones/util/datasets/manifest.rb @@ -61,7 +61,7 @@ def uuid def files [ { - 'path' => "#{name}.zfs.bz2", + 'path' => "#{name}.zfs.gz", 'sha1' => sha1, 'size' => size }