Class: VagrantPlugins::ProviderLocal::Action::Import

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-local/action/import.rb

Overview

This will import the instance boot image from the cloud, cache or file

Instance Method Summary collapse

Constructor Details

#initialize(app, _env) ⇒ Import

Returns a new instance of Import.



16
17
18
19
# File 'lib/vagrant-local/action/import.rb', line 16

def initialize(app, _env)
  @logger = Log4r::Logger.new('vagrant_local::action::import')
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/vagrant-local/action/import.rb', line 26

def call(env)
  @machine = env[:machine]
  @executor = Executor::Exec.new
  image = @machine.config.vm.box
  datadir = @machine.data_dir
  @driver = @machine.provider.driver
  ui = env[:ui]
  ui.info(I18n.t('vagrant_local.meeting'))
  ui.info(I18n.t('vagrant_local.datadir'))
  ui.info("  #{datadir}")
  ui.info(I18n.t('vagrant_local.detecting_box'))

  # Support zss maybe zst? Same thing? format only for now, use other images and convert later
  box_format = env[:machine].box.['format'] unless env[:machine].box.nil?

  # Insert Future Code to try to convert existing box
  ui.info(I18n.t('vagrant_local.detected_format')) if %w[ovf ova].include?(box_format)

  ## No Local box template exists, Lets use Vagrant HandleBox to download the Box template
  ui.info(I18n.t('vagrant_local.vagrant_cloud_box_detected'))
  ui.info("  #{image}")
  ui.clear_line
  @app.call(env)
end

#validate_uuid_format(uuid) ⇒ Object



21
22
23
24
# File 'lib/vagrant-local/action/import.rb', line 21

def validate_uuid_format(uuid)
  uuid_regex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/
  true if uuid_regex.match?(uuid.to_s.downcase)
end