fix delete disk panic

This commit is contained in:
wanyaoqi
2019-02-27 13:50:35 +08:00
parent 6ced91d2db
commit 4d21562556
+2 -1
View File
@@ -1395,7 +1395,8 @@ func (self *SDisk) PerformPurge(ctx context.Context, userCred mcclient.TokenCred
}
func (self *SDisk) CustomizeDelete(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) error {
if self.GetCloudprovider().Provider == CLOUD_PROVIDER_HUAWEI && self.GetSnapshotCount() > 0 {
provider := self.GetCloudprovider()
if provider != nil && provider.Provider == CLOUD_PROVIDER_HUAWEI && self.GetSnapshotCount() > 0 {
return httperrors.NewForbiddenError("not allow to delete. Virtual disk must not have snapshots")
}