diff --git a/pkg/cloudcommon/db/virtualresource.go b/pkg/cloudcommon/db/virtualresource.go index 7945353b40..8224741df5 100644 --- a/pkg/cloudcommon/db/virtualresource.go +++ b/pkg/cloudcommon/db/virtualresource.go @@ -213,7 +213,7 @@ func (model *SVirtualResourceBase) AllowPerformChangeOwner(ctx context.Context, func (model *SVirtualResourceBase) PerformChangeOwner(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) { tenant := jsonutils.GetAnyString(data, []string{"project", "tenant", "project_id", "tenant_id"}) if len(tenant) == 0 { - return nil, httperrors.NewInputParameterError("missing parameter tenant") + return nil, httperrors.NewMissingParameterError("tenant_id") } tobj, _ := TenantCacheManager.FetchTenantByIdOrName(ctx, tenant) if tobj == nil { diff --git a/pkg/compute/hostdrivers/managedvirtual.go b/pkg/compute/hostdrivers/managedvirtual.go index f3e931b175..2061231381 100644 --- a/pkg/compute/hostdrivers/managedvirtual.go +++ b/pkg/compute/hostdrivers/managedvirtual.go @@ -13,7 +13,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudprovider" "yunion.io/x/onecloud/pkg/compute/models" "yunion.io/x/onecloud/pkg/compute/options" - "yunion.io/x/onecloud/pkg/httperrors" ) type SManagedVirtualizationHostDriver struct { @@ -147,7 +146,7 @@ func (self *SManagedVirtualizationHostDriver) RequestSaveUploadImageOnHost(ctx c } iStoragecache := iStorage.GetIStoragecache() if iStoragecache == nil { - return httperrors.NewResourceNotFoundError("fail to find iStoragecache for storage: %s", iStorage.GetName()) + return fmt.Errorf("fail to find iStoragecache for storage: %s", iStorage.GetName()) } taskman.LocalTaskRun(task, func() (jsonutils.JSONObject, error) { snapshot, err := iDisk.CreateISnapshot(ctx, fmt.Sprintf("Snapshot-%s", imageId), "PrepareSaveImage") diff --git a/pkg/compute/models/cloudproviders.go b/pkg/compute/models/cloudproviders.go index 6ee076f6a9..9288c047d9 100644 --- a/pkg/compute/models/cloudproviders.go +++ b/pkg/compute/models/cloudproviders.go @@ -471,7 +471,7 @@ func (self *SCloudprovider) AllowPerformChangeProject(ctx context.Context, userC func (self *SCloudprovider) PerformChangeProject(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) { project, err := data.GetString("project") if err != nil { - return nil, httperrors.NewInputParameterError("Missing project parameter") + return nil, httperrors.NewMissingParameterError("project") } tenant, err := db.TenantCacheManager.FetchTenantByIdOrName(ctx, project) diff --git a/pkg/compute/models/cloudregions.go b/pkg/compute/models/cloudregions.go index ad32f71d41..4ce50333bd 100644 --- a/pkg/compute/models/cloudregions.go +++ b/pkg/compute/models/cloudregions.go @@ -333,7 +333,7 @@ func (self *SCloudregion) PerformDefaultVpc(ctx context.Context, userCred mcclie } vpcStr, _ := data.GetString("vpc") if len(vpcStr) == 0 { - return nil, httperrors.NewInputParameterError("no vpc id") + return nil, httperrors.NewMissingParameterError("vpc") } findVpc := false for _, vpc := range vpcs { diff --git a/pkg/compute/models/dynamicschedtags.go b/pkg/compute/models/dynamicschedtags.go index f80008ebb8..d337916ca2 100644 --- a/pkg/compute/models/dynamicschedtags.go +++ b/pkg/compute/models/dynamicschedtags.go @@ -7,6 +7,7 @@ import ( "yunion.io/x/log" "database/sql" + "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" @@ -66,7 +67,7 @@ func (self *SDynamicschedtag) AllowDeleteItem(ctx context.Context, userCred mccl func validateDynamicSchedtagInputData(data *jsonutils.JSONDict, create bool) error { condStr := jsonutils.GetAnyString(data, []string{"condition"}) if len(condStr) == 0 && create { - return httperrors.NewInputParameterError("empty condition") + return httperrors.NewMissingParameterError("condition") } if len(condStr) > 0 && !conditionparser.IsValid(condStr) { return httperrors.NewInputParameterError("invalid condition") @@ -74,7 +75,7 @@ func validateDynamicSchedtagInputData(data *jsonutils.JSONDict, create bool) err schedStr := jsonutils.GetAnyString(data, []string{"schedtag", "schedtag_id"}) if len(schedStr) == 0 && create { - return httperrors.NewInputParameterError("missing schedtag") + return httperrors.NewMissingParameterError("schedtag_id") } if len(schedStr) > 0 { schedObj, err := SchedtagManager.FetchByIdOrName(nil, schedStr) diff --git a/pkg/compute/models/elasticips.go b/pkg/compute/models/elasticips.go index d1786cb9fc..b81b081b42 100644 --- a/pkg/compute/models/elasticips.go +++ b/pkg/compute/models/elasticips.go @@ -501,7 +501,7 @@ func (manager *SElasticipManager) getEipByExtEip(ctx context.Context, userCred m func (manager *SElasticipManager) ValidateCreateData(ctx context.Context, userCred mcclient.TokenCredential, ownerProjId string, query jsonutils.JSONObject, data *jsonutils.JSONDict) (*jsonutils.JSONDict, error) { regionStr := jsonutils.GetAnyString(data, []string{"region", "region_id"}) if len(regionStr) == 0 { - return nil, httperrors.NewInputParameterError("Missing region/region_id") + return nil, httperrors.NewMissingParameterError("region_id") } region, err := CloudregionManager.FetchByIdOrName(nil, regionStr) if err != nil { @@ -515,7 +515,7 @@ func (manager *SElasticipManager) ValidateCreateData(ctx context.Context, userCr managerStr := jsonutils.GetAnyString(data, []string{"manager", "manager_id"}) if len(managerStr) == 0 { - return nil, httperrors.NewInputParameterError("Missing manager/manager_id") + return nil, httperrors.NewMissingParameterError("manager_id") } provider, err := CloudproviderManager.FetchByIdOrName(nil, managerStr) @@ -621,7 +621,7 @@ func (self *SElasticip) PerformAssociate(ctx context.Context, userCred mcclient. instanceId := jsonutils.GetAnyString(data, []string{"instance", "instance_id"}) if len(instanceId) == 0 { - return nil, httperrors.NewInputParameterError("Missing instance_id") + return nil, httperrors.NewMissingParameterError("instance_id") } instanceType := jsonutils.GetAnyString(data, []string{"instance_type"}) if len(instanceType) == 0 { diff --git a/pkg/compute/models/guest_actions.go b/pkg/compute/models/guest_actions.go index a39451b604..378e053d0d 100644 --- a/pkg/compute/models/guest_actions.go +++ b/pkg/compute/models/guest_actions.go @@ -251,7 +251,7 @@ func (self *SGuest) PerformLiveMigrate(ctx context.Context, userCred mcclient.To return nil, err } if image.DiskFormat != "qcow2" { - return nil, httperrors.NewBadRequestError("Live migrate only support image fromat qocw2") + return nil, httperrors.NewBadRequestError("Live migrate only support image format qocw2") } if utils.IsInStringArray(self.Status, []string{VM_RUNNING, VM_SUSPEND}) { cdrom := self.getCdrom() @@ -1374,7 +1374,7 @@ func (self *SGuest) PerformChangeIpaddr(ctx context.Context, userCred mcclient.T netDesc, err := data.Get("net_desc") if err != nil { log.Errorf("net_desc not found") - return nil, httperrors.NewInputParameterError("missing net_desc") + return nil, httperrors.NewMissingParameterError("net_desc") } conf, err := parseNetworkInfo(userCred, netDesc) if err != nil { @@ -2048,7 +2048,7 @@ func (self *SGuest) AllowPerformSendkeys(ctx context.Context, userCred mcclient. func (self *SGuest) PerformSendkeys(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) { if self.Hypervisor != HYPERVISOR_KVM { - return nil, httperrors.NewUnsupportOperationError("Not allow for hypervisor %s", self.Hypervisor) + return nil, httperrors.NewNotAcceptableError("Not allow for hypervisor %s", self.Hypervisor) } if self.Status != VM_RUNNING { return nil, httperrors.NewInvalidStatusError("Cannot send keys in status %s", self.Status) @@ -2136,7 +2136,7 @@ func (self *SGuest) PerformAssociateEip(ctx context.Context, userCred mcclient.T } eipStr := jsonutils.GetAnyString(data, []string{"eip", "eip_id"}) if len(eipStr) == 0 { - return nil, httperrors.NewInputParameterError("missing eip or eip_id") + return nil, httperrors.NewMissingParameterError("eip_id") } eipObj, err := ElasticipManager.FetchByIdOrName(userCred, eipStr) if err != nil { @@ -2218,7 +2218,7 @@ func (self *SGuest) AllowPerformCreateEip(ctx context.Context, userCred mcclient func (self *SGuest) PerformCreateEip(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) { bw, err := data.Int("bandwidth") if err != nil { - return nil, httperrors.NewInputParameterError("Missing bandwidth") + return nil, httperrors.NewMissingParameterError("bandwidth") } chargeType, _ := data.GetString("charge_type") @@ -2278,7 +2278,7 @@ func (self *SGuest) AllowPerformUserData(ctx context.Context, userCred mcclient. func (self *SGuest) PerformUserData(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) { userData, err := data.GetString("user_data") if err != nil { - return nil, httperrors.NewInputParameterError("missing user_data %s", err) + return nil, httperrors.NewMissingParameterError("user_data") } err = self.setUserData(ctx, userCred, userData) if err != nil { @@ -2341,7 +2341,7 @@ func (manager *SGuestManager) AllowPerformDirtyServerStart(ctx context.Context, func (manager *SGuestManager) PerformDirtyServerStart(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) { guestId, err := data.GetString("guest_id") if err != nil { - return nil, httperrors.NewBadRequestError("Missing guest_id") + return nil, httperrors.NewMissingParameterError("guest_id") } guest := manager.FetchGuestById(guestId) if guest == nil { @@ -2349,7 +2349,7 @@ func (manager *SGuestManager) PerformDirtyServerStart(ctx context.Context, userC } hostId, _ := data.GetString("host_id") if len(hostId) == 0 { - return nil, httperrors.NewBadRequestError("Missing host_id or host id is nil?") + return nil, httperrors.NewMissingParameterError("host_id") } if guest.HostId == hostId { @@ -2371,7 +2371,7 @@ func (manager *SGuestManager) AllowPerformDirtyServerVerify(ctx context.Context, func (manager *SGuestManager) PerformDirtyServerVerify(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) { guestId, err := data.GetString("guest_id") if err != nil { - return nil, httperrors.NewBadRequestError("Missing guest_id") + return nil, httperrors.NewMissingParameterError("guest_id") } guest := manager.FetchGuestById(guestId) if guest == nil { @@ -2379,7 +2379,7 @@ func (manager *SGuestManager) PerformDirtyServerVerify(ctx context.Context, user } hostId, _ := data.GetString("host_id") if len(hostId) == 0 { - return nil, httperrors.NewBadRequestError("Missing host_id or host id is nil?") + return nil, httperrors.NewMissingParameterError("host_id") } if guest.HostId != hostId && guest.BackupHostId != hostId { @@ -2529,7 +2529,7 @@ func (self *SGuest) AllowPerformSetExtraOption(ctx context.Context, userCred mcc func (self *SGuest) PerformSetExtraOption(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) { key, err := data.GetString("key") if err != nil { - return nil, httperrors.NewBadRequestError("Option key required") + return nil, httperrors.NewMissingParameterError("key") } value, _ := data.GetString("value") extraOptions := self.GetExtraOptions(userCred) @@ -2557,7 +2557,7 @@ func (self *SGuest) AllowPerformDelExtraOption(ctx context.Context, userCred mcc func (self *SGuest) PerformDelExtraOption(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) { key, err := data.GetString("key") if err != nil { - return nil, httperrors.NewBadRequestError("Option key required") + return nil, httperrors.NewMissingParameterError("key") } extraOptions := self.GetExtraOptions(userCred) extraOptions.Remove(key) diff --git a/pkg/compute/models/guests.go b/pkg/compute/models/guests.go index c6d2eb0965..bff21518fc 100644 --- a/pkg/compute/models/guests.go +++ b/pkg/compute/models/guests.go @@ -789,7 +789,7 @@ func (self *SGuest) ValidateUpdateData(ctx context.Context, userCred mcclient.To if data.Contains("name") { if name, _ := data.GetString("name"); len(name) < 2 { - return nil, httperrors.NewInputParameterError("name is to short") + return nil, httperrors.NewInputParameterError("name is too short") } } return self.SVirtualResourceBase.ValidateUpdateData(ctx, userCred, query, data) @@ -897,7 +897,7 @@ func (manager *SGuestManager) ValidateCreateData(ctx context.Context, userCred m } if vmemSize == 0 { - return nil, httperrors.NewInputParameterError("Missing memory size") + return nil, httperrors.NewMissingParameterError("vmem_size") } if vcpuCount == 0 { vcpuCount = 1 diff --git a/pkg/compute/models/host_recycle.go b/pkg/compute/models/host_recycle.go index c81a817cac..afb8b2709e 100644 --- a/pkg/compute/models/host_recycle.go +++ b/pkg/compute/models/host_recycle.go @@ -692,7 +692,7 @@ func (self *SHost) AllowPerformRenewPrepaidRecycle(ctx context.Context, userCred func (self *SHost) PerformRenewPrepaidRecycle(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) { durationStr := jsonutils.GetAnyString(data, []string{"duration"}) if len(durationStr) == 0 { - return nil, httperrors.NewInputParameterError("missing duration") + return nil, httperrors.NewMissingParameterError("duration") } bc, err := billing.ParseBillingCycle(durationStr) diff --git a/pkg/compute/models/loadbalancerlisteners.go b/pkg/compute/models/loadbalancerlisteners.go index 45d694a771..705be1d2e1 100644 --- a/pkg/compute/models/loadbalancerlisteners.go +++ b/pkg/compute/models/loadbalancerlisteners.go @@ -306,10 +306,10 @@ func (man *SLoadbalancerListenerManager) checkTypeV(listenerType string) validat func (man *SLoadbalancerListenerManager) validateAcl(aclStatusV *validators.ValidatorStringChoices, aclTypeV *validators.ValidatorStringChoices, aclV *validators.ValidatorModelIdOrName, data *jsonutils.JSONDict) error { if aclStatusV.Value == consts.LB_BOOL_ON { if aclV.Model == nil { - return httperrors.NewInputParameterError("missing acl") + return httperrors.NewMissingParameterError("acl") } if len(aclTypeV.Value) == 0 { - return httperrors.NewInputParameterError("missing acl_type") + return httperrors.NewMissingParameterError("acl_type") } } else { data.Set("acl_id", jsonutils.NewString("")) diff --git a/pkg/compute/models/networks.go b/pkg/compute/models/networks.go index bdcc8586be..fd51821f92 100644 --- a/pkg/compute/models/networks.go +++ b/pkg/compute/models/networks.go @@ -1166,11 +1166,11 @@ func (manager *SNetworkManager) ValidateCreateData(ctx context.Context, userCred wireId, _ := data.GetString("wire_id") if len(wireId) == 0 { - return nil, httperrors.NewInputParameterError("missing wire_id") + return nil, httperrors.NewMissingParameterError("wire_id") } wire := WireManager.FetchWireById(wireId) if wire == nil { - return nil, httperrors.NewInputParameterError("wire_id %s not valid", wireId) + return nil, httperrors.NewResourceNotFoundError("wire %s not found", wireId) } vpc := wire.getVpc() if vpc == nil { diff --git a/pkg/compute/models/schedpolicies.go b/pkg/compute/models/schedpolicies.go index 1b5e820af1..5f2c957342 100644 --- a/pkg/compute/models/schedpolicies.go +++ b/pkg/compute/models/schedpolicies.go @@ -50,7 +50,7 @@ func validateSchedpolicyInputData(data *jsonutils.JSONDict, create bool) error { strategyStr := jsonutils.GetAnyString(data, []string{"strategy"}) if len(strategyStr) == 0 && create { - return httperrors.NewInputParameterError("missing strategy") + return httperrors.NewMissingParameterError("strategy") } if len(strategyStr) > 0 && !utils.IsInStringArray(strategyStr, STRATEGY_LIST) { diff --git a/pkg/compute/models/secgrouprules.go b/pkg/compute/models/secgrouprules.go index 036c83e41e..975afdc5a8 100644 --- a/pkg/compute/models/secgrouprules.go +++ b/pkg/compute/models/secgrouprules.go @@ -134,7 +134,7 @@ func (self *SSecurityGroupRule) BeforeInsert() { func (manager *SSecurityGroupRuleManager) ValidateCreateData(ctx context.Context, userCred mcclient.TokenCredential, ownerProjId string, query jsonutils.JSONObject, data *jsonutils.JSONDict) (*jsonutils.JSONDict, error) { defsecgroup, _ := data.GetString("secgroup") if len(defsecgroup) == 0 { - return nil, httperrors.NewInputParameterError("Missing Security Group info") + return nil, httperrors.NewMissingParameterError("secgroup") } secgroup, _ := SecurityGroupManager.FetchByIdOrName(userCred, defsecgroup) if secgroup == nil { diff --git a/pkg/compute/models/secgroups.go b/pkg/compute/models/secgroups.go index 1da452c9da..a5eb4347cf 100644 --- a/pkg/compute/models/secgroups.go +++ b/pkg/compute/models/secgroups.go @@ -214,7 +214,7 @@ func (self *SSecurityGroup) AllowPerformClone(ctx context.Context, userCred mccl func (self *SSecurityGroup) PerformClone(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) { if name, _ := data.GetString("name"); len(name) == 0 { - return nil, httperrors.NewInputParameterError("Missing name params") + return nil, httperrors.NewMissingParameterError("name") } else { sql := SecurityGroupManager.Query() sql = SecurityGroupManager.FilterByName(sql, name) diff --git a/pkg/compute/models/storagecaches.go b/pkg/compute/models/storagecaches.go index 15413399c2..9914476c53 100644 --- a/pkg/compute/models/storagecaches.go +++ b/pkg/compute/models/storagecaches.go @@ -386,7 +386,7 @@ func (self *SStoragecache) AllowPerformUncacheImage(ctx context.Context, userCre func (self *SStoragecache) PerformUncacheImage(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) { imageStr, _ := data.GetString("image") if len(imageStr) == 0 { - return nil, httperrors.NewInputParameterError("missing image id or name") + return nil, httperrors.NewMissingParameterError("image") } isForce := jsonutils.QueryBoolean(data, "is_force", false) diff --git a/pkg/compute/models/vpcs.go b/pkg/compute/models/vpcs.go index 0ed306150b..b472e6e5e4 100644 --- a/pkg/compute/models/vpcs.go +++ b/pkg/compute/models/vpcs.go @@ -414,19 +414,16 @@ func (manager *SVpcManager) InitializeData() error { func (manager *SVpcManager) ValidateCreateData(ctx context.Context, userCred mcclient.TokenCredential, ownerProjId string, query jsonutils.JSONObject, data *jsonutils.JSONDict) (*jsonutils.JSONDict, error) { regionId, err := data.GetString("cloudregion_id") if err != nil { - return nil, httperrors.NewInputParameterError("No cloudregion_id") + return nil, httperrors.NewMissingParameterError("cloudregion_id") } region := CloudregionManager.FetchRegionById(regionId) if region == nil { return nil, httperrors.NewInputParameterError("Invalid cloudregion_id") } if region.isManaged() { - managerStr, _ := data.GetString("manager_id") + managerStr := jsonutils.GetAnyString(data, []string{"manager_id", "manager"}) if len(managerStr) == 0 { - managerStr, _ = data.GetString("manager") - if len(managerStr) == 0 { - return nil, httperrors.NewInputParameterError("cloud provider/manager must be provided") - } + return nil, httperrors.NewMissingParameterError("manager_id") } managerObj := CloudproviderManager.FetchCloudproviderByIdOrName(managerStr) if err != nil { diff --git a/pkg/compute/models/wires.go b/pkg/compute/models/wires.go index 3f86f777ac..5db7ab6ba6 100644 --- a/pkg/compute/models/wires.go +++ b/pkg/compute/models/wires.go @@ -80,7 +80,7 @@ func (manager *SWireManager) ValidateCreateData(ctx context.Context, userCred mc vpcStr := jsonutils.GetAnyString(data, []string{"vpc", "vpc_id"}) if len(vpcStr) == 0 { - return nil, httperrors.NewInternalServerError("missing vpc") + return nil, httperrors.NewMissingParameterError("vpc_id") } if len(vpcStr) > 0 { diff --git a/pkg/hostman/guesthandlers/guesthandler.go b/pkg/hostman/guesthandlers/guesthandler.go index fa7bdceccf..40bbde46fa 100644 --- a/pkg/hostman/guesthandlers/guesthandler.go +++ b/pkg/hostman/guesthandlers/guesthandler.go @@ -256,7 +256,7 @@ func guestDestPrepareMigrate(ctx context.Context, sid string, body jsonutils.JSO } else { targetStorageId, _ := disks[0].GetString("target_storage_id") if len(targetStorageId) == 0 { - return nil, httperrors.NewInputParameterError("Disk desc missing target storage id") + return nil, httperrors.NewMissingParameterError("target_storage_id") } params.TargetStorageId = targetStorageId } diff --git a/pkg/httperrors/errors.go b/pkg/httperrors/errors.go index d3ffd49bb7..854c3f634f 100644 --- a/pkg/httperrors/errors.go +++ b/pkg/httperrors/errors.go @@ -3,6 +3,7 @@ package httperrors import ( "bytes" "fmt" + "yunion.io/x/onecloud/pkg/util/httputils" ) diff --git a/pkg/image/models/images.go b/pkg/image/models/images.go index 8d240b2799..50a0853ae7 100644 --- a/pkg/image/models/images.go +++ b/pkg/image/models/images.go @@ -1091,7 +1091,7 @@ func (self *SImage) AllowPerformUpdateTorrentStatus(ctx context.Context, userCre func (self *SImage) PerformUpdateTorrentStatus(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) { formatStr, _ := query.GetString("format") if len(formatStr) == 0 { - return nil, httperrors.NewInputParameterError("missing parameter format") + return nil, httperrors.NewMissingParameterError("format") } subimg := ImageSubformatManager.FetchSubImage(self.Id, formatStr) if subimg == nil { diff --git a/pkg/util/aliyun/storagecache.go b/pkg/util/aliyun/storagecache.go index 4be1250805..ef5a6c8d12 100644 --- a/pkg/util/aliyun/storagecache.go +++ b/pkg/util/aliyun/storagecache.go @@ -14,7 +14,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudprovider" "yunion.io/x/onecloud/pkg/compute/options" - "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/auth" "yunion.io/x/onecloud/pkg/mcclient/modules" @@ -336,7 +335,7 @@ func (self *SStoragecache) downloadImage(userCred mcclient.TokenCredential, imag } else if imageList, err := bucket.ListObjects(oss.Prefix(fmt.Sprintf("%sexport", strings.Replace(extId, "-", "", -1)))); err != nil { return nil, err } else if len(imageList.Objects) != 1 { - return nil, httperrors.NewResourceNotFoundError("exported image not find") + return nil, fmt.Errorf("exported image not find") } else if err := bucket.DownloadFile(imageList.Objects[0].Key, tmpImageFile.Name(), 12*1024*1024, oss.Routines(3), oss.Progress(&OssProgressListener{})); err != nil { return nil, err } else {