Class: VagrantPlugins::Parallels::Action::PrepareCloneSnapshot
- Inherits:
-
Object
- Object
- VagrantPlugins::Parallels::Action::PrepareCloneSnapshot
- Defined in:
- lib/vagrant-parallels/action/prepare_clone_snapshot.rb
Constant Summary collapse
- @@lock =
Mutex.new
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ PrepareCloneSnapshot
constructor
A new instance of PrepareCloneSnapshot.
Constructor Details
#initialize(app, env) ⇒ PrepareCloneSnapshot
Returns a new instance of PrepareCloneSnapshot.
11 12 13 14 |
# File 'lib/vagrant-parallels/action/prepare_clone_snapshot.rb', line 11 def initialize(app, env) @app = app @logger = Log4r::Logger.new('vagrant_parallels::action::prepare_clone_snapshot') 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 35 36 37 38 39 40 41 42 43 |
# File 'lib/vagrant-parallels/action/prepare_clone_snapshot.rb', line 16 def call(env) if !env[:clone_id] @logger.info('No source VM for cloning, skip snapshot preparing') return @app.call(env) end if Util::Common::is_macvm(env[:machine]) #Ignore, since macvms doesn't support snapshot creation @logger.info('Snapshot creation is not supported yet for macOS ARM Guests, skip snapshot preparing') return @app.call(env) end # If we're not doing a linked clone, snapshots don't matter if !env[:machine].provider_config.linked_clone return @app.call(env) end # We lock so that we don't snapshot in parallel @@lock.synchronize do lock_key = Digest::MD5.hexdigest("#{env[:clone_id]}-snapshot") env[:machine].env.lock(lock_key, retry: true) do prepare_snapshot(env) end end # Continue @app.call(env) end |