Class: VagrantPlugins::QEMU::Action::ReadState
- Inherits:
-
Object
- Object
- VagrantPlugins::QEMU::Action::ReadState
- Defined in:
- lib/vagrant-qemu/action/read_state.rb
Overview
This action reads the state of the machine and puts it in the ‘:machine_state_id` key in the environment.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ ReadState
constructor
A new instance of ReadState.
Constructor Details
#initialize(app, env) ⇒ ReadState
Returns a new instance of ReadState.
9 10 11 12 |
# File 'lib/vagrant-qemu/action/read_state.rb', line 9 def initialize(app, env) @app = app @logger = Log4r::Logger.new("vagrant_qemu::action::read_state") end |
Instance Method Details
#call(env) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/vagrant-qemu/action/read_state.rb', line 14 def call(env) if env[:machine].id env[:machine_state_id] = env[:machine].provider.driver.get_current_state # If the machine isn't created, then our ID is stale, so just # mark it as not created. if env[:machine_state_id] == :not_created env[:machine].id = nil end else env[:machine_state_id] = :not_created end @app.call(env) end |