Skip to content

Commit

Permalink
Merge pull request #536 from akutz/feature/cinder
Browse files Browse the repository at this point in the history
Cinder storage driver
  • Loading branch information
codenrhoden committed May 2, 2017
2 parents 72cc8d6 + d3bfca5 commit 66c4909
Show file tree
Hide file tree
Showing 15 changed files with 1,776 additions and 5 deletions.
56 changes: 56 additions & 0 deletions .docs/user-guide/storage-providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,61 @@ libstorage:
attached to another node. Mounting and writing to such a volume could lead to
data corruption.

## Cinder
The Cinder driver registers a storage driver named `cinder` with the
`libStorage` driver manager and is used to connect and manage storage on
Cinder-compatible instances, such as OpenStack.

### Configuration
The following is an example configuration of the OpenStack driver.

```yaml
cinder:
authURL: https://domain.com/openstack
userID: 0
userName: myusername
password: mypassword
tenantID: 0
tenantName: customer
domainID: 0
domainName: corp
regionName: USNW
availabilityZoneName: Gold
```

#### Configuration Notes
- `regionName` is optional, it should be empty if you only have one region.
- `availabilityZoneName` is optional, the volume will be created in the default
availability zone if not specified.

For information on the equivalent environment variable and CLI flag names
please see the section on how non top-level configuration properties are
[transformed](./config.md#configuration-properties).

### Activating the Driver
To activate the Cinder driver please follow the instructions for
[activating storage drivers](./config.md#storage-drivers),
using `cinder` as the driver name.

### Examples
Below is a full `config.yml` file that works with Cinder.

```yaml
libstorage:
# The libstorage.service property directs a libStorage client to direct its
# requests to the given service by default. It is not used by the server.
service: cinder
server:
services:
cinder:
driver: cinder
cinder:
authUrl: https://keystoneHost:35357/v2.0/
username: username
password: password
tenantName: tenantName
```

## Dell EMC
libStorage includes support for several Dell EMC storage platforms.

Expand Down Expand Up @@ -1183,6 +1238,7 @@ libstorage:
[here](https://docs.microsoft.com/en-us/azure/storage/storage-standard-storage)
and [here](https://docs.microsoft.com/en-us/azure/storage/storage-about-disks-and-vhds-linux).


## VirtualBox
The VirtualBox driver registers a storage driver named `virtualbox` with the
libStorage service registry and is used by VirtualBox's VMs to connect and
Expand Down
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1143,6 +1143,13 @@ test-rbd-clean:
test-vfs:
DRIVERS=vfs $(MAKE) ./drivers/storage/vfs/tests/vfs.test

test-cinder:
DRIVERS=cinder $(MAKE) deps
DRIVERS=cinder $(MAKE) ./drivers/storage/cinder/tests/cinder.test

test-cinder-clean:
DRIVERS=cinder $(MAKE) clean

clean: $(GO_CLEAN)

clobber: clean $(GO_CLOBBER)
Expand Down
1 change: 1 addition & 0 deletions api/types/types_drivers_os.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ type NewOSDriver func() OSDriver
type DeviceMountOpts struct {
MountOptions string
MountLabel string
FsType string
Opts Store
}

Expand Down
10 changes: 7 additions & 3 deletions drivers/os/linux/linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,13 @@ func (d *driver) Mount(
return nil
}

fsType, err := probeFsType(deviceName)
if err != nil {
return err
fsType := opts.FsType
if opts.FsType == "" {
var err error
fsType, err = probeFsType(deviceName)
if err != nil {
return err
}
}

options := formatMountLabel("", opts.MountLabel)
Expand Down
83 changes: 83 additions & 0 deletions drivers/storage/cinder/cinder.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// +build !libstorage_storage_driver libstorage_storage_driver_cinder

package cinder

import (
gofigCore "github.com/akutz/gofig"
gofig "github.com/akutz/gofig/types"
)

const (
// Name is the provider's name.
Name string = "cinder"

// ConfigAuthURL is the config key for the Identity Auth URL
ConfigAuthURL = Name + ".authURL"

// ConfigUserID is the config key for the user ID
ConfigUserID = Name + ".userID"

// ConfigUserName is the config key for the user name
ConfigUserName = Name + ".userName"

// ConfigPassword is the config key for the user password
ConfigPassword = Name + ".password"

// ConfigTokenID is the config key for the token ID
ConfigTokenID = Name + ".tokenID"

// ConfigTenantID is the config key for the tenant ID
ConfigTenantID = Name + ".tenantID"

// ConfigTenantName is the config key for the tenant name
ConfigTenantName = Name + ".tenantName"

// ConfigDomainID is the config key for the domain ID
ConfigDomainID = Name + ".domainID"

// ConfigDomainName is the config key for the domain name
ConfigDomainName = Name + ".domainName"

// ConfigRegionName is the config key for the region name
ConfigRegionName = Name + ".regionName"

// ConfigAvailabilityZoneName is the config key for the availability
// zone name
ConfigAvailabilityZoneName = Name + ".availabilityZoneName"

// ConfigTrustID is the config key for the trust ID
ConfigTrustID = Name + ".trustID"

// ConfigAttachTimeout is the config key for the attach timeout
ConfigAttachTimeout = Name + ".attachTimeout"

// ConfigDeleteTimeout is the config key for the delete timeout
ConfigDeleteTimeout = Name + ".deleteTimeout"

// ConfigCreateTimeout is the config key for the create timeout
ConfigCreateTimeout = Name + ".createTimeout"

// ConfigSnapshotTimeout is the config key for the snapshot timeout
ConfigSnapshotTimeout = Name + ".snapshotTimeout"
)

func init() {
r := gofigCore.NewRegistration("Cinder")
r.Key(gofig.String, "", "", "", ConfigAuthURL)
r.Key(gofig.String, "", "", "", ConfigUserID)
r.Key(gofig.String, "", "", "", ConfigUserName)
r.Key(gofig.String, "", "", "", ConfigPassword)
r.Key(gofig.String, "", "", "", ConfigTokenID)
r.Key(gofig.String, "", "", "", ConfigTenantID)
r.Key(gofig.String, "", "", "", ConfigTenantName)
r.Key(gofig.String, "", "", "", ConfigDomainID)
r.Key(gofig.String, "", "", "", ConfigDomainName)
r.Key(gofig.String, "", "", "", ConfigRegionName)
r.Key(gofig.String, "", "", "", ConfigAvailabilityZoneName)
r.Key(gofig.String, "", "", "", ConfigTrustID)
r.Key(gofig.String, "", "1m", "", ConfigAttachTimeout)
r.Key(gofig.String, "", "10m", "", ConfigDeleteTimeout)
r.Key(gofig.String, "", "10m", "", ConfigCreateTimeout)
r.Key(gofig.String, "", "10m", "", ConfigSnapshotTimeout)
gofigCore.Register(r)
}
Loading

0 comments on commit 66c4909

Please sign in to comment.