Class: VagrantPlugins::Openstack::Action::SnapshotRestore
- Inherits:
-
AbstractAction
- Object
- AbstractAction
- VagrantPlugins::Openstack::Action::SnapshotRestore
- Defined in:
- lib/vagrant-openstack-provider/action/snapshot_restore.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, _env) ⇒ SnapshotRestore
constructor
A new instance of SnapshotRestore.
Constructor Details
#initialize(app, _env) ⇒ SnapshotRestore
Returns a new instance of SnapshotRestore.
7 8 9 |
# File 'lib/vagrant-openstack-provider/action/snapshot_restore.rb', line 7 def initialize(app, _env) @app = app end |
Instance Method Details
#call(env) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/vagrant-openstack-provider/action/snapshot_restore.rb', line 11 def call(env) nova = env[:openstack_client].nova machine_snapshots = nova.list_snapshots(env, env[:machine].id) snapshot = machine_snapshots.find { |s| s.name == env[:snapshot_name] } unless snapshot.nil? env[:ui].info(I18n.t('vagrant.actions.vm.snapshot.restoring', name: snapshot.name)) nova.restore_snapshot(env, env[:machine].id, snapshot.id) end @app.call env end |