@@ -60,9 +60,10 @@ type SnapshotInfoData struct {
60
60
}
61
61
62
62
const (
63
- SNAPSHOT_SUBURI = "/SnapshotCloneService"
64
- ACTION_GET_FILE_SNAPSHOT_LIST = "GetFileSnapshotList"
65
- ENTRIES_PER_TIME = 100
63
+ SNAPSHOT_QUERY_LIMIT = 100
64
+ SNAPSHOT_QUERY_INITIAL_OFFSET = 0
65
+ SNAPSHOT_QUERY_CODE_SUCCESS = "0"
66
+ LENGTH_EMPTY = 0
66
67
)
67
68
68
69
const (
@@ -114,7 +115,7 @@ func NewVolumeSnapshotCommand() *SnapshotCommand {
114
115
vsCmd := & SnapshotCommand {
115
116
FinalCurveCmd : basecmd.FinalCurveCmd {
116
117
Use : "snapshot" ,
117
- Short : "create snapshot of curvebs volume " ,
118
+ Short : "show the snapshot status " ,
118
119
},
119
120
}
120
121
basecmd .NewFinalCurveCli (& vsCmd .FinalCurveCmd , vsCmd )
@@ -142,13 +143,10 @@ func (sCmd *SnapshotCommand) RunCommand(cmd *cobra.Command, args []string) error
142
143
cobrautil .QueryAction : cobrautil .ActionGetFileSnapshotList ,
143
144
cobrautil .QueryUser : sCmd .user ,
144
145
cobrautil .QueryFile : sCmd .filename ,
145
- cobrautil .QueryLimit : 100 ,
146
- cobrautil .QueryOffset : 0 ,
146
+ cobrautil .QueryLimit : SNAPSHOT_QUERY_LIMIT ,
147
+ cobrautil .QueryOffset : SNAPSHOT_QUERY_INITIAL_OFFSET ,
147
148
}
148
149
count := make (map [int ]int )
149
- for _ , s := range statusList {
150
- count [s ] = 0
151
- }
152
150
for {
153
151
subUri := cobrautil .NewSnapshotQuerySubUri (params )
154
152
@@ -162,10 +160,10 @@ func (sCmd *SnapshotCommand) RunCommand(cmd *cobra.Command, args []string) error
162
160
if err := json .Unmarshal ([]byte (result ), & resp ); err != nil {
163
161
return err
164
162
}
165
- if resp .Code != "0" {
163
+ if resp .Code != SNAPSHOT_QUERY_CODE_SUCCESS {
166
164
return fmt .Errorf ("get clone list fail, error code: %s" , resp .Code )
167
165
}
168
- if len (resp .Snapshots ) == 0 {
166
+ if len (resp .Snapshots ) == LENGTH_EMPTY {
169
167
break
170
168
}
171
169
for _ , s := range resp .Snapshots {
0 commit comments