|
|
|
|
@ -21,15 +21,15 @@ import (
|
|
|
|
|
type stepWaitGuestAddress struct {
|
|
|
|
|
CommunicatorType string
|
|
|
|
|
NetBridge string
|
|
|
|
|
timeout time.Duration
|
|
|
|
|
|
|
|
|
|
timeout time.Duration
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *stepWaitGuestAddress) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
|
|
|
|
|
config := state.Get("config").(*Config)
|
|
|
|
|
ui := state.Get("ui").(packer.Ui)
|
|
|
|
|
|
|
|
|
|
if s.CommunicatorType == "none" {
|
|
|
|
|
ui.Message("Not using a communicator -- skipping StepWaitGuestAddress")
|
|
|
|
|
ui.Message("No communicator is configured -- skipping StepWaitGuestAddress")
|
|
|
|
|
return multistep.ActionContinue
|
|
|
|
|
}
|
|
|
|
|
if s.NetBridge == "" {
|
|
|
|
|
@ -41,9 +41,9 @@ func (s *stepWaitGuestAddress) Run(ctx context.Context, state multistep.StateBag
|
|
|
|
|
ctx, cancel := context.WithTimeout(ctx, s.timeout)
|
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
|
|
ui.Say(fmt.Sprintf("Waiting for the guest address to become available in the %s network bridge...", config.NetBridge))
|
|
|
|
|
ui.Say(fmt.Sprintf("Waiting for the guest address to become available in the %s network bridge...", s.NetBridge))
|
|
|
|
|
for {
|
|
|
|
|
guestAddress := getGuestAddress(qmpMonitor, config.NetBridge, "user.0")
|
|
|
|
|
guestAddress := getGuestAddress(qmpMonitor, s.NetBridge, "user.0")
|
|
|
|
|
if guestAddress != "" {
|
|
|
|
|
log.Printf("Found guest address %s", guestAddress)
|
|
|
|
|
state.Put("guestAddress", guestAddress)
|
|
|
|
|
|