From 8e9c6787dd048e422541342b9108c5c64ee2c5c8 Mon Sep 17 00:00:00 2001 From: Julien Vey Date: Wed, 4 Feb 2015 22:14:36 +0100 Subject: [PATCH] Just try the first IP available if none found before Some cloud don't implement correctly IP addresses. Instead of failing during the provisionning, we just take the first IP available and try with this one. --- .../resource_openstack_compute_instance_v2.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/builtin/providers/openstack/resource_openstack_compute_instance_v2.go b/builtin/providers/openstack/resource_openstack_compute_instance_v2.go index 7b3db0c6c..2d9a0cdb8 100644 --- a/builtin/providers/openstack/resource_openstack_compute_instance_v2.go +++ b/builtin/providers/openstack/resource_openstack_compute_instance_v2.go @@ -246,11 +246,25 @@ func resourceComputeInstanceV2Read(d *schema.ResourceData, meta interface{}) err pa := paRaw.(map[string]interface{}) if pa["version"].(float64) == 4 { host = pa["addr"].(string) - d.Set("access_ip_v4", host) + break } } } } + + // If no host found, just get the first IP we find + if host == "" { + for _, networkAddresses := range server.Addresses { + for _, element := range networkAddresses.([]interface{}) { + address := element.(map[string]interface{}) + if address["version"].(float64) == 4 { + host = address["addr"].(string) + break + } + } + } + } + d.Set("access_ip_v4", host) d.Set("host", host) log.Printf("host: %s", host)