class Fission::Command::Suspend
Public Class Methods
new(args=[])
click to toggle source
Calls superclass method
Fission::Command.new
# File lib/fission/command/suspend.rb, line 5 def initialize(args=[]) super @options.all = false end
Public Instance Methods
execute()
click to toggle source
Calls superclass method
Fission::Command#execute
# File lib/fission/command/suspend.rb, line 10 def execute super incorrect_arguments if @args.count != 1 && !@options.all vms_to_suspend.each do |vm| output "Suspending '#{vm.name}'" response = vm.suspend if response.successful? output "VM '#{vm.name}' suspended" else output_and_exit "There was an error suspending the VM. The error was:\n#{response.message}", response.code end end end
option_parser()
click to toggle source
# File lib/fission/command/suspend.rb, line 42 def option_parser optparse = OptionParser.new do |opts| opts.banner = "Usage: fission suspend [TARGET_VM | --all]" opts.separator '' opts.separator 'Suspend TARGET_VM or all VMs.' opts.separator '' opts.separator 'OPTIONS:' opts.on '--all', 'Suspend all running VMs' do @options.all = true end end optparse end
summary()
click to toggle source
# File lib/fission/command/suspend.rb, line 57 def summary 'Suspend a VM' end
vms_to_suspend()
click to toggle source
# File lib/fission/command/suspend.rb, line 26 def vms_to_suspend if @options.all response = VM.all_running if response.successful? vms = response.data else output_and_exit "There was an error getting the list of running VMs. The error was:\n#{response.message}", response.code end else vms = [ VM.new(@args.first) ] end vms end