mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix: fail to create huawei server with native image
This commit is contained in:
@@ -424,18 +424,22 @@ func (manager *SCachedimageManager) newFromCloudImage(ctx context.Context, userC
|
||||
func (image *SCachedimage) requestRefreshExternalImage(ctx context.Context, userCred mcclient.TokenCredential) (*cloudprovider.SImage, error) {
|
||||
caches := image.getValidStoragecache()
|
||||
if caches == nil || len(caches) == 0 {
|
||||
log.Errorf("requestRefreshExternalImage: no valid storage cache")
|
||||
return nil, fmt.Errorf("no valid storage cache")
|
||||
}
|
||||
iCache, err := caches[0].GetIStorageCache()
|
||||
if err != nil {
|
||||
log.Errorf("GetIStorageCache fail %s", err)
|
||||
return nil, err
|
||||
}
|
||||
iImage, err := iCache.GetIImageById(image.ExternalId)
|
||||
if err != nil {
|
||||
log.Errorf("iCache.GetIImageById fail %s", err)
|
||||
return nil, err
|
||||
}
|
||||
err = image.syncWithCloudImage(ctx, userCred, iImage)
|
||||
if err != nil {
|
||||
log.Errorf("image.syncWithCloudImage fail %s", err)
|
||||
return nil, err
|
||||
}
|
||||
return image.GetImage()
|
||||
|
||||
@@ -41,6 +41,7 @@ func NewImageManager(regionId string, projectId string, signer auth.Signer, debu
|
||||
}}
|
||||
}
|
||||
|
||||
//https://support.huaweicloud.com/api-ims/zh-cn_topic_0020091566.html
|
||||
func (self *SImageManager) Get(id string, querys map[string]string) (jsonutils.JSONObject, error) {
|
||||
if querys == nil {
|
||||
querys = make(map[string]string, 0)
|
||||
@@ -48,9 +49,9 @@ func (self *SImageManager) Get(id string, querys map[string]string) (jsonutils.J
|
||||
|
||||
querys["id"] = id
|
||||
// 这里默认使用private
|
||||
if t, exists := querys["__imagetype"]; !exists || len(t) == 0 {
|
||||
querys["__imagetype"] = "private"
|
||||
}
|
||||
// if t, exists := querys["__imagetype"]; !exists || len(t) == 0 {
|
||||
// querys["__imagetype"] = "private"
|
||||
// }
|
||||
|
||||
ret, err := self.ListInContext(nil, querys)
|
||||
if err != nil {
|
||||
|
||||
@@ -30,4 +30,13 @@ func init() {
|
||||
shellutils.R(&ImageDeleteOptions{}, "image-delete", "Delete image", func(cli *huawei.SRegion, args *ImageDeleteOptions) error {
|
||||
return cli.DeleteImage(args.ID)
|
||||
})
|
||||
|
||||
shellutils.R(&ImageDeleteOptions{}, "image-show", "Show image", func(cli *huawei.SRegion, args *ImageDeleteOptions) error {
|
||||
img, err := cli.GetImage(args.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(img)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user