ggiamarchi / vagrant-openstack-provider

Use Vagrant to manage OpenStack Cloud instances.
MIT License
247 stars 101 forks source link

Handle multiple networks with no floating IP assigned #356

Closed ekohl closed 6 years ago

ekohl commented 6 years ago

When a VM has multiple addresses but no networks assigned in the config the current code fails because env[:machine].provider_config.networks is nil.

The content of addresses:

{
  "public"=>[
    {"version"=>6, "addr"=>"PUBLIC_IPV6_ADDRESS"},
    {"version"=>4, "addr"=>"PUBLIC_IPV4_ADDRESS"}
  ],
  "private"=>[
    {"version"=>4, "addr"=>"PRIVATE_IPV4_ADDRESS"}
  ]
}

Fixes GH-289

coveralls commented 6 years ago

Coverage Status

Coverage remained the same at 87.74% when pulling ed738616f70a5b33f57a099e62f78e7149af3675 on ekohl:multiple-networks into 425bb0628d82540b01e96fff530f217ea09e064e on ggiamarchi:master.

ggiamarchi commented 6 years ago

@ekohl I'm curious to know how you end up in this situation. Because if you have several networks in your project but no network specified in your Vagrantfile you can't create the instance. vagrant up fails with the message

Multiple possible networks found, use a Network ID to be more specific.

By the way, I see a use case. If you first have only one network in your project, you vagrant up your instance, then you create a second network in the project. The next vagrant ssh fails.

I'm wondering if this is your use case or if you have another one (just to be sure we don't miss something) because in your snippet you have a network called "public". This is why I suppose both your private and public network exist before you run the vagrant up command. And in this case this issue can't occur given that vagrant will refuse to create the instance.

By the way, this fix is good to merge. But if you have more information, I'll appreciate.

Related to theforeman/foreman-infra/pull/518

ekohl commented 6 years ago

@ggiamarchi I'm not sure how it was actually set up. We're using Rackspace. There a VM gets a public network with both globally routable v4 and v6 IPs. It also gets a private network with a RFC1918 IP for management purposes. Those networks existed from before I started to get involved.