Sha256: a58e4440f09adf4c765a80649f19d377b0a160c7981efe67f1fa7582ad16f1a6

Contents?: true

Size: 1.25 KB

Versions: 13

Compression:

Stored size: 1.25 KB

Contents

module VagrantPlugins
  module Parallels
    module Action
      class Customize
        def initialize(app, env, event)
          @app = app
          @event = event
        end

        def call(env)
          customizations = []
          env[:machine].provider_config.customizations.each do |event, command|
            if event == @event
              customizations << command
            end
          end

          if !customizations.empty?
            env[:ui].info I18n.t("vagrant.actions.vm.customize.running", event: @event)

            # Execute each customization command.
            customizations.each do |command|
              processed_command = command.collect do |arg|
                arg = env[:machine].id if arg == :id
                arg.to_s
              end

              begin
                env[:machine].provider.driver.execute_command(
                  processed_command + [retryable: true])
              rescue VagrantPlugins::Parallels::Errors::PrlCtlError => e
                raise Vagrant::Errors::VMCustomizationFailed, {
                  :command => command,
                  :error   => e.inspect
                }
              end
            end
          end

          @app.call(env)
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
vagrant-parallels-1.0.9.rc1 lib/vagrant-parallels/action/customize.rb
vagrant-parallels-1.0.8 lib/vagrant-parallels/action/customize.rb
vagrant-parallels-1.0.7 lib/vagrant-parallels/action/customize.rb
vagrant-parallels-1.0.6 lib/vagrant-parallels/action/customize.rb
vagrant-parallels-1.0.6.rc1 lib/vagrant-parallels/action/customize.rb
vagrant-parallels-1.0.5 lib/vagrant-parallels/action/customize.rb
vagrant-parallels-1.0.4 lib/vagrant-parallels/action/customize.rb
vagrant-parallels-1.0.3 lib/vagrant-parallels/action/customize.rb
vagrant-parallels-1.0.2 lib/vagrant-parallels/action/customize.rb
vagrant-parallels-1.0.1 lib/vagrant-parallels/action/customize.rb
vagrant-parallels-1.0.0 lib/vagrant-parallels/action/customize.rb
vagrant-parallels-0.2.2 lib/vagrant-parallels/action/customize.rb
vagrant-parallels-0.2.2.rc1 lib/vagrant-parallels/action/customize.rb