Sha256: 11de64a3448b2864e25cf64f3ba8d4afa09f9e7673f7b96ac28452e4aeb9fb95

Contents?: true

Size: 1.19 KB

Versions: 11

Compression:

Stored size: 1.19 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

              result = env[:machine].provider.driver.set_vm_settings(processed_command)
              if result.exit_code != 0
                raise Vagrant::Errors::VMCustomizationFailed, {
                    :command => processed_command.inspect,
                    :error   => result.stderr
                }
              end
            end
          end

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

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
vagrant-parallels-0.2.1 lib/vagrant-parallels/action/customize.rb
vagrant-parallels-0.2.0 lib/vagrant-parallels/action/customize.rb
vagrant-parallels-0.1.3 lib/vagrant-parallels/action/customize.rb
vagrant-parallels-0.1.2 lib/vagrant-parallels/action/customize.rb
vagrant-parallels-0.1.1 lib/vagrant-parallels/action/customize.rb
vagrant-parallels-0.1.0 lib/vagrant-parallels/action/customize.rb
vagrant-parallels-0.0.9 lib/vagrant-parallels/action/customize.rb
vagrant-parallels-0.0.8 lib/vagrant-parallels/action/customize.rb
vagrant-parallels-0.0.7 lib/vagrant-parallels/action/customize.rb
vagrant-parallels-0.0.6 lib/vagrant-parallels/action/customize.rb
vagrant-parallels-0.0.5 lib/vagrant-parallels/action/customize.rb