packer-cn/builder/qemu/ssh.go

31 lines
597 B
Go
Raw Normal View History

package qemu
import (
"log"
"github.com/hashicorp/packer/helper/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) {
sshHostPort, ok := state.Get("sshHostPort").(int)
if !ok {
sshHostPort = 22
}
2019-03-19 09:47:21 -04:00
return int(sshHostPort), nil
}