1 2 3 4 5 6 7 8 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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
module Fission
class Command
class Start < Command
def initialize(args=[])
super
@options.headless = false
end
def execute
super
incorrect_arguments if @args.empty?
vm = VM.new @args.first
output "Starting '#{vm.name}'"
start_args = {}
start_args[:headless] = true if @options.headless
response = vm.start start_args
if response.successful?
output "VM '#{vm.name}' started"
else
output_and_exit "There was a problem starting the VM. The error was:\n#{response.message}", response.code
end
end
def option_parser
optparse = OptionParser.new do |opts|
opts.banner = "Usage: fission start TARGET_VM [OPTIONS]"
opts.separator ''
opts.separator 'Starts TARGET_VM.'
opts.separator ''
opts.separator 'OPTIONS:'
opts.on '--headless', 'Start the VM in headless mode (i.e. no Fusion GUI console)' do
@options.headless = true
end
end
optparse
end
def summary
'Start a VM'
end
end
end
end
|