Class: VagrantPlugins::PersistentStorage::Action::CreateAdapter
- Inherits:
-
Object
- Object
- VagrantPlugins::PersistentStorage::Action::CreateAdapter
- Defined in:
- lib/vagrant-persistent-storage/action/create_adapter.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ CreateAdapter
constructor
A new instance of CreateAdapter.
Constructor Details
#initialize(app, env) ⇒ CreateAdapter
Returns a new instance of CreateAdapter.
8 9 10 11 12 13 14 |
# File 'lib/vagrant-persistent-storage/action/create_adapter.rb', line 8 def initialize(app, env) @app = app @machine = env[:machine] @global_env = @machine.env @provider = env[:provider] @logger = Log4r::Logger.new('vagrant::persistent_storage::action::create_adapter') end |
Instance Method Details
#call(env) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/vagrant-persistent-storage/action/create_adapter.rb', line 16 def call(env) # skip if machine is not running and the action is destroy, halt or suspend return @app.call(env) if @machine.state.id != :running && [:destroy, :halt, :suspend].include?(env[:machine_action]) # skip if machine is not saved and the action is resume return @app.call(env) if @machine.state.id != :saved && env[:machine_action] == :resume # skip if machine is powered off and the action is resume or up return @app.call(env) if @machine.state.id == :poweroff && [:resume, :up].include?(env[:machine_action]) # skip if machine is saved return @app.call(env) if @machine.state.id == :saved return @app.call(env) unless env[:machine].config.persistent_storage.enabled? @logger.info '** Creating Persistent Storage Adapter **' env[:ui].info I18n.t("vagrant_persistent_storage.action.create_adapter") env[:machine].provider.driver.create_adapter @app.call(env) end |