/
pwx.go
50 lines (43 loc) · 1.18 KB
/
pwx.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package pwx
import (
"github.com/libopenstorage/openstorage/api"
"github.com/libopenstorage/openstorage/api/client"
volumeclient "github.com/libopenstorage/openstorage/api/client/volume"
"github.com/libopenstorage/openstorage/config"
"github.com/libopenstorage/openstorage/volume"
)
const (
// Name of the driver
Name = "pwx"
// Type of the driver
Type = api.DriverType_DRIVER_TYPE_BLOCK
// DefaultUrl where the driver's socket resides
DefaultUrl = "unix:///" + volume.DriverAPIBase + "pxd.sock"
)
type driver struct {
volume.VolumeDriver
}
// Init initialized the Portworx driver.
// Portworx natively implements the openstorage.org API specification, so
// we can directly point the VolumeDriver to the PWX API server.
func Init(params map[string]string) (volume.VolumeDriver, error) {
url, ok := params[config.UrlKey]
if !ok {
url = DefaultUrl
}
version, ok := params[config.VersionKey]
if !ok {
version = volume.APIVersion
}
c, err := client.NewClient(url, version, "")
if err != nil {
return nil, err
}
return &driver{VolumeDriver: volumeclient.VolumeDriver(c)}, nil
}
func (d *driver) Name() string {
return Name
}
func (d *driver) Type() api.DriverType {
return Type
}