Sha256: b3eeccb3562d3e5f00404f3dac15ec53bd44c32ea7c33ac60cd1ffdccd5695df

Contents?: true

Size: 1.44 KB

Versions: 2

Compression:

Stored size: 1.44 KB

Contents

module Veewee
  module Provider
    module Virtualbox
      module BoxCommand

        def up(options={})

          unless self.exists?
            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")
              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

2 entries across 2 versions & 1 rubygems

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