Class: Fission::Command::Start
- Inherits:
-
Fission::Command
- Object
- Fission::Command
- Fission::Command::Start
- Defined in:
- lib/fission/command/start.rb
Instance Attribute Summary
Attributes inherited from Fission::Command
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(args = []) ⇒ Start
constructor
A new instance of Start.
- #option_parser ⇒ Object
Methods inherited from Fission::Command
Constructor Details
#initialize(args = []) ⇒ Start
Returns a new instance of Start.
5 6 7 8 |
# File 'lib/fission/command/start.rb', line 5 def initialize(args=[]) super @options.headless = false end |
Instance Method Details
#execute ⇒ Object
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 |
# File 'lib/fission/command/start.rb', line 10 def execute option_parser.parse! @args if @args.empty? Fission.ui.output self.class.help Fission.ui.output "" Fission.ui.output_and_exit "Incorrect arguments for start 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 if VM.all_running.include?(vm_name) Fission.ui.output '' Fission.ui.output_and_exit "VM '#{vm_name}' is already running", 0 end Fission.ui.output "Starting '#{vm_name}'" @vm = Fission::VM.new vm_name if @options.headless if Fission::Fusion.is_running? Fission.ui.output 'It looks like the Fusion GUI is currently running' Fission.ui.output 'A VM cannot be started in headless mode when the Fusion GUI is running' Fission.ui.output_and_exit "Exit the Fusion GUI and try again", 1 else @vm.start :headless => true end else @vm.start end end |
#option_parser ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/fission/command/start.rb', line 46 def option_parser optparse = OptionParser.new do |opts| opts. = "\nstart usage: fission start vm [options]" opts.on '--headless', 'Start the VM in headless mode (i.e. no Fusion GUI console)' do @options.headless = true end end optparse end |