class Fission::Action::VM::Suspender
def initialize(vm)
Fission::Action::VMSuspender.new @my_vm
Examples:
vm - An instance of VM
Internal: Creates a new VMSuspender object. This accepts a VM object.
def initialize(vm) @vm = vm end
def suspend
If successful, the Response's data attribute will be nil.
Returns a Response with the result.
@suspender.suspend
Examples
Public: Suspends a VM. The VM must be running in order to suspend it.
def suspend unless @vm.exists? return Response.new :code => 1, :message => 'VM does not exist' end running_response = @vm.running? return running_response unless running_response.successful? unless running_response.data return Response.new :code => 1, :message => 'VM is not running' end conf_file_response = @vm.conf_file return conf_file_response unless conf_file_response.successful? command = "#{vmrun_cmd} suspend " command << "'#{conf_file_response.data}' 2>&1" command_exec = Fission::Action::ShellExecutor.new command Response.from_shell_executor command_exec.execute end
def vmrun_cmd
Returns a String for the configured value of
# => "/foo/bar/vmrun -T fusion"
@suspender.vmrun_cmd
Examples
Internal: Helper for getting the configured vmrun_cmd value.
def vmrun_cmd Fission.config['vmrun_cmd'] end