vagrant-vcloud 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +4 -1
- data/README.md +30 -6
- data/lib/vagrant-vcloud/action/build_vapp.rb +28 -28
- data/lib/vagrant-vcloud/action/connect_vcloud.rb +0 -1
- data/lib/vagrant-vcloud/action/destroy.rb +1 -9
- data/lib/vagrant-vcloud/action/forward_ports.rb +2 -38
- data/lib/vagrant-vcloud/action/handle_nat_port_collisions.rb +0 -8
- data/lib/vagrant-vcloud/action/inventory_check.rb +11 -12
- data/lib/vagrant-vcloud/action/power_off.rb +22 -4
- data/lib/vagrant-vcloud/action/power_on.rb +3 -1
- data/lib/vagrant-vcloud/action/read_ssh_info.rb +4 -6
- data/lib/vagrant-vcloud/action/sync_folders.rb +41 -10
- data/lib/vagrant-vcloud/config.rb +15 -7
- data/lib/vagrant-vcloud/driver/base.rb +35 -54
- data/lib/vagrant-vcloud/driver/meta.rb +28 -17
- data/lib/vagrant-vcloud/driver/version_5_1.rb +54 -54
- data/lib/vagrant-vcloud/errors.rb +7 -0
- data/lib/vagrant-vcloud/version.rb +1 -1
- data/locales/en.yml +20 -0
- data/vagrant-vcloud.gemspec +0 -3
- metadata +3 -44
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 029dca042c07fcb3034c6eba92c07f24d2f59c2e
         | 
| 4 | 
            +
              data.tar.gz: aa3429ccf19e966599bb4aa4812f5c8cdd194184
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 9dded16f1a7f486d507006b29f7d5e7d87c83eb45b912f464227f93d99647943f3ec17bf2309c1343d3d09887780ee953e6ea49c6f8677eea3161dd1182c3c83
         | 
