From 51aa826e1452ed958e7f7c702bb42e56c95e7e0b Mon Sep 17 00:00:00 2001 From: Evan Hazlett Date: Mon, 9 Mar 2015 22:20:47 -0400 Subject: [PATCH] digitalocean: update to driver interface Signed-off-by: Evan Hazlett --- commands.go | 2 +- drivers/digitalocean/digitalocean.go | 37 +++++++++++++++++++++++ test/integration/driver-digitalocean.bats | 1 + 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/commands.go b/commands.go index 7290206e..fad11d7f 100644 --- a/commands.go +++ b/commands.go @@ -17,7 +17,7 @@ import ( "github.com/docker/machine/drivers" _ "github.com/docker/machine/drivers/amazonec2" //_ "github.com/docker/machine/drivers/azure" - //_ "github.com/docker/machine/drivers/digitalocean" + _ "github.com/docker/machine/drivers/digitalocean" //_ "github.com/docker/machine/drivers/google" //_ "github.com/docker/machine/drivers/hyperv" _ "github.com/docker/machine/drivers/none" diff --git a/drivers/digitalocean/digitalocean.go b/drivers/digitalocean/digitalocean.go index 7c8f9ef7..c759352a 100644 --- a/drivers/digitalocean/digitalocean.go +++ b/drivers/digitalocean/digitalocean.go @@ -12,6 +12,7 @@ import ( "github.com/codegangsta/cli" "github.com/digitalocean/godo" "github.com/docker/machine/drivers" + "github.com/docker/machine/provider" "github.com/docker/machine/ssh" "github.com/docker/machine/state" ) @@ -29,6 +30,8 @@ type Driver struct { IPAddress string Region string SSHKeyID int + SSHUser string + SSHPort int Size string IPv6 bool Backups bool @@ -98,6 +101,38 @@ func NewDriver(machineName string, storePath string, caCert string, privateKey s return &Driver{MachineName: machineName, storePath: storePath, CaCertPath: caCert, PrivateKeyPath: privateKey}, nil } +func (d *Driver) AuthorizePort(ports []*drivers.Port) error { + return nil +} + +func (d *Driver) DeauthorizePort(ports []*drivers.Port) error { + return nil +} + +func (d *Driver) GetMachineName() string { + return d.MachineName +} + +func (d *Driver) GetSSHHostname() (string, error) { + return d.GetIP() +} + +func (d *Driver) GetSSHKeyPath() string { + return filepath.Join(d.storePath, "id_rsa") +} + +func (d *Driver) GetSSHPort() (int, error) { + return d.SSHPort, nil +} + +func (d *Driver) GetSSHUsername() string { + return d.SSHUser +} + +func (d *Driver) GetProviderType() provider.ProviderType { + return provider.Remote +} + func (d *Driver) DriverName() string { return "digitalocean" } @@ -113,6 +148,8 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error { d.SwarmMaster = flags.Bool("swarm-master") d.SwarmHost = flags.String("swarm-host") d.SwarmDiscovery = flags.String("swarm-discovery") + d.SSHUser = "root" + d.SSHPort = 22 if d.AccessToken == "" { return fmt.Errorf("digitalocean driver requires the --digitalocean-access-token option") diff --git a/test/integration/driver-digitalocean.bats b/test/integration/driver-digitalocean.bats index 86b58230..511e15d7 100644 --- a/test/integration/driver-digitalocean.bats +++ b/test/integration/driver-digitalocean.bats @@ -95,6 +95,7 @@ export MACHINE_STORAGE_PATH=/tmp/machine-bats-test-$DRIVER } @test "$DRIVER: remove" { + run sleep 20 run machine rm -f $NAME [ "$status" -eq 0 ] }