Sha256: e90764b4582fd5d7eda0257a4b35a1306e4b9bd756cb5e0f26667edd4832836f

Contents?: true

Size: 1.21 KB

Versions: 23

Compression:

Stored size: 1.21 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_prlctl(*processed_command)
              rescue VagrantPlugins::Parallels::Errors::ExecutionError => e
                raise Vagrant::Errors::VMCustomizationFailed, {
                  command: command,
                  error:   e.inspect
                }
              end
            end
          end

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

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
vagrant-parallels-1.4.2 lib/vagrant-parallels/action/customize.rb
vagrant-parallels-1.4.1 lib/vagrant-parallels/action/customize.rb
vagrant-parallels-1.4.0 lib/vagrant-parallels/action/customize.rb
vagrant-parallels-1.4.0.rc1 lib/vagrant-parallels/action/customize.rb
vagrant-parallels-1.3.13 lib/vagrant-parallels/action/customize.rb
vagrant-parallels-1.3.12 lib/vagrant-parallels/action/customize.rb
vagrant-parallels-1.3.10 lib/vagrant-parallels/action/customize.rb
vagrant-parallels-1.3.9 lib/vagrant-parallels/action/customize.rb
vagrant-parallels-1.3.8 lib/vagrant-parallels/action/customize.rb
vagrant-parallels-1.3.7 lib/vagrant-parallels/action/customize.rb
vagrant-parallels-1.3.6 lib/vagrant-parallels/action/customize.rb
vagrant-parallels-1.3.5 lib/vagrant-parallels/action/customize.rb
vagrant-parallels-1.3.4 lib/vagrant-parallels/action/customize.rb
vagrant-parallels-1.3.3 lib/vagrant-parallels/action/customize.rb
vagrant-parallels-1.3.3.rc1 lib/vagrant-parallels/action/customize.rb
vagrant-parallels-1.3.2 lib/vagrant-parallels/action/customize.rb
vagrant-parallels-1.3.1 lib/vagrant-parallels/action/customize.rb
vagrant-parallels-1.3.0 lib/vagrant-parallels/action/customize.rb
vagrant-parallels-1.2.2 lib/vagrant-parallels/action/customize.rb
vagrant-parallels-1.2.1 lib/vagrant-parallels/action/customize.rb