Browse Source

Refactoring drivers to embed drivers.DefaultDriver

Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Dave Henderson 3 years ago
parent
commit
6511219f6d
1 changed files with 3 additions and 50 deletions
  1. 3
    50
      drivers/openstack/openstack.go

+ 3
- 50
drivers/openstack/openstack.go View File

@@ -3,7 +3,6 @@ package openstack
3 3
 import (
4 4
 	"fmt"
5 5
 	"io/ioutil"
6
-	"path/filepath"
7 6
 	"strings"
8 7
 	"time"
9 8
 
@@ -16,6 +15,7 @@ import (
16 15
 )
17 16
 
18 17
 type Driver struct {
18
+	*drivers.BaseDriver
19 19
 	AuthUrl          string
20 20
 	Insecure         bool
21 21
 	DomainID         string
@@ -27,7 +27,6 @@ type Driver struct {
27 27
 	Region           string
28 28
 	AvailabilityZone string
29 29
 	EndpointType     string
30
-	MachineName      string
31 30
 	MachineId        string
32 31
 	FlavorName       string
33 32
 	FlavorId         string
@@ -39,15 +38,6 @@ type Driver struct {
39 38
 	SecurityGroups   []string
40 39
 	FloatingIpPool   string
41 40
 	FloatingIpPoolId string
42
-	SSHUser          string
43
-	SSHPort          int
44
-	IPAddress        string
45
-	CaCertPath       string
46
-	PrivateKeyPath   string
47
-	storePath        string
48
-	SwarmMaster      bool
49
-	SwarmHost        string
50
-	SwarmDiscovery   string
51 41
 	client           Client
52 42
 }
53 43
 
@@ -189,51 +179,14 @@ func NewDriver(machineName string, storePath string, caCert string, privateKey s
189 179
 }
190 180
 
191 181
 func NewDerivedDriver(machineName string, storePath string, client Client, caCert string, privateKey string) (*Driver, error) {
192
-	return &Driver{
193
-		MachineName:    machineName,
194
-		storePath:      storePath,
195
-		client:         client,
196
-		CaCertPath:     caCert,
197
-		PrivateKeyPath: privateKey,
198
-	}, nil
199
-}
200
-
201
-func (d *Driver) AuthorizePort(ports []*drivers.Port) error {
202
-	return nil
203
-}
204
-
205
-func (d *Driver) DeauthorizePort(ports []*drivers.Port) error {
206
-	return nil
207
-}
208
-
209
-func (d *Driver) GetMachineName() string {
210
-	return d.MachineName
182
+	inner := drivers.NewBaseDriver(machineName, storePath, caCert, privateKey)
183
+	return &Driver{BaseDriver: inner, client: client}, nil
211 184
 }
212 185
 
213 186
 func (d *Driver) GetSSHHostname() (string, error) {
214 187
 	return d.GetIP()
215 188
 }
216 189
 
217
-func (d *Driver) GetSSHKeyPath() string {
218
-	return filepath.Join(d.storePath, "id_rsa")
219
-}
220
-
221
-func (d *Driver) GetSSHPort() (int, error) {
222
-	if d.SSHPort == 0 {
223
-		d.SSHPort = 22
224
-	}
225
-
226
-	return d.SSHPort, nil
227
-}
228
-
229
-func (d *Driver) GetSSHUsername() string {
230
-	if d.SSHUser == "" {
231
-		d.SSHUser = "root"
232
-	}
233
-
234
-	return d.SSHUser
235
-}
236
-
237 190
 func (d *Driver) DriverName() string {
238 191
 	return "openstack"
239 192
 }

Loading…
Cancel
Save