| 7 | 
            +
              data.tar.gz: 83c9c33dc8d33a12f1dd2c16bb3a112f1f8b0bbcf32b529ddbbc9be8ea0c91b7478e99695e09cf2cb716ac699f745517b6ae392c2498ab73dfee0595f98b84ec
         | 
    
        data/.gitignore
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | @@ -1,13 +1,24 @@ | |
| 1 1 | 
             
            [Vagrant](http://www.vagrantup.com) provider for VMware vCloud Director®
         | 
| 2 2 | 
             
            =============
         | 
| 3 3 |  | 
| 4 | 
            -
            [Version 0.1. | 
| 4 | 
            +
            [Version 0.1.1](https://github.com/frapposelli/vagrant-vcloud/releases/tag/v0.1.1) has been released!
         | 
| 5 5 | 
             
            -------------
         | 
| 6 6 |  | 
| 7 7 | 
             
            Please note that this software is still Alpha/Beta quality and is not recommended for production usage.
         | 
| 8 8 |  | 
| 9 9 | 
             
            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.
         | 
| 10 10 |  | 
| 11 | 
            +
            Features of Version 0.1.1 are:
         | 
| 12 | 
            +
             | 
| 13 | 
            +
              - bugfix multiple sub allocation pools ranges [ISSUE #24]
         | 
| 14 | 
            +
              - Putting back Google DNS as default if not specified
         | 
| 15 | 
            +
              - binding vCloud 5.5 API on 5.1 driver
         | 
| 16 | 
            +
              - Debug cut and general cosmetic cleanup
         | 
| 17 | 
            +
              - added DNS choice using the "ip_dns" Array config property.
         | 
| 18 | 
            +
              - Updated sync_folders.rb with code from vagrant-aws, Will focus on a better sync engine later in the future.
         | 
| 19 | 
            +
              - Removed dependency on rest-client gem, moved everything to httpclient.
         | 
| 20 | 
            +
              - Fixed destroy vApp bug.
         | 
| 21 | 
            +
             | 
| 11 22 | 
             
            Features of Version 0.1.0 are:
         | 
| 12 23 |  | 
| 13 24 | 
             
            - Basic Create/Provision/Destroy lifecycle.
         | 
| @@ -30,16 +41,27 @@ What is still missing: | |
| 30 41 |  | 
| 31 42 | 
             
            If you're a developer and want to lend us a hand, head over to our ```develop``` branch and get busy!
         | 
| 32 43 |  | 
| 33 | 
            -
             | 
| 44 | 
            +
            Install
         | 
| 45 | 
            +
            -------------
         | 
| 46 | 
            +
             | 
| 47 | 
            +
            Version 0.1.0 can be easily installed by running:
         | 
| 48 | 
            +
             | 
| 49 | 
            +
            ```vagrant plugin install vagrant-vcloud```
         | 
| 50 | 
            +
             | 
| 51 | 
            +
            Vagrant will download all the required gems during the installation process.
         | 
| 52 | 
            +
             | 
| 53 | 
            +
            After the install has completed a ```vagrant up --provider=vcloud``` will trigger the newly installed provider.
         | 
| 54 | 
            +
             | 
| 55 | 
            +
            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.
         | 
| 34 56 |  | 
| 35 57 | 
             
            ```ruby
         | 
| 36 58 | 
             
            precise32_vm_box_url = "http://vagrant.tsugliani.fr/precise32.box"
         | 
| 37 59 |  | 
| 38 60 | 
             
            nodes = [
         | 
| 39 | 
            -
              { :hostname => "web-vm",  :box => "precise32", :box_url => precise32_vm_box_url},
         | 
| 40 | 
            -
              { :hostname => "ssh-vm",  :box => "precise32" | 
| 61 | 
            +
              { :hostname => "web-vm",  :box => "precise32", :box_url => precise32_vm_box_url },
         | 
| 62 | 
            +
              { :hostname => "ssh-vm",  :box => "precise32", :box_url => precise32_vm_box_url },
         | 
| 41 63 | 
             
              { :hostname => "sql-vm",  :box => "precise32", :box_url => precise32_vm_box_url },
         | 
| 42 | 
            -
              { :hostname => "lb-vm", | 
| 64 | 
            +
              { :hostname => "lb-vm",   :box => "precise64", :box_url => precise32_vm_box_url },
         | 
| 43 65 | 
             
              { :hostname => "app-vm",  :box => "precise32", :box_url => precise32_vm_box_url },
         | 
| 44 66 | 
             
            ]
         | 
| 45 67 |  | 
| @@ -77,4 +99,6 @@ Vagrant.configure("2") do |config| | |
| 77 99 | 
             
                end
         | 
| 78 100 | 
             
              end
         | 
| 79 101 | 
             
            end
         | 
| 80 | 
            -
            ```
         | 
| 102 | 
            +
            ```
         | 
| 103 | 
            +
             | 
| 104 | 
            +
            [](https://bitdeli.com/free "Bitdeli Badge")
         | 
| @@ -20,6 +20,14 @@ module VagrantPlugins | |
| 20 20 | 
             
                      cnx = cfg.vcloud_cnx.driver
         | 
| 21 21 | 
             
                      vmName = env[:machine].name
         | 
| 22 22 |  | 
| 23 | 
            +
                      if cfg.ip_dns.nil?
         | 
| 24 | 
            +
                        dnsAddress1 = "8.8.8.8"
         | 
| 25 | 
            +
                        dnsAddress2 = "8.8.4.4"
         | 
| 26 | 
            +
                      else
         | 
| 27 | 
            +
                        dnsAddress1 = cfg.ip_dns.shift
         | 
| 28 | 
            +
                        dnsAddress2 = cfg.ip_dns.shift
         | 
| 29 | 
            +
                      end
         | 
| 30 | 
            +
             | 
| 23 31 | 
             
                      if !cfg.ip_subnet.nil?
         | 
| 24 32 |  | 
| 25 33 | 
             
                        @logger.debug("Input address: #{cfg.ip_subnet}")
         | 
| @@ -38,15 +46,17 @@ module VagrantPlugins | |
| 38 46 |  | 
| 39 47 | 
             
                        @logger.debug("Range: #{rangeAddresses}")
         | 
| 40 48 |  | 
| 41 | 
            -
                        rangeAddresses.shift | 
| 42 | 
            -
                        gatewayIp = rangeAddresses.shift | 
| 43 | 
            -
                        rangeAddresses.reverse! | 
| 44 | 
            -
                        rangeAddresses.shift | 
| 45 | 
            -
                        rangeAddresses.reverse! | 
| 49 | 
            +
                        rangeAddresses.shift              # Delete the "network" address from the range.
         | 
| 50 | 
            +
                        gatewayIp = rangeAddresses.shift  # Retrieve the first usable IP, to be used as a gateway.
         | 
| 51 | 
            +
                        rangeAddresses.reverse!           # Reverse the array in place.
         | 
| 52 | 
            +
                        rangeAddresses.shift              # Delete the "broadcast" address from the range.
         | 
| 53 | 
            +
                        rangeAddresses.reverse!           # Reverse back the array.
         | 
| 46 54 |  | 
| 47 55 | 
             
                        @logger.debug("Gateway IP: #{gatewayIp.to_s}")
         | 
| 48 56 | 
             
                        @logger.debug("Netmask: #{cidr.wildcard_mask}")
         | 
| 49 57 | 
             
                        @logger.debug("IP Pool: #{rangeAddresses.first}-#{rangeAddresses.last}")
         | 
| 58 | 
            +
                        @logger.debug("DNS1: #{dnsAddress1} DNS2: #{dnsAddress2}")
         | 
| 59 | 
            +
             | 
| 50 60 |  | 
| 51 61 | 
             
                        network_options = { 
         | 
| 52 62 | 
             
                          :name => "Vagrant-vApp-Net", 
         | 
| @@ -58,12 +68,13 @@ module VagrantPlugins | |
| 58 68 | 
             
                          :ip_allocation_mode => "POOL",
         | 
| 59 69 | 
             
                          :parent_network =>  cfg.vdc_network_id,
         | 
| 60 70 | 
             
                          :enable_firewall => "false",
         | 
| 61 | 
            -
                          :dns1 =>  | 
| 62 | 
            -
                          :dns2 =>  | 
| 71 | 
            +
                          :dns1 => dnsAddress1,
         | 
| 72 | 
            +
                          :dns2 => dnsAddress2
         | 
| 63 73 | 
             
                        }
         | 
| 64 74 |  | 
| 65 75 | 
             
                      else
         | 
| 66 76 |  | 
| 77 | 
            +
                        @logger.debug("DNS1: #{dnsAddress1} DNS2: #{dnsAddress2}")
         | 
| 67 78 | 
             
                        # No IP subnet specified, reverting to defaults
         | 
| 68 79 | 
             
                        network_options = { 
         | 
| 69 80 | 
             
                          :name => "Vagrant-vApp-Net", 
         | 
| @@ -75,8 +86,8 @@ module VagrantPlugins | |
| 75 86 | 
             
                          :ip_allocation_mode => "POOL",
         | 
| 76 87 | 
             
                          :parent_network =>  cfg.vdc_network_id,
         | 
| 77 88 | 
             
                          :enable_firewall => "false",
         | 
| 78 | 
            -
                          :dns1 =>  | 
| 79 | 
            -
                          :dns2 =>  | 
| 89 | 
            +
                          :dns1 => dnsAddress1,
         | 
| 90 | 
            +
                          :dns2 => dnsAddress2
         | 
| 80 91 | 
             
                        }
         | 
| 81 92 |  | 
| 82 93 | 
             
                      end
         | 
| @@ -115,28 +126,25 @@ module VagrantPlugins | |
| 115 126 | 
             
                        # FIXME: Add a lot of error handling for each step here !
         | 
| 116 127 |  | 
| 117 128 | 
             
                        if newVApp
         | 
| 118 | 
            -
                          env[:ui].success("vApp #{newVApp[:name]} created | 
| 129 | 
            +
                          env[:ui].success("vApp #{newVApp[:name]} successfully created.")
         | 
| 119 130 |  | 
| 120 131 | 
             
                          # Add the vm id as machine.id
         | 
| 121 132 | 
             
                          newVMProperties = newVApp[:vms_hash].fetch(vmName)
         | 
| 122 133 | 
             
                          env[:machine].id = newVMProperties[:id]
         | 
| 123 134 |  | 
| 124 135 | 
             
                          ### SET GUEST CONFIG
         | 
| 125 | 
            -
             | 
| 136 | 
            +
             | 
| 137 | 
            +
                          @logger.info("Setting Guest Customization on ID: [#{vmName}] of vApp [#{newVApp[:name]}]")
         | 
| 138 | 
            +
             | 
| 126 139 | 
             
                          setCustom = cnx.set_vm_guest_customization(newVMProperties[:id], vmName, {
         | 
| 127 140 | 
             
                            :enabled => true,
         | 
| 128 141 | 
             
                            :admin_passwd_enabled => false
         | 
| 129 142 | 
             
                            })
         | 
| 130 143 | 
             
                          cnx.wait_task_completion(setCustom)
         | 
| 131 144 |  | 
| 132 | 
            -
            #              @logger.info("Starting VM [#{vmName}] - this will take a while as vShield Edge is getting deployed as well")
         | 
| 133 | 
            -
            #              env[:ui].info("Starting VM [#{vmName}] - this will take a while as vShield Edge is getting deployed as well")
         | 
| 134 | 
            -
            #              poweronVM = cnx.poweron_vm(newVMProperties[:id])
         | 
| 135 | 
            -
            #              cnx.wait_task_completion(poweronVM)
         | 
| 136 | 
            -
             | 
| 137 145 | 
             
                        else
         | 
| 138 146 | 
             
                          env[:ui].error("vApp #{newVApp[:name]} creation failed!")
         | 
| 139 | 
            -
                          raise
         | 
| 147 | 
            +
                          raise # FIXME: error handling missing.
         | 
| 140 148 | 
             
                       end 
         | 
| 141 149 | 
             
                      else
         | 
| 142 150 | 
             
                        env[:ui].info("Adding VM to existing vApp...")
         | 
| @@ -160,27 +168,19 @@ module VagrantPlugins | |
| 160 168 |  | 
| 161 169 | 
             
                        if newVApp
         | 
| 162 170 |  | 
| 163 | 
            -
                          #env[:ui].success("VM #{vmName} added to #{newVApp[:name]} successfully!")
         | 
| 164 | 
            -
                          #@logger.info("VM #{vmName} added to #{newVApp[:name]} successfully!")
         | 
| 165 | 
            -
             | 
| 166 | 
            -
                          # Add the vm id as machine.id
         | 
| 167 171 | 
             
                          newVMProperties = newVApp[:vms_hash].fetch(vmName)
         | 
| 168 172 | 
             
                          env[:machine].id = newVMProperties[:id]
         | 
| 169 173 |  | 
| 170 174 | 
             
                          ### SET GUEST CONFIG
         | 
| 171 | 
            -
                           | 
| 172 | 
            -
                           | 
| 175 | 
            +
                          
         | 
| 176 | 
            +
                          @logger.info("Setting Guest Customization on ID: [#{newVMProperties[:id]}] of vApp [#{newVApp[:name]}]")
         | 
| 177 | 
            +
                          
         | 
| 173 178 | 
             
                          setCustom = cnx.set_vm_guest_customization(newVMProperties[:id], vmName, {
         | 
| 174 179 | 
             
                            :enabled => true,
         | 
| 175 180 | 
             
                            :admin_passwd_enabled => false
         | 
| 176 181 | 
             
                            })
         | 
| 177 182 | 
             
                          cnx.wait_task_completion(setCustom)
         | 
| 178 183 |  | 
| 179 | 
            -
            #              @logger.info("Starting VM [#{vmName}]")
         | 
| 180 | 
            -
            #              env[:ui].info("Starting VM [#{vmName}]")
         | 
| 181 | 
            -
            #              poweronVM = cnx.poweron_vm(newVMProperties[:id])
         | 
| 182 | 
            -
            #              cnx.wait_task_completion(poweronVM)
         | 
| 183 | 
            -
             | 
| 184 184 | 
             
                        else
         | 
| 185 185 |  | 
| 186 186 | 
             
                          env[:ui].error("VM #{vmName} add to #{newVApp[:name]} failed!")
         | 
| @@ -28,20 +28,12 @@ module VagrantPlugins | |
| 28 28 | 
             
                        env[:ui].info("Single VM left in the vApp, destroying the vApp...")
         | 
| 29 29 |  | 
| 30 30 | 
             
                        if cfg.vdc_edge_gateway_ip && cfg.vdc_edge_gateway
         | 
| 31 | 
            -
                          env[:ui].info("Removing  | 
| 31 | 
            +
                          env[:ui].info("Removing NAT rules on [#{cfg.vdc_edge_gateway}] for IP [#{cfg.vdc_edge_gateway_ip}].")
         | 
| 32 32 | 
             
                          @logger.debug("Deleting Edge Gateway rules - vdc id: #{cfg.vdc_id}")
         | 
| 33 33 | 
             
                          edge_remove = cnx.remove_edge_gateway_rules(cfg.vdc_edge_gateway, cfg.vdc_id, cfg.vdc_edge_gateway_ip, vAppId)
         | 
| 34 34 | 
             
                          cnx.wait_task_completion(edge_remove)
         | 
| 35 35 | 
             
                        end
         | 
| 36 36 |  | 
| 37 | 
            -
                        env[:ui].info("Powering off vApp...")
         | 
| 38 | 
            -
                        vAppStopTask = cnx.poweroff_vapp(vAppId)
         | 
| 39 | 
            -
                        vAppStopWait = cnx.wait_task_completion(vAppStopTask)
         | 
| 40 | 
            -
             | 
| 41 | 
            -
                        if !vAppStopWait[:errormsg].nil?
         | 
| 42 | 
            -
                          raise Errors::StopVAppError, :message => vAppStopWait[:errormsg]
         | 
| 43 | 
            -
                        end
         | 
| 44 | 
            -
             | 
| 45 37 | 
             
                        env[:ui].info("Destroying vApp...")
         | 
| 46 38 | 
             
                        vAppDeleteTask = cnx.delete_vapp(vAppId)
         | 
| 47 39 | 
             
                        @logger.debug("vApp Delete task id #{vAppDeleteTask}")
         | 
| @@ -18,8 +18,6 @@ module VagrantPlugins | |
| 18 18 | 
             
                      # Get the ports we're forwarding
         | 
| 19 19 | 
             
                      env[:forwarded_ports] ||= compile_forwarded_ports(env[:machine].config)
         | 
| 20 20 |  | 
| 21 | 
            -
                      @logger.debug("WE'RE GOING TO FORWARD THIS!: #{@env[:forwarded_ports]}")
         | 
| 22 | 
            -
             | 
| 23 21 | 
             
                      forward_ports
         | 
| 24 22 |  | 
| 25 23 | 
             
                      @app.call(env)
         | 
| @@ -28,8 +26,6 @@ module VagrantPlugins | |
| 28 26 | 
             
                    def forward_ports
         | 
| 29 27 | 
             
                      ports = []
         | 
| 30 28 |  | 
| 31 | 
            -
                      # interfaces = @env[:machine].provider.driver.read_network_interfaces
         | 
| 32 | 
            -
             | 
| 33 29 | 
             
                      cfg = @env[:machine].provider_config
         | 
| 34 30 | 
             
                      cnx = cfg.vcloud_cnx.driver
         | 
| 35 31 | 
             
                      vmName = @env[:machine].name
         | 
| @@ -49,28 +45,8 @@ module VagrantPlugins | |
| 49 45 | 
             
                          :host_port => fp.host_port
         | 
| 50 46 | 
             
                        }
         | 
| 51 47 |  | 
| 52 | 
            -
                        # Assuming the only reason to establish port forwarding is
         | 
| 53 | 
            -
                        # because the VM is using Virtualbox NAT networking. Host-only
         | 
| 54 | 
            -
                        # bridged networking don't require port-forwarding and establishing
         | 
| 55 | 
            -
                        # forwarded ports on these attachment types has uncertain behaviour.
         | 
| 56 48 | 
             
                        @env[:ui].info("Forwarding Ports: VM port #{fp.guest_port} -> vShield Edge port #{fp.host_port}")
         | 
| 57 49 |  | 
| 58 | 
            -
                        # Verify we have the network interface to attach to
         | 
| 59 | 
            -
                        # if !interfaces[fp.adapter]
         | 
| 60 | 
            -
                        #   raise Vagrant::Errors::ForwardPortAdapterNotFound,
         | 
| 61 | 
            -
                        #     :adapter => fp.adapter.to_s,
         | 
| 62 | 
            -
                        #     :guest => fp.guest_port.to_s,
         | 
| 63 | 
            -
                        #     :host => fp.host_port.to_s
         | 
| 64 | 
            -
                        # end
         | 
| 65 | 
            -
             | 
| 66 | 
            -
                        # Port forwarding requires the network interface to be a NAT interface,
         | 
| 67 | 
            -
                        # so verify that that is the case.
         | 
| 68 | 
            -
                        # if interfaces[fp.adapter][:type] != :nat
         | 
| 69 | 
            -
                        #   @env[:ui].info(I18n.t("vagrant.actions.vm.forward_ports.non_nat",
         | 
| 70 | 
            -
                        #                         message_attributes))
         | 
| 71 | 
            -
                        #   next
         | 
| 72 | 
            -
                        # end
         | 
| 73 | 
            -
             | 
| 74 50 | 
             
                        # Add the options to the ports array to send to the driver later
         | 
| 75 51 | 
             
                        ports << {
         | 
| 76 52 | 
             
                          :guestip   => fp.guest_ip,
         | 
| @@ -85,20 +61,11 @@ module VagrantPlugins | |
| 85 61 |  | 
| 86 62 | 
             
                      if !ports.empty?
         | 
| 87 63 | 
             
                        # We only need to forward ports if there are any to forward
         | 
| 88 | 
            -
             | 
| 89 | 
            -
                        @logger.debug(" | 
| 90 | 
            -
                        @logger.debug("here's our network id #{cfg.vdc_network_id}")
         | 
| 91 | 
            -
                        # @env[:machine].provider.driver.forward_ports(ports)
         | 
| 92 | 
            -
             | 
| 93 | 
            -
                        # newvapp[:vms_hash].each do |key, value|
         | 
| 94 | 
            -
             | 
| 95 | 
            -
                        # nat_rules << { :nat_external_port => j.to_s, :nat_internal_port => "873", :nat_protocol => "UDP", :vm_scoped_local_id => value[:vapp_scoped_local_id]}
         | 
| 96 | 
            -
                        # j += 1
         | 
| 64 | 
            +
                        @logger.debug("Port object to be passed: #{ports.inspect}")
         | 
| 65 | 
            +
                        @logger.debug("Current network id #{cfg.vdc_network_id}")
         | 
| 97 66 |  | 
| 98 67 | 
             
                        ### Here we apply the nat_rules to the vApp we just built
         | 
| 99 68 |  | 
| 100 | 
            -
                        # puts "### Applying Port Forwarding NAT Rules"
         | 
| 101 | 
            -
             | 
| 102 69 | 
             
                        addports = cnx.add_vapp_port_forwarding_rules(
         | 
| 103 70 | 
             
                          vAppId,
         | 
| 104 71 | 
             
                          "Vagrant-vApp-Net",
         | 
| @@ -115,11 +82,8 @@ module VagrantPlugins | |
| 115 82 | 
             
                          raise Errors::ComposeVAppError, :message => wait[:errormsg]
         | 
| 116 83 | 
             
                        end
         | 
| 117 84 |  | 
| 118 | 
            -
             | 
| 119 85 | 
             
                      end
         | 
| 120 86 |  | 
| 121 | 
            -
             | 
| 122 | 
            -
             | 
| 123 87 | 
             
                    end
         | 
| 124 88 | 
             
                  end
         | 
| 125 89 | 
             
                end
         | 
| @@ -33,15 +33,11 @@ module VagrantPlugins | |
| 33 33 | 
             
                      # Determine a list of usable ports for repair
         | 
| 34 34 | 
             
                      usable_ports = Set.new(env[:machine].config.vm.usable_port_range)
         | 
| 35 35 |  | 
| 36 | 
            -
                      @logger.debug("USABLE PORTS: #{usable_ports.inspect}")
         | 
| 37 | 
            -
             | 
| 38 36 | 
             
                      # Pass one, remove all defined host ports from usable ports
         | 
| 39 37 | 
             
                      with_forwarded_ports(env) do |options|
         | 
| 40 38 | 
             
                        usable_ports.delete(options[:host])
         | 
| 41 39 | 
             
                      end
         | 
| 42 40 |  | 
| 43 | 
            -
                      @logger.debug("USABLE PORTS AFTER IN USE DELETION: #{usable_ports.inspect}")
         | 
| 44 | 
            -
             | 
| 45 41 | 
             
                      cfg = env[:machine].provider_config
         | 
| 46 42 | 
             
                      cnx = cfg.vcloud_cnx.driver
         | 
| 47 43 | 
             
                      vmName = env[:machine].name
         | 
| @@ -59,12 +55,8 @@ module VagrantPlugins | |
| 59 55 | 
             
                        guest_port = options[:guest]
         | 
| 60 56 | 
             
                        host_port  = options[:host]
         | 
| 61 57 |  | 
| 62 | 
            -
                        #testHash = rules.flatten
         | 
| 63 | 
            -
                        @logger.debug("DEBUGGING NETWORKS: rules: #{rules.inspect}")         
         | 
| 64 | 
            -
             | 
| 65 58 | 
             
                        # If the port is open (listening for TCP connections)
         | 
| 66 59 | 
             
                        if rules.include?(host_port)
         | 
| 67 | 
            -
                          @logger.debug("SO OUR PORT IS INCLUDED IN RULES BUT WHAT'S IN OPTIONS?: #{options.inspect}")
         | 
| 68 60 | 
             
                          if !options[:auto_correct]
         | 
| 69 61 | 
             
                            raise Errors::ForwardPortCollision,
         | 
| 70 62 | 
             
                              :guest_port => guest_port.to_s,
         | 
| @@ -27,7 +27,7 @@ module VagrantPlugins | |
| 27 27 |  | 
| 28 28 | 
             
                      boxOVF = "#{boxDir}/#{boxFile}.ovf"
         | 
| 29 29 |  | 
| 30 | 
            -
                       | 
| 30 | 
            +
                      # Still relying on ruby-progressbar because report_progress basically sucks.
         | 
| 31 31 |  | 
| 32 32 | 
             
                      @logger.debug("OVF File: #{boxOVF}")
         | 
| 33 33 | 
             
                      uploadOVF = cnx.upload_ovf(
         | 
| @@ -38,6 +38,7 @@ module VagrantPlugins | |
| 38 38 | 
             
                        cfg.catalog_id,
         | 
| 39 39 | 
             
                        {
         | 
| 40 40 | 
             
                          :progressbar_enable => true
         | 
| 41 | 
            +
                          # FIXME: export chunksize as a parameter and lower the default to 1M.
         | 
| 41 42 | 
             
                          #:chunksize => 262144
         | 
| 42 43 | 
             
                        }
         | 
| 43 44 | 
             
                      )
         | 
| @@ -49,7 +50,7 @@ module VagrantPlugins | |
| 49 50 | 
             
                        raise Errors::CatalogAddError, :message => addOVFtoCatalog[:errormsg]
         | 
| 50 51 | 
             
                      end
         | 
| 51 52 |  | 
| 52 | 
            -
                       | 
| 53 | 
            +
                      # Retrieve catalog_item ID
         | 
| 53 54 | 
             
                      cfg.catalog_item = cnx.get_catalog_item_by_name(cfg.catalog_id, env[:machine].box.name.to_s)
         | 
| 54 55 |  | 
| 55 56 | 
             
                    end
         | 
| @@ -63,7 +64,7 @@ module VagrantPlugins | |
| 63 64 |  | 
| 64 65 | 
             
                      @logger.debug("Catalog Creation result: #{catalogCreation.inspect}")
         | 
| 65 66 |  | 
| 66 | 
            -
                      env[:ui].info("Catalog [#{cfg.catalog_name}] created | 
| 67 | 
            +
                      env[:ui].info("Catalog [#{cfg.catalog_name}] successfully created.")
         | 
| 67 68 |  | 
| 68 69 | 
             
                      cfg.catalog_id = catalogCreation[:catalog_id]
         | 
| 69 70 |  | 
| @@ -83,11 +84,7 @@ module VagrantPlugins | |
| 83 84 |  | 
| 84 85 | 
             
                      cfg.catalog = cnx.get_catalog_by_name(cfg.org, cfg.catalog_name)
         | 
| 85 86 |  | 
| 86 | 
            -
             | 
| 87 | 
            -
                      @logger.debug("BEFORE get_catalog_id_by_name")          
         | 
| 88 87 | 
             
                      cfg.catalog_id = cnx.get_catalog_id_by_name(cfg.org, cfg.catalog_name)
         | 
| 89 | 
            -
                      @logger.debug("AFTER get_catalog_id_by_name: #{cfg.catalog_id}")
         | 
| 90 | 
            -
             | 
| 91 88 |  | 
| 92 89 | 
             
                      if cfg.catalog_id.nil?
         | 
| 93 90 | 
             
                        env[:ui].warn("Catalog [#{cfg.catalog_name}] does not exist!")
         | 
| @@ -96,12 +93,12 @@ module VagrantPlugins | |
| 96 93 | 
             
                          "Would you like to create the [#{cfg.catalog_name}] catalog?\nChoice (yes/no): "
         | 
| 97 94 | 
             
                        )
         | 
| 98 95 |  | 
| 99 | 
            -
                         | 
| 100 | 
            -
                        if user_input.downcase == "yes"
         | 
| 96 | 
            +
                        if user_input.downcase == "yes" || user_input.downcase == "y" 
         | 
| 101 97 | 
             
                          vcloud_create_catalog(env)
         | 
| 102 98 | 
             
                        else
         | 
| 103 99 | 
             
                          env[:ui].error("Catalog not created, exiting...")
         | 
| 104 100 |  | 
| 101 | 
            +
                          # FIXME: wrong error message
         | 
| 105 102 | 
             
                          raise VagrantPlugins::VCloud::Errors::VCloudError, 
         | 
| 106 103 | 
             
                                :message => "Catalog not available, exiting..."
         | 
| 107 104 |  | 
| @@ -118,6 +115,8 @@ module VagrantPlugins | |
| 118 115 | 
             
                      # Checking Catalog mandatory requirements
         | 
| 119 116 | 
             
                      if !cfg.catalog_id
         | 
| 120 117 | 
             
                        @logger.info("Catalog [#{cfg.catalog_name}] STILL does not exist!")
         | 
| 118 | 
            +
             | 
| 119 | 
            +
                          # FIXME: wrong error message
         | 
| 121 120 | 
             
                          raise VagrantPlugins::VCloud::Errors::VCloudError, 
         | 
| 122 121 | 
             
                                :message => "Catalog not available, exiting..."
         | 
| 123 122 |  | 
| @@ -133,20 +132,20 @@ module VagrantPlugins | |
| 133 132 | 
             
                          "[#{cfg.catalog_name}] Catalog?\nChoice (yes/no): "
         | 
| 134 133 | 
             
                        )
         | 
| 135 134 |  | 
| 136 | 
            -
                         | 
| 137 | 
            -
                        if user_input.downcase == "yes"
         | 
| 135 | 
            +
                        if user_input.downcase == "yes" || user_input.downcase == "y" 
         | 
| 138 136 | 
             
                          env[:ui].info("Uploading [#{env[:machine].box.name.to_s}]...")
         | 
| 139 137 | 
             
                          vcloud_upload_box(env)
         | 
| 140 138 | 
             
                        else
         | 
| 141 139 | 
             
                          env[:ui].error("Catalog item not available, exiting...")
         | 
| 142 140 |  | 
| 141 | 
            +
                          # FIXME: wrong error message
         | 
| 143 142 | 
             
                          raise VagrantPlugins::VCloud::Errors::VCloudError, 
         | 
| 144 143 | 
             
                                :message => "Catalog item not available, exiting..."
         | 
| 145 144 |  | 
| 146 145 | 
             
                        end
         | 
| 147 146 |  | 
| 148 147 | 
             
                      else
         | 
| 149 | 
            -
                         | 
| 148 | 
            +
                        @logger.info("Using catalog item [#{env[:machine].box.name.to_s}] in Catalog [#{cfg.catalog_name}]...")
         | 
| 150 149 | 
             
                      end
         | 
| 151 150 | 
             
                    end
         | 
| 152 151 |  | 
| @@ -19,10 +19,28 @@ module VagrantPlugins | |
| 19 19 | 
             
                      vmId = env[:machine].id
         | 
| 20 20 | 
             
                      vmName = env[:machine].name
         | 
| 21 21 |  | 
| 22 | 
            -
                       | 
| 23 | 
            -
             | 
| 24 | 
            -
                       | 
| 25 | 
            -
             | 
| 22 | 
            +
                      testvApp = cnx.get_vapp(vAppId)
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                      @logger.debug("Number of VMs in the vApp: #{testvApp[:vms_hash].count}")
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                      if testvApp[:vms_hash].count == 1
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                        # Poweroff vApp
         | 
| 29 | 
            +
                        env[:ui].info("Powering off vApp...")
         | 
| 30 | 
            +
                        vAppStopTask = cnx.poweroff_vapp(vAppId)
         | 
| 31 | 
            +
                        vAppStopWait = cnx.wait_task_completion(vAppStopTask)
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                        if !vAppStopWait[:errormsg].nil?
         | 
| 34 | 
            +
                          raise Errors::StopVAppError, :message => vAppStopWait[:errormsg]
         | 
| 35 | 
            +
                        end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                      else
         | 
| 38 | 
            +
                        # Poweroff VM
         | 
| 39 | 
            +
                        env[:ui].info("Powering off VM...")
         | 
| 40 | 
            +
                        task_id = cnx.poweroff_vm(vmId)
         | 
| 41 | 
            +
                        wait = cnx.wait_task_completion(task_id)
         | 
| 42 | 
            +
                      end
         | 
| 43 | 
            +
             | 
| 26 44 | 
             
                      true
         | 
| 27 45 |  | 
| 28 46 | 
             
                      @app.call env
         | 
| @@ -27,7 +27,9 @@ module VagrantPlugins | |
| 27 27 |  | 
| 28 28 | 
             
                    if testIp.nil? && cfg.vdc_edge_gateway_ip && cfg.vdc_edge_gateway
         | 
| 29 29 | 
             
                      @logger.debug("This is our first boot, we should map ports on org edge!")
         | 
| 30 | 
            -
             | 
| 30 | 
            +
             | 
| 31 | 
            +
                      env[:ui].info("Creating NAT rules on [#{cfg.vdc_edge_gateway}] for IP [#{cfg.vdc_edge_gateway_ip}].")
         | 
| 32 | 
            +
             | 
| 31 33 | 
             
                      edgeMap = cnx.set_edge_gateway_rules(cfg.vdc_edge_gateway, cfg.vdc_id, cfg.vdc_edge_gateway_ip, vAppId)
         | 
| 32 34 | 
             
                      cnx.wait_task_completion(edgeMap)
         | 
| 33 35 | 
             
                    end
         | 
| @@ -1,5 +1,3 @@ | |
| 1 | 
            -
            require "awesome_print"
         | 
| 2 | 
            -
             | 
| 3 1 | 
             
            module VagrantPlugins
         | 
| 4 2 | 
             
              module VCloud
         | 
| 5 3 | 
             
                module Action
         | 
| @@ -42,10 +40,7 @@ module VagrantPlugins | |
| 42 40 | 
             
                      rules = cnx.get_vapp_port_forwarding_rules(vAppId)
         | 
| 43 41 |  | 
| 44 42 | 
             
                      rules.each do |rule|
         | 
| 45 | 
            -
                        if rule[:vapp_scoped_local_id] == myhash[:vapp_scoped_local_id] && rule[:nat_internal_port] == "22"
         | 
| 46 | 
            -
             | 
| 47 | 
            -
                          @logger.debug("Our variables: IP #{rule[:nat_external_ip]} and Port #{rule[:nat_external_port]}")
         | 
| 48 | 
            -
                          
         | 
| 43 | 
            +
                        if rule[:vapp_scoped_local_id] == myhash[:vapp_scoped_local_id] && rule[:nat_internal_port] == "22"              
         | 
| 49 44 | 
             
                          @externalIP = rule[:nat_external_ip]
         | 
| 50 45 | 
             
                          @externalPort = rule[:nat_external_port]
         | 
| 51 46 | 
             
                          break
         | 
| @@ -57,6 +52,9 @@ module VagrantPlugins | |
| 57 52 | 
             
                        @externalIP = cfg.vdc_edge_gateway_ip
         | 
| 58 53 | 
             
                      end
         | 
| 59 54 |  | 
| 55 | 
            +
                      # FIXME: fix the selfs and create a meaningful info message
         | 
| 56 | 
            +
                      # @logger.debug("Our variables: IP #{@externalIP} and Port #{@externalPort}")
         | 
| 57 | 
            +
             | 
| 60 58 | 
             
                      return {
         | 
| 61 59 | 
             
                        # FIXME: these shouldn't be self
         | 
| 62 60 | 
             
                          :host => @externalIP,
         | 
| @@ -1,7 +1,27 @@ | |
| 1 | 
            +
            # The MIT License (MIT)
         | 
| 2 | 
            +
            # Copyright (c) 2013 Mitchell Hashimoto
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            # Permission is hereby granted, free of charge, to any person obtaining a copy of 
         | 
| 5 | 
            +
            # this software and associated documentation files (the "Software"), to deal in 
         | 
| 6 | 
            +
            # the Software without restriction, including without limitation the rights to
         | 
| 7 | 
            +
            # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
         | 
| 8 | 
            +
            # of the Software, and to permit persons to whom the Software is furnished to do 
         | 
| 9 | 
            +
            # so, subject to the following conditions:
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            # The above copyright notice and this permission notice shall be included in all
         | 
| 12 | 
            +
            # copies or substantial portions of the Software.
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
         | 
| 15 | 
            +
            # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
         | 
| 16 | 
            +
            # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 
         | 
| 17 | 
            +
            # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 
         | 
| 18 | 
            +
            # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 
         | 
| 19 | 
            +
            # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         | 
| 20 | 
            +
             | 
| 1 21 | 
             
            require "log4r"
         | 
| 2 22 | 
             
            require "vagrant/util/subprocess"
         | 
| 3 23 | 
             
            require "vagrant/util/scoped_hash_override"
         | 
| 4 | 
            -
            require " | 
| 24 | 
            +
            require "vagrant/util/which"
         | 
| 5 25 |  | 
| 6 26 | 
             
            module VagrantPlugins
         | 
| 7 27 | 
             
              module VCloud
         | 
| @@ -27,6 +47,11 @@ module VagrantPlugins | |
| 27 47 | 
             
                        # Ignore disabled shared folders
         | 
| 28 48 | 
             
                        next if data[:disabled]
         | 
| 29 49 |  | 
| 50 | 
            +
                        unless Vagrant::Util::Which.which('rsync')
         | 
| 51 | 
            +
                          env[:ui].warn(I18n.t('vagrant_vcloud.rsync_not_found_warning'))
         | 
| 52 | 
            +
                          break
         | 
| 53 | 
            +
                        end
         | 
| 54 | 
            +
             | 
| 30 55 | 
             
                        hostpath  = File.expand_path(data[:hostpath], env[:root_path])
         | 
| 31 56 | 
             
                        guestpath = data[:guestpath]
         | 
| 32 57 |  | 
| @@ -34,11 +59,14 @@ module VagrantPlugins | |
| 34 59 | 
             
                        # avoid creating an additional directory with rsync
         | 
| 35 60 | 
             
                        hostpath = "#{hostpath}/" if hostpath !~ /\/$/
         | 
| 36 61 |  | 
| 37 | 
            -
                         | 
| 62 | 
            +
                        # on windows rsync.exe requires cygdrive-style paths
         | 
| 63 | 
            +
                        if Vagrant::Util::Platform.windows?
         | 
| 64 | 
            +
                          hostpath = hostpath.gsub(/^(\w):/) { "/cygdrive/#{$1}" }
         | 
| 65 | 
            +
                        end
         | 
| 38 66 |  | 
| 39 | 
            -
                         | 
| 40 | 
            -
             | 
| 41 | 
            -
             | 
| 67 | 
            +
                        env[:ui].info(I18n.t("vagrant_vcloud.rsync_folder",
         | 
| 68 | 
            +
                                            :hostpath => hostpath,
         | 
| 69 | 
            +
                                            :guestpath => guestpath))
         | 
| 42 70 |  | 
| 43 71 | 
             
                        # Create the host path if it doesn't exist and option flag is set
         | 
| 44 72 | 
             
                        if data[:create]
         | 
| @@ -59,11 +87,17 @@ module VagrantPlugins | |
| 59 87 | 
             
                        # Rsync over to the guest path using the SSH info
         | 
| 60 88 | 
             
                        command = [
         | 
| 61 89 | 
             
                          "rsync", "--verbose", "--archive", "-z",
         | 
| 62 | 
            -
                          "--exclude", ".vagrant/",
         | 
| 90 | 
            +
                          "--exclude", ".vagrant/", "--exclude", "Vagrantfile",
         | 
| 63 91 | 
             
                          "-e", "ssh -p #{ssh_info[:port]} -o StrictHostKeyChecking=no -i '#{ssh_info[:private_key_path]}'",
         | 
| 64 92 | 
             
                          hostpath,
         | 
| 65 93 | 
             
                          "#{ssh_info[:username]}@#{ssh_info[:host]}:#{guestpath}"]
         | 
| 66 94 |  | 
| 95 | 
            +
                        # we need to fix permissions when using rsync.exe on windows, see
         | 
| 96 | 
            +
                        # http://stackoverflow.com/questions/5798807/rsync-permission-denied-created-directories-have-no-permissions
         | 
| 97 | 
            +
                        if Vagrant::Util::Platform.windows?
         | 
| 98 | 
            +
                          command.insert(1, "--chmod", "ugo=rwX")
         | 
| 99 | 
            +
                        end
         | 
| 100 | 
            +
             | 
| 67 101 | 
             
                        r = Vagrant::Util::Subprocess.execute(*command)
         | 
| 68 102 | 
             
                        if r.exit_code != 0
         | 
| 69 103 | 
             
                          raise Errors::RsyncError,
         | 
| @@ -76,7 +110,4 @@ module VagrantPlugins | |
| 76 110 | 
             
                  end
         | 
| 77 111 | 
             
                end
         | 
| 78 112 | 
             
              end
         | 
| 79 | 
            -
            end
         | 
| 80 | 
            -
             | 
| 81 | 
            -
             | 
| 82 | 
            -
             
         | 
| 113 | 
            +
            end
         | 
| @@ -63,6 +63,11 @@ module VagrantPlugins | |
| 63 63 | 
             
                  # @return [String]
         | 
| 64 64 | 
             
                  attr_accessor :ip_subnet
         | 
| 65 65 |  | 
| 66 | 
            +
                  # DNS
         | 
| 67 | 
            +
                  #
         | 
| 68 | 
            +
                  # @return [Array]
         | 
| 69 | 
            +
                  attr_accessor :ip_dns
         | 
| 70 | 
            +
             | 
| 66 71 | 
             
                  # Port forwarding rules
         | 
| 67 72 | 
             
                  #
         | 
| 68 73 | 
             
                  # @return [Hash]
         | 
| @@ -116,14 +121,17 @@ module VagrantPlugins | |
| 116 121 | 
             
                    errors = _detected_errors
         | 
| 117 122 |  | 
| 118 123 | 
             
                    # TODO: add blank?
         | 
| 119 | 
            -
                    errors << I18n.t("config.hostname") if hostname.nil?
         | 
| 120 | 
            -
                    errors << I18n.t("config.org_name") if org_name.nil?
         | 
| 121 | 
            -
                    errors << I18n.t("config.username") if username.nil?
         | 
| 122 | 
            -
                    errors << I18n.t("config.password") if password.nil?
         | 
| 124 | 
            +
                    errors << I18n.t("vagrant_vcloud.config.hostname") if hostname.nil?
         | 
| 125 | 
            +
                    errors << I18n.t("vagrant_vcloud.config.org_name") if org_name.nil?
         | 
| 126 | 
            +
                    errors << I18n.t("vagrant_vcloud.config.username") if username.nil?
         | 
| 127 | 
            +
                    errors << I18n.t("vagrant_vcloud.config.password") if password.nil?
         | 
| 123 128 |  | 
| 124 | 
            -
                     | 
| 125 | 
            -
             | 
| 126 | 
            -
                     | 
| 129 | 
            +
                    if !ip_dns.nil?
         | 
| 130 | 
            +
                      errors << I18n.t("vagrant_vcloud.config.ip_dns") if !ip_dns.kind_of?(Array)
         | 
| 131 | 
            +
                    end
         | 
| 132 | 
            +
                    errors << I18n.t("vagrant_vcloud.config.catalog_name") if catalog_name.nil?
         | 
| 133 | 
            +
                    errors << I18n.t("vagrant_vcloud.config.vdc_name") if vdc_name.nil?
         | 
| 134 | 
            +
                    errors << I18n.t("vagrant_vcloud.config.vdc_network_name") if vdc_network_name.nil?
         | 
| 127 135 |  | 
| 128 136 | 
             
                    { "vCloud Provider" => errors }
         | 
| 129 137 | 
             
                  end
         |