Skip to content
This repository has been archived by the owner on Dec 8, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/v0.2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
frapposelli committed Apr 3, 2014
2 parents 13913d1 + e661928 commit 12f590e
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 90 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
[Vagrant](http://www.vagrantup.com) provider for VMware vCloud Director®
=============

[Version 0.2.0](https://github.com/frapposelli/vagrant-vcloud/releases/tag/v0.2.0) has been released!
[Version 0.2.1](https://github.com/frapposelli/vagrant-vcloud/releases/tag/v0.2.1) has been released!
-------------

Please note that this software is still Alpha/Beta quality and is not recommended for production usage.

Right now a [Precise32](http://vagrant.tsugliani.fr/precise32.box) is available for use, or you can roll your own as you please, make sure to install VMware tools in it.

Features of Version 0.2.1 are:

- Critical Bugfixes

Features of Version 0.2.0 are:

- It's now possible to connect to an existing VDC network without creating a vShield Edge [ISSUE #23].
- It's now possible to connect to an existing VDC network without creating a vShield Edge using ```network_bridge = true``` in the Vagrantfile [ISSUE #23]. *experimental*
- Added a ```upload_chunksize``` parameter to specify the chunk dimension during box uploads [ISSUE #21].
- Added support for [vCloud® Hybrid Service™](http://www.vmware.com/products/vcloud-hybrid-service) API version 5.7.
- Added a new command to vagrant called ```vcloud-status``` that shows the current status of the vCloud instance relative to the Vagrant deployment. *experimental*
Expand Down
6 changes: 2 additions & 4 deletions lib/vagrant-vcloud/action/read_ssh_info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,10 @@ def read_ssh_info(env)
else

@logger.debug('Getting port forwarding rules...')
rules = cnx.get_vapp_port_forwarding_rules(vAppId)
rules = cnx.get_vapp_port_forwarding_rules(vapp_id)

rules.each do |rule|
if rule[:vapp_scoped_local_id] == myhash[:vapp_scoped_local_id] \
&& rule[:nat_internal_port] == '22'

if rule[:vapp_scoped_local_id] == myhash[:vapp_scoped_local_id] && rule[:nat_internal_port] == '22'
@external_ip = rule[:nat_external_ip]
@external_port = rule[:nat_external_port]
break
Expand Down
172 changes: 95 additions & 77 deletions lib/vagrant-vcloud/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,92 +87,110 @@ def execute
# FIXME: this needs to be fixed to accomodate the bridged scenario
# potentially showing only the assigned IPs in the VMs

vapp_edge_ip = cnx.get_vapp_edge_public_ip(vapp_id)
vapp_edge_rules = cnx.get_vapp_port_forwarding_rules(vapp_id)
edge_gateway_rules = cnx.get_edge_gateway_rules(cfg.vdc_edge_gateway,
cfg.vdc_id)

# Create a new table for the network information
network_table = Terminal::Table.new
network_table.title = 'Vagrant vCloud Director Network Map'

network_table << ['VM Name', 'Destination NAT Mapping', 'Enabled']
network_table << :separator

# Fetching Destination NAT Rules for each vApp/Edge/VM/Mapping
edge_gateway_rules.each do |edge_gateway_rule|
vapp_edge_rules.each do |vapp_edge_rule|

# Only check DNAT and src/dst
if edge_gateway_rule[:rule_type] == 'DNAT' &&
edge_gateway_rule[:original_ip] == cfg.vdc_edge_gateway_ip &&
edge_gateway_rule[:translated_ip] == vapp_edge_ip

# Loop on every VM in the vApp
vapp[:vms_hash].each do |vm|
# Only Map valid vAppEdge scope to VM scope
vm_scope = vm[1][:vapp_scoped_local_id]
vapp_edge_scope = vapp_edge_rule[:vapp_scoped_local_id]

if vm_scope == vapp_edge_scope

# Generate DNAT Mappings for the valid machines
# If rules don't match, you will not see them !
network_table << [
"#{vm[0]}",
"#{cfg.vdc_edge_gateway_ip}:" +
"#{vapp_edge_rule[:nat_external_port]}" +
" -> #{vapp_edge_ip}:" +
"#{vapp_edge_rule[:nat_external_port]}" +
" -> #{vm[1][:addresses][0]}:" +
"#{vapp_edge_rule[:nat_internal_port]}",
edge_gateway_rule[:is_enabled]
]
if !cfg.network_bridge.nil?

# Create a new table for the network information
network_table = Terminal::Table.new
network_table.title = 'Network Map'

network_table << ['VM Name', 'IP Address', 'Connection']
network_table << :separator

# ap vapp[:vms_hash]

vapp[:vms_hash].each do |vm|
# ap vm

network_table << [vm[0], vm[1][:addresses][0], 'Direct']
end
else

vapp_edge_ip = cnx.get_vapp_edge_public_ip(vapp_id)
vapp_edge_rules = cnx.get_vapp_port_forwarding_rules(vapp_id)
edge_gateway_rules = cnx.get_edge_gateway_rules(cfg.vdc_edge_gateway,
cfg.vdc_id)

# Create a new table for the network information
network_table = Terminal::Table.new
network_table.title = 'Vagrant vCloud Director Network Map'

network_table << ['VM Name', 'Destination NAT Mapping', 'Enabled']
network_table << :separator

# Fetching Destination NAT Rules for each vApp/Edge/VM/Mapping
edge_gateway_rules.each do |edge_gateway_rule|
vapp_edge_rules.each do |vapp_edge_rule|

# Only check DNAT and src/dst
if edge_gateway_rule[:rule_type] == 'DNAT' &&
edge_gateway_rule[:original_ip] == cfg.vdc_edge_gateway_ip &&
edge_gateway_rule[:translated_ip] == vapp_edge_ip

# Loop on every VM in the vApp
vapp[:vms_hash].each do |vm|
# Only Map valid vAppEdge scope to VM scope
vm_scope = vm[1][:vapp_scoped_local_id]
vapp_edge_scope = vapp_edge_rule[:vapp_scoped_local_id]

if vm_scope == vapp_edge_scope

# Generate DNAT Mappings for the valid machines
# If rules don't match, you will not see them !
network_table << [
"#{vm[0]}",
"#{cfg.vdc_edge_gateway_ip}:" +
"#{vapp_edge_rule[:nat_external_port]}" +
" -> #{vapp_edge_ip}:" +
"#{vapp_edge_rule[:nat_external_port]}" +
" -> #{vm[1][:addresses][0]}:" +
"#{vapp_edge_rule[:nat_internal_port]}",
edge_gateway_rule[:is_enabled]
]
end
end
end
end
end
end

# Fetching Source NAT Rules for the vApp
network_table << :separator
network_table << ['Network Name', 'Source NAT Mapping', 'Enabled']
network_table << :separator

edge_gateway_rules.each do |edge_gateway_rule|
# Only check SNAT and src/dst
if edge_gateway_rule[:rule_type] == 'SNAT' &&
edge_gateway_rule[:original_ip] == vapp_edge_ip &&
edge_gateway_rule[:translated_ip] == cfg.vdc_edge_gateway_ip

network_table << [
edge_gateway_rule[:interface_name],
"#{vapp_edge_ip} -> #{cfg.vdc_edge_gateway_ip}",
edge_gateway_rule[:is_enabled]
]
# Fetching Source NAT Rules for the vApp
network_table << :separator
network_table << ['Network Name', 'Source NAT Mapping', 'Enabled']
network_table << :separator

edge_gateway_rules.each do |edge_gateway_rule|
# Only check SNAT and src/dst
if edge_gateway_rule[:rule_type] == 'SNAT' &&
edge_gateway_rule[:original_ip] == vapp_edge_ip &&
edge_gateway_rule[:translated_ip] == cfg.vdc_edge_gateway_ip

network_table << [
edge_gateway_rule[:interface_name],
"#{vapp_edge_ip} -> #{cfg.vdc_edge_gateway_ip}",
edge_gateway_rule[:is_enabled]
]
end
end
end

# Fetching Edge Gateway Firewall Rules
network_table << :separator
network_table << ['Rule# - Description', 'Firewall Rules', 'Enabled']
network_table << :separator
edge_gateway_rules.each do |edge_gateway_rule|
# Only add firewall rules
if edge_gateway_rule[:rule_type] == 'Firewall'
network_table << [
"#{edge_gateway_rule[:id]} - " +
"(#{edge_gateway_rule[:description]})",
"#{edge_gateway_rule[:policy]} " +
"SRC:#{edge_gateway_rule[:source_ip]}:" +
"#{edge_gateway_rule[:source_portrange]} to " +
"DST:#{edge_gateway_rule[:destination_ip]}:" +
"#{edge_gateway_rule[:destination_portrange]}",
"#{edge_gateway_rule[:is_enabled]}"
]
# Fetching Edge Gateway Firewall Rules
network_table << :separator
network_table << ['Rule# - Description', 'Firewall Rules', 'Enabled']
network_table << :separator
edge_gateway_rules.each do |edge_gateway_rule|
# Only add firewall rules
if edge_gateway_rule[:rule_type] == 'Firewall'
network_table << [
"#{edge_gateway_rule[:id]} - " +
"(#{edge_gateway_rule[:description]})",
"#{edge_gateway_rule[:policy]} " +
"SRC:#{edge_gateway_rule[:source_ip]}:" +
"#{edge_gateway_rule[:source_portrange]} to " +
"DST:#{edge_gateway_rule[:destination_ip]}:" +
"#{edge_gateway_rule[:destination_portrange]}",
"#{edge_gateway_rule[:is_enabled]}"
]
end
end
end

# Print the Network Table
puts
puts network_table
Expand Down
12 changes: 6 additions & 6 deletions lib/vagrant-vcloud/driver/version_5_1.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1251,7 +1251,7 @@ def set_edge_gateway_rules(edge_gateway_name, vdc_id, edge_gateway_ip, vapp_id)
nat_rule_1 = Nokogiri::XML::Node.new 'NatRule', response
rule_type = Nokogiri::XML::Node.new 'RuleType', response
rule_type.content = 'DNAT'
nat_rule_1.add_child ruleType
nat_rule_1.add_child rule_type

is_enabled = Nokogiri::XML::Node.new 'IsEnabled', response
is_enabled.content = 'true'
Expand All @@ -1268,7 +1268,7 @@ def set_edge_gateway_rules(edge_gateway_name, vdc_id, edge_gateway_ip, vapp_id)

original_ip = Nokogiri::XML::Node.new 'OriginalIp', response
original_ip.content = edge_gateway_ip
gatewayNatRule.add_child original_ip
gateway_nat_rule.add_child original_ip

original_port = Nokogiri::XML::Node.new 'OriginalPort', response
original_port.content = 'any'
Expand Down Expand Up @@ -1301,11 +1301,11 @@ def set_edge_gateway_rules(edge_gateway_name, vdc_id, edge_gateway_ip, vapp_id)

is_enabled = Nokogiri::XML::Node.new 'IsEnabled', response
is_enabled.content = 'true'
nat_rule_2.add_child isEnabled
nat_rule_2.add_child is_enabled

gateway_nat_rule = Nokogiri::XML::Node.new 'GatewayNatRule',
response
nat_rule_2.add_child gatewayNatRule
nat_rule_2.add_child gateway_nat_rule

interface = Nokogiri::XML::Node.new 'Interface', response
interface['href'] = edge_network_id
Expand All @@ -1314,7 +1314,7 @@ def set_edge_gateway_rules(edge_gateway_name, vdc_id, edge_gateway_ip, vapp_id)

original_ip = Nokogiri::XML::Node.new 'OriginalIp', response
original_ip.content = edge_vapp_ip
gatewayNatRule.add_child original_ip
gateway_nat_rule.add_child original_ip

translated_ip = Nokogiri::XML::Node.new 'TranslatedIp', response
translated_ip.content = edge_gateway_ip
Expand Down Expand Up @@ -1444,7 +1444,7 @@ def get_edge_gateway_rules(edge_gateway_name, vdc_id)

end
if node.css('RuleType').text == 'SNAT'
gw_node = node.css('gatewayNatRule')
gw_node = node.css('GatewayNatRule')
nat_fw_rules << {
:rule_type => 'SNAT',
:interface_name => gw_node.css('Interface').first['name'],
Expand Down
2 changes: 1 addition & 1 deletion lib/vagrant-vcloud/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module VagrantPlugins
module VCloud
VERSION = '0.2.0'
VERSION = '0.2.1'
end
end

0 comments on commit 12f590e

Please sign in to comment.