Commit ecbb0e84 authored by asatara's avatar asatara

Added ssh_address variable to vmware builders

parent dc21bf01
......@@ -17,6 +17,10 @@ func SSHAddressFunc(config *SSHConfig) func(multistep.StateBag) (string, error)
driver := state.Get("driver").(Driver)
vmxPath := state.Get("vmx_path").(string)
if config.SSHHost != "" {
return fmt.Sprintf("%s:%d", config.SSHHost, config.SSHPort), nil
}
log.Println("Lookup up IP information...")
f, err := os.Open(vmxPath)
if err != nil {
......
......@@ -3,6 +3,7 @@ package common
import (
"errors"
"fmt"
"net"
"os"
"time"
......@@ -13,6 +14,7 @@ type SSHConfig struct {
SSHUser string `mapstructure:"ssh_username"`
SSHKeyPath string `mapstructure:"ssh_key_path"`
SSHPassword string `mapstructure:"ssh_password"`
SSHHost string `mapstructure:"ssh_host"`
SSHPort uint `mapstructure:"ssh_port"`
SSHSkipRequestPty bool `mapstructure:"ssh_skip_request_pty"`
RawSSHWaitTimeout string `mapstructure:"ssh_wait_timeout"`
......@@ -53,6 +55,14 @@ func (c *SSHConfig) Prepare(t *packer.ConfigTemplate) []error {
}
}
if c.SSHHost != "" {
if ip := net.ParseIP(c.SSHHost); ip == nil {
if _, err := net.LookupHost(c.SSHHost); err != nil {
errs = append(errs, errors.New("ssh_host is an invalid IP or hostname"))
}
}
}
if c.SSHUser == "" {
errs = append(errs, errors.New("An ssh_username must be specified."))
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment