Class: VagrantPlugins::Proxmox::Action::AdjustForwardedPortParams
- Inherits:
-
ProxmoxAction
- Object
- ProxmoxAction
- VagrantPlugins::Proxmox::Action::AdjustForwardedPortParams
- Defined in:
- lib/vagrant-proxmox/action/adjust_forwarded_port_params.rb
Overview
This action creates a new virtual machine on the Proxmox server and stores its node and vm_id env.id
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ AdjustForwardedPortParams
constructor
A new instance of AdjustForwardedPortParams.
Constructor Details
#initialize(app, env) ⇒ AdjustForwardedPortParams
Returns a new instance of AdjustForwardedPortParams.
9 10 11 12 |
# File 'lib/vagrant-proxmox/action/adjust_forwarded_port_params.rb', line 9 def initialize app, env @app = app @logger = Log4r::Logger.new 'vagrant_proxmox::action::adjust_forwarded_port_params' end |
Instance Method Details
#call(env) ⇒ Object
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 |
# File 'lib/vagrant-proxmox/action/adjust_forwarded_port_params.rb', line 14 def call env env[:ui].info I18n.t('vagrant_proxmox.adjust_forwarded_port_params') config = env[:machine].provider_config node = env[:proxmox_selected_node] vm_id = nil begin vm_id = env[:machine].id.split("/").last node_ip = env[:proxmox_connection].get_node_ip(node, 'vmbr0') env[:machine].config.vm.networks.each do |type, | next if type != :forwarded_port if [:id] == "ssh" # Provisioning and vagrant ssh will use this # high port of the selected proxmox node [:auto_correct] = false [:host_ip] = node_ip [:host] = sprintf("22%03d", vm_id.to_i).to_i env[:machine].config.ssh.host = node_ip env[:machine].config.ssh.port = sprintf("22%03d", vm_id.to_i).to_s break end end end next_action env end |