diff --git a/drivers/amazonec2/amazonec2.go b/drivers/amazonec2/amazonec2.go index 5a9586f6af..2692fe28e7 100644 --- a/drivers/amazonec2/amazonec2.go +++ b/drivers/amazonec2/amazonec2.go @@ -8,7 +8,7 @@ import ( "io/ioutil" "net/url" "os/exec" - "path" + "path/filepath" "strconv" "strings" @@ -65,6 +65,7 @@ type Driver struct { SwarmDiscovery string storePath string keyPath string + sshPort int } type CreateFlags struct { @@ -413,6 +414,19 @@ func (d *Driver) GetState() (state.State, error) { return state.None, nil } +func (d *Driver) GetSSHAddress() (string, error) { + // TODO: use @nathanleclaire retry func here (ehazlett) + return d.GetIP() +} + +func (d *Driver) GetSSHPort() (int, error) { + return d.sshPort, nil +} + +func (d *Driver) GetSSHUsername() string { + return "ubuntu" +} + func (d *Driver) Start() error { if err := d.getClient().StartInstance(d.InstanceId); err != nil { return err @@ -509,7 +523,7 @@ func (d *Driver) Upgrade() error { } func (d *Driver) GetSSHCommand(args ...string) (*exec.Cmd, error) { - return ssh.GetSSHCommand(d.IPAddress, 22, "ubuntu", d.sshKeyPath(), args...), nil + return ssh.GetSSHCommand(d.IPAddress, d.GetSSHPort(), "ubuntu", d.sshKeyPath(), args...), nil } func (d *Driver) getClient() *amz.EC2 { @@ -517,8 +531,8 @@ func (d *Driver) getClient() *amz.EC2 { return amz.NewEC2(auth, d.Region) } -func (d *Driver) sshKeyPath() string { - return path.Join(d.storePath, "id_rsa") +func (d *Driver) GetSSHKeyPath() string { + return filepath.Join(d.storePath, "id_rsa") } func (d *Driver) publicSSHKeyPath() string { diff --git a/drivers/drivers.go b/drivers/drivers.go index 84440820a8..059d1307de 100644 --- a/drivers/drivers.go +++ b/drivers/drivers.go @@ -9,19 +9,27 @@ import ( "github.com/docker/machine/state" ) +type Port struct { + Protocol string + Port int +} + // Driver defines how a host is created and controlled. Different types of // driver represent different ways hosts can be created (e.g. different // hypervisors, different cloud providers) type Driver interface { + // AuthorizePort authorizes a port for machine access + AuthorizePort(port Port) error + // Create a host using the driver's config Create() error + // DeauthorizePort removes a port for machine access + DeauthorizePort(port Port) error + // DriverName returns the name of the driver as it is registered DriverName() string - // GetDockerPort returns the port specified for Docker - GetDockerPort() int - // GetIP returns an IP or hostname that this host is available at // e.g. 1.2.3.4 or docker-host-d60b70a14d3a.cloudapp.net GetIP() (string, error)