-
Notifications
You must be signed in to change notification settings - Fork 51
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
Add option=terminate for delete mcis #959
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1333,6 +1333,8 @@ func UpdateVmInfo(nsId string, mcisId string, vmInfoData TbVmInfo) { | |
// DelMcis is func to delete MCIS object | ||
func DelMcis(nsId string, mcisId string, option string) error { | ||
|
||
option = common.ToLower(option) | ||
|
||
err := common.CheckString(nsId) | ||
if err != nil { | ||
common.CBLog.Error(err) | ||
|
@@ -1353,18 +1355,27 @@ func DelMcis(nsId string, mcisId string, option string) error { | |
|
||
fmt.Println("[Delete MCIS] " + mcisId) | ||
|
||
// // ControlMcis first | ||
// err = ControlMcisAsync(nsId, mcisId, ActionTerminate) | ||
// if err != nil { | ||
// common.CBLog.Error(err) | ||
// if option != "force" { | ||
// return err | ||
// } | ||
// } | ||
// // for deletion, need to wait until termination is finished | ||
// // Sleep for 5 seconds | ||
// fmt.Printf("\n\n[Info] Sleep for 5 seconds for safe MCIS-VMs termination.\n\n") | ||
// time.Sleep(5 * time.Second) | ||
// with terminate option, do MCIS refine and terminate in advance | ||
if strings.EqualFold(option, ActionTerminate) { | ||
|
||
// ActionRefine | ||
_, err := HandleMcisAction(nsId, mcisId, ActionRefine) | ||
if err != nil { | ||
common.CBLog.Error(err) | ||
return err | ||
} | ||
|
||
// ActionTerminate | ||
_, err = HandleMcisAction(nsId, mcisId, ActionTerminate) | ||
if err != nil { | ||
common.CBLog.Error(err) | ||
return err | ||
} | ||
// for deletion, need to wait until termination is finished | ||
// Sleep for 5 seconds | ||
fmt.Printf("\n\n[Info] Sleep for 5 seconds for safe MCIS-VMs termination.\n\n") | ||
time.Sleep(5 * time.Second) | ||
} | ||
|
||
// Check MCIS status is Terminated so that approve deletion | ||
mcisStatus, _ := GetMcisStatus(nsId, mcisId) | ||
|
@@ -1376,7 +1387,7 @@ func DelMcis(nsId string, mcisId string, option string) error { | |
} | ||
} | ||
// Check MCIS status is Terminated (not Partial) | ||
if !(!strings.Contains(mcisStatus.Status, "Partial-") && (strings.Contains(mcisStatus.Status, StatusTerminated) || strings.Contains(mcisStatus.Status, StatusUndefined) || strings.Contains(mcisStatus.Status, StatusFailed))) { | ||
if mcisStatus.Id != "" && !(!strings.Contains(mcisStatus.Status, "Partial-") && (strings.Contains(mcisStatus.Status, StatusTerminated) || strings.Contains(mcisStatus.Status, StatusUndefined) || strings.Contains(mcisStatus.Status, StatusFailed))) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아주 드물게 (spider가 중간에 죽는다거나 하는 상황) , mcis 정보에 오류가 포함되어 mcisStatus.Id 가 비어 있는 경우가 있습니다. 이 경우에는 force delete 로 처리되도록 안전옵션을 추가하였습니다. |
||
err := fmt.Errorf("MCIS " + mcisId + " is " + mcisStatus.Status + " and not " + StatusTerminated + "/" + StatusUndefined + "/" + StatusFailed + ", Deletion is not allowed (use option=force for force deletion)") | ||
common.CBLog.Error(err) | ||
if option != "force" { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
case in-sensitive 비교 방식 입니다. 사용자 입력을 string으로 받으니, 대소문자를 항상 처리해야 하니 좀 귀찮긴하네요.ㅎ