Skip to content

Commit

Permalink
Merge pull request #3636 from rakutentech/fix-connection-info
Browse files Browse the repository at this point in the history
provider/vsphere: Fix d.SetConnInfo error in case of a missing IP address
  • Loading branch information
phinze committed Oct 29, 2015
2 parents 485dbcc + 8390154 commit 38c20a5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions builtin/providers/vsphere/resource_vsphere_virtual_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ func resourceVSphereVirtualMachineRead(d *schema.ResourceData, meta interface{})
networkInterfaces = append(networkInterfaces, networkInterface)
}
}
log.Printf("[DEBUG] networkInterfaces: %#v", networkInterfaces)
err = d.Set("network_interface", networkInterfaces)
if err != nil {
return fmt.Errorf("Invalid network interfaces to set: %#v", networkInterfaces)
Expand Down Expand Up @@ -420,10 +421,12 @@ func resourceVSphereVirtualMachineRead(d *schema.ResourceData, meta interface{})
d.Set("datastore", rootDatastore)

// Initialize the connection info
d.SetConnInfo(map[string]string{
"type": "ssh",
"host": networkInterfaces[0]["ip_address"].(string),
})
if len(networkInterfaces) > 0 {
d.SetConnInfo(map[string]string{
"type": "ssh",
"host": networkInterfaces[0]["ip_address"].(string),
})
}

return nil
}
Expand Down

0 comments on commit 38c20a5

Please sign in to comment.