Skip to content
Open
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
40 changes: 29 additions & 11 deletions lib/provider/data_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ type Volume struct {
// The Capacity of the volume, in GiB
Capacity *int `json:"capacity"`

// The size of the snapshot space, in GiB
SnapshotSpace *int `json:"snapshotSpace,omitempty"`

// Volume IOPS for performance storage type only
Iops *string `json:"iops"`

Expand Down Expand Up @@ -98,26 +95,38 @@ type Volume struct {

// Only for VPC volume provider
VPCVolume

// ID of snapshot to be restored
SnapshotID string `json:"snapshotID,omitempty"`
}

// Snapshot ...
type Snapshot struct {
Volume
VolumeID string `json:"volumeID"`

// a unique Snapshot ID which created by the provider
SnapshotID string `json:"snapshotID,omitempty"`

// The size of the snapshot, in GiB
SnapshotSize *int `json:"snapshotSize,omitempty"`
SnapshotID string `json:"snapshotID"`

// Source volume details
//SnapshotedVolume *Volume `json:"SnapshotedVolume"`
// The size of the snapshot, in bytes
SnapshotSize int64 `json:"snapshotSize"`

// Time stamp when snapshot creation was initiated
SnapshotCreationTime time.Time `json:"snapCreationTime,omitempty"`
SnapshotCreationTime time.Time `json:"snapCreationTime"`

// tags for the snapshot
SnapshotTags SnapshotTags `json:"tags,omitempty"`

// status of snapshot
ReadyToUse bool `json:"readyToUse"`

// VPC contains vpc fields
VPC
}

// SnapshotList ...
type SnapshotList struct {
Next string `json:"next,omitempty"`
Snapshots []*Snapshot `json:"snapshots"`
}

// VolumeAuthorization capture details of autorization to be made
Expand Down Expand Up @@ -148,3 +157,12 @@ type ExpandVolumeRequest struct {
// The new Capacity of the volume, in GiB
Capacity int64 `json:"capacity"`
}

// SnapshotParameters ...
type SnapshotParameters struct {
// Name of snapshot
Name string `json:"name,omitempty"`

// tags for the snapshot
SnapshotTags SnapshotTags `json:"tags,omitempty"`
}
13 changes: 4 additions & 9 deletions lib/provider/default_volume_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func (volprov *DefaultVolumeProvider) OrderSnapshot(VolumeRequest Volume) error
}

// CreateSnapshot on the volume
func (volprov *DefaultVolumeProvider) CreateSnapshot(volume *Volume, tags map[string]string) (*Snapshot, error) {
func (volprov *DefaultVolumeProvider) CreateSnapshot(sourceVolumeID string, snapshotParameters SnapshotParameters) (*Snapshot, error) {
return nil, nil
}

Expand All @@ -132,18 +132,13 @@ func (volprov *DefaultVolumeProvider) GetSnapshot(snapshotID string) (*Snapshot,
return nil, nil
}

//GetSnapshotWithVolumeID gets the snapshot with volumeID
func (volprov *DefaultVolumeProvider) GetSnapshotWithVolumeID(volumeID string, snapshotID string) (*Snapshot, error) {
//GetSnapshotByName gets the snapshot

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider resource group also

func (volprov *DefaultVolumeProvider) GetSnapshotByName(snapshotName string) (*Snapshot, error) {
return nil, nil
}

//ListSnapshots list the snapshots
func (volprov *DefaultVolumeProvider) ListSnapshots() ([]*Snapshot, error) {
return nil, nil
}

//ListAllSnapshots list all the snapshots
func (volprov *DefaultVolumeProvider) ListAllSnapshots(volumeID string) ([]*Snapshot, error) {
func (volprov *DefaultVolumeProvider) ListSnapshots(limit int, start string, tags map[string]string) (*SnapshotList, error) {
return nil, nil
}

Expand Down
20 changes: 3 additions & 17 deletions lib/provider/default_volume_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ func TestOrderSnapshot(t *testing.T) {
func TestCreateSnapshot(t *testing.T) {
ccf := &DefaultVolumeProvider{sess: nil}

volume, _ := ccf.CreateSnapshot(&Volume{}, nil)
assert.Nil(t, volume)
snapshot, _ := ccf.CreateSnapshot("vol-id", SnapshotParameters{})
assert.Nil(t, snapshot)
}

func TestDeleteSnapshot(t *testing.T) {
Expand All @@ -128,27 +128,13 @@ func TestGetSnapshot(t *testing.T) {
assert.Nil(t, getSnap)
}

func TestGetSnapshotWithVolumeID(t *testing.T) {
ccf := &DefaultVolumeProvider{sess: nil}

getSnapWithID, _ := ccf.GetSnapshotWithVolumeID("VolumeID", "SnapshotID")
assert.Nil(t, getSnapWithID)
}

func TestListSnapshots(t *testing.T) {
ccf := &DefaultVolumeProvider{sess: nil}

listSnapWithID, _ := ccf.ListSnapshots()
listSnapWithID, _ := ccf.ListSnapshots(50, "1", nil)
assert.Nil(t, listSnapWithID)
}

func TestListAllSnapshots(t *testing.T) {
ccf := &DefaultVolumeProvider{sess: nil}

listAllSnapWithID, _ := ccf.ListAllSnapshots("VolumeID")
assert.Nil(t, listAllSnapWithID)
}

func TestUpdateVolume(t *testing.T) {
ccf := &DefaultVolumeProvider{sess: nil}

Expand Down
Loading