Skip to content

Commit

Permalink
Merge branch 'refs/heads/master' into issue_1207_fmt_logger_change_20…
Browse files Browse the repository at this point in the history
…240531_synn

# Conflicts:
#	cloud-control-manager/cloud-driver/drivers/aws/resources/ClusterHandler.go
  • Loading branch information
CliffSynn committed Jul 2, 2024
2 parents 85b5ed9 + ebd9deb commit 43acaa3
Show file tree
Hide file tree
Showing 26 changed files with 946 additions and 622 deletions.
39 changes: 23 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,27 +55,31 @@ If you have any difficulties in using Cloud-Barista, please let us know.

#### 3. 제공 자원

| Provider | Price<br>Info | Region/Zone<br>Info | Image<br>Info | VMSpec<br>Info | VPC<br>Subnet | Security<br>Group | VM KeyPair | VM | Disk | NLB | MyImage | managed-K8S |
| Provider | Price<br>Info | Region/Zone<br>Info | Image<br>Info | VMSpec<br>Info | VPC<br>Subnet | Security<br>Group | VM KeyPair | VM | Disk | MyImage | NLB | managed-K8S |
|:-------------:|:-------------:|:-------------------:|:-------------:|:--------------:|:-------------------:|:-----------------:|:---------------:|:--------------:|:----:|:---:|:-------:|:-----------:|
| AWS | O | O | O | O | O | O | O | O | O | O | O | Soon |
| Azure | O<br>(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 | O |
| Azure | O<br>(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<br>(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<br>(Type-1) | O<br>(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<br>(Type-2) | O | O | O<br>(Note-2) | O | Soon| Soon | O |
| KT Classic | - | O | O | O | O<br>(Type-1) | O | O | O | O | O | O | - |
| KT VPC | - | O | O | O | O<br>(Type-3) | O | O | O | O | O | Soon | - |
| IBM VPC | O<br>(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<br>(Type1) | O<br>(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<br>(Type2) | O | O | O<br>(Note2) | O | WIP| WIP | O |
| KT Classic | NA | O | O | O | O<br>(Type1) | O | O | O | O | O | O | NA |
| KT VPC | NA | O | O | O | O<br>(Type3) | O | O | O | O | WIP | O<br>(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 활용
Expand All @@ -86,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 활용
Expand All @@ -104,7 +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 참고)
◉ Note3: NLB에 등록할 VM은 NLB와 동일 Subnet에 존재해야 함


#### 4. VM 계정
Expand Down
23 changes: 20 additions & 3 deletions api-runtime/common-runtime/ClusterManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -626,13 +636,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
Expand Down
8 changes: 8 additions & 0 deletions api-runtime/common-runtime/CommonManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
97 changes: 70 additions & 27 deletions api-runtime/common-runtime/VPC-SubnetManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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()")

Expand Down Expand Up @@ -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 := ""
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -516,21 +537,34 @@ 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

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 ""
Expand Down Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -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)

Expand All @@ -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 {
Expand Down
5 changes: 3 additions & 2 deletions api-runtime/rest-runtime/VPC-SubnetRest.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand All @@ -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())
}
Expand Down
Loading

0 comments on commit 43acaa3

Please sign in to comment.