Skip to content

Commit

Permalink
Merge pull request #1316 from MZC-CSC/master
Browse files Browse the repository at this point in the history
[Alibaba] Fix issue with myImage Tag, add statement to handle CSP error messages
  • Loading branch information
powerkimhub authored Sep 2, 2024
2 parents c41b05d + 4ada1bf commit aa2d54c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
2 changes: 1 addition & 1 deletion api-runtime/common-runtime/CommonManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func checkNotFoundError(err error) bool {
msg = strings.ToLower(msg)

return strings.Contains(msg, "does not exist") || strings.Contains(msg, "notfound") ||
strings.Contains(msg, "notexist") || strings.Contains(msg, "failedtofind") || strings.Contains(msg, "failedtogetthevm")
strings.Contains(msg, "notexist") || strings.Contains(msg, "failedtofind") || strings.Contains(msg, "failedtogetthevm") || strings.Contains(msg, "noresult")
}

func getUserIIDList(iidInfoList []*iidm.IIDInfo) []*cres.IID {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ func GetAlibabaResourceType(resType irs.RSType) (string, error) {
return "disk", nil
case irs.MYIMAGE:
// return "snapshot", nil
return "ecs", nil
return "image", nil
case irs.CLUSTER:
return "CLUSTER", nil
case irs.ALL:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,40 @@ func (myImageHandler AlibabaMyImageHandler) SnapshotVM(snapshotReqInfo irs.MyIma
request.InstanceId = snapshotReqInfo.SourceVM.SystemId
request.ImageName = snapshotReqInfo.IId.NameId
// 0717 tag 추가

// request Tag 추가
myImageTags := []ecs.CreateImageTag{}
if snapshotReqInfo.TagList != nil && len(snapshotReqInfo.TagList) > 0 {

myImageTags := []ecs.CreateImageTag{}
for _, myImageTag := range snapshotReqInfo.TagList {
tag0 := ecs.CreateImageTag{
Key: myImageTag.Key,
Value: myImageTag.Value,
}
myImageTags = append(myImageTags, tag0)

}
request.Tag = &myImageTags

}

///
// MyImage를 위한 Tag추가
cbMetaTag := ecs.CreateImageTag{
Key: CBMetaDefaultTagName, // "cbCat",
Value: CBMetaDefaultTagValue, // "cbAlibaba",
}
myImageTags = append(myImageTags, cbMetaTag)
cbImageTag := ecs.CreateImageTag{
Key: IMAGE_TAG_DEFAULT, // "Name",
Value: snapshotReqInfo.IId.NameId,
}
myImageTags = append(myImageTags, cbImageTag)
cbSourceVmTag := ecs.CreateImageTag{
Key: IMAGE_TAG_SOURCE_VM,
Value: snapshotReqInfo.SourceVM.SystemId,
}
myImageTags = append(myImageTags, cbSourceVmTag)

request.Tag = &myImageTags

// TAG에 연관 instanceID set 할 것
// // TAG에 연관 instanceID set 할 것
// request.Tag = &[]ecs.CreateImageTag{ // Default Hidden Tags Info
// {
// Key: CBMetaDefaultTagName, // "cbCat",
Expand Down Expand Up @@ -149,6 +165,7 @@ func (myImageHandler AlibabaMyImageHandler) GetMyImage(myImageIID irs.IID) (irs.
if err != nil {
cblogger.Error(err)
LoggingError(hiscallInfo, err)

return irs.MyImageInfo{}, err
}
calllogger.Info(call.String(hiscallInfo))
Expand Down Expand Up @@ -256,8 +273,8 @@ func ExtractMyImageDescribeInfo(aliMyImage *ecs.Image) (irs.MyImageInfo, error)
tagList := []irs.KeyValue{}
for _, aliTag := range aliMyImage.Tags.Tag {
sTag := irs.KeyValue{}
sTag.Key = aliTag.Key
sTag.Value = aliTag.Value
sTag.Key = aliTag.TagKey
sTag.Value = aliTag.TagValue

tagList = append(tagList, sTag)
}
Expand Down Expand Up @@ -316,6 +333,7 @@ func ExtractMyImageDescribeInfo(aliMyImage *ecs.Image) (irs.MyImageInfo, error)
keyValueList = append(keyValueList, irs.KeyValue{Key: "OSType", Value: aliMyImage.OSType})

returnMyImageInfo.KeyValueList = keyValueList

return returnMyImageInfo, nil
}

Expand Down

0 comments on commit aa2d54c

Please sign in to comment.