Skip to content

Commit

Permalink
Influencing cb-spider resource objects with namespace (#909)
Browse files Browse the repository at this point in the history
* Go mod tidy

* Use NS prefix for CSP vnet Name

* Use NS prefix for CSP SSHKEY Name

* Use NS prefix for CSP SG Name

* Use NS prefix for CSP name del Res

* Fix GetCspResourceId return value
  • Loading branch information
seokho-son authored Nov 2, 2021
1 parent 93f4f7d commit e44f883
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 494 deletions.
3 changes: 0 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ require (
github.com/cloud-barista/cb-log v0.4.0
github.com/cloud-barista/cb-spider v0.4.13
github.com/cloud-barista/cb-store v0.4.1
github.com/go-openapi/jsonreference v0.19.6 // indirect
github.com/go-openapi/swag v0.19.15 // indirect
github.com/go-playground/validator/v10 v10.9.0
github.com/go-resty/resty/v2 v2.6.0
github.com/go-sql-driver/mysql v1.6.0
Expand All @@ -26,7 +24,6 @@ require (
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
github.com/labstack/echo/v4 v4.6.1
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-sqlite3 v2.0.3+incompatible
github.com/opentracing/opentracing-go v1.2.0
github.com/prometheus/client_golang v1.11.0
Expand Down
483 changes: 0 additions & 483 deletions go.sum

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/core/common/utility.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,15 @@ func GetCspResourceId(nsId string, resourceType string, resourceId string) (stri
case StrSSHKey:
content := mcirIds{}
json.Unmarshal([]byte(keyValue.Value), &content)
return resourceId, nil
return content.CspSshKeyName, nil
case StrSpec:
content := mcirIds{}
json.Unmarshal([]byte(keyValue.Value), &content)
return content.CspSpecName, nil
case StrVNet:
content := mcirIds{}
json.Unmarshal([]byte(keyValue.Value), &content)
return resourceId, nil // contains CspSubnetId
return content.CspVNetName, nil // contains CspSubnetId
// case "subnet":
// content := subnetInfo{}
// json.Unmarshal([]byte(keyValue.Value), &content)
Expand Down
6 changes: 3 additions & 3 deletions src/core/mcir/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func DelResource(nsId string, resourceType string, resourceId string, forceFlag
return err
}
tempReq.ConnectionName = temp.ConnectionName
url = common.SpiderRestUrl + "/keypair/" + temp.Name
url = common.SpiderRestUrl + "/keypair/" + temp.CspSshKeyName
case common.StrVNet:
temp := TbVNetInfo{}
err = json.Unmarshal([]byte(keyValue.Value), &temp)
Expand All @@ -219,7 +219,7 @@ func DelResource(nsId string, resourceType string, resourceId string, forceFlag
return err
}
tempReq.ConnectionName = temp.ConnectionName
url = common.SpiderRestUrl + "/vpc/" + temp.Name
url = common.SpiderRestUrl + "/vpc/" + temp.CspVNetName
childResources = temp.SubnetInfoList
case common.StrSecurityGroup:
temp := TbSecurityGroupInfo{}
Expand All @@ -229,7 +229,7 @@ func DelResource(nsId string, resourceType string, resourceId string, forceFlag
return err
}
tempReq.ConnectionName = temp.ConnectionName
url = common.SpiderRestUrl + "/securitygroup/" + temp.Name
url = common.SpiderRestUrl + "/securitygroup/" + temp.CspSecurityGroupName
/*
case "subnet":
temp := subnetInfo{}
Expand Down
14 changes: 13 additions & 1 deletion src/core/mcir/securitygroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,22 @@ func CreateSecurityGroup(nsId string, u *TbSecurityGroupReq) (TbSecurityGroupInf
return content, err
}

tempInterface, err := GetResource(nsId, common.StrVNet, u.VNetId)
if err != nil {
err := fmt.Errorf("Failed to get the TbVNetInfo " + u.VNetId + ".")
return TbSecurityGroupInfo{}, err
}
vNetInfo := TbVNetInfo{}
err = common.CopySrcToDest(&tempInterface, &vNetInfo)
if err != nil {
err := fmt.Errorf("Failed to get the TbVNetInfo-CopySrcToDest() " + u.VNetId + ".")
return TbSecurityGroupInfo{}, err
}

tempReq := SpiderSecurityReqInfoWrapper{}
tempReq.ConnectionName = u.ConnectionName
tempReq.ReqInfo.Name = u.Name
tempReq.ReqInfo.VPCName = u.VNetId
tempReq.ReqInfo.VPCName = vNetInfo.CspVNetName
tempReq.ReqInfo.SecurityRules = u.FirewallRules

var tempSpiderSecurityInfo *SpiderSecurityInfo
Expand Down
2 changes: 1 addition & 1 deletion src/core/mcir/sshkey.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func CreateSshKey(nsId string, u *TbSshKeyReq) (TbSshKeyInfo, error) {

tempReq := SpiderKeyPairReqInfoWrapper{}
tempReq.ConnectionName = u.ConnectionName
tempReq.ReqInfo.Name = u.Name
tempReq.ReqInfo.Name = nsId + "-" + u.Name

var tempSpiderKeyPairInfo *SpiderKeyPairInfo

Expand Down
2 changes: 1 addition & 1 deletion src/core/mcir/vnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func CreateVNet(nsId string, u *TbVNetReq) (TbVNetInfo, error) {

tempReq := SpiderVPCReqInfoWrapper{}
tempReq.ConnectionName = u.ConnectionName
tempReq.ReqInfo.Name = u.Name
tempReq.ReqInfo.Name = nsId + "-" + u.Name
tempReq.ReqInfo.IPv4_CIDR = u.CidrBlock

// tempReq.ReqInfo.SubnetInfoList = u.SubnetInfoList
Expand Down

0 comments on commit e44f883

Please sign in to comment.