Sha256: fdc972b55d25fcc1ca0df6d6dc8af33c7aec1b6cbffe164d43e3073339855a7f

Contents?: true

Size: 1.45 KB

Versions: 1

Compression:

Stored size: 1.45 KB

Contents

module Veewee
  module Provider
    module Virtualbox
      module BoxCommand

        def up(options={})

          unless self.exists?
            env.ui.error "Error:: You tried to up a non-existing box '#{name}'"
            exit -1
          end

          gui_enabled=options[:nogui]==true ? false : true

          raise Veewee::Error,"Box is already running" if self.running?

          # Before we start,correct the ssh port if needed
          forward=self.forwarding("guestssh")
          guessed_port=guess_free_port(definition.ssh_host_port.to_i,definition.ssh_host_port.to_i+40).to_s
          definition.ssh_host_port=guessed_port.to_s

          unless forward.nil?
            if guessed_port!=forward[:guest_port]
              # Remove the existing one
              self.delete_forwarding("guestssh")
              env.ui.warn "Changing ssh port from #{forward[:guest_port]} to #{guessed_port}"
              self.add_ssh_nat_mapping
            end
          else
            self.add_ssh_nat_mapping
          end

          self.suppress_messages    

          # Once assembled we start the machine
          env.logger.info "Started the VM with GUI Enabled? #{gui_enabled}"

          command="#{@vboxcmd} startvm --type gui '#{name}'"
          unless (gui_enabled)
            command="#{@vboxcmd} startvm --type headless '#{name}'"
          end
          shell_results=shell_exec("#{command}",{:mute => true})
        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
veewee-0.3.0.alpha5 lib/veewee/provider/virtualbox/box/up.rb