Skip to content

Commit

Permalink
Show access info of Global-NLB
Browse files Browse the repository at this point in the history
  • Loading branch information
seokho-son committed Nov 12, 2022
1 parent 804a574 commit 0c0dc03
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/api/rest/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -8693,6 +8693,9 @@ const docTemplate = `{
"mcisId": {
"type": "string"
},
"mcisNlbListener": {
"$ref": "#/definitions/mcis.McisAccessInfo"
},
"mcisSubGroupAccessInfo": {
"type": "array",
"items": {
Expand Down
3 changes: 3 additions & 0 deletions src/api/rest/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -8685,6 +8685,9 @@
"mcisId": {
"type": "string"
},
"mcisNlbListener": {
"$ref": "#/definitions/mcis.McisAccessInfo"
},
"mcisSubGroupAccessInfo": {
"type": "array",
"items": {
Expand Down
2 changes: 2 additions & 0 deletions src/api/rest/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1179,6 +1179,8 @@ definitions:
properties:
mcisId:
type: string
mcisNlbListener:
$ref: '#/definitions/mcis.McisAccessInfo'
mcisSubGroupAccessInfo:
items:
$ref: '#/definitions/mcis.McisSubGroupAccessInfo'
Expand Down
7 changes: 7 additions & 0 deletions src/core/mcis/manageInfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,11 +348,18 @@ func GetMcisAccessInfo(nsId string, mcisId string, option string) (*McisAccessIn
}

output.McisId = mcisId

mcNlbAccess, err := GetMcNlbAccess(nsId, mcisId)
if err == nil {
output.McisNlbListener = mcNlbAccess
}

subGroupList, err := ListSubGroupId(nsId, mcisId)
if err != nil {
common.CBLog.Error(err)
return temp, err
}
// TODO: make in parallel
for _, groupId := range subGroupList {
subGroupAccessInfo := McisSubGroupAccessInfo{}
subGroupAccessInfo.SubGroupId = groupId
Expand Down
9 changes: 8 additions & 1 deletion src/core/mcis/nlb.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import (
"github.com/go-resty/resty/v2"
)

const nlbPostfix = "-nlb"

// 2022-07-15 https://github.com/cloud-barista/cb-spider/blob/master/cloud-control-manager/cloud-driver/interfaces/resources/NLBHandler.go

// SpiderNLBReqInfoWrapper is a wrapper struct to create JSON body of 'Create NLB request'
Expand Down Expand Up @@ -288,7 +290,6 @@ func CreateMcSwNlb(nsId string, mcisId string, req *TbNLBReq, option string) (Tb
return emptyObj, err
}

nlbPostfix := "-nlb"
nlbMcisId := mcisId + nlbPostfix

// create a special MCIS for (SW)NLB
Expand Down Expand Up @@ -780,6 +781,12 @@ func GetNLB(nsId string, mcisId string, resourceId string) (TbNLBInfo, error) {
return res, err
}

// GetMcNlbAccess returns the requested TB G-NLB access info (currenly MCIS)
func GetMcNlbAccess(nsId string, mcisId string) (*McisAccessInfo, error) {
nlbMcisId := mcisId + nlbPostfix
return GetMcisAccessInfo(nsId, nlbMcisId, "")
}

// CheckNLB returns the existence of the TB NLB object in bool form.
func CheckNLB(nsId string, mcisId string, resourceId string) (bool, error) {

Expand Down
1 change: 1 addition & 0 deletions src/core/mcis/provisioning.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ type TbVmInfo struct {
// McisAccessInfo is struct to retrieve overall access information of a MCIS
type McisAccessInfo struct {
McisId string
McisNlbListener *McisAccessInfo `json:"mcisNlbListener,omitempty"`
McisSubGroupAccessInfo []McisSubGroupAccessInfo
}

Expand Down

0 comments on commit 0c0dc03

Please sign in to comment.