Class: Fission::Action::Snapshot::Lister
- Defined in:
- lib/fission/action/snapshot/lister.rb
Instance Method Summary collapse
-
#initialize(vm) ⇒ Lister
constructor
Internal: Creates a new SnapshotLister object.
-
#snapshots ⇒ Object
Internal: List the snapshots for a VM.
Constructor Details
#initialize(vm) ⇒ Lister
17 18 19 |
# File 'lib/fission/action/snapshot/lister.rb', line 17 def initialize(vm) @vm = vm end |
Instance Method Details
#snapshots ⇒ Object
Internal: List the snapshots for a VM.
Examples
@lister.snapshots.data
# => ['snap 1', 'snap 2']
Returns a Response with the result. If successful, the Repsonse’s data attribute will be an Array of the snapshot names (String). If there is an error, an unsuccessful Response will be returned.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/fission/action/snapshot/lister.rb', line 32 def snapshots unless @vm.exists? return Response.new :code => 1, :message => 'VM does not exist' end conf_file_response = @vm.conf_file return conf_file_response unless conf_file_response.successful? command = "#{vmrun_cmd} listSnapshots " command << "'#{conf_file_response.data}' 2>&1" command_exec = Fission::Action::ShellExecutor.new command result = command_exec.execute response = Response.new :code => result['process_status'].exitstatus if response.successful? response.data = parse_snapshot_names_from_output result['output'] else response. = result['output'] end response end |