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

Commit

Permalink
Merge branch 'release/v0.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
frapposelli committed Jun 16, 2014
2 parents 2e243a3 + fc130fc commit bb9bc20
Show file tree
Hide file tree
Showing 20 changed files with 347 additions and 185 deletions.
103 changes: 27 additions & 76 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,64 +1,15 @@
[Vagrant](http://www.vagrantup.com) provider for VMware vCloud Director®
=============

[Version 0.3.3](../../releases/tag/v0.3.3) has been released!
[Version 0.4.0](../../releases/tag/v0.4.0) 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.
We have a wide array of boxes available at [Vagrant Cloud](https://vagrantcloud.com/gosddc) you can use them directly or you can roll your own as you please, make sure to install VMware tools in it.

If you're unsure about what are the correct network settings for your Vagrantfile make sure to check out the [Network Deployment Options](https://github.com/frapposelli/vagrant-vcloud/wiki/Network-Deployment-Options) wiki page.

Features of Version 0.3.3 are:

- Critical Bug Fix for ```network_bridge``` users [[#67](../../issues/67)]

Features of Version 0.3.2 are:

- Added support for ```vagrant share``` command [[#31](../../issues/31)] *experimental*
- Restructured the ```vagrant vcloud-status``` command to ```vagrant vcloud``` namespace for future-proofing [[#53](../../issues/53)]
- Added ```vagrant vcloud --redeploy-edge-gw``` to redeploy Edge Gateway [[#54](../../issues/54)]
- Fixed Issues [[#45](https://github.com/frapposelli/vagrant-vcloud/issues/45), [#46](https://github.com/frapposelli/vagrant-vcloud/issues/46), [#47](https://github.com/frapposelli/vagrant-vcloud/issues/47), [#48](https://github.com/frapposelli/vagrant-vcloud/issues/48), [#51](https://github.com/frapposelli/vagrant-vcloud/issues/51), [#52](https://github.com/frapposelli/vagrant-vcloud/issues/52), [#56](https://github.com/frapposelli/vagrant-vcloud/issues/56), [#57](https://github.com/frapposelli/vagrant-vcloud/issues/57), [#61](https://github.com/frapposelli/vagrant-vcloud/issues/61)]


Features of Version 0.3.1 are:

- Small hotfix to include "preRunning" condition when using vCloud Director 5.5 [[#44](https://github.com/frapposelli/vagrant-vcloud/issues/44)]. - [Andrew Poland](https://github.com/apoland)

Features of Version 0.3.0 are:

A substantial release, major kudos to [Stefan Scherer](https://github.com/StefanScherer) who submitted some substantious PRs!

- Added support for port mapping at the Organization Edge Gateway.
- Added a new configuration options ```vapp_prefix``` to change vApp prefix (defaults to Vagrant).
- Improved vcloud-status command.
- Fixed cygdrive path for rsync on Windows.
- Fixed Issue [[#33](../../issues/33)] - Error removing/creating NAT rules on second vagrant up.
- Fixed Issue [[#43](../../issues/43)] - Destroy fails if VMs are halted.

Features of Version 0.2.2 are:

- Fixed Issue [[#32](../../issues/32)] - Port Forwarding rules are deleted when Halting a VM.

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 using ```network_bridge = true``` in the Vagrantfile [[#23](../../issues/23)]. *experimental*
- Added a ```upload_chunksize``` parameter to specify the chunk dimension during box uploads [[#21](../../issues/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*
- General code cleanup, code should be more readable and there's a rubocop file for our code conventions.
- Passwords are now hidden when running in DEBUG mode.
- Initial support for Vagrant 1.5 (currently not supporting the new "share" features).
- Lowered Nokogiri requirement to 1.5.5 (you may need to remove a later version if installed).
- Fixed the Edge Gateway NAT rules creation / deletion.
- Added debug capabilities down to XML traffic exchanged during the REST calls.


Check the full releases changelog [here](../../releases)

Install
Expand All @@ -78,44 +29,44 @@ Configuration
Here's a sample Multi-VM Vagrantfile, please note that ```vcloud.vdc_edge_gateway``` and ```vcloud.vdc_edge_gateway_ip``` are required only when you cannot access ```vcloud.vdc_network_name``` directly and there's an Organization Edge between your workstation and the vCloud Network.

```ruby
precise32_vm_box_url = "http://vagrant.tsugliani.fr/precise32.box"

nodes = [
{ :hostname => "web-vm", :box => "precise32", :box_url => precise32_vm_box_url },
{ :hostname => "ssh-vm", :box => "precise32", :box_url => precise32_vm_box_url },
{ :hostname => "sql-vm", :box => "precise32", :box_url => precise32_vm_box_url },
{ :hostname => "lb-vm", :box => "precise64", :box_url => precise32_vm_box_url },
{ :hostname => "app-vm", :box => "precise32", :box_url => precise32_vm_box_url },
{ hostname: 'web-vm', box: 'gosddc/precise32' },
{ hostname: 'ssh-vm', box: 'gosddc/precise32' },
{ hostname: 'sql-vm', box: 'gosddc/precise32' },
{ hostname: 'app-vm', box: 'gosddc/precise32' }
]

Vagrant.configure("2") do |config|
Vagrant.configure('2') do |config|

# vCloud Director provider settings
config.vm.provider :vcloud do |vcloud|
vcloud.vapp_prefix = "multibox-sample"

vcloud.hostname = "https://my.cloudprovider.com"
vcloud.username = "MyUserName"
vcloud.password = "MySup3rS3cr3tPassw0rd!"
vcloud.org_name = "OrganizationName"
vcloud.vdc_name = "vDC_Name"

vcloud.catalog_name = "Vagrant"
vcloud.ip_subnet = "172.16.32.125/255.255.255.240"
vcloud.vdc_network_name = "MyNetwork"

vcloud.vdc_edge_gateway = "MyOrgEdgeGateway"
vcloud.vdc_edge_gateway_ip = "10.10.10.10"
vcloud.vapp_prefix = 'multibox-sample'

vcloud.hostname = 'https://my.cloudprovider.com'
vcloud.username = 'MyUserName'
vcloud.password = 'MySup3rS3cr3tPassw0rd!'

vcloud.org_name = 'OrganizationName'
vcloud.vdc_name = 'vDC_Name'

vcloud.catalog_name = 'Vagrant'
vcloud.ip_subnet = '172.16.32.125/255.255.255.240'

vcloud.vdc_network_name = 'MyNetwork'

vcloud.vdc_edge_gateway = 'MyOrgEdgeGateway'
vcloud.vdc_edge_gateway_ip = '10.10.10.10'
end

nodes.each do |node|
config.vm.define node[:hostname] do |node_config|
node_config.vm.box = node[:box]
node_config.vm.hostname = node[:hostname]
node_config.vm.box_url = node[:box_url]
node_config.vm.network :forwarded_port, guest: 80, host: 8080, auto_correct: true
node_config.vm.network :forwarded_port,
guest: 80,
host: 8080,
auto_correct: true
# node_config.vm.provision :puppet do |puppet|
# puppet.manifests_path = 'puppet/manifests'
# puppet.manifest_file = 'site.pp'
Expand Down
51 changes: 36 additions & 15 deletions lib/vagrant-vcloud/action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,28 @@ def self.action_destroy
if env[:result]
b2.use ConfigValidate
b2.use ConnectVCloud
b2.use Call, IsRunning do |env2, b3|
# If the VM is running, must power off
b3.use action_halt if env2[:result]
end
b2.use Call, IsLastVM do |env2, b3|
if env2[:result]
# Check if the network is bridged
b3.use Call, IsBridged do |env3, b4|
# if it's not, delete port forwardings.
b4.use UnmapPortForwardings unless env3[:bridged_network]
b2.use Call, IsCreated do |env2, b3|
unless env2[:result]
b3.use MessageNotCreated
next
end

b3.use Call, IsRunning do |env3, b4|
# If the VM is running, must power off
b4.use action_halt if env3[:result]
end
b3.use Call, IsLastVM do |env3, b4|
if env3[:result]
# Check if the network is bridged
b4.use Call, IsBridged do |env4, b5|
# if it's not, delete port forwardings.
b5.use UnmapPortForwardings unless env4[:bridged_network]
end
b4.use PowerOffVApp
b4.use DestroyVApp
else
b4.use DestroyVM
end
b3.use PowerOffVApp
b3.use DestroyVApp
else
b3.use DestroyVM
end
end
else
Expand Down Expand Up @@ -140,7 +147,21 @@ def self.action_provision
def self.action_read_ssh_info
Vagrant::Action::Builder.new.tap do |b|
b.use ConnectVCloud
b.use ReadSSHInfo
b.use ReadSSHInfo, 22
end
end

def self.action_read_winrm_info
Vagrant::Action::Builder.new.tap do |b|
b.use ConnectVCloud
b.use ReadSSHInfo, 5985
end
end

def self.action_read_rdp_info
Vagrant::Action::Builder.new.tap do |b|
b.use ConnectVCloud
b.use ReadSSHInfo, 3389
end
end

Expand Down
8 changes: 3 additions & 5 deletions lib/vagrant-vcloud/action/build_vapp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,7 @@ def call(env)
env[:ui].info('Building vApp...')

vapp_prefix = cfg.vapp_prefix
if vapp_prefix.nil?
vapp_prefix = "Vagrant"
end
vapp_prefix = 'Vagrant' if vapp_prefix.nil?

compose = cnx.compose_vapp_from_vm(
cfg.vdc_id,
Expand All @@ -124,7 +122,7 @@ def call(env)
"#{Socket.gethostname.downcase} using vagrant-vcloud on " +
"#{Time.now.strftime("%B %d, %Y")}",
{
vm_name => cfg.catalog_item[:vms_hash][env[:machine].box.name.to_s][:id]
vm_name => cfg.catalog_item[:vms_hash].first.last[:id]
},
network_options
)
Expand Down Expand Up @@ -180,7 +178,7 @@ def call(env)
recompose = cnx.recompose_vapp_from_vm(
env[:machine].get_vapp_id,
{
vm_name => cfg.catalog_item[:vms_hash][env[:machine].box.name.to_s][:id]
vm_name => cfg.catalog_item[:vms_hash].first.last[:id]
},
network_options
)
Expand Down
50 changes: 31 additions & 19 deletions lib/vagrant-vcloud/action/forward_ports.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ def forward_ports
:nat_protocol => fp.protocol.upcase,
:vapp_scoped_local_id => vm_info[:vapp_scoped_local_id]
}

edge_ports << fp.host_port
end

if !ports.empty?
Expand Down Expand Up @@ -91,27 +89,41 @@ def forward_ports
cfg.vdc_edge_gateway && \
cfg.network_bridge.nil?


edge_ports.each do |port|
@env[:ui].info(
"Creating NAT rules on [#{cfg.vdc_edge_gateway}] " +
"for IP [#{cfg.vdc_edge_gateway_ip}] port #{port}."
)
vapp_edge_ip = cnx.get_vapp_edge_public_ip(vapp_id)
@logger.debug('Getting edge gateway port forwarding rules...')
edge_gateway_rules = cnx.get_edge_gateway_rules(cfg.vdc_edge_gateway,
cfg.vdc_id)
vapp_edge_dnat_rules = edge_gateway_rules.select {|r| (r[:rule_type] == 'DNAT' &&
r[:translated_ip] == vapp_edge_ip)}
vapp_edge_ports_in_use = vapp_edge_dnat_rules.map{|r| r[:original_port].to_i}.to_set

ports.each do |port|
if port[:vapp_scoped_local_id] == vm_info[:vapp_scoped_local_id] &&
!vapp_edge_ports_in_use.include?(port[:nat_external_port])
@env[:ui].info(
"Creating NAT rules on [#{cfg.vdc_edge_gateway}] " +
"for IP [#{vapp_edge_ip}] port #{port[:nat_external_port]}."
)

edge_ports << port[:nat_external_port]
end
end

# Add the vShield Edge Gateway rules
add_ports = cnx.add_edge_gateway_rules(
cfg.vdc_edge_gateway,
cfg.vdc_id,
cfg.vdc_edge_gateway_ip,
vapp_id,
edge_ports
)
if !edge_ports.empty?
# Add the vShield Edge Gateway rules
add_ports = cnx.add_edge_gateway_rules(
cfg.vdc_edge_gateway,
cfg.vdc_id,
cfg.vdc_edge_gateway_ip,
vapp_id,
edge_ports
)

wait = cnx.wait_task_completion(add_ports)
wait = cnx.wait_task_completion(add_ports)

if !wait[:errormsg].nil?
raise Errors::ComposeVAppError, :message => wait[:errormsg]
if !wait[:errormsg].nil?
raise Errors::ComposeVAppError, :message => wait[:errormsg]
end
end

end
Expand Down
14 changes: 3 additions & 11 deletions lib/vagrant-vcloud/action/handle_nat_port_collisions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ def call(env)
vm = cnx.get_vapp(vapp_id)
vm_info = vm[:vms_hash][vm_name.to_sym]

vapp_edge_ip = cnx.get_vapp_edge_public_ip(vapp_id)

@logger.debug('Getting edge gateway port forwarding rules...')
edge_gateway_rules = cnx.get_edge_gateway_rules(cfg.vdc_edge_gateway,
cfg.vdc_id)
edge_dnat_rules = edge_gateway_rules.select {|r| (r[:rule_type] == 'DNAT')}
edge_dnat_rules = edge_gateway_rules.select {|r| (r[:rule_type] == 'DNAT' && r[:translated_ip] != vapp_edge_ip)}
edge_ports_in_use = edge_dnat_rules.map{|r| r[:original_port].to_i}.to_set

@logger.debug('Getting port forwarding rules...')
Expand All @@ -65,16 +67,6 @@ def call(env)
guest_port = options[:guest]
host_port = options[:host]

# Find if there already is a DNAT rule to this vApp
if r = edge_dnat_rules.find { |rule| (rule[:translated_ip] == vm_info[:ip] &&
rule[:translated_port] == guest_port.to_s) }

@logger.info(
"Found existing edge gateway port forwarding rule #r[:original_port] to #{guest_port}"
)
options[:already_exists_on_edge] = true
end

# Find if there already is a NAT rule to guest_port of this VM
if r = vapp_nat_rules.find { |rule| (rule[:vapp_scoped_local_id] == vm_info[:vapp_scoped_local_id] &&
rule[:nat_internal_port] == guest_port.to_s) }
Expand Down
Loading

0 comments on commit bb9bc20

Please sign in to comment.