Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Alibaba] Fix issue with myImage Tag, add statement to handle CSP error messages #173

Merged
merged 3 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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