mirror of https://github.com/docker/docs.git
add AuthorizePort and DeauthorizePort
Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
This commit is contained in:
parent
ae439188a0
commit
b8ef936e90
|
@ -8,7 +8,7 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -65,6 +65,7 @@ type Driver struct {
|
||||||
SwarmDiscovery string
|
SwarmDiscovery string
|
||||||
storePath string
|
storePath string
|
||||||
keyPath string
|
keyPath string
|
||||||
|
sshPort int
|
||||||
}
|
}
|
||||||
|
|
||||||
type CreateFlags struct {
|
type CreateFlags struct {
|
||||||
|
@ -413,6 +414,19 @@ func (d *Driver) GetState() (state.State, error) {
|
||||||
return state.None, nil
|
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 {
|
func (d *Driver) Start() error {
|
||||||
if err := d.getClient().StartInstance(d.InstanceId); err != nil {
|
if err := d.getClient().StartInstance(d.InstanceId); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -509,7 +523,7 @@ func (d *Driver) Upgrade() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) GetSSHCommand(args ...string) (*exec.Cmd, 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 {
|
func (d *Driver) getClient() *amz.EC2 {
|
||||||
|
@ -517,8 +531,8 @@ func (d *Driver) getClient() *amz.EC2 {
|
||||||
return amz.NewEC2(auth, d.Region)
|
return amz.NewEC2(auth, d.Region)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) sshKeyPath() string {
|
func (d *Driver) GetSSHKeyPath() string {
|
||||||
return path.Join(d.storePath, "id_rsa")
|
return filepath.Join(d.storePath, "id_rsa")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) publicSSHKeyPath() string {
|
func (d *Driver) publicSSHKeyPath() string {
|
||||||
|
|
|
@ -9,19 +9,27 @@ import (
|
||||||
"github.com/docker/machine/state"
|
"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 defines how a host is created and controlled. Different types of
|
||||||
// driver represent different ways hosts can be created (e.g. different
|
// driver represent different ways hosts can be created (e.g. different
|
||||||
// hypervisors, different cloud providers)
|
// hypervisors, different cloud providers)
|
||||||
type Driver interface {
|
type Driver interface {
|
||||||
|
// AuthorizePort authorizes a port for machine access
|
||||||
|
AuthorizePort(port Port) error
|
||||||
|
|
||||||
// Create a host using the driver's config
|
// Create a host using the driver's config
|
||||||
Create() error
|
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 returns the name of the driver as it is registered
|
||||||
DriverName() string
|
DriverName() string
|
||||||
|
|
||||||
// GetDockerPort returns the port specified for Docker
|
|
||||||
GetDockerPort() int
|
|
||||||
|
|
||||||
// GetIP returns an IP or hostname that this host is available at
|
// GetIP returns an IP or hostname that this host is available at
|
||||||
// e.g. 1.2.3.4 or docker-host-d60b70a14d3a.cloudapp.net
|
// e.g. 1.2.3.4 or docker-host-d60b70a14d3a.cloudapp.net
|
||||||
GetIP() (string, error)
|
GetIP() (string, error)
|
||||||
|
|
Loading…
Reference in New Issue