Merge pull request #1081 in YUNIONIO/onecloud from ~QIUJIAN/onecloud:hotfix/qj-fix-huawei-native-image-not-found to release/2.6.0

* commit '766ad18d1a7704fddcd259ca6bea11181ac04975':
  fix: fail to create huawei server with native image
This commit is contained in:
邱剑
2019-02-19 19:06:49 +08:00
3 changed files with 17 additions and 3 deletions
+4
View File
@@ -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()
+4 -3
View File
@@ -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 {
+9
View File
@@ -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
})
}