โฏ ./delete-all-ns.sh
####################################################################
## 0. Namespace: Delete
####################################################################
{
"message" : "All namespaces has been deleted"
}
(There should be no namespaces.)
โฏ ./list-ns.sh | less
####################################################################
## 0. Namespace: List
####################################################################
{
"ns" : [
{
"name" : "222f9394-f2b7-4c62-8024-586304b45eb3",
"id" : "222f9394-f2b7-4c62-8024-586304b45eb3",
"description" : ""
},
{
"name" : "fe149015-ca50-4497-9cde-9ff0b3be2df2",
"description" : "",
"id" : "fe149015-ca50-4497-9cde-9ff0b3be2df2"
},
{
"name" : "",
"description" : "",
"id" : "aws-us-east-1-t2.nano"
},
{
"name" : "",
"id" : "aws-us-east-1-t1.micro",
"description" : ""
},
{
"name" : "",
"id" : "aws-us-east-1-t2.micro",
"description" : ""
},
{
"name" : "",
"id" : "aws-us-east-1-a1.medium",
"description" : ""
},
{
"id" : "aws-us-east-1-c6g.medium",
"description" : "",
"name" : ""
},
{
"description" : "",
"id" : "aws-us-east-1-c6gd.medium",
"name" : ""
},
{
"id" : "aws-us-east-1-m1.small",
"description" : "",
"name" : ""
},
{
"description" : "",
"id" : "aws-us-east-1-t2.small",
"name" : ""
},
...
List Ns ํ์ ๋ ๋์ค๋ ๊ฒ๋ค
Issue-Label Bot is automatically applying the label bug to this issue, with a confidence of 0.98. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!
Links: app homepage, dashboard and code for this bot.
@jihoon-seo ์ด๋ค ์ํฉ์์ ๋ฒ๊ทธ๊ฐ ๋ฐ์ํ๋์ง์?
๋ค๋ฅธ ์ ์ฅ์์ ์
๋ฐ์ดํธ ์ํฉ๊ณผ ์ฐ๊ณ๋์ด ์๋์?
TB ์์ CreateNs() ํจ์๋ฅผ ๋ถ๋ฅด๋ฉด
Key-Value store์
{
"id": "NS-01",
"name": "NS-01",
"description": "my desc"
}
์ด๋ฐ ํ์์ผ๋ก ์ ์ฅํฉ๋๋ค.
์ดํ Image ๊ฐ์ฒด๋ฅผ ์์ฑํ๋ฉด
Key-Value store์
{
"connectionName": "'${CONN_CONFIG[$INDEX,$REGION]}'",
"name": "'${CONN_CONFIG[$INDEX,$REGION]}'-'${POSTFIX}'",
"cspImageId": "'${IMAGE_NAME[$INDEX,$REGION]}'",
"cspImageName": "",
"creationDate": "",
"description": "Canonical, Ubuntu, 18.04 LTS, amd64 bionic",
"guestOS": "Ubuntu",
"status": "",
"keyValueList": [
{
"Key": "",
"Value": ""
},
{
"Key": "",
"Value": ""
}
]
}
์ด๋ฐ ํ์์ผ๋ก ์ ์ฅํฉ๋๋ค.
TB ์ ListNs() ํจ์๋ฅผ ๋ถ๋ฅด๋ฉด
key := "/ns"
keyValue, err := CBStore.GetList(key, true)
๋ฅผ ํธ์ถํ๋๋ฐ
CBStore.GetList() ํจ์๋
/ns ๋ผ๋ ํค์ ํ์์ ์๋ ๋ชจ๋ Key-Val pair ๋ฅผ ๋ฆฌํดํฉ๋๋ค.
์ด๋ฌํ ์ด์ ๋ก ์์ ๊ฐ์ ํ์์ด ๋ํ๋๊ณ ์์ต๋๋ค.
KV store ์์
ํน์ ๊ณ์ (์: /ns) ์ ์ง์ํ๋ฐฐ๋ง ๋ฆฌํดํ๋ ํจ์๋ฅผ
cb-store ์ ์ถ๊ฐ ์์ฒญ ๋๋ ธ์ต๋๋ค.
์ด ํจ์๊ฐ ์์ฑ๋๋ฉด, TB ์์ ์ฌ์ฉํ๊ณ ์๋ CBStore.GetList() ํจ์ ๋ถ๋ถ์
์ ํจ์๋ก ๋์ฒดํ๊ฒ ์ต๋๋ค.
Ref: @powerkimhub
[Files and functions that using CBStore.GetList() function]
src/core/common/namespace.gofunc ListNs() ([]NsInfo, error)func ListNsId() []stringsrc/core/mcir/common.gofunc ListResourceId(nsId string, resourceType string) []stringfunc ListResource(nsId string, resourceType string) (interface{}, error)src/core/mcir/obsolete/publicip.gofunc getPublicIpList(nsId string) []stringsrc/core/mcir/obsolete/subnet.gofunc getSubnetList(nsId string) []stringsrc/core/mcir/obsolete/vnic.gofunc getVNicList(nsId string) []stringsrc/core/mcis/control.gofunc ListMcisId(nsId string) []stringfunc ListVmId(nsId string, mcisId string) ([]string, error)func GetRecommendList(nsId string, cpuSize string, memSize string, diskSize string) ([]TbVmPriority, error)func ListNsId() []string ์ ํด๋น ๋ก์ง์ด ์์ต๋๋ค.
https://github.com/cloud-barista/cb-tumblebug/blob/e42e87081448772bcb459971079e1d677e18d10d/src/core/common/namespace.go#L131
๊ทธ๋ฐ๋ฐ ํํฐ๋ง์ ์๋์ผ๋ก ํด ์ค์ผ ํฉ๋๋ค.
(์์ ๋งํฌ์์๋
if !strings.Contains(v.Key, "mcis") && !strings.Contains(v.Key, "cpu") && !strings.Contains(v.Key, "resources") {
nsList = append(nsList, strings.TrimPrefix(v.Key, "/ns/"))
}
์ด๋ ๊ฒ ํํฐ๋ง ํ๊ณ ์์)
[์]
func ListNsId() []string ์ ์๋ ๋ก์ง์ func ListNs() ([]NsInfo, error) ์๋ ๋ฃ๋๋ค. (๋ค๋ฅธ ํจ์๋ค์๋ ๋ง์ฐฌ๊ฐ์ง)func ListNs() ([]NsInfo, error) ๋ฅผ ํธ์ถํ๋ฉดfunc ListNsId() []string ๋ฅผ ํธ์ถํ๊ณ func GetNs(id string) (NsInfo, error) ํ์ฌ[]NsInfo ๋ฅผ ๋ฆฌํดํ๋ค.@jihoon-seo @seokho-son
[๊ฐ์]
[๊ณํ]
[์ฌ์ฉ์์]
keyValueList, _ := store.GetList("/ns", true) // => /ns*
targetList, _ := utils.GetChildList(keyValueList, "/ns") // => /ns/[*]
@jihoon-seo @seokho-son
[utils.GetChildList() ์ถ๊ฐ ๋ฐ ์ํ ์๋ฃ]
Most helpful comment
@jihoon-seo @seokho-son
[utils.GetChildList() ์ถ๊ฐ ๋ฐ ์ํ ์๋ฃ]