From e43da502f3384d8d0a0c9c1833334922975ce58d Mon Sep 17 00:00:00 2001 From: Evan Hazlett Date: Mon, 9 Mar 2015 12:49:46 -0400 Subject: [PATCH] refactor commands.go to use host ssh and upgrade Signed-off-by: Evan Hazlett --- commands.go | 28 ++++++++++++++-------------- commands_test.go | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 14 deletions(-) diff --git a/commands.go b/commands.go index 0d063d558e..58b92fff56 100644 --- a/commands.go +++ b/commands.go @@ -16,18 +16,18 @@ 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/google" - _ "github.com/docker/machine/drivers/hyperv" + //_ "github.com/docker/machine/drivers/azure" + //_ "github.com/docker/machine/drivers/digitalocean" + //_ "github.com/docker/machine/drivers/google" + //_ "github.com/docker/machine/drivers/hyperv" _ "github.com/docker/machine/drivers/none" - _ "github.com/docker/machine/drivers/openstack" - _ "github.com/docker/machine/drivers/rackspace" - _ "github.com/docker/machine/drivers/softlayer" - _ "github.com/docker/machine/drivers/virtualbox" - _ "github.com/docker/machine/drivers/vmwarefusion" - _ "github.com/docker/machine/drivers/vmwarevcloudair" - _ "github.com/docker/machine/drivers/vmwarevsphere" + //_ "github.com/docker/machine/drivers/openstack" + //_ "github.com/docker/machine/drivers/rackspace" + //_ "github.com/docker/machine/drivers/softlayer" + //_ "github.com/docker/machine/drivers/virtualbox" + //_ "github.com/docker/machine/drivers/vmwarefusion" + //_ "github.com/docker/machine/drivers/vmwarevcloudair" + //_ "github.com/docker/machine/drivers/vmwarevsphere" "github.com/docker/machine/state" "github.com/docker/machine/utils" ) @@ -554,9 +554,9 @@ func cmdSsh(c *cli.Context) { } if len(c.Args()) <= 1 { - sshCmd, err = host.Driver.GetSSHCommand() + sshCmd, err = host.GetSSHCommand() } else { - sshCmd, err = host.Driver.GetSSHCommand(c.Args()[1:]...) + sshCmd, err = host.GetSSHCommand(c.Args()[1:]...) } if err != nil { log.Fatal(err) @@ -578,7 +578,7 @@ func machineCommand(actionName string, machine *Host, errorChan chan<- error) { "stop": machine.Driver.Stop, "restart": machine.Driver.Restart, "kill": machine.Driver.Kill, - "upgrade": machine.Driver.Upgrade, + "upgrade": machine.Upgrade, } log.Debugf("command=%s machine=%s", actionName, machine.Name) diff --git a/commands_test.go b/commands_test.go index 51651a276f..1267533c31 100644 --- a/commands_test.go +++ b/commands_test.go @@ -12,6 +12,7 @@ import ( "github.com/codegangsta/cli" drivers "github.com/docker/machine/drivers" + "github.com/docker/machine/hypervisor" "github.com/docker/machine/state" ) @@ -23,6 +24,14 @@ func (d *FakeDriver) DriverName() string { return "fakedriver" } +func (d *FakeDriver) AuthorizePort(ports []*drivers.Port) error { + return nil +} + +func (d *FakeDriver) DeauthorizePort(ports []*drivers.Port) error { + return nil +} + func (d *FakeDriver) SetConfigFromFlags(flags drivers.DriverOptions) error { return nil } @@ -31,10 +40,34 @@ func (d *FakeDriver) GetURL() (string, error) { return "", nil } +func (d *FakeDriver) GetMachineName() string { + return "" +} + +func (d *FakeDriver) GetHypervisorType() hypervisor.HypervisorType { + return hypervisor.None +} + func (d *FakeDriver) GetIP() (string, error) { return "", nil } +func (d *FakeDriver) GetSSHAddress() (string, error) { + return "", nil +} + +func (d *FakeDriver) GetSSHKeyPath() string { + return "" +} + +func (d *FakeDriver) GetSSHPort() (int, error) { + return 0, nil +} + +func (d *FakeDriver) GetSSHUsername() string { + return "" +} + func (d *FakeDriver) GetState() (state.State, error) { return d.MockState, nil }