diff --git a/pkg/compute/models/disks.go b/pkg/compute/models/disks.go index d4c2af46ef..08916d9a54 100644 --- a/pkg/compute/models/disks.go +++ b/pkg/compute/models/disks.go @@ -1038,13 +1038,15 @@ func (self *SDisk) StartDiskSaveTask(ctx context.Context, userCred mcclient.Toke func (self *SDisk) ValidateDeleteCondition(ctx context.Context) error { provider := self.GetCloudprovider() - if provider != nil && !provider.IsAvailable() { - return httperrors.NewNotSufficientPrivilegeError("cloud provider %s is not available", provider.GetName()) - } + if provider != nil { + if !provider.IsAvailable() { + return httperrors.NewNotSufficientPrivilegeError("cloud provider %s is not available", provider.GetName()) + } - account := provider.GetCloudaccount() - if account != nil && !account.IsAvailable() { - return httperrors.NewNotSufficientPrivilegeError("cloud account %s is not available", account.GetName()) + account := provider.GetCloudaccount() + if account != nil && !account.IsAvailable() { + return httperrors.NewNotSufficientPrivilegeError("cloud account %s is not available", account.GetName()) + } } return self.validateDeleteCondition(ctx, false) @@ -1070,13 +1072,15 @@ func (self *SDisk) validateDeleteCondition(ctx context.Context, isPurge bool) er func (self *SDisk) AllowDeleteItem(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) bool { provider := self.GetCloudprovider() - if provider != nil && !provider.IsAvailable() { - return false - } + if provider != nil { + if !provider.IsAvailable() { + return false + } - account := provider.GetCloudaccount() - if account != nil && !account.IsAvailable() { - return false + account := provider.GetCloudaccount() + if account != nil && !account.IsAvailable() { + return false + } } overridePendingDelete := false diff --git a/pkg/compute/models/loadbalancers.go b/pkg/compute/models/loadbalancers.go index 6730bfe98d..79f8a9ad24 100644 --- a/pkg/compute/models/loadbalancers.go +++ b/pkg/compute/models/loadbalancers.go @@ -692,7 +692,7 @@ func (self *SLoadbalancer) DeleteEip(ctx context.Context, userCred mcclient.Toke } func (self *SLoadbalancer) GetEip() (*SElasticip, error) { - return ElasticipManager.getEipForInstance(api.EIP_ASSOCIATE_TYPE_LOADBALANCER, self.Id) + return ElasticipManager.getEip(api.EIP_ASSOCIATE_TYPE_LOADBALANCER, self.Id, "") } func (self *SLoadbalancer) SyncLoadbalancerEip(ctx context.Context, userCred mcclient.TokenCredential, provider *SCloudprovider, extEip cloudprovider.ICloudEIP) compare.SyncResult {