lib/vagrant-vcloud/command.rb in vagrant-vcloud-0.3.3 vs lib/vagrant-vcloud/command.rb in vagrant-vcloud-0.4.0
- old
+ new
@@ -42,11 +42,11 @@
# Print the General Information Table
puts table
end
- def command_vcloud_network(cfg, vapp_id)
+ def command_vcloud_network(cfg, vapp_id, ssh_host)
# FIXME: this needs to be fixed to accomodate the bridged scenario
# potentially showing only the assigned IPs in the VMs
puts 'Fetching vCloud Director network settings ...'
cnx = cfg.vcloud_cnx.driver
@@ -95,14 +95,27 @@
if vm_scope == vapp_edge_scope
# Generate DNAT Mappings for the valid machines
# If rules don't match, you will not see them !
if edge_gateway_rule
# DNAT rule from edge to vapp to vm
+ connect_host = nil
+
+ # Add support for config.ssh.host
+ if ssh_host
+ connect_host = "#{ssh_host}:" +
+ "#{vapp_edge_rule[:nat_external_port]}" +
+ ' -> ' +
+ "#{cfg.vdc_edge_gateway_ip}:" +
+ "#{vapp_edge_rule[:nat_external_port]}"
+ else
+ connect_host = "#{cfg.vdc_edge_gateway_ip}:" +
+ "#{vapp_edge_rule[:nat_external_port]}"
+ end
+
network_table << [
"#{vm[0]}",
- "#{cfg.vdc_edge_gateway_ip}:" +
- "#{vapp_edge_rule[:nat_external_port]}" +
+ "#{connect_host}" +
" -> #{vapp_edge_ip}:" +
"#{vapp_edge_rule[:nat_external_port]}" +
" -> #{vm[1][:addresses][0]}:" +
"#{vapp_edge_rule[:nat_internal_port]}",
edge_gateway_rule[:is_enabled]
@@ -221,10 +234,11 @@
exit 1
end
puts 'Initializing vCloud Director provider...'
# initialize some variables
+ ssh_host = nil
vapp_id = nil
cfg = nil
# Go through the vagrant machines
with_target_vms(@argv) do |machine|
@@ -244,19 +258,20 @@
machine.provider.ssh_info
# populate cfg & vApp Id for later use.
cfg = machine.provider_config
vapp_id = machine.get_vapp_id
+ ssh_host = machine.config.ssh.host
break
end
# iterate through each option and call the according command.
options.keys.each do |key|
case key
when :status
command_vcloud_status(cfg, vapp_id)
when :network
- command_vcloud_network(cfg, vapp_id)
+ command_vcloud_network(cfg, vapp_id, ssh_host)
when :redeploy_edge_gw
command_vcloud_redeploy_edge_gw(cfg)
end
end