Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provider/vsphere: Fix missing ssh connection info #6293

Merged
merged 2 commits into from
Apr 21, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion builtin/providers/vsphere/resource_vsphere_virtual_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,6 @@ func resourceVSphereVirtualMachineCreate(d *schema.ResourceData, meta interface{
}

func resourceVSphereVirtualMachineRead(d *schema.ResourceData, meta interface{}) error {

log.Printf("[DEBUG] reading virtual machine: %#v", d)
client := meta.(*govmomi.Client)
dc, err := getDatacenter(client, d.Get("datacenter").(string))
Expand Down Expand Up @@ -641,6 +640,16 @@ func resourceVSphereVirtualMachineRead(d *schema.ResourceData, meta interface{})
return fmt.Errorf("Invalid network interfaces to set: %#v", networkInterfaces)
}

ip, err := vm.WaitForIP(context.TODO())
if err != nil {
return err
}
log.Printf("[DEBUG] ip address: %v", ip)
d.SetConnInfo(map[string]string{
"type": "ssh",
"host": ip,
})

var rootDatastore string
for _, v := range mvm.Datastore {
var md mo.Datastore
Expand Down