Class: VagrantPlugins::VSphere::Action::SnapshotSave

Inherits:
Object
  • Object
show all
Includes:
Util::VimHelpers, Util::VmHelpers
Defined in:
lib/vSphere/action/snapshot_save.rb

Instance Method Summary collapse

Methods included from Util::VmHelpers

#create_snapshot, #delete_snapshot, #enumerate_snapshots, #get_vm_state, #power_off_vm, #power_on_vm, #powered_off?, #powered_on?, #restore_snapshot, #suspended?

Methods included from Util::VimHelpers

#find_clustercompute_or_compute_resource, #get_compute_resource, #get_customization_spec_info_by_name, #get_datacenter, #get_datastore, #get_network_by_name, #get_resource_pool, #get_vm_by_uuid

Constructor Details

#initialize(app, _env) ⇒ SnapshotSave

Returns a new instance of SnapshotSave.



11
12
13
# File 'lib/vSphere/action/snapshot_save.rb', line 11

def initialize(app, _env)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/vSphere/action/snapshot_save.rb', line 15

def call(env)
  vm = get_vm_by_uuid(env[:vSphere_connection], env[:machine])

  env[:ui].info(I18n.t(
    "vagrant.actions.vm.snapshot.saving",
    name: env[:snapshot_name]))

  create_snapshot(vm, env[:snapshot_name]) do |progress|
    env[:ui].clear_line
    env[:ui].report_progress(progress, 100, false)
  end

  env[:ui].clear_line

  env[:ui].success(I18n.t(
    "vagrant.actions.vm.snapshot.saved",
    name: env[:snapshot_name]))
  @app.call env
end