Class: Fission::Command::SnapshotRevert

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

Instance Attribute Summary

Attributes inherited from Fission::Command

#args, #options

Instance Method Summary collapse

Methods inherited from Fission::Command

#command_name, help, #initialize, #ui

Methods included from Fission::CommandHelpers

#incorrect_arguments, #parse_arguments

Constructor Details

This class inherits a constructor from Fission::Command

Instance Method Details

#executeObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/fission/command/snapshot_revert.rb', line 5

def execute
  super
  incorrect_arguments unless @args.count == 2

  vm = VM.new @args[0]
  snap_name = @args[1]

  output "Reverting to snapshot '#{snap_name}'"
  response = vm.revert_to_snapshot snap_name

  if response.successful?
    output "Reverted to snapshot '#{snap_name}'"
  else
    output_and_exit "There was an error reverting to the snapshot.  The error was:\n#{response.message}", response.code
  end
end

#option_parserObject



22
23
24
25
26
27
28
29
30
# File 'lib/fission/command/snapshot_revert.rb', line 22

def option_parser
  optparse = OptionParser.new do |opts|
    opts.banner = "Usage: fission snapshot revert TARGET_VM TARGET_SNAPSHOT"
    opts.separator ''
    opts.separator 'Reverts TARGET_VM to TARGET_SNAPSHOT'
  end

  optparse
end

#summaryObject



32
33
34
# File 'lib/fission/command/snapshot_revert.rb', line 32

def summary
  'Revert a VM to a snapshot'
end