Skip to content

Commit

Permalink
Centralize local dataset directory creation
Browse files Browse the repository at this point in the history
[refs #26]
  • Loading branch information
sax committed Jun 19, 2015
1 parent 13d80a4 commit eec4871
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
7 changes: 0 additions & 7 deletions lib/vagrant/smartos/zones/commands/dataset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ def host
end

def create(zonename, dataset)
setup_local_directory
with_zone(zonename) do |zone|
ui.info(I18n.t('vagrant.smartos.zones.commands.dataset.create', uuid: zone.uuid, dataset: dataset))
Models::Dataset.create(dataset, zone)
Expand Down Expand Up @@ -82,12 +81,6 @@ def with_zone(name)
ui.warn(I18n.t('vagrant.smartos.zones.warning.zone_not_found',
name: name), prefix: false)
end

def setup_local_directory
home_path = @env.respond_to?(:home_path) ? @env.home_path : @env[:home_path]
image_path = home_path.join('smartos', 'datasets')
FileUtils.mkdir_p(image_path)
end
end
end
end
Expand Down
2 changes: 2 additions & 0 deletions lib/vagrant/smartos/zones/models/dataset.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'vagrant/smartos/zones/models/snapshot'
require 'vagrant/smartos/zones/util/datasets'
require 'vagrant/smartos/zones/util/global_zone/helper'

module Vagrant
Expand All @@ -21,6 +22,7 @@ def self.create(name, zone)
end

def create
Zones::Util::Dataset.new(machine.env).setup_smartos_directories
create_dataset
download
end
Expand Down
6 changes: 2 additions & 4 deletions lib/vagrant/smartos/zones/util/datasets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ class Datasets
def initialize(env, machine = nil)
@env = env
@machine = machine
setup_smartos_directories
end

def list
setup_smartos_directories
ui.info(datasets.join("\n"), prefix: false)
end

protected

def setup_smartos_directories
env.setup_home_path if env.respond_to?(:setup_home_path)
FileUtils.mkdir_p(dataset_dir)
Expand All @@ -33,7 +31,7 @@ def home_path
end

def datasets
Dir[dataset_dir.join('*')].map do |f|
Dir[dataset_dir.join('*.zfs.bz2')].map do |f|
File.basename(f, '.zfs.bz2')
end.sort
end
Expand Down

0 comments on commit eec4871

Please sign in to comment.