Class: VagrantPlugins::ProviderVeertu::Action::Customize
- Inherits:
-
Object
- Object
- VagrantPlugins::ProviderVeertu::Action::Customize
- Defined in:
- lib/vagrant-veertu/action/customize.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env, event) ⇒ Customize
constructor
A new instance of Customize.
Constructor Details
#initialize(app, env, event) ⇒ Customize
Returns a new instance of Customize.
5 6 7 8 |
# File 'lib/vagrant-veertu/action/customize.rb', line 5 def initialize(app, env, event) @app = app @event = event end |
Instance Method Details
#call(env) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/vagrant-veertu/action/customize.rb', line 10 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 Vagrant::Errors::VeertuManageError => e raise Vagrant::Errors::VMCustomizationFailed, { command: command, error: e.inspect } end end end @app.call(env) end |