From 9321fbcef0aebd3c9beb2cecc34dc6b10a549e11 Mon Sep 17 00:00:00 2001 From: ByoungSeob Kim <46367962+powerkimhub@users.noreply.github.com> Date: Mon, 27 May 2024 16:32:55 +0900 Subject: [PATCH 01/19] Update README.md --- README.md | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 85f2565a6..f6213011d 100644 --- a/README.md +++ b/README.md @@ -57,19 +57,21 @@ If you have any difficulties in using Cloud-Barista, please let us know. | Provider | Price
Info | Region/Zone
Info | Image
Info | VMSpec
Info | VPC
Subnet | Security
Group | VM KeyPair | VM | Disk | NLB | MyImage | managed-K8S | |:-------------:|:-------------:|:-------------------:|:-------------:|:--------------:|:-------------------:|:-----------------:|:---------------:|:--------------:|:----:|:---:|:-------:|:-----------:| -| AWS | O | O | O | O | O | O | O | O | O | O | O | Soon | -| Azure | O
(Spec제외)| O | O | O | O | O | O | O | O | O | O | Soon | -| GCP | Soon | O | O | O | O | O | O | O | O | O | O | Soon | +| AWS | O | O | O | O | O | O | O | O | O | O | O | WIP | +| Azure | O
(Spec제외)| O | O | O | O | O | O | O | O | O | O | WIP | +| GCP | WIP | O | O | O | O | O | O | O | O | O | O | WIP | | Alibaba | O | O | O | O | O | O | O | O | O | O | O | O | | Tencent | O | O | O | O | O | O | O | O | O | O | O | O | -| IBM VPC | O
(Spec제외)| O | O | O | O | O | O | O | O | O | O | Soon | -| OpenStack | - | O | O | O | O | O | O | O | O | O | O | - | -| NCP Classic | Soon | O | O | O | O
(Type-1) | O
(Note-1) | O | O | O | O | O | - | -| NCP VPC | Soon | O | O | O | O | O | O | O | O | O | O | - | -| NHN | - | O | O | O | O
(Type-2) | O | O | O
(Note-2) | O | Soon| Soon | O | -| KT Classic | - | O | O | O | O
(Type-1) | O | O | O | O | O | O | - | -| KT VPC | - | O | O | O | O
(Type-3) | O | O | O | O | O | Soon | - | - +| IBM VPC | O
(Spec제외)| O | O | O | O | O | O | O | O | O | O | WIP | +| OpenStack | NA | O | O | O | O | O | O | O | O | O | O | ? | +| NCP Classic | WIP | O | O | O | O
(Type-1) | O
(Note-1) | O | O | O | O | O | NA | +| NCP VPC | WIP | O | O | O | O | O | O | O | O | O | O | ? | +| NHN | NA | O | O | O | O
(Type-2) | O | O | O
(Note-2) | O | WIP| WIP | O | +| KT Classic | NA | O | O | O | O
(Type-1) | O | O | O | O | O | O | NA | +| KT VPC | NA | O | O | O | O
(Type-3) | O | O | O | O | O | WIP | Wait API | + + ※ WIP: Work In Progress, NA: Not Applicable, Wait API: CSP API 공개 대기, ?: 미정/분석필요 + ※ VPC 특이사항(세부 내용: 각 드라이버 Readme 참고) ◉ Type-1: VPC/Subnet Emulation - CSP: VPC 개념 제공하지 않음 From f79d8162403bc81bc62bdc59602db445837c4725 Mon Sep 17 00:00:00 2001 From: ByoungSeob Kim <46367962+powerkimhub@users.noreply.github.com> Date: Mon, 27 May 2024 16:46:04 +0900 Subject: [PATCH 02/19] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index f6213011d..2cba5232e 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,7 @@ If you have any difficulties in using Cloud-Barista, please let us know. - CSP: VPC 개념 제공하지 않음 - CB-Spider: API 추상화를 위한 단일 VPC/Subnet 생성 제공 (두개 이상 VPC/Subnet 생성 불가) - CIDR: 제공하지 않음(설정 무의미) + ◉ Type-2: Console에서 사전 생성 후 등록 활용 - CSP(NHN) IG(Internet Gateway) 제어 API 부재(추후 제공 예정) - 사전 작업: Console에서 VPC 사전 생성 및 IG(Internet Gateway) 맵핑 필요(#1109 참고) From 1afa427871c77902eea5f4efa5f2fc6e8bfca82c Mon Sep 17 00:00:00 2001 From: ByoungSeob Kim <46367962+powerkimhub@users.noreply.github.com> Date: Mon, 27 May 2024 16:56:43 +0900 Subject: [PATCH 03/19] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2cba5232e..3f4369b26 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ If you have any difficulties in using Cloud-Barista, please let us know. #### 3. 제공 자원 -| Provider | Price
Info | Region/Zone
Info | Image
Info | VMSpec
Info | VPC
Subnet | Security
Group | VM KeyPair | VM | Disk | NLB | MyImage | managed-K8S | +| Provider | Price
Info | Region/Zone
Info | Image
Info | VMSpec
Info | VPC
Subnet | Security
Group | VM KeyPair | VM | Disk | MyImage | NLB | managed-K8S | |:-------------:|:-------------:|:-------------------:|:-------------:|:--------------:|:-------------------:|:-----------------:|:---------------:|:--------------:|:----:|:---:|:-------:|:-----------:| | AWS | O | O | O | O | O | O | O | O | O | O | O | WIP | | Azure | O
(Spec제외)| O | O | O | O | O | O | O | O | O | O | WIP | @@ -68,7 +68,7 @@ If you have any difficulties in using Cloud-Barista, please let us know. | NCP VPC | WIP | O | O | O | O | O | O | O | O | O | O | ? | | NHN | NA | O | O | O | O
(Type-2) | O | O | O
(Note-2) | O | WIP| WIP | O | | KT Classic | NA | O | O | O | O
(Type-1) | O | O | O | O | O | O | NA | -| KT VPC | NA | O | O | O | O
(Type-3) | O | O | O | O | O | WIP | Wait API | +| KT VPC | NA | O | O | O | O
(Type-3) | O | O | O | O | WIP | O | Wait API | ※ WIP: Work In Progress, NA: Not Applicable, Wait API: CSP API 공개 대기, ?: 미정/분석필요 From ed46f08fe5a20f1817fbbf88f8217b9a6616652b Mon Sep 17 00:00:00 2001 From: ByoungSeob Kim <46367962+powerkimhub@users.noreply.github.com> Date: Mon, 27 May 2024 21:09:53 +0900 Subject: [PATCH 04/19] Update README.md --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3f4369b26..839a72a1b 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ If you have any difficulties in using Cloud-Barista, please let us know. | NCP VPC | WIP | O | O | O | O | O | O | O | O | O | O | ? | | NHN | NA | O | O | O | O
(Type-2) | O | O | O
(Note-2) | O | WIP| WIP | O | | KT Classic | NA | O | O | O | O
(Type-1) | O | O | O | O | O | O | NA | -| KT VPC | NA | O | O | O | O
(Type-3) | O | O | O | O | WIP | O | Wait API | +| KT VPC | NA | O | O | O | O
(Type-3) | O | O | O | O | WIP | O
(Note-3)| Wait API | ※ WIP: Work In Progress, NA: Not Applicable, Wait API: CSP API 공개 대기, ?: 미정/분석필요 @@ -109,6 +109,9 @@ If you have any difficulties in using Cloud-Barista, please let us know. ※ VM 특이사항(세부 내용: 각 드라이버 Readme 참고) ◉ Note-2: Wdindows VM일 경우 SSH Key 사용한 VM 생성 후 Console에서 Key를 이용하여 PW 확인 필요 + ※ NLB 특이사항(세부 내용: 각 드라이버 Readme 참고) + ◉ Note-3: NLB에 등록할 VM은 NLB와 동일 Subnet에 존재해야 함 + #### 4. VM 계정 - Ubuntu, Debian VM User: cb-user From 3e716ebb5cb8be28b5fecc2e9e75b7e17ca47676 Mon Sep 17 00:00:00 2001 From: ByoungSeob Kim <46367962+powerkimhub@users.noreply.github.com> Date: Mon, 27 May 2024 21:17:44 +0900 Subject: [PATCH 05/19] Update README.md --- README.md | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 839a72a1b..2cd8e812c 100644 --- a/README.md +++ b/README.md @@ -64,21 +64,22 @@ If you have any difficulties in using Cloud-Barista, please let us know. | Tencent | O | O | O | O | O | O | O | O | O | O | O | O | | IBM VPC | O
(Spec제외)| O | O | O | O | O | O | O | O | O | O | WIP | | OpenStack | NA | O | O | O | O | O | O | O | O | O | O | ? | -| NCP Classic | WIP | O | O | O | O
(Type-1) | O
(Note-1) | O | O | O | O | O | NA | +| NCP Classic | WIP | O | O | O | O
(Type1) | O
(Note1) | O | O | O | O | O | NA | | NCP VPC | WIP | O | O | O | O | O | O | O | O | O | O | ? | -| NHN | NA | O | O | O | O
(Type-2) | O | O | O
(Note-2) | O | WIP| WIP | O | -| KT Classic | NA | O | O | O | O
(Type-1) | O | O | O | O | O | O | NA | -| KT VPC | NA | O | O | O | O
(Type-3) | O | O | O | O | WIP | O
(Note-3)| Wait API | +| NHN | NA | O | O | O | O
(Type2) | O | O | O
(Note2) | O | WIP| WIP | O | +| KT Classic | NA | O | O | O | O
(Type1) | O | O | O | O | O | O | NA | +| KT VPC | NA | O | O | O | O
(Type3) | O | O | O | O | WIP | O
(Note3)| Wait API | + ※ WIP: Work In Progress, NA: Not Applicable, Wait API: CSP API 공개 대기, ?: 미정/분석필요 ※ VPC 특이사항(세부 내용: 각 드라이버 Readme 참고) - ◉ Type-1: VPC/Subnet Emulation + ◉ Type1: VPC/Subnet Emulation - CSP: VPC 개념 제공하지 않음 - CB-Spider: API 추상화를 위한 단일 VPC/Subnet 생성 제공 (두개 이상 VPC/Subnet 생성 불가) - CIDR: 제공하지 않음(설정 무의미) - ◉ Type-2: Console에서 사전 생성 후 등록 활용 + ◉ Type2: Console에서 사전 생성 후 등록 활용 - CSP(NHN) IG(Internet Gateway) 제어 API 부재(추후 제공 예정) - 사전 작업: Console에서 VPC 사전 생성 및 IG(Internet Gateway) 맵핑 필요(#1109 참고) - CB-Spider: Register/UnRegister API 활용 @@ -89,13 +90,13 @@ If you have any difficulties in using Cloud-Barista, please let us know. "ReqInfo": { "Name": "'${VPC_NAME}'", "CSPId": "'${VPC_CSPID}'"} }' - ◉ Type-3: default VPC 활용 (KT VPC) + ◉ Type3: default VPC 활용 (KT VPC) - CSP: 생성 제공 없이 고정된 default VPC 1개만 제공 - CB-Spider: API 추상화를 위한 단일 VPC 생성만 제공 (이름 등록 수준) - 두개 이상 VPC 생성 불가, Subnet은 추가/삭제 가능 ※ Security Group 특이사항(세부 내용: 각 드라이버 Readme 참고) - ◉ Note-1: Console에서 사전 생성 후 등록 활용 + ◉ Note1: Console에서 사전 생성 후 등록 활용 - CSP: Security Group Create API 부재 - 사전 작업: Console에서 Security Group 사전 생성 - CB-Spider: Register/UnRegister API 활용 @@ -107,10 +108,10 @@ If you have any difficulties in using Cloud-Barista, please let us know. }' ※ VM 특이사항(세부 내용: 각 드라이버 Readme 참고) - ◉ Note-2: Wdindows VM일 경우 SSH Key 사용한 VM 생성 후 Console에서 Key를 이용하여 PW 확인 필요 + ◉ Note2: Wdindows VM일 경우 SSH Key 사용한 VM 생성 후 Console에서 Key를 이용하여 PW 확인 필요 ※ NLB 특이사항(세부 내용: 각 드라이버 Readme 참고) - ◉ Note-3: NLB에 등록할 VM은 NLB와 동일 Subnet에 존재해야 함 + ◉ Note3: NLB에 등록할 VM은 NLB와 동일 Subnet에 존재해야 함 #### 4. VM 계정 From 09f82fbd3bd6caa01ca6b5ced53b393486f4fc1a Mon Sep 17 00:00:00 2001 From: powerkimhub Date: Mon, 27 May 2024 22:20:56 +0900 Subject: [PATCH 06/19] Fix the invalid page display about Region/Zone Info --- api-runtime/rest-runtime/admin-web/AdminWeb-Common.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/api-runtime/rest-runtime/admin-web/AdminWeb-Common.go b/api-runtime/rest-runtime/admin-web/AdminWeb-Common.go index 2ee6a059f..1a765d846 100644 --- a/api-runtime/rest-runtime/admin-web/AdminWeb-Common.go +++ b/api-runtime/rest-runtime/admin-web/AdminWeb-Common.go @@ -498,7 +498,15 @@ func genLoggingResult2(response string) string { // to escape back-slash in the 'Property' Values response = strings.ReplaceAll(response, `\"`, `"`) - htmlStr := ` parent.frames["log_frame"].Log(" ==> ` + strings.ReplaceAll(response, "\"", "\\\"") + `");` + htmlStr := ` + + ` return htmlStr } From 7a1b2c841d9ae2e7ca69d18bdc5d4e257f1126ff Mon Sep 17 00:00:00 2001 From: powerkimhub Date: Tue, 28 May 2024 01:28:55 +0900 Subject: [PATCH 07/19] Improved the AdminWeb Dashboard to enable control from VPC to VM --- .../admin-web/AdminWeb-KeyPair.go | 42 +++-- .../admin-web/AdminWeb-RegionZone.go | 2 +- .../admin-web/AdminWeb-SecurityGroup.go | 169 ++++++++++-------- .../rest-runtime/admin-web/AdminWeb-VM.go | 91 ++++++---- .../admin-web/html/dashboard.html | 97 ++++++++-- 5 files changed, 269 insertions(+), 132 deletions(-) diff --git a/api-runtime/rest-runtime/admin-web/AdminWeb-KeyPair.go b/api-runtime/rest-runtime/admin-web/AdminWeb-KeyPair.go index ce9f4e66f..baa8ac448 100644 --- a/api-runtime/rest-runtime/admin-web/AdminWeb-KeyPair.go +++ b/api-runtime/rest-runtime/admin-web/AdminWeb-KeyPair.go @@ -23,7 +23,6 @@ import ( "github.com/labstack/echo/v4" ) - //====================================== KeyPair // number, KeyPair Name, KeyPair Info, Key User, Additional Info, checkbox @@ -101,8 +100,7 @@ func makePostKeyPairFunc_js() string { // -d '{ "ConnectionName": "'${CONN_CONFIG}'", "ReqInfo": { "Name": "keypair-01" } }' strFunc := ` - function postKeyPair() { - var connConfig = parent.frames["top_frame"].document.getElementById("connConfig").innerHTML; + function postKeyPair(connConfig) { var textboxes = document.getElementsByName('text_box'); sendJson = '{ "ConnectionName" : "' + connConfig + '", "ReqInfo" : { "Name" : "$$KEYPAIRNAME$$"}}' @@ -121,12 +119,20 @@ func makePostKeyPairFunc_js() string { xhr.setRequestHeader('Content-Type', 'application/json'); // client logging - parent.frames["log_frame"].Log("curl -sX POST " + "$$SPIDER_SERVER$$/spider/keypair -H 'Content-Type: application/json' -d '" + sendJson + "'"); + try { + parent.frames["log_frame"].Log("curl -sX POST " + "$$SPIDER_SERVER$$/spider/keypair -H 'Content-Type: application/json' -d '" + sendJson + "'"); + } catch (e) { + // Do nothing if error occurs + } - xhr.send(sendJson); + xhr.send(sendJson); // client logging - parent.frames["log_frame"].Log(" ==> " + xhr.response); + try { + parent.frames["log_frame"].Log(" ==> " + xhr.response); + } catch (e) { + // Do nothing if error occurs + } var jsonVal = JSON.parse(xhr.response) //---------------- download this private key @@ -154,8 +160,7 @@ func makeDeleteKeyPairFunc_js() string { // -d '{ "ConnectionName": "'${CONN_CONFIG}'"}' strFunc := ` - function deleteKeyPair() { - var connConfig = parent.frames["top_frame"].document.getElementById("connConfig").innerHTML; + function deleteKeyPair(connConfig) { var checkboxes = document.getElementsByName('check_box'); for (var i = 0; i < checkboxes.length; i++) { // @todo make parallel executions if (checkboxes[i].checked) { @@ -165,12 +170,19 @@ func makeDeleteKeyPairFunc_js() string { sendJson = '{ "ConnectionName": "' + connConfig + '"}' // client logging - parent.frames["log_frame"].Log("curl -sX DELETE " + "$$SPIDER_SERVER$$/spider/keypair/" + checkboxes[i].value + " -H 'Content-Type: application/json' -d '" + sendJson + "'"); - - xhr.send(sendJson); + try { + parent.frames["log_frame"].Log("curl -sX DELETE " + "$$SPIDER_SERVER$$/spider/keypair/" + checkboxes[i].value + " -H 'Content-Type: application/json' -d '" + sendJson + "'"); + } catch (e) { + // Do nothing if error occurs + } + xhr.send(sendJson); // client logging - parent.frames["log_frame"].Log(" ==> " + xhr.response); + try { + parent.frames["log_frame"].Log(" ==> " + xhr.response); + } catch (e) { + // Do nothing if error occurs + } } } location.reload(); @@ -244,7 +256,7 @@ func KeyPair(c echo.Context) error { // (2) make Table Action TR // colspan, f5_href, delete_href, fontSize //htmlStr += makeActionTR_html("6", "keypair", "deleteKeyPair()", "2") - htmlStr += makeActionTR_html("6", "", "deleteKeyPair()", "2") + htmlStr += makeActionTR_html("6", "", fmt.Sprintf("deleteKeyPair('%s')", connConfig), "2") // (3) make Table Header TR nameWidthList := []NameWidth{ @@ -265,7 +277,7 @@ func KeyPair(c echo.Context) error { if err != nil { cblog.Error(err) // client logging - htmlStr += genLoggingResult(err.Error()) + htmlStr += genLoggingResult(err.Error()) return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) } @@ -300,7 +312,7 @@ func KeyPair(c echo.Context) error { - + + diff --git a/api-runtime/rest-runtime/admin-web/AdminWeb-RegionZone.go b/api-runtime/rest-runtime/admin-web/AdminWeb-RegionZone.go index 1af28811e..c5c3def48 100644 --- a/api-runtime/rest-runtime/admin-web/AdminWeb-RegionZone.go +++ b/api-runtime/rest-runtime/admin-web/AdminWeb-RegionZone.go @@ -220,7 +220,7 @@ const htmlTemplate = ` function clearSearchInput() { document.getElementById("searchInput").value = ""; - searchTable(); // 검색 입력이 지워진 후 검색 결과를 업데이트합니다. + searchTable(); // Clear the search results } function filterStatus() { diff --git a/api-runtime/rest-runtime/admin-web/AdminWeb-SecurityGroup.go b/api-runtime/rest-runtime/admin-web/AdminWeb-SecurityGroup.go index 866e5cc9d..7fdc23903 100644 --- a/api-runtime/rest-runtime/admin-web/AdminWeb-SecurityGroup.go +++ b/api-runtime/rest-runtime/admin-web/AdminWeb-SecurityGroup.go @@ -26,7 +26,7 @@ import ( //====================================== Security Group // number, VPC Name, SecurityGroup Name, Security Rules, Additional Info, checkbox -func makeSecurityGroupTRList_html(bgcolor string, height string, fontSize string, infoList []*cres.SecurityInfo) string { +func makeSecurityGroupTRList_html(bgcolor string, height string, fontSize string, connConfig string, infoList []*cres.SecurityInfo) string { if bgcolor == "" { bgcolor = "#FFFFFF" } @@ -61,8 +61,7 @@ func makeSecurityGroupTRList_html(bgcolor string, height string, fontSize string `, bgcolor, height, fontSize, fontSize, fontSize, fontSize, fontSize) - - strRemoveRule := fmt.Sprintf(` + strRemoveRule := fmt.Sprintf(`  X @@ -75,7 +74,6 @@ func makeSecurityGroupTRList_html(bgcolor string, height string, fontSize string `, fontSize) - strData := "" // set data and make TR list for i, one := range infoList { @@ -89,11 +87,11 @@ func makeSecurityGroupTRList_html(bgcolor string, height string, fontSize string strSRList := "" if one.SecurityRules != nil { for _, rule := range *one.SecurityRules { - oneSR := fmt.Sprintf("{ \"FromPort\" : \"%s\", \"ToPort\" : \"%s\", \"IPProtocol\" : \"%s\", \"Direction\" : \"%s\", \"CIDR\" : \"%s\" }", - rule.FromPort, rule.ToPort, rule.IPProtocol, rule.Direction, rule.CIDR) + oneSR := fmt.Sprintf("{ \"FromPort\" : \"%s\", \"ToPort\" : \"%s\", \"IPProtocol\" : \"%s\", \"Direction\" : \"%s\", \"CIDR\" : \"%s\" }", + rule.FromPort, rule.ToPort, rule.IPProtocol, rule.Direction, rule.CIDR) strSRList += oneSR - strDelete := "deleteRule('"+sgName+"', '"+rule.FromPort+"', '"+rule.ToPort+"', '"+rule.IPProtocol+"', '"+rule.Direction+"', '"+rule.CIDR+"')" + strDelete := "deleteRule('" + connConfig + "', '" + sgName + "', '" + rule.FromPort + "', '" + rule.ToPort + "', '" + rule.IPProtocol + "', '" + rule.Direction + "', '" + rule.CIDR + "')" strSRList += strings.ReplaceAll(strRemoveRule, "$$REMOVERULE$$", strDelete) strSRList += "
" @@ -101,8 +99,8 @@ func makeSecurityGroupTRList_html(bgcolor string, height string, fontSize string } } - SGAddRule := strings.ReplaceAll(strAddRule, "$$ADDSG$$", sgName) - strSRList += strings.ReplaceAll(SGAddRule, "$$ADDRULE$$", "postRule('"+sgName+"')") + SGAddRule := strings.ReplaceAll(strAddRule, "$$ADDSG$$", sgName) + strSRList += strings.ReplaceAll(SGAddRule, "$$ADDRULE$$", "postRule('"+connConfig+"', '"+sgName+"')") str = strings.ReplaceAll(str, "$$SECURITYRULES$$", strSRList) @@ -128,8 +126,7 @@ func makePostSecurityGroupFunc_js() string { // "SecurityRules": [ {"FromPort": "1", "ToPort" : "65535", "IPProtocol" : "tcp", "Direction" : "inbound", "CIDR" : "0.0.0.0/0" } ] } }' strFunc := ` - function postSecurityGroup() { - var connConfig = parent.frames["top_frame"].document.getElementById("connConfig").innerHTML; + function postSecurityGroup(connConfig) { var textboxes = document.getElementsByName('text_box'); sendJson = '{ "ConnectionName" : "' + connConfig + '", "ReqInfo" : { "Name" : "$$SGNAME$$", "VPCName" : "$$VPCNAME$$", "SecurityRules" : $$SECURITYRULES$$ }}' @@ -154,13 +151,20 @@ func makePostSecurityGroupFunc_js() string { xhr.setRequestHeader('Content-Type', 'application/json'); // client logging - parent.frames["log_frame"].Log("curl -sX POST " + "$$SPIDER_SERVER$$/spider/securitygroup -H 'Content-Type: application/json' -d '" + sendJson + "'"); + try { + parent.frames["log_frame"].Log("curl -sX POST " + "$$SPIDER_SERVER$$/spider/securitygroup -H 'Content-Type: application/json' -d '" + sendJson + "'"); + } catch (e) { + // Do nothing if error occurs + } xhr.send(sendJson); // client logging - parent.frames["log_frame"].Log(" ==> " + xhr.response); - + try { + parent.frames["log_frame"].Log(" ==> " + xhr.response); + } catch (e) { + // Do nothing if error occurs + } location.reload(); @@ -175,8 +179,7 @@ func makeDeleteSecurityGroupFunc_js() string { // curl -sX DELETE http://localhost:1024/spider/securitygroup/sg-01 -H 'Content-Type: application/json' -d '{ "ConnectionName": "'${CONN_CONFIG}'"}' strFunc := ` - function deleteSecurityGroup() { - var connConfig = parent.frames["top_frame"].document.getElementById("connConfig").innerHTML; + function deleteSecurityGroup(connConfig) { var checkboxes = document.getElementsByName('check_box'); for (var i = 0; i < checkboxes.length; i++) { // @todo make parallel executions if (checkboxes[i].checked) { @@ -186,12 +189,20 @@ func makeDeleteSecurityGroupFunc_js() string { sendJson = '{ "ConnectionName": "' + connConfig + '"}' // client logging - parent.frames["log_frame"].Log("curl -sX DELETE " + "$$SPIDER_SERVER$$/spider/securitygroup/" + checkboxes[i].value + " -H 'Content-Type: application/json' -d '" + sendJson + "'"); + try { + parent.frames["log_frame"].Log("curl -sX DELETE " + "$$SPIDER_SERVER$$/spider/securitygroup/" + checkboxes[i].value + " -H 'Content-Type: application/json' -d '" + sendJson + "'"); + } catch (e) { + // Do nothing if error occurs + } xhr.send(sendJson); // client logging - parent.frames["log_frame"].Log(" ==> " + xhr.response); + try { + parent.frames["log_frame"].Log(" ==> " + xhr.response); + } catch (e) { + // Do nothing if error occurs + } } } location.reload(); @@ -203,29 +214,27 @@ func makeDeleteSecurityGroupFunc_js() string { // make the string of javascript function func makeDeleteRuleFunc_js() string { - /* - curl -sX DELETE http://localhost:1024/spider/securitygroup/${SG_NAME}/rules -H 'Content-Type: application/json' -d \ - '{ - "ConnectionName": "'${CONN_CONFIG}'", - "ReqInfo": { - "RuleInfoList" : - [ - { - "Direction": "inbound", - "IPProtocol": "ALL", - "FromPort": "-1", - "ToPort": "-1", - "CIDR" : "0.0.0.0/0" - } - ] - } - }' + /* + curl -sX DELETE http://localhost:1024/spider/securitygroup/${SG_NAME}/rules -H 'Content-Type: application/json' -d \ + '{ + "ConnectionName": "'${CONN_CONFIG}'", + "ReqInfo": { + "RuleInfoList" : + [ + { + "Direction": "inbound", + "IPProtocol": "ALL", + "FromPort": "-1", + "ToPort": "-1", + "CIDR" : "0.0.0.0/0" + } + ] + } + }' */ - strFunc := ` - function deleteRule(sgName, fromPort, toPort, protocol, direction, cidr) { - - var connConfig = parent.frames["top_frame"].document.getElementById("connConfig").innerHTML; + strFunc := ` + function deleteRule(connConfig, sgName, fromPort, toPort, protocol, direction, cidr) { var xhr = new XMLHttpRequest(); xhr.open("DELETE", "$$SPIDER_SERVER$$/spider/securitygroup/" + sgName + "/rules", false); @@ -245,44 +254,52 @@ func makeDeleteRuleFunc_js() string { sendJson += '}' // client logging - parent.frames["log_frame"].Log("curl -sX DELETE " + "$$SPIDER_SERVER$$/spider/securitygroup/" + sgName + "/rules" + " -H 'Content-Type: application/json' -d '" + sendJson + "'"); + try { + parent.frames["log_frame"].Log("curl -sX DELETE " + "$$SPIDER_SERVER$$/spider/securitygroup/" + sgName + "/rules" + " -H 'Content-Type: application/json' -d '" + sendJson + "'"); + } catch (e) { + // Do nothing if error occurs + } + xhr.send(sendJson); // client logging - parent.frames["log_frame"].Log(" => " + xhr.response); + try { + parent.frames["log_frame"].Log(" => " + xhr.response); + } catch (e) { + // Do nothing if error occurs + } location.reload(); } ` - strFunc = strings.ReplaceAll(strFunc, "$$SPIDER_SERVER$$", "http://"+cr.ServiceIPorName+cr.ServicePort) // cr.ServicePort = ":1024" - return strFunc + strFunc = strings.ReplaceAll(strFunc, "$$SPIDER_SERVER$$", "http://"+cr.ServiceIPorName+cr.ServicePort) // cr.ServicePort = ":1024" + return strFunc } // make the string of javascript function func makePostRuleFunc_js() string { - /* - curl -sX POST http://localhost:1024/spider/securitygroup/${SG_NAME}/rules -H 'Content-Type: application/json' -d \ - '{ - "ConnectionName": "'${CONN_CONFIG}'", - "ReqInfo": { - "RuleInfoList" : - [ - { - "Direction": "inbound", - "IPProtocol": "ALL", - "FromPort": "-1", - "ToPort": "-1", - "CIDR" : "0.0.0.0/0" - } - ] - } - }' - */ + /* + curl -sX POST http://localhost:1024/spider/securitygroup/${SG_NAME}/rules -H 'Content-Type: application/json' -d \ + '{ + "ConnectionName": "'${CONN_CONFIG}'", + "ReqInfo": { + "RuleInfoList" : + [ + { + "Direction": "inbound", + "IPProtocol": "ALL", + "FromPort": "-1", + "ToPort": "-1", + "CIDR" : "0.0.0.0/0" + } + ] + } + }' + */ - strFunc := ` - function postRule(sgName, rule) { - var connConfig = parent.frames["top_frame"].document.getElementById("connConfig").innerHTML; + strFunc := ` + function postRule(connConfig, sgName, rule) { var textbox = document.getElementById('security_text_box_' + sgName); var xhr = new XMLHttpRequest(); @@ -299,18 +316,26 @@ func makePostRuleFunc_js() string { // client logging - parent.frames["log_frame"].Log("curl -sX POST " + "$$SPIDER_SERVER$$/spider/securitygroup/" + sgName + "/rules" + " -H 'Content-Type: application/json' -d '" + sendJson + "'"); + try { + parent.frames["log_frame"].Log("curl -sX POST " + "$$SPIDER_SERVER$$/spider/securitygroup/" + sgName + "/rules" + " -H 'Content-Type: application/json' -d '" + sendJson + "'"); + } catch (e) { + // Do nothing if error occurs + } xhr.send(sendJson); // client logging - parent.frames["log_frame"].Log(" => " + xhr.response); + try { + parent.frames["log_frame"].Log(" => " + xhr.response); + } catch (e) { + // Do nothing if error occurs + } location.reload(); } ` - strFunc = strings.ReplaceAll(strFunc, "$$SPIDER_SERVER$$", "http://"+cr.ServiceIPorName+cr.ServicePort) // cr.ServicePort = ":1024" - return strFunc + strFunc = strings.ReplaceAll(strFunc, "$$SPIDER_SERVER$$", "http://"+cr.ServiceIPorName+cr.ServicePort) // cr.ServicePort = ":1024" + return strFunc } func SecurityGroup(c echo.Context) error { @@ -379,7 +404,7 @@ func SecurityGroup(c echo.Context) error { // (2) make Table Action TR // colspan, f5_href, delete_href, fontSize //htmlStr += makeActionTR_html("6", "securitygroup", "deleteSecurityGroup()", "2") - htmlStr += makeActionTR_html("6", "", "deleteSecurityGroup()", "2") + htmlStr += makeActionTR_html("6", "", fmt.Sprintf("deleteSecurityGroup('%s')", connConfig), "2") // (3) make Table Header TR nameWidthList := []NameWidth{ @@ -400,7 +425,7 @@ func SecurityGroup(c echo.Context) error { if err != nil { cblog.Error(err) // client logging - htmlStr += genLoggingResult(err.Error()) + htmlStr += genLoggingResult(err.Error()) return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) } @@ -413,7 +438,7 @@ func SecurityGroup(c echo.Context) error { json.Unmarshal(resBody, &info) // (4-2) make TR list with info list - htmlStr += makeSecurityGroupTRList_html("", "", "", info.ResultList) + htmlStr += makeSecurityGroupTRList_html("", "", "", connConfig, info.ResultList) // (5) make input field and add // attach text box for add @@ -441,7 +466,7 @@ func SecurityGroup(c echo.Context) error { - + + diff --git a/api-runtime/rest-runtime/admin-web/AdminWeb-VM.go b/api-runtime/rest-runtime/admin-web/AdminWeb-VM.go index 0ef73722e..a983af4b6 100644 --- a/api-runtime/rest-runtime/admin-web/AdminWeb-VM.go +++ b/api-runtime/rest-runtime/admin-web/AdminWeb-VM.go @@ -51,7 +51,7 @@ func makeVMTRList_html(connConfig string, bgcolor string, height string, fontSiz $$VMCONTROL$$
- + $$VMSTATUS$$ @@ -115,9 +115,9 @@ func makeVMTRList_html(connConfig string, bgcolor string, height string, fontSiz str = strings.ReplaceAll(str, "$$VMSTATUS$$", status) if cres.VMStatus(status) == cres.Running { - str = strings.ReplaceAll(str, "$$VMCONTROL$$", `[Suspend / Reboot]`) + str = strings.ReplaceAll(str, "$$VMCONTROL$$", `[Suspend / Reboot]`) } else if cres.VMStatus(status) == cres.Suspended { - str = strings.ReplaceAll(str, "$$VMCONTROL$$", `[Resume]`) + str = strings.ReplaceAll(str, "$$VMCONTROL$$", `[Resume]`) } else { str = strings.ReplaceAll(str, "$$VMCONTROL$$", `[vm control disabed]
you can control when Running / Suspended.
try refresh page...`) } @@ -224,12 +224,15 @@ func genLoggingOneGETURL(connConfig string, rsType string, name string) string { url := "http://" + "localhost" + cr.ServerPort + "/spider/" + rsType + "/" + name + " -H 'Content-Type: application/json' -d '{\\\"ConnectionName\\\": \\\"" + connConfig + "\\\"}'" htmlStr := ` - - ` + +` + return htmlStr } @@ -238,8 +241,7 @@ func makeVMControlFunc_js() string { //curl -sX PUT http://localhost:1024/spider/controlvm/vm-01?action=suspend -H 'Content-Type: application/json' -d '{ "ConnectionName": "'${CONN_CONFIG}'"}' strFunc := ` - function vmControl(vmName, action) { - var connConfig = parent.frames["top_frame"].document.getElementById("connConfig").innerHTML; + function vmControl(connConfig, vmName, action) { document.getElementById("vmcontrol-" + vmName).innerHTML = 'Waiting...'; setTimeout(function(){ @@ -249,12 +251,20 @@ func makeVMControlFunc_js() string { sendJson = '{ "ConnectionName": "' + connConfig + '"}' // client logging - parent.frames["log_frame"].Log("PUT> " + "$$SPIDER_SERVER$$/spider/controlvm/" + vmName + "?action=" + action + " -H 'Content-Type: application/json' -d '" + sendJson + "'"); + try { + parent.frames["log_frame"].Log("PUT> " + "$$SPIDER_SERVER$$/spider/controlvm/" + vmName + "?action=" + action + " -H 'Content-Type: application/json' -d '" + sendJson + "'"); + } catch(e) { + // Do nothing if error occurs + } xhr.send(sendJson); // client logging - parent.frames["log_frame"].Log(" ==> " + xhr.response); + try { + parent.frames["log_frame"].Log(" ==> " + xhr.response); + } catch(e) { + // Do nothing if error occurs + } location.reload(); }, 10); @@ -273,8 +283,7 @@ func makePostVMFunc_js() string { // "SubnetName": "subnet-01", "SecurityGroupNames": [ "sg-01" ], "VMSpecName": "t2.micro", "KeyPairName": "keypair-01"} }' strFunc := ` - function postVM() { - var connConfig = parent.frames["top_frame"].document.getElementById("connConfig").innerHTML; + function postVM(connConfig) { var textboxes = document.getElementsByName('text_box'); sendJson = '{ "ConnectionName" : "' + connConfig + '", "ReqInfo" : { "Name" : "$$VMNAME$$", "ImageType" : "$$IMAGETYPE$$",\ "ImageName" : "$$IMAGE$$", "VMSpecName" : "$$SPEC$$", "VPCName" : "$$VPC$$", "SubnetName" : "$$SUBNET$$", \ @@ -339,12 +348,20 @@ func makePostVMFunc_js() string { xhr.setRequestHeader('Content-Type', 'application/json'); // client logging - parent.frames["log_frame"].Log("curl -sX POST " + "$$SPIDER_SERVER$$/spider/vm -H 'Content-Type: application/json' -d '" + sendJson + "'"); + try { + parent.frames["log_frame"].Log("curl -sX POST " + "$$SPIDER_SERVER$$/spider/vm -H 'Content-Type: application/json' -d '" + sendJson + "'"); + } catch(e) { + // Do nothing if error occurs + } - xhr.send(sendJson); + xhr.send(sendJson); // client logging - parent.frames["log_frame"].Log(" ==> " + xhr.response); + try { + parent.frames["log_frame"].Log(" ==> " + xhr.response); + } catch(e) { + // Do nothing if error occurs + } location.reload(); } @@ -391,8 +408,7 @@ func makeDeleteVMFunc_js() string { // curl -sX DELETE http://localhost:1024/spider/vm/vm-01 -H 'Content-Type: application/json' -d '{ "ConnectionName": "'${CONN_CONFIG}'"}' strFunc := ` - function deleteVM() { - var connConfig = parent.frames["top_frame"].document.getElementById("connConfig").innerHTML; + function deleteVM(connConfig) { var checkboxes = document.getElementsByName('check_box'); for (var i = 0; i < checkboxes.length; i++) { // @todo make parallel executions if (checkboxes[i].checked) { @@ -402,12 +418,20 @@ func makeDeleteVMFunc_js() string { sendJson = '{ "ConnectionName": "' + connConfig + '"}' // client logging - parent.frames["log_frame"].Log("curl -sX DELETE " + "$$SPIDER_SERVER$$/spider/vm/" + checkboxes[i].value + " -H 'Content-Type: application/json' -d '" + sendJson + "'"); + try { + parent.frames["log_frame"].Log("curl -sX DELETE " + "$$SPIDER_SERVER$$/spider/vm/" + checkboxes[i].value + " -H 'Content-Type: application/json' -d '" + sendJson + "'"); + } catch(e) { + // Do nothing if error occurs + } - xhr.send(sendJson); + xhr.send(sendJson); // client logging - parent.frames["log_frame"].Log(" ==> " + xhr.response); + try { + parent.frames["log_frame"].Log(" ==> " + xhr.response); + } catch(e) { + // Do nothing if error occurs + } } } location.reload(); @@ -483,7 +507,7 @@ func VM(c echo.Context) error { // (2) make Table Action TR // colspan, f5_href, delete_href, fontSize - htmlStr += makeActionTR_html("11", "", "deleteVM()", "2") + htmlStr += makeActionTR_html("11", "", fmt.Sprintf("deleteVM('%s')", connConfig), "2") // (3) make Table Header TR nameWidthList := []NameWidth{ @@ -668,7 +692,7 @@ func VM(c echo.Context) error { - + + @@ -807,9 +831,7 @@ func makePostSnapshotVMFunc_js() string { // } }' strFunc := ` - function postSnapshotVM(i, vmName) { - var connConfig = parent.frames["top_frame"].document.getElementById("connConfig").innerHTML; - + function postSnapshotVM(connConfig, i, vmName) { var myImages = document.getElementsByName('myimage-name'); var idx = parseInt(i)-1; var myImageName = myImages[idx].value; @@ -823,16 +845,23 @@ func makePostSnapshotVMFunc_js() string { xhr.setRequestHeader('Content-Type', 'application/json'); // client logging - parent.frames["log_frame"].Log("curl -sX POST " + + try { + parent.frames["log_frame"].Log("curl -sX POST " + "$$SPIDER_SERVER$$/spider/myimage -H 'Content-Type: application/json' -d '" + sendJson + "'"); + } catch(e) { + // Do nothing if error occurs + } xhr.send(sendJson); // client logging - parent.frames["log_frame"].Log(" ==> " + xhr.response); + try { + parent.frames["log_frame"].Log(" ==> " + xhr.response); + } catch(e) { + // Do nothing if error occurs + } var jsonVal = JSON.parse(xhr.response) - location.reload(); } ` diff --git a/api-runtime/rest-runtime/admin-web/html/dashboard.html b/api-runtime/rest-runtime/admin-web/html/dashboard.html index b9216cf04..338a83e24 100644 --- a/api-runtime/rest-runtime/admin-web/html/dashboard.html +++ b/api-runtime/rest-runtime/admin-web/html/dashboard.html @@ -91,20 +91,68 @@ .content { margin-top: 100px; } + /* Input styles */ + .refresh-input { + width: 50px; + } + .form-inline { + display: flex; + align-items: center; + justify-content: space-between; + } + .form-inline > * { + margin-right: 10px; + } + .interval-container { + display: none; + margin-left: 10px; + } + .right-controls { + display: flex; + align-items: center; + } + .right-controls > * { + margin-left: 10px; + }

Cloud Connection Dashboard

-
+
- - +
+ +
+ +
+
+
{{range $provider, $counts := .ResourceCounts}} From 6f7e40b8ffafbee4ff901f3963dcf2995316eaec Mon Sep 17 00:00:00 2001 From: raccoom-mh Date: Tue, 28 May 2024 14:29:59 +0900 Subject: [PATCH 08/19] [AWS:Cluster] Change the subnet configuration to 'Enable auto-assign public ip address' #1141 --- .../drivers/aws/connect/AwsCloudConnection.go | 5 ++++- .../drivers/aws/resources/ClusterHandler.go | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/cloud-control-manager/cloud-driver/drivers/aws/connect/AwsCloudConnection.go b/cloud-control-manager/cloud-driver/drivers/aws/connect/AwsCloudConnection.go index 611a35b6c..39067a306 100644 --- a/cloud-control-manager/cloud-driver/drivers/aws/connect/AwsCloudConnection.go +++ b/cloud-control-manager/cloud-driver/drivers/aws/connect/AwsCloudConnection.go @@ -153,13 +153,16 @@ func (cloudConn *AwsCloudConnection) CreateClusterHandler() (irs.ClusterHandler, if cloudConn.EKSClient == nil { cblogger.Info("cloudConn.EKSClient is nil") } + if cloudConn.VNetworkClient == nil { + cblogger.Info("cloudConn.VNetworkClient is nil") + } if cloudConn.IamClient == nil { cblogger.Info("cloudConn.IamClient is nil") } if cloudConn.AutoScalingClient == nil { cblogger.Info("cloudConn.AutoScalingClient is nil") } - handler := ars.AwsClusterHandler{cloudConn.Region, cloudConn.EKSClient, cloudConn.IamClient, cloudConn.AutoScalingClient} + handler := ars.AwsClusterHandler{cloudConn.Region, cloudConn.EKSClient, cloudConn.VNetworkClient, cloudConn.IamClient, cloudConn.AutoScalingClient} return &handler, nil } diff --git a/cloud-control-manager/cloud-driver/drivers/aws/resources/ClusterHandler.go b/cloud-control-manager/cloud-driver/drivers/aws/resources/ClusterHandler.go index 6a6199cd2..3aea034a8 100644 --- a/cloud-control-manager/cloud-driver/drivers/aws/resources/ClusterHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/aws/resources/ClusterHandler.go @@ -10,6 +10,7 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/service/autoscaling" + "github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/eks" "github.com/aws/aws-sdk-go/service/iam" call "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/call-log" @@ -21,6 +22,7 @@ import ( type AwsClusterHandler struct { Region idrv.RegionInfo Client *eks.EKS + EC2Client *ec2.EC2 Iam *iam.IAM AutoScaling *autoscaling.AutoScaling } @@ -564,6 +566,23 @@ func (ClusterHandler *AwsClusterHandler) AddNodeGroup(clusterIID irs.IID, nodeGr subnetList = append(subnetList, &subnetId) } + // 이 부분에서 VPC subnet ID 를 바탕으로 리스트 순회하며 ModifySubnetAttribute 를 통해 Auto-assign public IPv4 address를 활성화 + for _, subnetIdPtr := range subnetList { + input := &ec2.ModifySubnetAttributeInput{ + MapPublicIpOnLaunch: &ec2.AttributeBooleanValue{ + Value: aws.Bool(true), + }, + SubnetId: subnetIdPtr, + } + _, err := ClusterHandler.EC2Client.ModifySubnetAttribute(input) + if err != nil { + errmsg := "error during ModifySubnetAttribute to MapPublicIpOnLaunch=TRUE on subnet : " + *subnetIdPtr + cblogger.Error(err) + cblogger.Error(errmsg) + // return irs.NodeGroupInfo{}, errors.New(errmsg) // 서브넷 순회 이므로 나머지 서브넷은 진행하도록 주석처리함. + } + } + cblogger.Debug("최종 Subnet 목록") if cblogger.Level.String() == "debug" { spew.Dump(subnetList) From 32bc2d668c0c531d6c38acd58031aaf3ca1155c6 Mon Sep 17 00:00:00 2001 From: powerkimhub Date: Thu, 30 May 2024 22:11:25 +0900 Subject: [PATCH 09/19] Improved the AdminWeb Dashboard to enable control from nlb to pmks --- .../admin-web/AdminWeb-Cluster.go | 316 ++++++++++-------- .../rest-runtime/admin-web/AdminWeb-Disk.go | 95 ++++-- .../admin-web/AdminWeb-MyImage.go | 249 +++++++------- .../rest-runtime/admin-web/AdminWeb-NLB.go | 182 +++++----- 4 files changed, 465 insertions(+), 377 deletions(-) diff --git a/api-runtime/rest-runtime/admin-web/AdminWeb-Cluster.go b/api-runtime/rest-runtime/admin-web/AdminWeb-Cluster.go index 6ccf8ccd0..e6683c7c1 100644 --- a/api-runtime/rest-runtime/admin-web/AdminWeb-Cluster.go +++ b/api-runtime/rest-runtime/admin-web/AdminWeb-Cluster.go @@ -23,11 +23,10 @@ import ( "github.com/labstack/echo/v4" ) - //====================================== Cluster: Provider Managed Kubernetes(PMKS) -// number, CLUSTERNAME/Version, Status/CreatedTime, NetworkInfo(VPC/Sub/SG), AccessInfo(AccessPoint/KubeConfig), Addons, -// NodeGroups, +// number, CLUSTERNAME/Version, Status/CreatedTime, NetworkInfo(VPC/Sub/SG), AccessInfo(AccessPoint/KubeConfig), Addons, +// NodeGroups, // Additional Info, checkbox func makeClusterTRList_html(bgcolor string, height string, fontSize string, providerName string, connConfig string, infoList []*cres.ClusterInfo) string { if bgcolor == "" { @@ -91,8 +90,8 @@ $$ADDITIONALINFO$$ - `, bgcolor, height, fontSize, fontSize, fontSize, fontSize, fontSize, - fontSize, fontSize, fontSize, fontSize, fontSize, fontSize) + `, bgcolor, height, fontSize, fontSize, fontSize, fontSize, fontSize, + fontSize, fontSize, fontSize, fontSize, fontSize, fontSize) strRemoveNodeGroup := fmt.Sprintf(` @@ -109,8 +108,6 @@ $$ADDITIONALINFO$$ `, generateNodeGroupReqString(providerName), fontSize) - - strData := "" // set data and make TR list for i, one := range infoList { @@ -127,19 +124,19 @@ $$ADDITIONALINFO$$ // for Subnet strSRList := "" for _, one := range one.Network.SubnetIIDs { - strSRList += one.NameId + "," + strSRList += one.NameId + "," } strSRList = strings.TrimSuffix(strSRList, ",") - strSRList = "[" + strSRList + "]" + strSRList = "[" + strSRList + "]" str = strings.ReplaceAll(str, "$$SUBNET$$", strSRList) // for security rules info strSRList = "" for _, one := range one.Network.SecurityGroupIIDs { - strSRList += one.NameId + "," + strSRList += one.NameId + "," } strSRList = strings.TrimSuffix(strSRList, ",") - strSRList = "[" + strSRList + "]" + strSRList = "[" + strSRList + "]" str = strings.ReplaceAll(str, "$$SECURITYGROUP$$", strSRList) str = strings.ReplaceAll(str, "$$ENDPOINT$$", one.AccessInfo.Endpoint) @@ -178,7 +175,7 @@ $$ADDITIONALINFO$$ strVMList += generateNodeInfoHyperlinkNodeString(idx, connConfig, vmIID.SystemId) + ", " } strVMList = strings.TrimRight(strVMList, ", ") - + strNodeGroupList += "         Nodes: [ " + strVMList + " ] " + "
" strNodeGroupList += "}" @@ -192,13 +189,13 @@ $$ADDITIONALINFO$$ // strNodeGroupList += "}" var nodegroupName = one.IId.NameId - strNodeGroupList += strings.ReplaceAll(strRemoveNodeGroup, "$$REMOVENODEGROUP$$", "removeNodeGroup('"+clusterName+"', '"+nodegroupName+"')") + strNodeGroupList += strings.ReplaceAll(strRemoveNodeGroup, "$$REMOVENODEGROUP$$", "removeNodeGroup('"+connConfig+"', '"+clusterName+"', '"+nodegroupName+"')") strNodeGroupList += "
----------" strNodeGroupList += "
" } clusterAddNodeGroup := strings.ReplaceAll(strAddNodegroup, "$$ADDCLUSTER$$", clusterName) - strNodeGroupList += strings.ReplaceAll(clusterAddNodeGroup, "$$ADDNODEGROUP$$", "postNodeGroup('"+clusterName+"')") + strNodeGroupList += strings.ReplaceAll(clusterAddNodeGroup, "$$ADDNODEGROUP$$", "postNodeGroup('"+connConfig+"', '"+clusterName+"')") str = strings.ReplaceAll(str, "$$NODEGROUPS$$", strNodeGroupList) // for KeyValueList @@ -230,21 +227,29 @@ func makeOpenNodeInfoFunc_js() string { strFunc := ` function openNodeInfoWindow(connConfig, nodeCSPName) { - var xhr = new XMLHttpRequest(); - xhr.open("GET", "$$SPIDER_SERVER$$/spider/cspvm/" + nodeCSPName + "?ConnectionName=" + connConfig, false); + var xhr = new XMLHttpRequest(); + xhr.open("GET", "$$SPIDER_SERVER$$/spider/cspvm/" + nodeCSPName + "?ConnectionName=" + connConfig, false); - // client logging - parent.frames["log_frame"].Log("curl -sX GET " + "$$SPIDER_SERVER$$/spider/cspvm" + nodeCSPName + "?ConnectionName=" + connConfig); + // client logging + try { + parent.frames["log_frame"].Log("curl -sX GET " + "$$SPIDER_SERVER$$/spider/cspvm" + nodeCSPName + "?ConnectionName=" + connConfig); + } catch (e) { + // Do nothing if error occurs + } - xhr.send(null); + xhr.send(null); - // client logging - parent.frames["log_frame"].Log(" => " + xhr.response); - - var win = window.open("", "_blank", "width=500,height=690,location=no,scrollbars=no,menubar=no,status=no,titlebar=no,toolbar=no,resizable=no,top=300,left=500,"); - var jsonPretty = JSON.stringify(JSON.parse(xhr.response),null,2); - var textArea = '' - win.document.write(textArea); + // client logging + try { + parent.frames["log_frame"].Log(" => " + xhr.response); + } catch (e) { + // Do nothing if error occurs + } + + var win = window.open("", "_blank", "width=500,height=690,location=no,scrollbars=no,menubar=no,status=no,titlebar=no,toolbar=no,resizable=no,top=300,left=500,"); + var jsonPretty = JSON.stringify(JSON.parse(xhr.response),null,2); + var textArea = '' + win.document.write(textArea); } ` strFunc = strings.ReplaceAll(strFunc, "$$SPIDER_SERVER$$", "http://"+cr.ServiceIPorName+cr.ServicePort) // cr.ServicePort = ":1024" @@ -252,45 +257,44 @@ func makeOpenNodeInfoFunc_js() string { } func generateNodeGroupReqString(providerName string) string { - - Name := "economy" - ImageName := "" - VMSpecName := "" - RootDiskType := "" - RootDiskSize := "60" - KeyPairName := "keypair-01" - OnAutoScaling := "true" - DesiredNodeSize := "2" - MinNodeSize := "1" - MaxNodeSize := "3" - - - switch providerName { - case "AWS": - case "AZURE": - VMSpecName = "Standard_B2s" - case "GCP": - case "ALIBABA": - VMSpecName = "ecs.c6.xlarge" - RootDiskType = "cloud_essd" - case "TENCENT": - ImageName = "tlinux3.1x86_64" - VMSpecName = "S3.MEDIUM8" - RootDiskType = "CLOUD_BSSD" - - case "IBM": - case "CLOUDIT": - case "OPENSTACK": - case "NCP": - case "KTCLOUD": - case "NHNCLOUD": - case "DOCKER": - case "MOCK": - case "CLOUDTWIN": - default: - } - - reqString := fmt.Sprintf(`{ + + Name := "economy" + ImageName := "" + VMSpecName := "" + RootDiskType := "" + RootDiskSize := "60" + KeyPairName := "keypair-01" + OnAutoScaling := "true" + DesiredNodeSize := "2" + MinNodeSize := "1" + MaxNodeSize := "3" + + switch providerName { + case "AWS": + case "AZURE": + VMSpecName = "Standard_B2s" + case "GCP": + case "ALIBABA": + VMSpecName = "ecs.c6.xlarge" + RootDiskType = "cloud_essd" + case "TENCENT": + ImageName = "tlinux3.1x86_64" + VMSpecName = "S3.MEDIUM8" + RootDiskType = "CLOUD_BSSD" + + case "IBM": + case "CLOUDIT": + case "OPENSTACK": + case "NCP": + case "KTCLOUD": + case "NHNCLOUD": + case "DOCKER": + case "MOCK": + case "CLOUDTWIN": + default: + } + + reqString := fmt.Sprintf(`{ "Name" : "%s", "ImageName" : "%s", "VMSpecName" : "%s", @@ -301,31 +305,31 @@ func generateNodeGroupReqString(providerName string) string { "DesiredNodeSize" : "%s", "MinNodeSize" : "%s", "MaxNodeSize" : "%s" -}`, Name, ImageName, VMSpecName, RootDiskType, RootDiskSize, KeyPairName, - OnAutoScaling, DesiredNodeSize, MinNodeSize, MaxNodeSize) +}`, Name, ImageName, VMSpecName, RootDiskType, RootDiskSize, KeyPairName, + OnAutoScaling, DesiredNodeSize, MinNodeSize, MaxNodeSize) return reqString } + // make the string of javascript function func makePostClusterFunc_js() string { -// curl -sX POST http://localhost:1024/spider/cluster -H 'Content-Type: application/json' -d \ -// '{ -// "ConnectionName": "alibaba-tokyo-config", + // curl -sX POST http://localhost:1024/spider/cluster -H 'Content-Type: application/json' -d \ + // '{ + // "ConnectionName": "alibaba-tokyo-config", -// "ReqInfo": { -// "Name": "spider-cluser-01", -// "Version": "1.22.15-aliyun.1", + // "ReqInfo": { + // "Name": "spider-cluser-01", + // "Version": "1.22.15-aliyun.1", -// "VPCName": "vpc-01", -// "SubnetNames": ["subnet-01"], -// "SecurityGroupNames": ["sg-01"] -// } -// }' |json_pp + // "VPCName": "vpc-01", + // "SubnetNames": ["subnet-01"], + // "SecurityGroupNames": ["sg-01"] + // } + // }' |json_pp strFunc := ` - function postCluster() { - var connConfig = parent.frames["top_frame"].document.getElementById("connConfig").innerHTML; + function postCluster(connConfig) { var textboxes = document.getElementsByName('text_box'); sendJson = '{ "ConnectionName" : "' + connConfig + '", "ReqInfo" : \ @@ -372,12 +376,20 @@ func makePostClusterFunc_js() string { xhr.setRequestHeader('Content-Type', 'application/json'); // client logging - parent.frames["log_frame"].Log("curl -sX POST " + "$$SPIDER_SERVER$$/spider/cluster -H 'Content-Type: application/json' -d '" + sendJson + "'"); + try { + parent.frames["log_frame"].Log("curl -sX POST " + "$$SPIDER_SERVER$$/spider/cluster -H 'Content-Type: application/json' -d '" + sendJson + "'"); + } catch (e) { + // Do nothing if error occurs + } - xhr.send(sendJson); + xhr.send(sendJson); // client logging - parent.frames["log_frame"].Log(" ==> " + xhr.response); + try { + parent.frames["log_frame"].Log(" ==> " + xhr.response); + } catch (e) { + // Do nothing if error occurs + } location.reload(); } @@ -388,14 +400,13 @@ func makePostClusterFunc_js() string { // make the string of javascript function func makeDeleteClusterFunc_js() string { -// curl -sX DELETE http://localhost:1024/spider/cluster/spider-cluser-01 -H 'Content-Type: application/json' -d \ -// '{ -// "ConnectionName": "alibaba-tokyo-config" -// }' |json_pp + // curl -sX DELETE http://localhost:1024/spider/cluster/spider-cluser-01 -H 'Content-Type: application/json' -d \ + // '{ + // "ConnectionName": "alibaba-tokyo-config" + // }' |json_pp strFunc := ` - function deleteCluster() { - var connConfig = parent.frames["top_frame"].document.getElementById("connConfig").innerHTML; + function deleteCluster(connConfig) { var checkboxes = document.getElementsByName('check_box'); for (var i = 0; i < checkboxes.length; i++) { // @todo make parallel executions @@ -406,12 +417,20 @@ func makeDeleteClusterFunc_js() string { sendJson = '{ "ConnectionName": "' + connConfig + '"}' // client logging - parent.frames["log_frame"].Log("curl -sX DELETE " + "$$SPIDER_SERVER$$/spider/cluster/" + checkboxes[i].value + " -H 'Content-Type: application/json' -d '" + sendJson + "'"); + try { + parent.frames["log_frame"].Log("curl -sX DELETE " + "$$SPIDER_SERVER$$/spider/cluster/" + checkboxes[i].value + " -H 'Content-Type: application/json' -d '" + sendJson + "'"); + } catch (e) { + // Do nothing if error occurs + } - xhr.send(sendJson); + xhr.send(sendJson); // client logging - parent.frames["log_frame"].Log(" ==> " + xhr.response); + try { + parent.frames["log_frame"].Log(" ==> " + xhr.response); + } catch (e) { + // Do nothing if error occurs + } } } location.reload(); @@ -424,28 +443,26 @@ func makeDeleteClusterFunc_js() string { // make the string of javascript function func makePostNodeGroupFunc_js() string { -// curl -sX POST http://localhost:1024/spider/cluster/spider-cluser-01/nodegroup -H 'Content-Type: application/json' -d \ -// '{ -// "ConnectionName": "alibaba-tokyo-config", - -// "ReqInfo": { -// "Name": "Economy", -// "ImageName": "ubuntu_18_04_x64_20G_alibase_20220322.vhd", -// "VMSpecName": "ecs.c6.xlarge", -// "RootDiskType": "cloud_essd", -// "RootDiskSize": "70", -// "KeyPairName": "keypair-01", -// "OnAutoScaling": "true", -// "DesiredNodeSize": "2", -// "MinNodeSize": "2", -// "MaxNodeSize": "2" -// } -// }' |json_pp + // curl -sX POST http://localhost:1024/spider/cluster/spider-cluser-01/nodegroup -H 'Content-Type: application/json' -d \ + // '{ + // "ConnectionName": "alibaba-tokyo-config", + + // "ReqInfo": { + // "Name": "Economy", + // "ImageName": "ubuntu_18_04_x64_20G_alibase_20220322.vhd", + // "VMSpecName": "ecs.c6.xlarge", + // "RootDiskType": "cloud_essd", + // "RootDiskSize": "70", + // "KeyPairName": "keypair-01", + // "OnAutoScaling": "true", + // "DesiredNodeSize": "2", + // "MinNodeSize": "2", + // "MaxNodeSize": "2" + // } + // }' |json_pp strFunc := ` - function postNodeGroup(clusterName) { - var connConfig = parent.frames["top_frame"].document.getElementById("connConfig").innerHTML; - + function postNodeGroup(connConfig, clusterName) { var textbox = document.getElementById('nodegroup_text_box_' + clusterName); sendJson = '{ "ConnectionName" : "' + connConfig + '", "ReqInfo" : $$NODEGROUPINFO$$ }' @@ -455,16 +472,23 @@ func makePostNodeGroupFunc_js() string { xhr.open("POST", "$$SPIDER_SERVER$$/spider/cluster/" + clusterName + "/nodegroup", false); xhr.setRequestHeader('Content-Type', 'application/json'); - // client logging - parent.frames["log_frame"].Log("curl -sX POST " + "$$SPIDER_SERVER$$/spider/cluster/" + clusterName + "/nodegroup" + " -H 'Content-Type: application/json' -d '" + sendJson + "'"); - - xhr.send(sendJson); - - // client logging - parent.frames["log_frame"].Log(" => " + xhr.response); - - location.reload(); - } + // client logging + try { + parent.frames["log_frame"].Log("curl -sX POST " + "$$SPIDER_SERVER$$/spider/cluster/" + clusterName + "/nodegroup" + " -H 'Content-Type: application/json' -d '" + sendJson + "'"); + } catch (e) { + // Do nothing if error occurs + } + xhr.send(sendJson); + + // client logging + try { + parent.frames["log_frame"].Log(" => " + xhr.response); + } catch (e) { + // Do nothing if error occurs + } + + location.reload(); + } ` strFunc = strings.ReplaceAll(strFunc, "$$SPIDER_SERVER$$", "http://"+cr.ServiceIPorName+cr.ServicePort) // cr.ServicePort = ":1024" return strFunc @@ -475,21 +499,27 @@ func makeRemoveNodeGroupFunc_js() string { //curl -sX DELETE http://localhost:1024/spider/cluster/spider-cluser-01/nodegroup/Economy -H 'Content-Type: application/json' -d '{ "ConnectionName": "'${CONN_CONFIG}'"}' strFunc := ` - function removeNodeGroup(clusterName, nodegroupName) { - var connConfig = parent.frames["top_frame"].document.getElementById("connConfig").innerHTML; - + function removeNodeGroup(connConfig, clusterName, nodegroupName) { var xhr = new XMLHttpRequest(); xhr.open("DELETE", "$$SPIDER_SERVER$$/spider/cluster/" + clusterName + "/nodegroup/" + nodegroupName, false); xhr.setRequestHeader('Content-Type', 'application/json'); sendJson = '{ "ConnectionName": "' + connConfig + '"}' - // client logging - parent.frames["log_frame"].Log("curl -sX DELETE " + "$$SPIDER_SERVER$$/spider/cluster/" + clusterName + "/nodegroup/" + nodegroupName + " -H 'Content-Type: application/json' -d '" + sendJson + "'"); + // client logging + try { + parent.frames["log_frame"].Log("curl -sX DELETE " + "$$SPIDER_SERVER$$/spider/cluster/" + clusterName + "/nodegroup/" + nodegroupName + " -H 'Content-Type: application/json' -d '" + sendJson + "'"); + } catch (e) { + // Do nothing if error occurs + } xhr.send(sendJson); - // client logging - parent.frames["log_frame"].Log(" => " + xhr.response); + // client logging + try { + parent.frames["log_frame"].Log(" => " + xhr.response); + } catch (e) { + // Do nothing if error occurs + } location.reload(); } @@ -498,7 +528,6 @@ func makeRemoveNodeGroupFunc_js() string { return strFunc } - func Cluster(c echo.Context) error { cblog.Info("call Cluster()") @@ -550,7 +579,7 @@ func Cluster(c echo.Context) error { // (1) make Javascript Function htmlStr += makeCheckBoxToggleFunc_js() htmlStr += makePostClusterFunc_js() - htmlStr += makeDeleteClusterFunc_js() + htmlStr += makeDeleteClusterFunc_js() htmlStr += makePostNodeGroupFunc_js() htmlStr += makeRemoveNodeGroupFunc_js() htmlStr += makeOpenNodeInfoFunc_js() @@ -565,7 +594,7 @@ func Cluster(c echo.Context) error { // (2) make Table Action TR // colspan, f5_href, delete_href, fontSize - htmlStr += makeActionTR_html("10", "", "deleteCluster()", "2") + htmlStr += makeActionTR_html("10", "", fmt.Sprintf("deleteCluster('%s')", connConfig), "2") // (3) make Table Header TR nameWidthList := []NameWidth{ @@ -589,14 +618,14 @@ func Cluster(c echo.Context) error { if err != nil { cblog.Error(err) // client logging - htmlStr += genLoggingResult(err.Error()) + htmlStr += genLoggingResult(err.Error()) return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) } // client logging htmlStr += genLoggingResult(string(resBody[:len(resBody)-1])) var info struct { - Connection string + Connection string ClusterInfoList []*cres.ClusterInfo } json.Unmarshal(resBody, &info) @@ -606,7 +635,7 @@ func Cluster(c echo.Context) error { // (4-2) make TR list with info list htmlStr += makeClusterTRList_html("", "", "", providerName, connConfig, info.ClusterInfoList) - // (5) make input field and add + // (5) make input field and add vpcList := vpcList(connConfig) version := "" @@ -670,8 +699,8 @@ func Cluster(c echo.Context) error { ` - // AccessInfo and Addons - htmlStr += ` + // AccessInfo and Addons + htmlStr += ` @@ -682,33 +711,32 @@ func Cluster(c echo.Context) error { // NodeGroup if nodegroupList == "" { // Tencent, Alibaba - htmlStr += ` + htmlStr += ` ` - } else { // Azure, NHN - htmlStr += fmt.Sprintf(` + } else { // Azure, NHN + htmlStr += fmt.Sprintf(` `, nodegroupList) - } + } // AdditionalInfo - htmlStr += ` + htmlStr += ` ` - // create button with '+' htmlStr += ` - + + diff --git a/api-runtime/rest-runtime/admin-web/AdminWeb-Disk.go b/api-runtime/rest-runtime/admin-web/AdminWeb-Disk.go index 99f1cfdc9..305e1fc20 100644 --- a/api-runtime/rest-runtime/admin-web/AdminWeb-Disk.go +++ b/api-runtime/rest-runtime/admin-web/AdminWeb-Disk.go @@ -27,7 +27,7 @@ import ( //====================================== Disk // number, Disk Name, Disk Type, Disk Size, Disk Status, Attach/Detach, Created Time, Additional Info, checkbox -func makeDiskTRList_html(bgcolor string, height string, fontSize string, infoList []*cres.DiskInfo, vmList []string) string { +func makeDiskTRList_html(bgcolor string, height string, fontSize string, connConfig string, infoList []*cres.DiskInfo, vmList []string) string { if bgcolor == "" { bgcolor = "#FFFFFF" } @@ -91,7 +91,7 @@ func makeDiskTRList_html(bgcolor string, height string, fontSize string, infoLis sizeInputText := ` GB  ` - sizeUpButton := `` + sizeUpButton := `` str = strings.ReplaceAll(str, "$$DISKSIZE$$", sizeInputText+sizeUpButton) // Status @@ -99,11 +99,11 @@ func makeDiskTRList_html(bgcolor string, height string, fontSize string, infoLis // Attach/Detach if one.Status == cres.DiskAvailable { - attachButton := `` str = strings.ReplaceAll(str, "$$ATTACHDETACH$$", selectHtml+"  "+attachButton) } else if one.Status == cres.DiskAttached { - detachButton := `` str = strings.ReplaceAll(str, "$$ATTACHDETACH$$", one.OwnerVM.NameId+"  "+detachButton) } else { @@ -138,9 +138,7 @@ func makePostDiskFunc_js() string { // } }' strFunc := ` - function postDisk() { - var connConfig = parent.frames["top_frame"].document.getElementById("connConfig").innerHTML; - + function postDisk(connConfig) { var textboxes = document.getElementsByName('text_box'); sendJson = '{ "ConnectionName" : "' + connConfig + '", "ReqInfo" : { "Name" : "$$DISKNAME$$", "Zone" : "$$ZONEID$$", "DiskType" : "$$DISKTYPE$$", "DiskSize" : "$$DISKSIZE$$"}}' @@ -167,14 +165,22 @@ func makePostDiskFunc_js() string { xhr.setRequestHeader('Content-Type', 'application/json'); // client logging - parent.frames["log_frame"].Log("curl -sX POST " + "$$SPIDER_SERVER$$/spider/disk -H 'Content-Type: application/json' -d '" + sendJson + "'"); + try { + parent.frames["log_frame"].Log("curl -sX POST " + "$$SPIDER_SERVER$$/spider/disk -H 'Content-Type: application/json' -d '" + sendJson + "'"); + } catch (e) { + // Do nothing if error occurs + } xhr.send(sendJson); // client logging - parent.frames["log_frame"].Log(" ==> " + xhr.response); - var jsonVal = JSON.parse(xhr.response) + try { + parent.frames["log_frame"].Log(" ==> " + xhr.response); + } catch (e) { + // Do nothing if error occurs + } + var jsonVal = JSON.parse(xhr.response) location.reload(); } @@ -196,9 +202,7 @@ func makeDiskSizeUpFunc_js() string { */ strFunc := ` - function diskSizeUp(diskName, sizeInputTextId) { - var connConfig = parent.frames["top_frame"].document.getElementById("connConfig").innerHTML; - + function diskSizeUp(connConfig, diskName, sizeInputTextId) { var textbox = document.getElementById('size_input_text_'+diskName); upSize = textbox.value @@ -208,12 +212,20 @@ func makeDiskSizeUpFunc_js() string { sendJson = '{ "ConnectionName": "' + connConfig + '", "ReqInfo": { "Size" : "' + upSize + '" } }' // client logging - parent.frames["log_frame"].Log("PUT> " + "$$SPIDER_SERVER$$/spider/disk/" + diskName + "/size" + " -H 'Content-Type: application/json' -d '" + sendJson + "'"); + try { + parent.frames["log_frame"].Log("PUT> " + "$$SPIDER_SERVER$$/spider/disk/" + diskName + "/size" + " -H 'Content-Type: application/json' -d '" + sendJson + "'"); + } catch (e) { + // Do nothing if error occurs + } xhr.send(sendJson); // client logging - parent.frames["log_frame"].Log(" ==> " + xhr.response); + try { + parent.frames["log_frame"].Log(" ==> " + xhr.response); + } catch (e) { + // Do nothing if error occurs + } location.reload(); } @@ -234,9 +246,7 @@ func makeAttachDiskFunc_js() string { */ strFunc := ` - function diskAttach(diskName) { - var connConfig = parent.frames["top_frame"].document.getElementById("connConfig").innerHTML; - + function diskAttach(connConfig, diskName) { var textbox = document.getElementById('select_box_'+diskName); vmName = textbox.value @@ -246,12 +256,20 @@ func makeAttachDiskFunc_js() string { sendJson = '{ "ConnectionName": "' + connConfig + '", "ReqInfo": { "VMName" : "' + vmName + '" } }' // client logging - parent.frames["log_frame"].Log("PUT> " + "$$SPIDER_SERVER$$/spider/disk/" + diskName + "/attach" + " -H 'Content-Type: application/json' -d '" + sendJson + "'"); + try { + parent.frames["log_frame"].Log("PUT> " + "$$SPIDER_SERVER$$/spider/disk/" + diskName + "/attach" + " -H 'Content-Type: application/json' -d '" + sendJson + "'"); + } catch (e) { + // Do nothing if error occurs + } xhr.send(sendJson); // client logging - parent.frames["log_frame"].Log(" ==> " + xhr.response); + try { + parent.frames["log_frame"].Log(" ==> " + xhr.response); + } catch (e) { + // Do nothing if error occurs + } location.reload(); } @@ -272,21 +290,27 @@ func makeDetachDiskFunc_js() string { */ strFunc := ` - function diskDetach(diskName, vmName) { - var connConfig = parent.frames["top_frame"].document.getElementById("connConfig").innerHTML; - + function diskDetach(connConfig, diskName, vmName) { var xhr = new XMLHttpRequest(); xhr.open("PUT", "$$SPIDER_SERVER$$/spider/disk/" + diskName + "/detach", false); xhr.setRequestHeader('Content-Type', 'application/json'); sendJson = '{ "ConnectionName": "' + connConfig + '", "ReqInfo": { "VMName" : "' + vmName + '" } }' // client logging - parent.frames["log_frame"].Log("PUT> " + "$$SPIDER_SERVER$$/spider/disk/" + diskName + "/detach" + " -H 'Content-Type: application/json' -d '" + sendJson + "'"); + try { + parent.frames["log_frame"].Log("PUT> " + "$$SPIDER_SERVER$$/spider/disk/" + diskName + "/detach" + " -H 'Content-Type: application/json' -d '" + sendJson + "'"); + } catch (e) { + // Do nothing if error occurs + } xhr.send(sendJson); // client logging - parent.frames["log_frame"].Log(" ==> " + xhr.response); + try { + parent.frames["log_frame"].Log(" ==> " + xhr.response); + } catch (e) { + // Do nothing if error occurs + } location.reload(); } @@ -301,8 +325,7 @@ func makeDeleteDiskFunc_js() string { // -d '{ "ConnectionName": "'${CONN_CONFIG}'"}' strFunc := ` - function deleteDisk() { - var connConfig = parent.frames["top_frame"].document.getElementById("connConfig").innerHTML; + function deleteDisk(connConfig) { var checkboxes = document.getElementsByName('check_box'); for (var i = 0; i < checkboxes.length; i++) { // @todo make parallel executions if (checkboxes[i].checked) { @@ -312,12 +335,20 @@ func makeDeleteDiskFunc_js() string { sendJson = '{ "ConnectionName": "' + connConfig + '"}' // client logging - parent.frames["log_frame"].Log("curl -sX DELETE " + "$$SPIDER_SERVER$$/spider/disk/" + checkboxes[i].value + " -H 'Content-Type: application/json' -d '" + sendJson + "'"); + try { + parent.frames["log_frame"].Log("curl -sX DELETE " + "$$SPIDER_SERVER$$/spider/disk/" + checkboxes[i].value + " -H 'Content-Type: application/json' -d '" + sendJson + "'"); + } catch (e) { + // Do nothing if error occurs + } xhr.send(sendJson); // client logging - parent.frames["log_frame"].Log(" ==> " + xhr.response); + try { + parent.frames["log_frame"].Log(" ==> " + xhr.response); + } catch (e) { + // Do nothing if error occurs + } } } location.reload(); @@ -393,7 +424,7 @@ func Disk(c echo.Context) error { // (2) make Table Action TR // colspan, f5_href, delete_href, fontSize - htmlStr += makeActionTR_html("10", "", "deleteDisk()", "2") + htmlStr += makeActionTR_html("10", "", fmt.Sprintf("deleteDisk('%s')", connConfig), "2") // (3) make Table Header TR nameWidthList := []NameWidth{ @@ -434,7 +465,7 @@ func Disk(c echo.Context) error { vmList := vmList(connConfig) // (4-2) make TR list with info list - htmlStr += makeDiskTRList_html("", "", "", info.ResultList, vmList) + htmlStr += makeDiskTRList_html("", "", "", connConfig, info.ResultList, vmList) providerName, _ := getProviderName(connConfig) diskTypeList := diskTypeList(providerName) @@ -503,7 +534,7 @@ func Disk(c echo.Context) error { - + + diff --git a/api-runtime/rest-runtime/admin-web/AdminWeb-MyImage.go b/api-runtime/rest-runtime/admin-web/AdminWeb-MyImage.go index 123b35cbb..11d06ff57 100644 --- a/api-runtime/rest-runtime/admin-web/AdminWeb-MyImage.go +++ b/api-runtime/rest-runtime/admin-web/AdminWeb-MyImage.go @@ -14,9 +14,9 @@ import ( cr "github.com/cloud-barista/cb-spider/api-runtime/common-runtime" cres "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces/resources" - "strconv" "encoding/json" "net/http" + "strconv" "strings" "github.com/labstack/echo/v4" @@ -26,18 +26,18 @@ import ( // number, MyImage Name, MyImage Source VM, MyImage Status, Created Time, Additional Info, checkbox func makeMyImageTRList_html(bgcolor string, height string, fontSize string, infoList []*cres.MyImageInfo) string { - if bgcolor == "" { - bgcolor = "#FFFFFF" - } - if height == "" { - height = "30" - } - if fontSize == "" { - fontSize = "2" - } - - // make base TR frame for info list - strTR := fmt.Sprintf(` + if bgcolor == "" { + bgcolor = "#FFFFFF" + } + if height == "" { + height = "30" + } + if fontSize == "" { + fontSize = "2" + } + + // make base TR frame for info list + strTR := fmt.Sprintf(` $$NUM$$ @@ -63,48 +63,46 @@ func makeMyImageTRList_html(bgcolor string, height string, fontSize string, info `, bgcolor, height, fontSize, fontSize, fontSize, fontSize, fontSize, fontSize) - strData := "" - // set data and make TR list - for i, one := range infoList { - str := strings.ReplaceAll(strTR, "$$NUM$$", strconv.Itoa(i+1)) - str = strings.ReplaceAll(str, "$$MYIMAGENAME$$", one.IId.NameId) + strData := "" + // set data and make TR list + for i, one := range infoList { + str := strings.ReplaceAll(strTR, "$$NUM$$", strconv.Itoa(i+1)) + str = strings.ReplaceAll(str, "$$MYIMAGENAME$$", one.IId.NameId) - // Source VM - str = strings.ReplaceAll(str, "$$SOURCEVM$$", one.SourceVM.NameId) + // Source VM + str = strings.ReplaceAll(str, "$$SOURCEVM$$", one.SourceVM.NameId) // Status - str = strings.ReplaceAll(str, "$$MYIMAGESTATUS$$", string(one.Status)) + str = strings.ReplaceAll(str, "$$MYIMAGESTATUS$$", string(one.Status)) // Created Time - str = strings.ReplaceAll(str, "$$CREATEDTIME$$", one.CreatedTime.Format("2006.01.02 15:04:05 Mon")) + str = strings.ReplaceAll(str, "$$CREATEDTIME$$", one.CreatedTime.Format("2006.01.02 15:04:05 Mon")) - // for KeyValueList - strKeyList := "" - for _, kv := range one.KeyValueList { - strKeyList += kv.Key + ":" + kv.Value + ", " - } - strKeyList = strings.TrimRight(strKeyList, ", ") - str = strings.ReplaceAll(str, "$$ADDITIONALINFO$$", strKeyList) + // for KeyValueList + strKeyList := "" + for _, kv := range one.KeyValueList { + strKeyList += kv.Key + ":" + kv.Value + ", " + } + strKeyList = strings.TrimRight(strKeyList, ", ") + str = strings.ReplaceAll(str, "$$ADDITIONALINFO$$", strKeyList) - strData += str - } + strData += str + } - return strData + return strData } // make the string of javascript function func makePostMyImageFunc_js() string { - //curl -sX POST http://localhost:1024/spider/myimage -H 'Content-Type: application/json' - // -d '{ "ConnectionName": "'${CONN_CONFIG}'", "ReqInfo": { - // "Name": "spider-myimage-01", - // "SourceVM": "vm-01" - // } }' - - strFunc := ` - function postMyImage() { - var connConfig = parent.frames["top_frame"].document.getElementById("connConfig").innerHTML; + //curl -sX POST http://localhost:1024/spider/myimage -H 'Content-Type: application/json' + // -d '{ "ConnectionName": "'${CONN_CONFIG}'", "ReqInfo": { + // "Name": "spider-myimage-01", + // "SourceVM": "vm-01" + // } }' + strFunc := ` + function postMyImage(connConfig) { var textboxes = document.getElementsByName('text_box'); sendJson = '{ "ConnectionName" : "' + connConfig + '", "ReqInfo" : { "Name" : "$$MYIMAGENAME$$", "SourceVM" : "$$SOURCEVM$$"}}' @@ -125,31 +123,38 @@ func makePostMyImageFunc_js() string { xhr.setRequestHeader('Content-Type', 'application/json'); // client logging - parent.frames["log_frame"].Log("curl -sX POST " + - "$$SPIDER_SERVER$$/spider/myimage -H 'Content-Type: application/json' -d '" + sendJson + "'"); + try { + parent.frames["log_frame"].Log("curl -sX POST " + + "$$SPIDER_SERVER$$/spider/myimage -H 'Content-Type: application/json' -d '" + sendJson + "'"); + } catch (e) { + // Do nothing if error occurs + } xhr.send(sendJson); // client logging - parent.frames["log_frame"].Log(" ==> " + xhr.response); + try { + parent.frames["log_frame"].Log(" ==> " + xhr.response); + } catch (e) { + // Do nothing if error occurs + } var jsonVal = JSON.parse(xhr.response) location.reload(); } ` - strFunc = strings.ReplaceAll(strFunc, "$$SPIDER_SERVER$$", "http://"+cr.ServiceIPorName+cr.ServicePort) // cr.ServicePort = ":1024" - return strFunc + strFunc = strings.ReplaceAll(strFunc, "$$SPIDER_SERVER$$", "http://"+cr.ServiceIPorName+cr.ServicePort) // cr.ServicePort = ":1024" + return strFunc } // make the string of javascript function func makeDeleteMyImageFunc_js() string { - // curl -sX DELETE http://localhost:1024/spider/myimage/spider-myimage-01 -H 'Content-Type: application/json' - // -d '{ "ConnectionName": "'${CONN_CONFIG}'"}' + // curl -sX DELETE http://localhost:1024/spider/myimage/spider-myimage-01 -H 'Content-Type: application/json' + // -d '{ "ConnectionName": "'${CONN_CONFIG}'"}' - strFunc := ` - function deleteMyImage() { - var connConfig = parent.frames["top_frame"].document.getElementById("connConfig").innerHTML; + strFunc := ` + function deleteMyImage(connConfig) { var checkboxes = document.getElementsByName('check_box'); for (var i = 0; i < checkboxes.length; i++) { // @todo make parallel executions if (checkboxes[i].checked) { @@ -159,28 +164,36 @@ func makeDeleteMyImageFunc_js() string { sendJson = '{ "ConnectionName": "' + connConfig + '"}' // client logging - parent.frames["log_frame"].Log("curl -sX DELETE " + "$$SPIDER_SERVER$$/spider/myimage/" + - checkboxes[i].value + " -H 'Content-Type: application/json' -d '" + sendJson + "'"); - + try { + parent.frames["log_frame"].Log("curl -sX DELETE " + "$$SPIDER_SERVER$$/spider/myimage/" + + checkboxes[i].value + " -H 'Content-Type: application/json' -d '" + sendJson + "'"); + } catch (e) { + // Do nothing if error occurs + } + xhr.send(sendJson); // client logging - parent.frames["log_frame"].Log(" ==> " + xhr.response); + try { + parent.frames["log_frame"].Log(" ==> " + xhr.response); + } catch (e) { + // Do nothing if error occurs + } } } location.reload(); } ` - strFunc = strings.ReplaceAll(strFunc, "$$SPIDER_SERVER$$", "http://"+cr.ServiceIPorName+cr.ServicePort) // cr.ServicePort = ":1024" - return strFunc + strFunc = strings.ReplaceAll(strFunc, "$$SPIDER_SERVER$$", "http://"+cr.ServiceIPorName+cr.ServicePort) // cr.ServicePort = ":1024" + return strFunc } func MyImage(c echo.Context) error { - cblog.Info("call MyImage()") + cblog.Info("call MyImage()") - connConfig := c.Param("ConnectConfig") - if connConfig == "region not set" { - htmlStr := ` + connConfig := c.Param("ConnectConfig") + if connConfig == "region not set" { + htmlStr := ` @@ -204,11 +217,11 @@ func MyImage(c echo.Context) error { ` - return c.HTML(http.StatusOK, htmlStr) - } + return c.HTML(http.StatusOK, htmlStr) + } - // make page header - htmlStr := ` + // make page header + htmlStr := ` @@ -223,12 +236,12 @@ func MyImage(c echo.Context) error { @@ -236,49 +249,49 @@ func MyImage(c echo.Context) error { ` - // (2) make Table Action TR - // colspan, f5_href, delete_href, fontSize - htmlStr += makeActionTR_html("8", "", "deleteMyImage()", "2") - - // (3) make Table Header TR - nameWidthList := []NameWidth{ - {"MyImage Name", "100"}, - {"MyImage SourceVM", "100"}, - {"MyImage Status", "100"}, - {"Created Time", "100"}, - {"Additional Info", "300"}, - } - htmlStr += makeTitleTRList_html("#DDDDDD", "2", nameWidthList, true) - - // (4) make TR list with info list - // (4-1) get info list - - // client logging - htmlStr += genLoggingGETURL(connConfig, "myimage") - - resBody, err := getResourceList_with_Connection_JsonByte(connConfig, "myimage") - if err != nil { - cblog.Error(err) - // client logging - htmlStr += genLoggingResult(err.Error()) - return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) - } - - // client logging - htmlStr += genLoggingResult(string(resBody[:len(resBody)-1])) - - var info struct { - ResultList []*cres.MyImageInfo `json:"myimage"` - } - json.Unmarshal(resBody, &info) - - // (4-2) make TR list with info list - htmlStr += makeMyImageTRList_html("", "", "", info.ResultList) - - // (5) make input field and add - // attach text box for add - - htmlStr += ` + // (2) make Table Action TR + // colspan, f5_href, delete_href, fontSize + htmlStr += makeActionTR_html("8", "", fmt.Sprintf("deleteMyImage('%s')", connConfig), "2") + + // (3) make Table Header TR + nameWidthList := []NameWidth{ + {"MyImage Name", "100"}, + {"MyImage SourceVM", "100"}, + {"MyImage Status", "100"}, + {"Created Time", "100"}, + {"Additional Info", "300"}, + } + htmlStr += makeTitleTRList_html("#DDDDDD", "2", nameWidthList, true) + + // (4) make TR list with info list + // (4-1) get info list + + // client logging + htmlStr += genLoggingGETURL(connConfig, "myimage") + + resBody, err := getResourceList_with_Connection_JsonByte(connConfig, "myimage") + if err != nil { + cblog.Error(err) + // client logging + htmlStr += genLoggingResult(err.Error()) + return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) + } + + // client logging + htmlStr += genLoggingResult(string(resBody[:len(resBody)-1])) + + var info struct { + ResultList []*cres.MyImageInfo `json:"myimage"` + } + json.Unmarshal(resBody, &info) + + // (4-2) make TR list with info list + htmlStr += makeMyImageTRList_html("", "", "", info.ResultList) + + // (5) make input field and add + // attach text box for add + + htmlStr += ` ` - // make page tail - htmlStr += ` + // make page tail + htmlStr += `
 create:  @@ -299,20 +312,20 @@ func MyImage(c echo.Context) error { - + +

` - //fmt.Println(htmlStr) - return c.HTML(http.StatusOK, htmlStr) + //fmt.Println(htmlStr) + return c.HTML(http.StatusOK, htmlStr) } diff --git a/api-runtime/rest-runtime/admin-web/AdminWeb-NLB.go b/api-runtime/rest-runtime/admin-web/AdminWeb-NLB.go index f523fb4bb..c79d85132 100644 --- a/api-runtime/rest-runtime/admin-web/AdminWeb-NLB.go +++ b/api-runtime/rest-runtime/admin-web/AdminWeb-NLB.go @@ -23,13 +23,12 @@ import ( "github.com/labstack/echo/v4" ) - //====================================== NLB: Network Load Balancer -// number, VPC Name, NLB Name, Type, Scope, +// number, VPC Name, NLB Name, Type, Scope, // Listner(IP/Protocol/Port), VMGroup(Protocol/Port/VMs), HealthChecker(Protocol/Port/Interval/Timeoute/Threshold), // Additional Info, checkbox -func makeNLBTRList_html(bgcolor string, height string, fontSize string, infoList []*cres.NLBInfo) string { +func makeNLBTRList_html(bgcolor string, height string, fontSize string, connConfig string, infoList []*cres.NLBInfo) string { if bgcolor == "" { bgcolor = "#FFFFFF" } @@ -101,19 +100,19 @@ func makeNLBTRList_html(bgcolor string, height string, fontSize string, infoList //if one.Listener.CspID != "" { // strListener += "CspID:" + one.Listener.CspID + ", " //} - /* complicated to see + /* complicated to see if strKeyList != "" { strListener += "(etc) " + strKeyList + "
" strListener += "--------------------------------
" } */ strListener += one.Listener.Protocol + "
" - strListener += "--------------------------------
" - strListener += ` + strListener += "--------------------------------
" + strListener += `
` - + str = strings.ReplaceAll(str, "$$LISTENER$$", strListener) // for VMGroup info @@ -136,7 +135,7 @@ func makeNLBTRList_html(bgcolor string, height string, fontSize string, infoList //if one.VMGroup.CspID != "" { // strVMGroup += "CspID:" + one.VMGroup.CspID + ", " //} - /* complicated to see + /* complicated to see if strKeyList != "" { strVMGroup += "(etc) " + strKeyList + "
" strVMGroup += "--------------------------------
" @@ -150,7 +149,7 @@ func makeNLBTRList_html(bgcolor string, height string, fontSize string, infoList
` - + str = strings.ReplaceAll(str, "$$VMGROUP$$", strVMGroup) // for HealthChecker info @@ -162,13 +161,13 @@ func makeNLBTRList_html(bgcolor string, height string, fontSize string, infoList strKeyList = strings.TrimRight(strKeyList, ", ") strHealthChecker := "" -/* - strHealthChecker := ` -
- -
- ` -*/ + /* + strHealthChecker := ` +
+ +
+ ` + */ strHealthChecker += " <= " + one.HealthChecker.Port + "
" strHealthChecker += "--------------------------------
" strHealthChecker += "Interval: " + strconv.Itoa(one.HealthChecker.Interval) + "
" @@ -178,7 +177,7 @@ func makeNLBTRList_html(bgcolor string, height string, fontSize string, infoList //if one.HealthChecker.CspID != "" { // strHealthChecker += "CspID:" + one.HealthChecker.CspID + ", " //} - /* complicated to see + /* complicated to see if strKeyList != "" { strHealthChecker += "(etc) " + strKeyList + "
" strHealthChecker += "------------------------
" @@ -186,19 +185,18 @@ func makeNLBTRList_html(bgcolor string, height string, fontSize string, infoList */ strHealthChecker += one.HealthChecker.Protocol + "
" strHealthChecker += "--------------------------------
" -/* - strHealthChecker += ` - -
Status
-

` -*/ + /* + strHealthChecker += ` + +
Status
+

` + */ strHealthChecker += ` - +
` - - str = strings.ReplaceAll(str, "$$HEALTHCHECKER$$", strHealthChecker) + str = strings.ReplaceAll(str, "$$HEALTHCHECKER$$", strHealthChecker) // for KeyValueList strKeyList = "" @@ -217,37 +215,35 @@ func makeNLBTRList_html(bgcolor string, height string, fontSize string, infoList // make the string of javascript function func makePostNLBFunc_js() string { -// curl -sX POST http://localhost:1024/spider/nlb -H 'Content-Type: application/json' -d \ -// '{ -// "ConnectionName": "'${CONN_CONFIG}'", -// "ReqInfo": { -// "Name": "spider-nlb-01", -// "VPCName": "vpc-01", -// "Type": "PUBLIC", -// "Scope": "REGION", -// "Listener": { -// "Protocol" : "TCP", -// "Port" : "80" -// }, -// "VMGroup": { -// "Protocol" : "TCP", -// "Port" : "80", -// "VMs" : ["vm-01", "vm-02"] -// }, -// "HealthChecker": { -// "Protocol" : "TCP", -// "Port" : "80", -// "Interval" : "10", -// "Timeout" : "10", -// "Threshold" : "3" -// } -// } -// }' + // curl -sX POST http://localhost:1024/spider/nlb -H 'Content-Type: application/json' -d \ + // '{ + // "ConnectionName": "'${CONN_CONFIG}'", + // "ReqInfo": { + // "Name": "spider-nlb-01", + // "VPCName": "vpc-01", + // "Type": "PUBLIC", + // "Scope": "REGION", + // "Listener": { + // "Protocol" : "TCP", + // "Port" : "80" + // }, + // "VMGroup": { + // "Protocol" : "TCP", + // "Port" : "80", + // "VMs" : ["vm-01", "vm-02"] + // }, + // "HealthChecker": { + // "Protocol" : "TCP", + // "Port" : "80", + // "Interval" : "10", + // "Timeout" : "10", + // "Threshold" : "3" + // } + // } + // }' strFunc := ` - function postNLB() { - var connConfig = parent.frames["top_frame"].document.getElementById("connConfig").innerHTML; - + function postNLB(connConfig) { var textboxes = document.getElementsByName('text_box'); sendJson = '{ "ConnectionName" : "' + connConfig + '", "ReqInfo" : \ { \ @@ -327,14 +323,20 @@ func makePostNLBFunc_js() string { xhr.setRequestHeader('Content-Type', 'application/json'); // client logging - parent.frames["log_frame"].Log("curl -sX POST " + "$$SPIDER_SERVER$$/spider/nlb -H 'Content-Type: application/json' -d '" + sendJson + "'"); - - xhr.send(sendJson); + try { + parent.frames["log_frame"].Log("curl -sX POST " + "$$SPIDER_SERVER$$/spider/nlb -H 'Content-Type: application/json' -d '" + sendJson + "'"); + } catch (error) { + // Do nothing if error occurs + } + + xhr.send(sendJson); // client logging - parent.frames["log_frame"].Log(" ==> " + xhr.response); - - + try { + parent.frames["log_frame"].Log(" ==> " + xhr.response); + } catch (error) { + // Do nothing if error occurs + } location.reload(); } @@ -346,13 +348,12 @@ func makePostNLBFunc_js() string { // make the string of javascript function func makeDeleteNLBFunc_js() string { // curl -sX DELETE http://localhost:1024/spider/nlb/spider-nlb-01 -H 'Content-Type: application/json' -d \ - // '{ - // "ConnectionName": "'${CONN_CONFIG}'" - // }' + // '{ + // "ConnectionName": "'${CONN_CONFIG}'" + // }' strFunc := ` - function deleteNLB() { - var connConfig = parent.frames["top_frame"].document.getElementById("connConfig").innerHTML; + function deleteNLB(connConfig) { var checkboxes = document.getElementsByName('check_box'); for (var i = 0; i < checkboxes.length; i++) { // @todo make parallel executions if (checkboxes[i].checked) { @@ -362,12 +363,20 @@ func makeDeleteNLBFunc_js() string { sendJson = '{ "ConnectionName": "' + connConfig + '"}' // client logging - parent.frames["log_frame"].Log("curl -sX DELETE " + "$$SPIDER_SERVER$$/spider/nlb/" + checkboxes[i].value + " -H 'Content-Type: application/json' -d '" + sendJson + "'"); + try { + parent.frames["log_frame"].Log("curl -sX DELETE " + "$$SPIDER_SERVER$$/spider/nlb/" + checkboxes[i].value + " -H 'Content-Type: application/json' -d '" + sendJson + "'"); + } catch (error) { + // Do nothing if error occurs + } - xhr.send(sendJson); + xhr.send(sendJson); // client logging - parent.frames["log_frame"].Log(" ==> " + xhr.response); + try { + parent.frames["log_frame"].Log(" ==> " + xhr.response); + } catch (error) { + // Do nothing if error occurs + } } } location.reload(); @@ -380,11 +389,11 @@ func makeDeleteNLBFunc_js() string { // make the string of javascript function func makeGetHealthStatusNLBFunc_js() string { // curl -sX GET http://localhost:1024/spider/nlb/spider-nlb-01/health -H 'Content-Type: application/json' -d \ - // '{ - // "ConnectionName": "'${CONN_CONFIG}'" - // }' + // '{ + // "ConnectionName": "'${CONN_CONFIG}'" + // }' - strFunc := ` + strFunc := ` function convertHealthyInfo(org) { const obj = JSON.parse(org); var healthinfo = obj.healthinfo @@ -409,26 +418,33 @@ func makeGetHealthStatusNLBFunc_js() string { return text } - function healthStatus(nlbName) { - var connConfig = parent.frames["top_frame"].document.getElementById("connConfig").innerHTML; + function healthStatus(connConfig, nlbName) { var xhr = new XMLHttpRequest(); xhr.open("GET", "$$SPIDER_SERVER$$/spider/nlb/" + nlbName + "/health?ConnectionName=" + connConfig, false); // client logging - parent.frames["log_frame"].Log("curl -sX GET " + "$$SPIDER_SERVER$$/spider/nlb/" + nlbName + "/health?ConnectionName=" + connConfig); + try { + parent.frames["log_frame"].Log("curl -sX GET " + "$$SPIDER_SERVER$$/spider/nlb/" + nlbName + "/health?ConnectionName=" + connConfig); + } catch (error) { + // Do nothing if error occurs + } xhr.send(); // client logging - parent.frames["log_frame"].Log(" ==> " + xhr.response); + try { + parent.frames["log_frame"].Log(" ==> " + xhr.response); + } catch (error) { + // Do nothing if error occurs + } var healthy = convertHealthyInfo(xhr.response); alert(healthy); } ` - strFunc = strings.ReplaceAll(strFunc, "$$SPIDER_SERVER$$", "http://"+cr.ServiceIPorName+cr.ServicePort) // cr.ServicePort = ":1024" - return strFunc + strFunc = strings.ReplaceAll(strFunc, "$$SPIDER_SERVER$$", "http://"+cr.ServiceIPorName+cr.ServicePort) // cr.ServicePort = ":1024" + return strFunc } func NLB(c echo.Context) error { @@ -495,7 +511,7 @@ func NLB(c echo.Context) error { // (2) make Table Action TR // colspan, f5_href, delete_href, fontSize - htmlStr += makeActionTR_html("10", "", "deleteNLB()", "2") + htmlStr += makeActionTR_html("10", "", fmt.Sprintf("deleteNLB('%s')", connConfig), "2") // (3) make Table Header TR nameWidthList := []NameWidth{ @@ -520,7 +536,7 @@ func NLB(c echo.Context) error { if err != nil { cblog.Error(err) // client logging - htmlStr += genLoggingResult(err.Error()) + htmlStr += genLoggingResult(err.Error()) return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) } @@ -533,7 +549,7 @@ func NLB(c echo.Context) error { json.Unmarshal(resBody, &info) // (4-2) make TR list with info list - htmlStr += makeNLBTRList_html("", "", "", info.ResultList) + htmlStr += makeNLBTRList_html("", "", "", connConfig, info.ResultList) // (5) make input field and add // attach text box for add @@ -606,7 +622,7 @@ func NLB(c echo.Context) error { - + + From 50b1e3bfea4190c6efcd70db2ca11e1fb44d3f1d Mon Sep 17 00:00:00 2001 From: ByoungSeob Kim <46367962+powerkimhub@users.noreply.github.com> Date: Thu, 30 May 2024 22:32:36 +0900 Subject: [PATCH 10/19] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2cd8e812c..6850cbc96 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ If you have any difficulties in using Cloud-Barista, please let us know. | Provider | Price
Info | Region/Zone
Info | Image
Info | VMSpec
Info | VPC
Subnet | Security
Group | VM KeyPair | VM | Disk | MyImage | NLB | managed-K8S | |:-------------:|:-------------:|:-------------------:|:-------------:|:--------------:|:-------------------:|:-----------------:|:---------------:|:--------------:|:----:|:---:|:-------:|:-----------:| -| AWS | O | O | O | O | O | O | O | O | O | O | O | WIP | +| AWS | O | O | O | O | O | O | O | O | O | O | O | O | | Azure | O
(Spec제외)| O | O | O | O | O | O | O | O | O | O | WIP | | GCP | WIP | O | O | O | O | O | O | O | O | O | O | WIP | | Alibaba | O | O | O | O | O | O | O | O | O | O | O | O | From 99bfb598ef60e5786b77f78755e5f2d3d4bdf76b Mon Sep 17 00:00:00 2001 From: powerkimhub Date: Thu, 30 May 2024 23:00:22 +0900 Subject: [PATCH 11/19] Fix the cluster list error when deleting NoddeGroup in a Cluster --- api-runtime/common-runtime/ClusterManager.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/api-runtime/common-runtime/ClusterManager.go b/api-runtime/common-runtime/ClusterManager.go index 279ff2567..efd812d34 100644 --- a/api-runtime/common-runtime/ClusterManager.go +++ b/api-runtime/common-runtime/ClusterManager.go @@ -626,13 +626,20 @@ func setResourcesNameId(connectionName string, info *cres.ClusterInfo) error { } // (1) NodeGroup IID var ngIIDInfo NodeGroupIIDInfo + hasNodeGroup := true err := infostore.GetByConditionsAndContain(&ngIIDInfo, CONNECTION_NAME_COLUMN, connectionName, OWNER_CLUSTER_NAME_COLUMN, info.IId.NameId, SYSTEM_ID_COLUMN, getMSShortID(ngInfo.IId.SystemId)) if err != nil { - cblog.Error(err) - return err + if checkNotFoundError(err) { + hasNodeGroup = false + } else { + cblog.Error(err) + return err + } + } + if hasNodeGroup { + info.NodeGroupList[idx].IId.NameId = ngIIDInfo.NameId } - info.NodeGroupList[idx].IId.NameId = ngIIDInfo.NameId // (2) ImageIID info.NodeGroupList[idx].ImageIID.NameId = ngInfo.ImageIID.SystemId From ef072bb9fee19d7674a8bc144fc589f4a015a0fb Mon Sep 17 00:00:00 2001 From: powerkimhub Date: Sun, 2 Jun 2024 15:52:21 +0900 Subject: [PATCH 12/19] Insert Subnet ZoneId to MetaDB for global subnet type like GCP --- api-runtime/common-runtime/ClusterManager.go | 10 ++ api-runtime/common-runtime/CommonManager.go | 8 ++ .../common-runtime/VPC-SubnetManager.go | 97 +++++++++++++------ api-runtime/rest-runtime/VPC-SubnetRest.go | 5 +- 4 files changed, 91 insertions(+), 29 deletions(-) diff --git a/api-runtime/common-runtime/ClusterManager.go b/api-runtime/common-runtime/ClusterManager.go index efd812d34..4d044e532 100644 --- a/api-runtime/common-runtime/ClusterManager.go +++ b/api-runtime/common-runtime/ClusterManager.go @@ -564,6 +564,16 @@ func CreateCluster(connectionName string, rsType string, reqInfo cres.ClusterInf return &info, nil } +// Get reqNameId from reqIIdList whith driver NameId +func getReqNameId(reqIIdList []cres.IID, driverNameId string) string { + for _, iid := range reqIIdList { + if iid.SystemId == driverNameId { + return iid.NameId + } + } + return "" +} + func setResourcesNameId(connectionName string, info *cres.ClusterInfo) error { //+++++++++++++++++++++ Set NetworkInfo's NameId netInfo := &info.Network diff --git a/api-runtime/common-runtime/CommonManager.go b/api-runtime/common-runtime/CommonManager.go index 76296d233..de6c5271c 100644 --- a/api-runtime/common-runtime/CommonManager.go +++ b/api-runtime/common-runtime/CommonManager.go @@ -111,6 +111,14 @@ type VPCDependentIIDInfo struct { OwnerVPCName string `gorm:"primaryKey"` // ex) "my_vpc" for NLB } +type ZoneLevelVPCDependentIIDInfo struct { + ConnectionName string `gorm:"primaryKey"` // ex) "aws-seoul-config" + ZoneId string // ex) "ap-northeast-2a" + NameId string `gorm:"primaryKey"` // ex) "my_resource" + SystemId string // ID in CSP, ex) "i7baab81a4ez" + OwnerVPCName string `gorm:"primaryKey"` // ex) "my_vpc" for NLB +} + type ClusterDependentIIDInfo struct { ConnectionName string `gorm:"primaryKey"` // ex) "aws-seoul-config" NameId string `gorm:"primaryKey"` // ex) "my_resource" diff --git a/api-runtime/common-runtime/VPC-SubnetManager.go b/api-runtime/common-runtime/VPC-SubnetManager.go index d70188722..fdef41558 100644 --- a/api-runtime/common-runtime/VPC-SubnetManager.go +++ b/api-runtime/common-runtime/VPC-SubnetManager.go @@ -29,7 +29,7 @@ func (VPCIIDInfo) TableName() string { return "vpc_iid_infos" } -type SubnetIIDInfo VPCDependentIIDInfo +type SubnetIIDInfo ZoneLevelVPCDependentIIDInfo func (SubnetIIDInfo) TableName() string { return "subnet_iid_infos" @@ -156,7 +156,7 @@ func RegisterVPC(connectionName string, userIID cres.IID) (*cres.VPCInfo, error) // (2) get resource info(CSP-ID) // (3) create spiderIID: {UserID, SP-XID:CSP-ID} // (4) insert spiderIID -func RegisterSubnet(connectionName string, vpcName string, userIID cres.IID) (*cres.VPCInfo, error) { +func RegisterSubnet(connectionName string, zoneId string, vpcName string, userIID cres.IID) (*cres.VPCInfo, error) { cblog.Info("call RegisterSubnet()") // check empty and trim user inputs @@ -180,7 +180,7 @@ func RegisterSubnet(connectionName string, vpcName string, userIID cres.IID) (*c return nil, err } - cldConn, err := ccm.GetCloudConnection(connectionName) + cldConn, err := ccm.GetZoneLevelCloudConnection(connectionName, zoneId) if err != nil { cblog.Error(err) return nil, err @@ -234,12 +234,21 @@ func RegisterSubnet(connectionName string, vpcName string, userIID cres.IID) (*c if subnetInfo.IId.SystemId == userIID.SystemId { // insert a subnet SpiderIID to metadb subnetSpiderIId := cres.IID{NameId: subnetUserId, SystemId: systemId + ":" + subnetInfo.IId.SystemId} - err = infostore.Insert(&SubnetIIDInfo{ConnectionName: connectionName, NameId: subnetSpiderIId.NameId, SystemId: subnetSpiderIId.SystemId, + err = infostore.Insert(&SubnetIIDInfo{ConnectionName: connectionName, ZoneId: zoneId, NameId: subnetSpiderIId.NameId, SystemId: subnetSpiderIId.SystemId, OwnerVPCName: vpcName}) if err != nil { cblog.Error(err) return nil, err } + if subnetInfo.Zone == "" { // GCP has no Zone info + var iidInfo SubnetIIDInfo + err = infostore.GetBy3Conditions(&iidInfo, CONNECTION_NAME_COLUMN, connectionName, NAME_ID_COLUMN, subnetInfo.IId.NameId, OWNER_VPC_NAME_COLUMN, vpcName) + if err != nil { + cblog.Info(err) + } else { + subnetInfo.Zone = iidInfo.ZoneId + } + } // setup subnet IID for return info subnetInfo.IId = cres.IID{NameId: subnetUserId, SystemId: subnetInfo.IId.SystemId} @@ -306,6 +315,12 @@ func UnregisterSubnet(connectionName string, vpcName string, nameId string) (boo // (4) create spiderIID: {reqNameID, "driverNameID:driverSystemID"} // (5) insert spiderIID // (6) create userIID + +type SubnetReqZoneInfo struct { + IId cres.IID + Zone string +} + func CreateVPC(connectionName string, rsType string, reqInfo cres.VPCReqInfo, IDTransformMode string) (*cres.VPCInfo, error) { cblog.Info("call CreateVPC()") @@ -409,7 +424,7 @@ func CreateVPC(connectionName string, rsType string, reqInfo cres.VPCReqInfo, ID } // for subnet list - subnetReqIIdList := []cres.IID{} + subnetReqIIdZoneList := []SubnetReqZoneInfo{} subnetInfoList := []cres.SubnetInfo{} for _, info := range reqInfo.SubnetInfoList { subnetUUID := "" @@ -434,12 +449,14 @@ func CreateVPC(connectionName string, rsType string, reqInfo cres.VPCReqInfo, ID // reqIID subnetReqIId := cres.IID{NameId: info.IId.NameId, SystemId: subnetUUID} - subnetReqIIdList = append(subnetReqIIdList, subnetReqIId) + subnetReqInfo := SubnetReqZoneInfo{IId: subnetReqIId, Zone: info.Zone} + subnetReqIIdZoneList = append(subnetReqIIdZoneList, subnetReqInfo) // driverIID subnetDriverIId := cres.IID{NameId: subnetUUID, SystemId: ""} info.IId = subnetDriverIId subnetInfoList = append(subnetInfoList, info) } // end of for _, info + reqInfo.SubnetInfoList = subnetInfoList // (3) create Resource @@ -470,13 +487,17 @@ func CreateVPC(connectionName string, rsType string, reqInfo cres.VPCReqInfo, ID } // for Subnet list for _, subnetInfo := range info.SubnetInfoList { - subnetReqNameId := getReqNameId(subnetReqIIdList, subnetInfo.IId.NameId) + subnetReqNameId := getSubnetReqNameId(subnetReqIIdZoneList, subnetInfo.IId.NameId) if subnetReqNameId == "" { cblog.Error(subnetInfo.IId.NameId + "is not requested Subnet.") continue } + if subnetInfo.Zone == "" { // GCP has no Zone info + subnetInfo.Zone = getSubnetReqZoneId(subnetReqIIdZoneList, subnetInfo.IId.NameId) + } + subnetSpiderIId := cres.IID{NameId: subnetReqNameId, SystemId: subnetInfo.IId.NameId + ":" + subnetInfo.IId.SystemId} - err = infostore.Insert(&SubnetIIDInfo{ConnectionName: connectionName, NameId: subnetSpiderIId.NameId, SystemId: subnetSpiderIId.SystemId, + err = infostore.Insert(&SubnetIIDInfo{ConnectionName: connectionName, ZoneId: subnetInfo.Zone, NameId: subnetSpiderIId.NameId, SystemId: subnetSpiderIId.SystemId, OwnerVPCName: reqIId.NameId}) if err != nil { cblog.Error(err) @@ -516,9 +537,12 @@ func CreateVPC(connectionName string, rsType string, reqInfo cres.VPCReqInfo, ID // for Subnet list subnetUserInfoList := []cres.SubnetInfo{} for _, subnetInfo := range info.SubnetInfoList { - subnetReqNameId := getReqNameId(subnetReqIIdList, subnetInfo.IId.NameId) + subnetReqNameId := getSubnetReqNameId(subnetReqIIdZoneList, subnetInfo.IId.NameId) userIId := cres.IID{NameId: subnetReqNameId, SystemId: subnetInfo.IId.SystemId} subnetInfo.IId = userIId + if subnetInfo.Zone == "" { // GCP has no Zone info + subnetInfo.Zone = getSubnetReqZoneId(subnetReqIIdZoneList, subnetInfo.IId.NameId) + } subnetUserInfoList = append(subnetUserInfoList, subnetInfo) } info.SubnetInfoList = subnetUserInfoList @@ -526,11 +550,21 @@ func CreateVPC(connectionName string, rsType string, reqInfo cres.VPCReqInfo, ID return &info, nil } -// Get reqNameId from reqIIdList whith driver NameId -func getReqNameId(reqIIdList []cres.IID, driverNameId string) string { - for _, iid := range reqIIdList { - if iid.SystemId == driverNameId { - return iid.NameId +// Get reqNameId from reqIIdZoneList whith driver NameId +func getSubnetReqNameId(reqIIdZoneList []SubnetReqZoneInfo, driverNameId string) string { + for _, reqInfo := range reqIIdZoneList { + if reqInfo.IId.SystemId == driverNameId { + return reqInfo.IId.NameId + } + } + return "" +} + +// Get reqZoneId from reqIIdZoneList whith driver NameId +func getSubnetReqZoneId(reqIIdZoneList []SubnetReqZoneInfo, driverNameId string) string { + for _, reqInfo := range reqIIdZoneList { + if reqInfo.IId.SystemId == driverNameId { + return reqInfo.Zone } } return "" @@ -659,6 +693,9 @@ func getVPCInfo(connectionName string, handler cres.VPCHandler, iid cres.IID, re } if subnetIIDInfo.NameId != "" { // insert only this user created. subnetInfo.IId = getUserIID(cres.IID{NameId: subnetIIDInfo.NameId, SystemId: subnetIIDInfo.SystemId}) + if subnetInfo.Zone == "" { // GCP has no Zone info + subnetInfo.Zone = subnetIIDInfo.ZoneId + } subnetInfoList = append(subnetInfoList, subnetInfo) } } @@ -737,6 +774,9 @@ func GetVPC(connectionName string, rsType string, nameID string) (*cres.VPCInfo, } if subnetIIDInfo.NameId != "" { // insert only this user created. subnetInfo.IId = getUserIID(cres.IID{NameId: subnetIIDInfo.NameId, SystemId: subnetIIDInfo.SystemId}) + if subnetInfo.Zone == "" { // GCP has no Zone info + subnetInfo.Zone = subnetIIDInfo.ZoneId + } subnetInfoList = append(subnetInfoList, subnetInfo) } } @@ -837,7 +877,7 @@ func AddSubnet(connectionName string, rsType string, vpcName string, reqInfo cre for _, subnetInfo := range info.SubnetInfoList { if subnetInfo.IId.NameId == reqInfo.IId.NameId { // NameId => SS-UUID subnetSpiderIId := cres.IID{NameId: subnetReqNameId, SystemId: subnetInfo.IId.NameId + ":" + subnetInfo.IId.SystemId} - err = infostore.Insert(&SubnetIIDInfo{ConnectionName: connectionName, NameId: subnetSpiderIId.NameId, SystemId: subnetSpiderIId.SystemId, + err = infostore.Insert(&SubnetIIDInfo{ConnectionName: connectionName, ZoneId: reqInfo.Zone, NameId: subnetSpiderIId.NameId, SystemId: subnetSpiderIId.SystemId, OwnerVPCName: vpcName}) if err != nil { cblog.Error(err) @@ -884,6 +924,9 @@ func AddSubnet(connectionName string, rsType string, vpcName string, reqInfo cre } if subnetIIDInfo.NameId != "" { // insert only this user created. subnetInfo.IId = getUserIID(cres.IID{NameId: subnetIIDInfo.NameId, SystemId: subnetInfo.IId.SystemId}) + if subnetInfo.Zone == "" { // GCP has no Zone info + subnetInfo.Zone = subnetIIDInfo.ZoneId + } subnetInfoList = append(subnetInfoList, subnetInfo) } } @@ -917,18 +960,6 @@ func RemoveSubnet(connectionName string, vpcName string, nameID string, force st return false, err } - cldConn, err := ccm.GetCloudConnection(connectionName) - if err != nil { - cblog.Error(err) - return false, err - } - - handler, err := cldConn.CreateVPCHandler() - if err != nil { - cblog.Error(err) - return false, err - } - vpcSPLock.Lock(connectionName, vpcName) defer vpcSPLock.Unlock(connectionName, vpcName) @@ -944,6 +975,18 @@ func RemoveSubnet(connectionName string, vpcName string, nameID string, force st driverIId := getDriverIID(cres.IID{NameId: iidInfo.NameId, SystemId: iidInfo.SystemId}) result := false + cldConn, err := ccm.GetZoneLevelCloudConnection(connectionName, iidInfo.ZoneId) + if err != nil { + cblog.Error(err) + return false, err + } + + handler, err := cldConn.CreateVPCHandler() + if err != nil { + cblog.Error(err) + return false, err + } + var iidVPCInfo VPCIIDInfo err = infostore.GetByConditions(&iidVPCInfo, CONNECTION_NAME_COLUMN, connectionName, NAME_ID_COLUMN, vpcName) if err != nil { diff --git a/api-runtime/rest-runtime/VPC-SubnetRest.go b/api-runtime/rest-runtime/VPC-SubnetRest.go index 25a6efc1c..9098da53d 100644 --- a/api-runtime/rest-runtime/VPC-SubnetRest.go +++ b/api-runtime/rest-runtime/VPC-SubnetRest.go @@ -54,8 +54,9 @@ func RegisterVPC(c echo.Context) error { type subnetRegisterReq struct { ConnectionName string ReqInfo struct { - VPCName string Name string + Zone string + VPCName string CSPId string } } @@ -73,7 +74,7 @@ func RegisterSubnet(c echo.Context) error { userIId := cres.IID{NameId: req.ReqInfo.Name, SystemId: req.ReqInfo.CSPId} // Call common-runtime API - result, err := cmrt.RegisterSubnet(req.ConnectionName, req.ReqInfo.VPCName, userIId) + result, err := cmrt.RegisterSubnet(req.ConnectionName, req.ReqInfo.Zone, req.ReqInfo.VPCName, userIId) if err != nil { return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) } From 4d1382aabde56ebad8aefbc7148f94b0af0552bc Mon Sep 17 00:00:00 2001 From: ish Date: Wed, 5 Jun 2024 19:56:17 +0900 Subject: [PATCH 13/19] OpenStack: Fix openstack connection initialization --- .../drivers/openstack/OpenStackDriver.go | 52 +++++++------------ 1 file changed, 19 insertions(+), 33 deletions(-) diff --git a/cloud-control-manager/cloud-driver/drivers/openstack/OpenStackDriver.go b/cloud-control-manager/cloud-driver/drivers/openstack/OpenStackDriver.go index 15cfa38fe..892bf9a53 100644 --- a/cloud-control-manager/cloud-driver/drivers/openstack/OpenStackDriver.go +++ b/cloud-control-manager/cloud-driver/drivers/openstack/OpenStackDriver.go @@ -68,7 +68,18 @@ func (driver *OpenStackDriver) ConnectCloud(connectionInfo idrv.ConnectionInfo) return iConn, nil } -func getIdentityClient(connInfo idrv.ConnectionInfo) (*gophercloud.ServiceClient, error) { +func getIdentityClient(provider *gophercloud.ProviderClient, connInfo idrv.ConnectionInfo) (*gophercloud.ServiceClient, error) { + client, err := openstack.NewIdentityV3(provider, gophercloud.EndpointOpts{ + Region: connInfo.RegionInfo.Region, + }) + if err != nil { + return nil, err + } + + return client, err +} + +func clientCreator(connInfo idrv.ConnectionInfo) (icon.CloudConnection, error) { authOpts := gophercloud.AuthOptions{ IdentityEndpoint: connInfo.CredentialInfo.IdentityEndpoint, Username: connInfo.CredentialInfo.Username, @@ -77,61 +88,36 @@ func getIdentityClient(connInfo idrv.ConnectionInfo) (*gophercloud.ServiceClient TenantID: connInfo.CredentialInfo.ProjectID, } - provider, err := openstack.AuthenticatedClient(authOpts) - if err != nil { - return nil, err - } - config := &tls.Config{InsecureSkipVerify: true} httpClient := &http.Client{ Transport: &http.Transport{TLSClientConfig: config}, } - provider.HTTPClient = *httpClient - - client, err := openstack.NewIdentityV3(provider, gophercloud.EndpointOpts{ - Region: connInfo.RegionInfo.Region, - }) + provider, err := openstack.NewClient(authOpts.IdentityEndpoint) if err != nil { return nil, err } - return client, err -} + provider.HTTPClient = *httpClient -func clientCreator(connInfo idrv.ConnectionInfo) (icon.CloudConnection, error) { - identityClient, err := getIdentityClient(connInfo) + err = openstack.Authenticate(provider, authOpts) if err != nil { return nil, err } - pager, err := services.List(identityClient, services.ListOpts{}).AllPages() + + identityClient, err := getIdentityClient(provider, connInfo) if err != nil { return nil, err } - list, err := services.ExtractServices(pager) + pager, err := services.List(identityClient, services.ListOpts{}).AllPages() if err != nil { return nil, err } - authOpts := gophercloud.AuthOptions{ - IdentityEndpoint: connInfo.CredentialInfo.IdentityEndpoint, - Username: connInfo.CredentialInfo.Username, - Password: connInfo.CredentialInfo.Password, - DomainName: connInfo.CredentialInfo.DomainName, - TenantID: connInfo.CredentialInfo.ProjectID, - } - - provider, err := openstack.AuthenticatedClient(authOpts) + list, err := services.ExtractServices(pager) if err != nil { return nil, err } - config := &tls.Config{InsecureSkipVerify: true} - httpClient := &http.Client{ - Transport: &http.Transport{TLSClientConfig: config}, - } - - provider.HTTPClient = *httpClient - iConn := oscon.OpenStackCloudConnection{ CredentialInfo: connInfo.CredentialInfo, Region: connInfo.RegionInfo, From bcf639798e7a712cf72fdb082823bb2547ff268c Mon Sep 17 00:00:00 2001 From: innodreamer Date: Thu, 6 Jun 2024 01:30:32 +0900 Subject: [PATCH 14/19] Update go.mod and go.sum --- go.mod | 4 ++-- go.sum | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 8e711de73..427cea750 100644 --- a/go.mod +++ b/go.mod @@ -74,7 +74,7 @@ require ( github.com/labstack/echo/v4 v4.9.0 github.com/tencentcloud/tencentcloud-sdk-go-intl-en v3.0.531+incompatible github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cbs v1.0.492 - golang.org/x/mod v0.8.0 + golang.org/x/mod v0.17.0 k8s.io/api v0.22.5 k8s.io/apimachinery v0.22.5 k8s.io/client-go v0.22.5 @@ -192,7 +192,7 @@ require ( golang.org/x/term v0.20.0 // indirect golang.org/x/text v0.15.0 // indirect golang.org/x/time v0.5.0 // indirect - golang.org/x/tools v0.6.0 // indirect + golang.org/x/tools v0.21.0 // indirect google.golang.org/appengine v1.6.8 // indirect google.golang.org/protobuf v1.33.0 // indirect gopkg.in/go-playground/validator.v9 v9.31.0 // indirect diff --git a/go.sum b/go.sum index 1990e5030..d5ae4c9fb 100644 --- a/go.sum +++ b/go.sum @@ -838,8 +838,9 @@ golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= +golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -927,8 +928,8 @@ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= -golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1107,8 +1108,9 @@ golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= +golang.org/x/tools v0.21.0 h1:qc0xYgIbsSDt9EyWz05J5wfa7LOVW0YTLOXrqdLAWIw= +golang.org/x/tools v0.21.0/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= From 6b42151e9d2261f42defe24c1fb2615ea0bf081e Mon Sep 17 00:00:00 2001 From: innodreamer Date: Thu, 6 Jun 2024 01:40:08 +0900 Subject: [PATCH 15/19] Modify cblogger.Error to cblogger..Debug --- .../cloud-driver/drivers/ktcloud/resources/KeyPairHandler.go | 2 +- .../cloud-driver/drivers/ktcloud/resources/MyImageHandler.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cloud-control-manager/cloud-driver/drivers/ktcloud/resources/KeyPairHandler.go b/cloud-control-manager/cloud-driver/drivers/ktcloud/resources/KeyPairHandler.go index 7acaaffa3..23f9bc558 100644 --- a/cloud-control-manager/cloud-driver/drivers/ktcloud/resources/KeyPairHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/ktcloud/resources/KeyPairHandler.go @@ -75,7 +75,7 @@ func (keyPairHandler *KtCloudKeyPairHandler) CreateKey(keyPairReqInfo irs.KeyPai //***** Make sure that Keypair Name already exists ***** resultKey, keyGetError := keyPairHandler.GetKey(keyPairReqInfo.IId) if keyGetError != nil { - cblogger.Errorf("The KeyPair with the Name does't exit!!: ", keyGetError) + cblogger.Debug("The KeyPair with the Name does't exit!!: [%v]", keyGetError) // spew.Dump(keyGetError) } diff --git a/cloud-control-manager/cloud-driver/drivers/ktcloud/resources/MyImageHandler.go b/cloud-control-manager/cloud-driver/drivers/ktcloud/resources/MyImageHandler.go index f527d720b..9c8f416c6 100644 --- a/cloud-control-manager/cloud-driver/drivers/ktcloud/resources/MyImageHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/ktcloud/resources/MyImageHandler.go @@ -336,7 +336,7 @@ func (myImageHandler *KtCloudMyImageHandler) getKTImage(myImageIID irs.IID) (*kt } if imgInfo.ID == "" { newErr := fmt.Errorf("Failed to Find any My Image(Image Template) with the Image ID!!") - cblogger.Error(newErr.Error()) + cblogger.Debug(newErr.Error()) return nil, newErr } } From 571fb045f4ac440f46ca65d215e645f900144484 Mon Sep 17 00:00:00 2001 From: innodreamer Date: Thu, 6 Jun 2024 01:40:42 +0900 Subject: [PATCH 16/19] Update logging message --- .../cloud-driver/drivers/ktcloud/resources/NLBHandler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloud-control-manager/cloud-driver/drivers/ktcloud/resources/NLBHandler.go b/cloud-control-manager/cloud-driver/drivers/ktcloud/resources/NLBHandler.go index c15289638..e22dbf04d 100644 --- a/cloud-control-manager/cloud-driver/drivers/ktcloud/resources/NLBHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/ktcloud/resources/NLBHandler.go @@ -89,7 +89,7 @@ func (nlbHandler *KtCloudNLBHandler) CreateNLB(nlbReqInfo irs.NLBInfo) (irs.NLBI LoggingInfo(callLogInfo, start) cblogger.Infof("# New NLBId : %s", nlbResp.Createnlbresponse.NLBId) - cblogger.Info("\n### New NLB is Creating Now!!") + cblogger.Info("\n### Creating New NLB Now!!") time.Sleep(time.Second * 7) newNlbIID := irs.IID{SystemId: nlbResp.Createnlbresponse.NLBId} From 1db2d7629e02934e58e35f90323fe0e122d4e56f Mon Sep 17 00:00:00 2001 From: innodreamer Date: Thu, 6 Jun 2024 01:43:34 +0900 Subject: [PATCH 17/19] Replace RunCommand() with Remove() to remve S/G file --- .../ktcloud/resources/SecurityHandler.go | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/cloud-control-manager/cloud-driver/drivers/ktcloud/resources/SecurityHandler.go b/cloud-control-manager/cloud-driver/drivers/ktcloud/resources/SecurityHandler.go index 2647dccae..4418a6f72 100644 --- a/cloud-control-manager/cloud-driver/drivers/ktcloud/resources/SecurityHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/ktcloud/resources/SecurityHandler.go @@ -13,6 +13,7 @@ package resources import ( "fmt" "os" + "io" "strings" // "crypto/aes" // "crypto/cipher" @@ -23,7 +24,6 @@ import ( "encoding/json" "errors" - "io/ioutil" // "strconv" cblog "github.com/cloud-barista/cb-log" @@ -115,7 +115,7 @@ func (securityHandler *KtCloudSecurityHandler) CreateSecurity(securityReqInfo ir cblogger.Infof("# Hashed FileName : "+ hashFileName + ".json") file, _ := json.MarshalIndent(securityReqInfo, "", " ") - writeErr := ioutil.WriteFile(sgFilePath + hashFileName + ".json", file, 0644) + writeErr := os.WriteFile(sgFilePath + hashFileName + ".json", file, 0644) if writeErr != nil { cblogger.Error("Failed to write the file: "+ sgFilePath + hashFileName + ".json", writeErr) return irs.SecurityInfo{}, writeErr @@ -174,7 +174,7 @@ func (securityHandler *KtCloudSecurityHandler) GetSecurity(securityIID irs.IID) defer jsonFile.Close() var sg SecurityGroup - byteValue, readErr := ioutil.ReadAll(jsonFile) + byteValue, readErr := io.ReadAll(jsonFile) if readErr != nil { cblogger.Error("Failed to Read the S/G file : "+ sgFileName, readErr) } @@ -221,7 +221,7 @@ func (securityHandler *KtCloudSecurityHandler) ListSecurity() ([]*irs.SecurityIn } // File list on the local directory - dirFiles, readRrr := ioutil.ReadDir(sgFilePath) + dirFiles, readRrr := os.ReadDir(sgFilePath) if readRrr != nil { return []*irs.SecurityInfo{}, readRrr } @@ -287,17 +287,14 @@ func (securityHandler *KtCloudSecurityHandler) DeleteSecurity(securityIID irs.II } // To Remove the S/G file on the Local machine. - cmdName := "rm" - cmdArgs := []string{sgFileName} - - if cmdOut, cmdErr := RunCommand(cmdName, cmdArgs); cmdErr != nil { - cblogger.Errorf("Failed to run the command to remove the S/G file.") - return false, cmdErr - } else { - cblogger.Infof("Succeeded in Deleting the S/G File!!") - cblogger.Infof("cmdOut : " + cmdOut) + delErr := os.Remove(sgFileName) + if delErr != nil { + newErr := fmt.Errorf("Failed to Delete the file : %s, [%v]", sgFileName, delErr) + cblogger.Error(newErr.Error()) + return false, newErr } - cblogger.Infof("Succeeded in Deleting the SecurityGroup : " + securityIID.SystemId) + cblogger.Infof("Succeeded in Deleting the SecurityGroup : " + securityIID.NameId) + return true, nil } From 546dc7495d438013739a3546fffdae32cee1e8aa Mon Sep 17 00:00:00 2001 From: innodreamer Date: Thu, 6 Jun 2024 01:46:48 +0900 Subject: [PATCH 18/19] Apply filter for VPC registration on CB-TB --- .../drivers/ktcloudvpc/resources/VPCHandler.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cloud-control-manager/cloud-driver/drivers/ktcloudvpc/resources/VPCHandler.go b/cloud-control-manager/cloud-driver/drivers/ktcloudvpc/resources/VPCHandler.go index d91d72b6c..0cba6338d 100644 --- a/cloud-control-manager/cloud-driver/drivers/ktcloudvpc/resources/VPCHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/ktcloudvpc/resources/VPCHandler.go @@ -318,7 +318,7 @@ func (vpcHandler *KTVpcVPCHandler) AddSubnet(vpcIID irs.IID, subnetReqInfo irs.S } } else { cblogger.Info("\n### Waiting for Adding the Subnet!!") - time.Sleep(time.Second * 15) + time.Sleep(time.Second * 25) // cblogger.Infof("Succeeded in Adding the Subnet : [%s]", subnet.ID) // To prevent 'panic: runtime error', maded this line as a comment. } @@ -390,12 +390,15 @@ func (vpcHandler *KTVpcVPCHandler) mappingVpcInfo(nvpc *networks.Network) (*irs. // Get Subnet info list. var subnetInfoList []irs.SubnetInfo for _, subnet := range nvpc.Subnets { - // if !strings.EqualFold(subnet.Name, "Private_Sub") && !strings.EqualFold(subnet.Name, "DMZ_Sub") && !strings.EqualFold(subnet.Name, "external"){ - // # When apply filtering + if !strings.EqualFold(subnet.Name, "Private_Sub") && !strings.EqualFold(subnet.Name, "DMZ_Sub") && !strings.EqualFold(subnet.Name, "external"){ + // # When apply filtering + + cblogger.Info("# Subnet Name : [%s]", subnet.Name) + // if strings.EqualFold(subnet.Name, "NLB-SUBNET_Sub"){ // Note) '_Sub' is automatically appended to the original subnet name subnetInfo := vpcHandler.mappingSubnetInfo(subnet) subnetInfoList = append(subnetInfoList, *subnetInfo) - // } + } } vpcInfo.SubnetInfoList = subnetInfoList From 49fee446578842c89e52a3c497dbf581f63a27cd Mon Sep 17 00:00:00 2001 From: innodreamer Date: Thu, 6 Jun 2024 01:49:08 +0900 Subject: [PATCH 19/19] Update Idmaxlength of KT Cloud VPC resources --- cloud-driver-libs/cloudos_meta.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cloud-driver-libs/cloudos_meta.yaml b/cloud-driver-libs/cloudos_meta.yaml index 81245f7d8..aaa5856c2 100644 --- a/cloud-driver-libs/cloudos_meta.yaml +++ b/cloud-driver-libs/cloudos_meta.yaml @@ -91,7 +91,7 @@ NCP: disktype: SSD / HDD disksize: SSD|10|2000|GB / HDD|10|2000|GB # idmaxlength: VPC / Subnet / SecurityGroup / KeyPair / VM / Disk / NLB / MyImage / Cluster - idmaxlength: 0 / 0 / 0 / 30 / 30 / 30 / 30 / 30 / 0 + idmaxlength: 30 / 30 / 30 / 30 / 30 / 30 / 30 / 30 / 0 NCPVPC: region: Region / Zone @@ -121,7 +121,7 @@ KTCLOUD: disktype: HDD / SSD-Provisioned disksize: HDD|10|500|GB / SSD-Provisioned|100|800|GB # idmaxlength: VPC / Subnet / SecurityGroup / KeyPair / VM / Disk / NLB / MyImage - idmaxlength: 0 / 0 / 30 / 100 / 100 / 50 / 30 / 32 + idmaxlength: 30 / 30 / 30 / 100 / 63 / 50 / 30 / 32 KTCLOUDVPC: region: Region / Zone @@ -131,7 +131,7 @@ KTCLOUDVPC: disktype: HDD / SSD disksize: HDD|10|2000|GB / SSD|10|2000|GB # idmaxlength: VPC / Subnet / SecurityGroup / KeyPair / VM / Disk / NLB / MyImage - idmaxlength: 300 / 300 / 30 / 100 / 300 / 50 / 30 / 50 + idmaxlength: 30 / 22 / 30 / 100 / 63 / 50 / 30 / 50 #--- PoC