Class: VagrantPlugins::VSphere::Action::Suspend
- Inherits:
-
Object
- Object
- VagrantPlugins::VSphere::Action::Suspend
- Includes:
- Util::VimHelpers, Util::VmHelpers
- Defined in:
- lib/vSphere/action/suspend.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, _env) ⇒ Suspend
constructor
A new instance of Suspend.
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, #resume_vm, #suspend_vm, #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) ⇒ Suspend
Returns a new instance of Suspend.
15 16 17 |
# File 'lib/vSphere/action/suspend.rb', line 15 def initialize(app, _env) @app = app end |
Instance Method Details
#call(env) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/vSphere/action/suspend.rb', line 19 def call(env) vm = get_vm_by_uuid env[:vSphere_connection], env[:machine] # Suspending is a no-op if we can't find the VM or it is already off # or suspended unless vm.nil? || suspended?(vm) || powered_off?(vm) env[:ui].info I18n.t('vsphere.suspend_vm') suspend_vm(vm) end @app.call env end |