class Fission::Action::VM::Stopper

def stop(options={})

If there is an error, an unsuccessful Response will be returned.
If successful, the Response's data attribute will be nil.
Returns a Response with the result.

@stopper.stop :hard => true

@stopper.stop

Examples

(default: false)
stop command.
is the equivalent of passing 'hard' to the vmrun
of attempting to initiate a graceful shutdown). This
:hard - Boolean which specifies to power off the VM (instead
options - Hash of options:

Public: Stops a VM. The VM must be running in order to stop it.
def stop(options={})
  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} stop "
  command << "'#{conf_file_response.data}' "
  command << 'hard ' unless options[:hard].blank?
  command << '2>&1'
  command_exec = Fission::Action::ShellExecutor.new command
  Response.from_shell_executor command_exec.execute
end