From 6511219f6defb9b9d83658ba73b79bfb76fdb5b6 Mon Sep 17 00:00:00 2001 From: Dave Henderson Date: Wed, 27 May 2015 14:12:36 -0400 Subject: [PATCH] Refactoring drivers to embed drivers.DefaultDriver Signed-off-by: Dave Henderson --- drivers/openstack/openstack.go | 53 ++-------------------------------- 1 file changed, 3 insertions(+), 50 deletions(-) diff --git a/drivers/openstack/openstack.go b/drivers/openstack/openstack.go index 3bae763..71becd1 100644 --- a/drivers/openstack/openstack.go +++ b/drivers/openstack/openstack.go @@ -3,7 +3,6 @@ package openstack import ( "fmt" "io/ioutil" - "path/filepath" "strings" "time" @@ -16,6 +15,7 @@ import ( ) type Driver struct { + *drivers.BaseDriver AuthUrl string Insecure bool DomainID string @@ -27,7 +27,6 @@ type Driver struct { Region string AvailabilityZone string EndpointType string - MachineName string MachineId string FlavorName string FlavorId string @@ -39,15 +38,6 @@ type Driver struct { SecurityGroups []string FloatingIpPool string FloatingIpPoolId string - SSHUser string - SSHPort int - IPAddress string - CaCertPath string - PrivateKeyPath string - storePath string - SwarmMaster bool - SwarmHost string - SwarmDiscovery string client Client } @@ -189,51 +179,14 @@ func NewDriver(machineName string, storePath string, caCert string, privateKey s } func NewDerivedDriver(machineName string, storePath string, client Client, caCert string, privateKey string) (*Driver, error) { - return &Driver{ - MachineName: machineName, - storePath: storePath, - client: client, - 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 + inner := drivers.NewBaseDriver(machineName, storePath, caCert, privateKey) + return &Driver{BaseDriver: inner, client: client}, nil } 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) { - if d.SSHPort == 0 { - d.SSHPort = 22 - } - - return d.SSHPort, nil -} - -func (d *Driver) GetSSHUsername() string { - if d.SSHUser == "" { - d.SSHUser = "root" - } - - return d.SSHUser -} - func (d *Driver) DriverName() string { return "openstack" }