packer-cn/builder/qemu/ssh.go

31 lines
600 B
Go
Raw Normal View History

package qemu
import (
"log"
2020-12-17 16:29:25 -05:00
"github.com/hashicorp/packer-plugin-sdk/multistep"
)
func commHost(host string) func(multistep.StateBag) (string, error) {
return func(state multistep.StateBag) (string, error) {
if host != "" {
log.Printf("Using host value: %s", host)
return host, nil
}
if guestAddress, ok := state.Get("guestAddress").(string); ok {
return guestAddress, nil
}
return "127.0.0.1", nil
}
}
2019-03-19 09:47:21 -04:00
func commPort(state multistep.StateBag) (int, error) {
commHostPort, ok := state.Get("commHostPort").(int)
if !ok {
commHostPort = 22
}
return commHostPort, nil
}