Class: VagrantPlugins::QEMU::Action::StartInstance
- Inherits:
-
Object
- Object
- VagrantPlugins::QEMU::Action::StartInstance
- Defined in:
- lib/vagrant-qemu/action/start_instance.rb
Overview
This starts a stopped instance.
Instance Method Summary collapse
- #call(env) ⇒ Object
- #forwarded_ports(env) ⇒ Object
-
#initialize(app, env) ⇒ StartInstance
constructor
A new instance of StartInstance.
Constructor Details
#initialize(app, env) ⇒ StartInstance
Returns a new instance of StartInstance.
8 9 10 11 |
# File 'lib/vagrant-qemu/action/start_instance.rb', line 8 def initialize(app, env) @app = app @logger = Log4r::Logger.new("vagrant_qemu::action::start_instance") end |
Instance Method Details
#call(env) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/vagrant-qemu/action/start_instance.rb', line 13 def call(env) = { :ssh_port => env[:machine].provider_config.ssh_port, :arch => env[:machine].provider_config.arch, :machine => env[:machine].provider_config.machine, :cpu => env[:machine].provider_config.cpu, :smp => env[:machine].provider_config.smp, :memory => env[:machine].provider_config.memory, :net_device => env[:machine].provider_config.net_device, :extra_qemu_args => env[:machine].provider_config.extra_qemu_args, :extra_netdev_args => env[:machine].provider_config.extra_netdev_args, :ports => forwarded_ports(env), :control_port => env[:machine].provider_config.control_port, :debug_port => env[:machine].provider_config.debug_port, :no_daemonize => env[:machine].provider_config.no_daemonize } env[:ui].output(I18n.t("vagrant_qemu.starting")) env[:machine].provider.driver.start() @app.call(env) end |
#forwarded_ports(env) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/vagrant-qemu/action/start_instance.rb', line 35 def forwarded_ports(env) result = [] env[:machine].config.vm.networks.each do |type, | next if type != :forwarded_port # Don't include SSH next if [:id] == "ssh" # Skip port if it is disabled next if [:disabled] host_ip = "" host_ip = "#{[:host_ip]}:" if [:host_ip] guest_ip = "" guest_ip = "#{[:guest_ip]}:" if [:guest_ip] result.push("#{[:protocol]}:#{host_ip}:#{[:host]}-#{guest_ip}:#{[:guest]}") end result end |