Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amazon EBS Storage Driver #248

Merged
merged 1 commit into from
Sep 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions api/drivers/storage/ebs/ebs_config_compat.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package types

import "github.com/akutz/gofig"
import log "github.com/Sirupsen/logrus"

const (
//ConfigEBS is a config key.
ConfigEBS = "ebs"

//ConfigEBSAccessKey is a config key.
ConfigEBSAccessKey = ConfigEBS + ".accessKey"

//ConfigEBSSecretKey is a config key.
ConfigEBSSecretKey = ConfigEBS + ".secretKey"

//ConfigEBSRegion is a config key.
ConfigEBSRegion = ConfigEBS + ".region"

//ConfigEBSEndpoint is a config key.
ConfigEBSEndpoint = ConfigEBS + ".endpoint"

//ConfigEBSMaxRetries is a config key.
ConfigEBSMaxRetries = ConfigEBS + ".maxRetries"

//ConfigEBSTag is a config key.
ConfigEBSTag = ConfigEBS + ".tag"

//ConfigEBSRexrayTag is a config key.
ConfigEBSRexrayTag = ConfigEBS + ".rexrayTag"

//ConfigOldEBS is a config key.
ConfigOldEBS = "ec2"

//ConfigOldEBSAccessKey is a config key.
ConfigOldEBSAccessKey = ConfigOldEBS + ".accessKey"

//ConfigOldEBSSecretKey is a config key.
ConfigOldEBSSecretKey = ConfigOldEBS + ".secretKey"

//ConfigOldEBSRegion is a config key.
ConfigOldEBSRegion = ConfigOldEBS + ".region"

//ConfigOldEBSEndpoint is a config key.
ConfigOldEBSEndpoint = ConfigOldEBS + ".endpoint"

//ConfigOldEBSMaxRetries is a config key.
ConfigOldEBSMaxRetries = ConfigOldEBS + ".maxRetries"

//ConfigOldEBSTag is a config key.
ConfigOldEBSTag = ConfigOldEBS + ".tag"

//ConfigOldEBSRexrayTag is a config key.
ConfigOldEBSRexrayTag = ConfigOldEBS + ".rexrayTag"
)

// BackCompat ensures keys can be used from old configurations.
func BackCompat(config gofig.Config) {
checks := [][]string{
{ConfigEBSAccessKey, ConfigOldEBSAccessKey},
{ConfigEBSSecretKey, ConfigOldEBSSecretKey},
{ConfigEBSRegion, ConfigOldEBSRegion},
{ConfigEBSEndpoint, ConfigOldEBSEndpoint},
{ConfigEBSMaxRetries, ConfigOldEBSMaxRetries},
{ConfigEBSTag, ConfigOldEBSTag},
{ConfigEBSRexrayTag, ConfigOldEBSRexrayTag},
}
for _, check := range checks {
if !config.IsSet(check[0]) && config.IsSet(check[1]) {
log.Debug(config.Get(check[1]))
config.Set(check[0], config.Get(check[1]))
}
}
}
1 change: 1 addition & 0 deletions api/server/router/volume/volume_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ func (r *router) volumeCreate(
IOPS: store.GetInt64Ptr("iops"),
Size: store.GetInt64Ptr("size"),
Type: store.GetStringPtr("type"),
Encrypted: store.GetBoolPtr("encrypted"),
Opts: store,
})

Expand Down
1 change: 1 addition & 0 deletions api/types/types_drivers_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type VolumeCreateOpts struct {
IOPS *int64
Size *int64
Type *string
Encrypted *bool
Opts Store
}

Expand Down
1 change: 1 addition & 0 deletions api/types/types_http_requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ type NewRequestObjFunc func() interface{}
type VolumeCreateRequest struct {
Name string `json:"name"`
AvailabilityZone *string `json:"availabilityZone,omitempty"`
Encrypted *bool `json:"encrypted,omitempty"`
IOPS *int64 `json:"iops,omitempty"`
Size *int64 `json:"size,omitempty"`
Type *string `json:"type,omitempty"`
Expand Down
6 changes: 6 additions & 0 deletions api/types/types_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ type Snapshot struct {
// The name of the snapshot.
Name string `json:"name,omitempty" yaml:",omitempty"`

// A flag indicating whether or not the snapshot is encrypted.
Encrypted bool `json:"encrypted,omitempty" yaml:"encrypted,omitempty"`

// The snapshot's ID.
ID string `json:"id" yaml:"id"`

Expand Down Expand Up @@ -129,6 +132,9 @@ type Volume struct {
// The availability zone for which the volume is available.
AvailabilityZone string `json:"availabilityZone,omitempty" yaml:"availabilityZone,omitempty"`

// A flag indicating whether or not the volume is encrypted.
Encrypted bool `json:"encrypted,omitempty" yaml:"encrypted,omitempty"`

// The volume IOPs.
IOPS int64 `json:"iops,omitempty" yaml:"iops,omitempty"`

Expand Down
11 changes: 11 additions & 0 deletions api/utils/schema/schema_generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ const (
"type": "string",
"description": "The zone for which the volume is available."
},
"encrypted": {
"type": "boolean",
"description": "A flag indicating whether or not the volume is encrypted."
},
"iops": {
"type": "number",
"description": "The volume IOPs."
Expand Down Expand Up @@ -156,6 +160,10 @@ const (
"type": "string",
"description": "A description of the snapshot."
},
"encrypted": {
"type": "boolean",
"description": "A flag indicating whether or not the snapshot is encrypted."
},
"startTime": {
"type": "number",
"description": "The time (epoch) at which the request to create the snapshot was submitted."
Expand Down Expand Up @@ -419,6 +427,9 @@ const (
"availabilityZone": {
"type": "string"
},
"encrypted": {
"type": "boolean"
},
"iops": {
"type": "number"
},
Expand Down
37 changes: 37 additions & 0 deletions drivers/storage/ebs/ebs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package ebs

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

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

// TagDelimiter separates tags from volume or snapshot names
TagDelimiter = "/"

// DefaultMaxRetries is the max number of times to retry failed operations
DefaultMaxRetries = 10
)

func init() {
registerConfig()
}

func registerConfig() {
r := gofig.NewRegistration("EBS")
r.Key(gofig.String, "", "", "", "ebs.accessKey")
r.Key(gofig.String, "", "", "", "ebs.secretKey")
r.Key(gofig.String, "", "", "", "ebs.region")
r.Key(gofig.String, "", "", "", "ebs.endpoint")
r.Key(gofig.String, "", "", "", "ebs.maxRetries")
r.Key(gofig.String, "", "", "Tag prefix for EBS naming", "ebs.tag")
r.Key(gofig.String, "", "", "", "ec2.accessKey")
r.Key(gofig.String, "", "", "", "ec2.secretKey")
r.Key(gofig.String, "", "", "", "ec2.region")
r.Key(gofig.String, "", "", "", "ec2.endpoint")
r.Key(gofig.String, "", "", "", "ec2.maxRetries")
r.Key(gofig.String, "", "", "Tag prefix for EBS naming", "ec2.tag")
gofig.Register(r)
}
Loading