builder/vmware: GuestIP lookup interface

This commit is contained in:
Mitchell Hashimoto 2013-06-05 20:53:34 -07:00
parent dfee3eb8ef
commit 60dba3f8ef
4 changed files with 52 additions and 28 deletions

View File

@ -55,7 +55,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook) packer.Artifact {
&stepHTTPServer{},
&stepRun{},
&stepTypeBootCommand{},
&stepWaitForIP{},
&stepWaitForSSH{},
}
// Setup the state bag

View File

@ -0,0 +1,20 @@
package vmware
// Interface to help find the IP address of a running virtual machine.
type GuestIPFinder interface {
GuestIP() (string, error)
}
// DHCPLeaseGuestLookup looks up the IP address of a guest using DHCP
// lease information from the VMware network devices.
type DHCPLeaseGuestLookup struct {
// Device that the guest is connected to.
Device string
// MAC address of the guest.
MACAddress string
}
func (f *DHCPLeaseGuestLookup) GuestIP() (string, error) {
return "", nil
}

View File

@ -1,27 +0,0 @@
package vmware
import (
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
)
// This step creates the virtual disks for the VM.
//
// Uses:
// config *config
// ui packer.Ui
//
// Produces:
// <nothing>
type stepWaitForIP struct{}
func (stepWaitForIP) Run(state map[string]interface{}) multistep.StepAction {
ui := state["ui"].(packer.Ui)
ui.Say("Waiting for SSH to become available...")
select {}
return multistep.ActionContinue
}
func (stepWaitForIP) Cleanup(map[string]interface{}) {}

View File

@ -0,0 +1,31 @@
package vmware
import (
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
)
// This step waits for SSH to become available and establishes an SSH
// connection.
//
// Uses:
// config *config
// ui packer.Ui
//
// Produces:
// <nothing>
type stepWaitForSSH struct{}
func (stepWaitForSSH) Run(state map[string]interface{}) multistep.StepAction {
ui := state["ui"].(packer.Ui)
ui.Say("Waiting for SSH to become available...")
for {
// First we wait for the IP to become available...
}
return multistep.ActionContinue
}
func (stepWaitForSSH) Cleanup(map[string]interface{}) {}