Class: VagrantPlugins::Skytap::Action::ReadState
- Includes:
- ActionHelpers
- Defined in:
- lib/vagrant-skytap/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 Attribute Summary collapse
-
#env ⇒ Object
readonly
Returns the value of attribute env.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ ReadState
constructor
A new instance of ReadState.
- #read_state(machine) ⇒ Object
Methods included from ActionHelpers
Constructor Details
#initialize(app, env) ⇒ ReadState
Returns a new instance of ReadState.
38 39 40 41 42 |
# File 'lib/vagrant-skytap/action/read_state.rb', line 38 def initialize(app, env) @app = app @env = env @logger = Log4r::Logger.new("vagrant_skytap::action::read_state") end |
Instance Attribute Details
#env ⇒ Object (readonly)
Returns the value of attribute env.
36 37 38 |
# File 'lib/vagrant-skytap/action/read_state.rb', line 36 def env @env end |
Instance Method Details
#call(env) ⇒ Object
44 45 46 47 48 |
# File 'lib/vagrant-skytap/action/read_state.rb', line 44 def call(env) env[:machine_state_id] = read_state(env[:machine]) @app.call(env) end |
#read_state(machine) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/vagrant-skytap/action/read_state.rb', line 50 def read_state(machine) if machine.id if environment = env[:environment] environment.reload elsif props = API::Environment.properties(env) @logger.info("env[:environment] was not set!") end if vm = current_vm(env) return vm.runstate.to_sym end end :not_created end |