Class: Fission::Action::VM::Suspender
- Defined in:
- lib/fission/action/vm/suspender.rb
Instance Method Summary collapse
-
#initialize(vm) ⇒ Suspender
constructor
Internal: Creates a new VMSuspender object.
-
#suspend ⇒ Object
Public: Suspends a VM.
Constructor Details
Instance Method Details
#suspend ⇒ Object
Public: Suspends a VM. The VM must be running in order to suspend it.
Examples
@suspender.suspend
Returns a Response with the result. If successful, the Response’s data attribute will be nil. If there is an error, an unsuccessful Response will be returned.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/fission/action/vm/suspender.rb', line 29 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 |