2013-09-02 23:23:52 -04:00
|
|
|
package qemu
|
|
|
|
|
|
|
|
import (
|
2019-07-02 16:56:28 -04:00
|
|
|
"log"
|
|
|
|
|
2020-11-17 19:31:03 -05:00
|
|
|
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
|
2013-09-02 23:23:52 -04:00
|
|
|
)
|
|
|
|
|
2019-07-02 16:56:28 -04:00
|
|
|
func commHost(host string) func(multistep.StateBag) (string, error) {
|
|
|
|
return func(state multistep.StateBag) (string, error) {
|
|
|
|
if host != "" {
|
2020-01-30 18:22:22 -05:00
|
|
|
log.Printf("Using host value: %s", host)
|
2019-07-02 16:56:28 -04:00
|
|
|
return host, nil
|
|
|
|
}
|
|
|
|
|
2020-05-03 09:47:03 -04:00
|
|
|
if guestAddress, ok := state.Get("guestAddress").(string); ok {
|
|
|
|
return guestAddress, nil
|
|
|
|
}
|
|
|
|
|
2019-07-02 16:56:28 -04:00
|
|
|
return "127.0.0.1", nil
|
|
|
|
}
|
2015-06-13 19:23:33 -04:00
|
|
|
}
|
|
|
|
|
2019-03-19 09:47:21 -04:00
|
|
|
func commPort(state multistep.StateBag) (int, error) {
|
2020-06-02 05:56:36 -04:00
|
|
|
commHostPort, ok := state.Get("commHostPort").(int)
|
2020-05-03 09:47:03 -04:00
|
|
|
if !ok {
|
2020-06-02 05:56:36 -04:00
|
|
|
commHostPort = 22
|
2020-05-03 09:47:03 -04:00
|
|
|
}
|
2020-06-02 05:56:36 -04:00
|
|
|
return commHostPort, nil
|
2013-09-02 23:23:52 -04:00
|
|
|
}
|