Class: VagrantPlugins::ProviderKvm::Action::Customize
- Inherits:
-
Object
- Object
- VagrantPlugins::ProviderKvm::Action::Customize
- Defined in:
- lib/vagrant-kvm/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 9 |
# File 'lib/vagrant-kvm/action/customize.rb', line 5 def initialize(app, env, event) @app = app @event = event @logger = Log4r::Logger.new("vagrant::kvm::action::customize") end |
Instance Method Details
#call(env) ⇒ Object
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-kvm/action/customize.rb', line 11 def call(env) customizations = [] env[:machine].provider_config.customizations.each do |event, command| if event == @event customizations << command end end if !customizations.empty? @logger.info("customize.running") # 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.execute_command(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 |