Sha256: 0711218bd8b25ad228902a91540206e65235939fff2099f26935382627515bf5

Contents?: true

Size: 1.79 KB

Versions: 2

Compression:

Stored size: 1.79 KB

Contents

# frozen_string_literal: true

require 'net/http'
require 'vagrant-local/util/subprocess'
require 'vagrant/box_metadata'
require 'vagrant/util/downloader'
require 'vagrant/util/platform'
require 'vagrant/util/safe_chdir'
require 'vagrant/util/subprocess'

module VagrantPlugins
  module ProviderLocal
    module Action
      # This will import the instance boot image from the cloud, cache or file
      class Import
        def initialize(app, _env)
          @logger = Log4r::Logger.new('vagrant_local::action::import')
          @app = app
        end

        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

        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.metadata['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
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vagrant-local-0.0.3 lib/vagrant-local/action/import.rb
vagrant-local-0.0.2 lib/vagrant-local/action/import.rb