Skip to content

Commit

Permalink
Fix dataset creation, switch to gzip
Browse files Browse the repository at this point in the history
[refs #26]
  • Loading branch information
sax committed Jun 21, 2015
1 parent 7303f5a commit 36e043f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 17 deletions.
20 changes: 8 additions & 12 deletions lib/vagrant/smartos/zones/models/dataset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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

Expand All @@ -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
Expand All @@ -92,7 +88,7 @@ def write_manifest
end

def filename
'%s.zfs.bz2' % name
'%s.zfs.gz' % name
end

def local_filename
Expand Down
8 changes: 4 additions & 4 deletions lib/vagrant/smartos/zones/util/datasets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib/vagrant/smartos/zones/util/datasets/manifest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def uuid
def files
[
{
'path' => "#{name}.zfs.bz2",
'path' => "#{name}.zfs.gz",
'sha1' => sha1,
'size' => size
}
Expand Down

0 comments on commit 36e043f

Please sign in to comment.