Skip to content

Commit

Permalink
[chore] add migrateStatus field into the volume entity
Browse files Browse the repository at this point in the history
  • Loading branch information
cuongpiger committed Jul 1, 2024
1 parent 6b5680c commit 1dd2a50
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 22 deletions.
2 changes: 1 addition & 1 deletion test/volume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func TestGetBlockVolumeByIdFailure(t *ltesting.T) {

func TestGetBlockVolumeByIdSuccess(t *ltesting.T) {
vngcloud := validSdkConfig()
opt := v2.NewGetBlockVolumeByIdRequest("vol-17dc6df0-43d3-4ad2-be88-69ddaef2f146")
opt := v2.NewGetBlockVolumeByIdRequest("vol-aa784f76-a13d-4f92-b807-d2df3180e030")
volume, sdkerr := vngcloud.VServerGateway().V2().VolumeService().GetBlockVolumeById(opt)
if sdkerr != nil {
t.Fatalf("Expect nil but got %v", sdkerr)
Expand Down
1 change: 1 addition & 0 deletions vngcloud/entity/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type Volume struct {
PersistentVolume bool
AttachedMachine []string
UnderId string
MigrateState string
}

type ListVolumes struct {
Expand Down
23 changes: 2 additions & 21 deletions vngcloud/services/volume/v2/blockvolume_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type (
Location *string `json:"location"`
Product string `json:"product"`
PersistentVolume bool `json:"persistentVolume"`
MigrateState string `json:"migrateState,omitempty"`
}
)

Expand All @@ -67,27 +68,6 @@ func (s *ListBlockVolumesResponse) ToEntityListVolumes() *lsentity.ListVolumes {
return lstVolumes
}

func (s *ListBlockVolumesResponse) toEntityVolume(pIdx int) *lsentity.Volume {
if s == nil {
return nil
}

if pIdx >= 0 && pIdx < len(s.ListData) {
vol := s.ListData[pIdx]
return &lsentity.Volume{
Id: vol.UUID,
Name: vol.Name,
Size: vol.Size,
Status: vol.Status,
CreatedAt: vol.CreatedAt,
UpdatedAt: vol.UpdatedAt,
VmId: vol.ServerID,
}
}

return nil
}

func (s *BlockVolume) toEntityVolume() *lsentity.Volume {
return &lsentity.Volume{
Id: s.UUID,
Expand All @@ -99,6 +79,7 @@ func (s *BlockVolume) toEntityVolume() *lsentity.Volume {
VmId: s.ServerID,
AttachedMachine: s.ServerIDList,
VolumeTypeID: s.VolumeTypeID,
MigrateState: s.MigrateState,
}
}

Expand Down

0 comments on commit 1dd2a50

Please sign in to comment.