Refactoring drivers to embed drivers.DefaultDriver
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
This commit is contained in:
parent
e10e42cbb7
commit
6511219f6d
|
@ -3,7 +3,6 @@ package openstack
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"path/filepath"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -16,6 +15,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Driver struct {
|
type Driver struct {
|
||||||
|
*drivers.BaseDriver
|
||||||
AuthUrl string
|
AuthUrl string
|
||||||
Insecure bool
|
Insecure bool
|
||||||
DomainID string
|
DomainID string
|
||||||
|
@ -27,7 +27,6 @@ type Driver struct {
|
||||||
Region string
|
Region string
|
||||||
AvailabilityZone string
|
AvailabilityZone string
|
||||||
EndpointType string
|
EndpointType string
|
||||||
MachineName string
|
|
||||||
MachineId string
|
MachineId string
|
||||||
FlavorName string
|
FlavorName string
|
||||||
FlavorId string
|
FlavorId string
|
||||||
|
@ -39,15 +38,6 @@ type Driver struct {
|
||||||
SecurityGroups []string
|
SecurityGroups []string
|
||||||
FloatingIpPool string
|
FloatingIpPool string
|
||||||
FloatingIpPoolId string
|
FloatingIpPoolId string
|
||||||
SSHUser string
|
|
||||||
SSHPort int
|
|
||||||
IPAddress string
|
|
||||||
CaCertPath string
|
|
||||||
PrivateKeyPath string
|
|
||||||
storePath string
|
|
||||||
SwarmMaster bool
|
|
||||||
SwarmHost string
|
|
||||||
SwarmDiscovery string
|
|
||||||
client Client
|
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) {
|
func NewDerivedDriver(machineName string, storePath string, client Client, caCert string, privateKey string) (*Driver, error) {
|
||||||
return &Driver{
|
inner := drivers.NewBaseDriver(machineName, storePath, caCert, privateKey)
|
||||||
MachineName: machineName,
|
return &Driver{BaseDriver: inner, client: client}, nil
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) GetSSHHostname() (string, error) {
|
func (d *Driver) GetSSHHostname() (string, error) {
|
||||||
return d.GetIP()
|
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 {
|
func (d *Driver) DriverName() string {
|
||||||
return "openstack"
|
return "openstack"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue