diff options
Diffstat (limited to 'vendor/github.com/mitchellh/packer/builder/cloudstack/ssh.go')
-rw-r--r-- | vendor/github.com/mitchellh/packer/builder/cloudstack/ssh.go | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/vendor/github.com/mitchellh/packer/builder/cloudstack/ssh.go b/vendor/github.com/mitchellh/packer/builder/cloudstack/ssh.go index ab350d05..7a4c2fcb 100644 --- a/vendor/github.com/mitchellh/packer/builder/cloudstack/ssh.go +++ b/vendor/github.com/mitchellh/packer/builder/cloudstack/ssh.go @@ -7,28 +7,29 @@ import ( packerssh "github.com/hashicorp/packer/communicator/ssh" "github.com/mitchellh/multistep" - "github.com/xanzy/go-cloudstack/cloudstack" "golang.org/x/crypto/ssh" "golang.org/x/crypto/ssh/agent" ) func commHost(state multistep.StateBag) (string, error) { - client := state.Get("client").(*cloudstack.CloudStackClient) - config := state.Get("config").(*Config) + ip, hasIP := state.Get("ipaddress").(string) + if !hasIP { + return "", fmt.Errorf("Failed to retrieve IP address") + } - if config.hostAddress == "" { - ipAddr, _, err := client.Address.GetPublicIpAddressByID(config.PublicIPAddress) - if err != nil { - return "", fmt.Errorf("Failed to retrieve IP address: %s", err) - } + return ip, nil +} - config.hostAddress = ipAddr.Ipaddress +func commPort(state multistep.StateBag) (int, error) { + commPort, hasPort := state.Get("commPort").(int) + if !hasPort { + return 0, fmt.Errorf("Failed to retrieve communication port") } - return config.hostAddress, nil + return commPort, nil } -func SSHConfig(useAgent bool, username, password string) func(state multistep.StateBag) (*ssh.ClientConfig, error) { +func sshConfig(useAgent bool, username, password string) func(state multistep.StateBag) (*ssh.ClientConfig, error) { return func(state multistep.StateBag) (*ssh.ClientConfig, error) { if useAgent { authSock := os.Getenv("SSH_AUTH_SOCK") |