mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #8392 from rainzm/fix/snapshotpolicy2
Fix of snapshotpolicy
This commit is contained in:
@@ -301,8 +301,9 @@ func FetchCustomizeColumns(
|
||||
retVal := make([]*jsonutils.JSONDict, ret[0].Len())
|
||||
for i := 0; i < ret[0].Len(); i += 1 {
|
||||
jsonDict := ValueToJSONDict(ret[0].Index(i))
|
||||
jsonDict.Update(jsonutils.Marshal(objs[i]).(*jsonutils.JSONDict))
|
||||
retVal[i] = jsonDict
|
||||
objDict := jsonutils.Marshal(objs[i]).(*jsonutils.JSONDict)
|
||||
objDict.Update(jsonDict)
|
||||
retVal[i] = objDict
|
||||
}
|
||||
return retVal, nil
|
||||
}
|
||||
|
||||
@@ -310,11 +310,11 @@ func (sp *SSnapshotPolicy) DetachAfterDelete(ctx context.Context, userCred mccli
|
||||
|
||||
func (sp *SSnapshotPolicy) CustomizeDelete(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) error {
|
||||
// check if sp bind to some disks
|
||||
sds, err := SnapshotPolicyDiskManager.FetchAllBySnapshotpolicyID(ctx, userCred, sp.GetId())
|
||||
count, err := SnapshotPolicyDiskManager.FetchDiskCountBySPID(sp.Id)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "fetch bind info failed")
|
||||
return errors.Wrap(err, "unable to FetchDiskCountBySPID")
|
||||
}
|
||||
if len(sds) != 0 {
|
||||
if count != 0 {
|
||||
return httperrors.NewBadRequestError("Couldn't delete snapshot policy binding to disks")
|
||||
}
|
||||
sp.SetStatus(userCred, api.SNAPSHOT_POLICY_DELETING, "")
|
||||
|
||||
Reference in New Issue
Block a user