Skip to content

Commit

Permalink
bugfix: change volume metadata struct
Browse files Browse the repository at this point in the history
change volume metadata struct for remote storage manager.

Signed-off-by: Rudy Zhang <rudyflyzhang@gmail.com>
  • Loading branch information
rudyfly committed May 4, 2018
1 parent 5ce1e4d commit aa9ab2a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 16 deletions.
12 changes: 6 additions & 6 deletions storage/volume/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (

// Config represents volume config struct.
type Config struct {
ControlAddress string
Timeout time.Duration // operation timeout.
RemoveVolume bool
DefaultBackend string `json:"volume-default-driver"`
VolumeMetaPath string `json:"volume-meta-dir"`
DriverAlias string `json:"volume-driver-alias"`
ControlAddress string `json:"control-address"`
Timeout time.Duration `json:"volume-timeout"` // operation timeout.
RemoveVolume bool `json:"remove-volume"`
DefaultBackend string `json:"volume-default-driver"`
VolumeMetaPath string `json:"volume-meta-dir"`
DriverAlias string `json:"volume-driver-alias"`
}
6 changes: 3 additions & 3 deletions storage/volume/modules/ceph/ceph.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (c *Ceph) Options() map[string]types.Option {
func (c *Ceph) Format(ctx driver.Context, v *types.Volume, s *types.Storage) error {
ctx.Log.Debugf("Ceph format volume: %s", v.Name)

device, err := rbdMap(ctx, v, s.Spec.Address, s.Spec.Key)
device, err := rbdMap(ctx, v, s.Spec.Address, s.Spec.Keyring)
if err != nil {
ctx.Log.Errorf("Ceph map volume: %s failed: %v", v.Name, err)
return err
Expand Down Expand Up @@ -159,7 +159,7 @@ func (c *Ceph) Attach(ctx driver.Context, v *types.Volume, s *types.Storage) err
volumePath := v.Path()

// Map rbd device
devName, err := rbdMap(ctx, v, s.Spec.Address, s.Spec.Key)
devName, err := rbdMap(ctx, v, s.Spec.Address, s.Spec.Keyring)
if err != nil {
ctx.Log.Errorf("Ceph volume: %s map error: %v", v.Name, err)
return err
Expand Down Expand Up @@ -257,7 +257,7 @@ func (c *Ceph) Report(ctx driver.Context) ([]*types.Storage, error) {
}
keyring := fmt.Sprintf("%s:%s", "admin", key.Value())
encoded := base64.StdEncoding.EncodeToString([]byte(keyring))
s.Spec.Key = encoded
s.Spec.Keyring = encoded

// get ceph quorum status
cmd := NewCephCommand("ceph", conf)
Expand Down
15 changes: 8 additions & 7 deletions storage/volume/types/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ import (

// StorageSpec represents storage spec.
type StorageSpec struct {
Type string `json:"type"` // storage type
ID string `json:"id,omitempty"` // storage uid or unique name
Name string `json:"name,omitempty"` // storage cluster name
Key string `json:"key,omitempty"` // storage access key
API string `json:"api"` // gateway address
Address string `json:"address"` // for ceph it's monitor ip:port,ip:port, pangu2's river master
PoolSpec map[string]PoolSpec `json:"poolspec"` // storage pool spec
Type string `json:"type"` // storage type
ID string `json:"id,omitempty"` // storage uid or unique name
API string `json:"api"` // gateway address
Address string `json:"address"` // storage address, such as ceph it's monitor ip:port,ip:port
PoolSpec map[string]PoolSpec `json:"poolspec"` // storage pool spec

ClusterName string `json:"clustername,omitempty"` // storage cluster name
Keyring string `json:"keyring,omitempty"` // storage access key, such as ceph's keyring user:secret
}

// PoolSpec represents storage pool spec.
Expand Down
2 changes: 2 additions & 0 deletions storage/volume/types/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,12 @@ type VolumeConfig struct {

// VolumeSpec represents volume spec.
type VolumeSpec struct {
ClusterAPI string `json:"clusterapi"`
ClusterID string `json:"clusterid"`
Selector Selector `json:"selector"`
Operable bool `json:"operable"`
Backend string `json:"backend,omitempty"`
MountMode string `json:"mountMode,omitempty"`
*VolumeConfig `json:"config,inline"`
Extra map[string]string `json:"extra"`
}
Expand Down

0 comments on commit aa9ab2a

Please sign in to comment.