Class: Fission::Command::SnapshotRevert
- Inherits:
-
Fission::Command
- Object
- Fission::Command
- Fission::Command::SnapshotRevert
- Defined in:
- lib/fission/command/snapshot_revert.rb
Instance Attribute Summary
Attributes inherited from Fission::Command
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(args = []) ⇒ SnapshotRevert
constructor
A new instance of SnapshotRevert.
- #option_parser ⇒ Object
Methods inherited from Fission::Command
Constructor Details
#initialize(args = []) ⇒ SnapshotRevert
Returns a new instance of SnapshotRevert.
5 6 7 |
# File 'lib/fission/command/snapshot_revert.rb', line 5 def initialize(args=[]) super end |
Instance Method Details
#execute ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/fission/command/snapshot_revert.rb', line 9 def execute unless @args.count == 2 Fission.ui.output self.class.help Fission.ui.output '' Fission.ui.output_and_exit 'Incorrect arguments for snapshot revert command', 1 end vm_name, snap_name = @args.take 2 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 if Fission::Fusion.is_running? Fission.ui.output 'It looks like the Fusion GUI is currently running' Fission.ui.output_and_exit 'Please exit the Fusion GUI and try again', 1 end @vm = Fission::VM.new vm_name unless @vm.snapshots.include? snap_name Fission.ui.output_and_exit "Unable to find the snapshot '#{snap_name}'", 1 end Fission.ui.output "Reverting to snapshot '#{snap_name}'" @vm.revert_to_snapshot(snap_name) end |
#option_parser ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/fission/command/snapshot_revert.rb', line 37 def option_parser optparse = OptionParser.new do |opts| opts. = "\nsnapshot revert: fission snapshot revert my_vm snapshot_1" end optparse end |