frapposelli / vagrant-vcloud

Vagrant provider for VMware vCloud Director®
MIT License
67 stars 38 forks source link

Error adding Edge Gateway NAT rules #116

Closed trilitheus closed 3 years ago

trilitheus commented 9 years ago

I'm using version of 1.1.0 0.4.4 of vagrant-vcloud and using the following Vagrantfile:

nodes = [
  { hostname: 'web-vm', box: 'packer-test-centos-ks', box_url: 'file:///Users/me/repos/packer_builds/packer_test-centos-ks_vmware_ovf.box' },
  { hostname: 'ssh-vm', box: 'packer-test-centos-ks', box_url: 'file:///Users/me/repos/packer_builds/packer_test-centos-ks_vmware_ovf.box' },
  { hostname: 'sql-vm', box: 'packer-test-centos-ks', box_url: 'file:///Users/me/repos/packer_builds/packer_test-centos-ks_vmware_ovf.box' },
  { hostname: 'app-vm', box: 'packer-test-centos-ks', box_url: 'file:///Users/me/repos/packer_builds/packer_test-centos-ks_vmware_ovf.box' }
]

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

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

    vcloud.hostname = 'https://api.endpoint.com'
    vcloud.username = 'USER'
    vcloud.password = 'PASSWORD'

    vcloud.org_name = 'ORGNAME'
    vcloud.vdc_name = 'DEVTEST'
    vcloud.catalog_name = 'test'

    vcloud.vdc_network_name = 'test_org_net'
    vcloud.vdc_edge_gateway = 'EDGE_GW_NAME'
    vcloud.vdc_edge_gateway_ip = 'EDGE_GW_IP'
  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
      # end
    end
  end
end

The Vapp is created succesfully, a VM is set up, the Vapp Edge is created with correct NAT rules but the vagrant up fails with

/Users/me/.vagrant.d/gems/gems/vagrant-vcloud-0.4.4/lib/vagrant-vcloud/driver/version_5_1.rb:1431:in `block in add_edge_gateway_rules': undefined method `<<' for nil:NilClass (NoMethodError)

So the NAT rules never get added to the Org Edge Gateway - it seems that for some reason 'nat_rules' is not being set but this may be me misinterpretting. I;ve added the following to version_5_1.rb at lines 1429 and 1430

puts "DEBUG: #{nat_rule.doc.root.to_xml}"
puts "DEBUG2: #{nat_rules}"

which outputs:

DEBUG: <NatRule>
  <RuleType>DNAT</RuleType>
  <IsEnabled>true</IsEnabled>
  <GatewayNatRule>
    <Interface href="https://API_END_POINT"/>
    <OriginalIp>EDGE_IP</OriginalIp>
    <OriginalPort>2200</OriginalPort>
    <TranslatedIp>10.10.10.2</TranslatedIp>
    <TranslatedPort>2200</TranslatedPort>
    <Protocol>tcpudp</Protocol>
  </GatewayNatRule>
</NatRule>
DEBUG2: 
ERROR warden: Error occurred: undefined method `<<' for nil:NilClass

Hence the assumption the nat_rules is not being set.

Many thanks

Thanks

pckls commented 8 years ago

I've also just experienced the exact same issue, will update once I've investigated more.

EDIT: Too frustrating, I'm just going to use AWS.