Class: Fission::Command::SnapshotList

Inherits:
Fission::Command show all
Defined in:
lib/fission/command/snapshot_list.rb

Instance Attribute Summary

Attributes inherited from Fission::Command

#args, #options

Instance Method Summary collapse

Methods inherited from Fission::Command

help

Constructor Details

#initialize(args = []) ⇒ SnapshotList

Returns a new instance of SnapshotList.



5
6
7
# File 'lib/fission/command/snapshot_list.rb', line 5

def initialize(args=[])
  super
end

Instance Method Details

#executeObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/fission/command/snapshot_list.rb', line 9

def execute
  unless @args.count == 1
    Fission.ui.output self.class.help
    Fission.ui.output ""
    Fission.ui.output_and_exit "Incorrect arguments for snapshot list command", 1
  end

  vm_name = @args.first

  unless Fission::VM.exists? vm_name
    Fission.ui.output_and_exit "Unable to find the VM #{vm_name} (#{Fission::VM.path(vm_name)})", 1 
  end

  @vm = Fission::VM.new vm_name
  snaps = @vm.snapshots

  if snaps.any?
    Fission.ui.output snaps.join("\n")
  else
    Fission.ui.output "No snapshots found for VM '#{vm_name}'"
  end
end

#option_parserObject



32
33
34
35
36
37
38
# File 'lib/fission/command/snapshot_list.rb', line 32

def option_parser
  optparse = OptionParser.new do |opts|
    opts.banner = "\nsnapshot list: fission snapshot list my_vm"
  end

  optparse
end