Skip to content

Commit

Permalink
PMKS Quick Release
Browse files Browse the repository at this point in the history
  • Loading branch information
powerkimhub committed Oct 25, 2022
1 parent 0d9de76 commit a02a8de
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 13 deletions.
7 changes: 4 additions & 3 deletions api-runtime/common-runtime/ClusterManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ defer clusterSPLock.Unlock(connectionName, reqInfo.IId.NameId)

func setResourcesNameId(connectionName string, info *cres.ClusterInfo) error {
//+++++++++++++++++++++ Set NetworkInfo's NameId
netInfo := info.Network
netInfo := &info.Network
// (1) VpcIID
// get spiderIID
vpcIIDInfo, err := iidRWLock.GetIIDbySystemID(iidm.IIDSGROUP, connectionName, rsVPC, netInfo.VpcIID)
Expand Down Expand Up @@ -857,6 +857,7 @@ defer clusterSPLock.Unlock(connectionName, clusterName)
}

// driverIID
nodeGroupNameId := reqInfo.IId.NameId
driverIId := cres.IID{nodeGroupUUID, ""}
reqInfo.IId = driverIId

Expand All @@ -867,7 +868,7 @@ defer clusterSPLock.Unlock(connectionName, clusterName)
return nil, err
}

ngSpiderIId := cres.IID{reqInfo.IId.NameId, nodeGroupUUID + ":" + ngInfo.IId.SystemId}
ngSpiderIId := cres.IID{nodeGroupNameId, nodeGroupUUID + ":" + ngInfo.IId.SystemId}
_, err2 := iidRWLock.CreateIID(iidm.NGGROUP, connectionName, clusterName, ngSpiderIId) // clusterName => rsType
if err2 != nil {
cblog.Error(err2)
Expand Down Expand Up @@ -1013,7 +1014,7 @@ func getClusterDriverIIDNodeGroupDriverIID(connectionName string, clusterName st
}

// (2) Get NodeGroup's DriverIID
ngIIdInfoList, err := getAllClusterIIDInfoList(connectionName)
ngIIdInfoList, err := getAllNodeGroupIIDInfoList(connectionName)
if err != nil {
cblog.Error(err)
return cres.IID{}, cres.IID{}, err
Expand Down
22 changes: 21 additions & 1 deletion api-runtime/common-runtime/CommonManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,7 @@ func DeleteResource(connectionName string, rsType string, nameID string, force s
}
}
}
// @todo Should we also delete the SG list of this VPC ?
// @todo Should we also delete the SG list of this VPC ? NO, We Can't delete the VPC had SGs

case rsSG:
_, err = iidRWLock.DeleteIID(iidm.SGGROUP, connectionName, iidInfo.ResourceType/*vpcName*/, cres.IID{nameID, ""})
Expand Down Expand Up @@ -1022,6 +1022,26 @@ func DeleteResource(connectionName string, rsType string, nameID string, force s
}
}

// for NodeGroup list
// key-value structure: ~/{NODEGROUP}/{ConnectionName}/{Cluster-NameId}/{NodeGroup-reqNameId} [nodegroup-driverNameId:nodegroup-driverSystemId] # Cluster NameId => rsType
ngIIdInfoList, err2 := iidRWLock.ListIID(iidm.NGGROUP, connectionName, iidInfo.IId.NameId/*clusterName*/)
if err2 != nil {
cblog.Error(err)
if force != "true" {
return false, "", err
}
}
for _, ngIIdInfo := range ngIIdInfoList {
_, err := iidRWLock.DeleteIID(iidm.NGGROUP, connectionName, iidInfo.IId.NameId/*clusterName*/, ngIIdInfo.IId)
if err != nil {
cblog.Error(err)
if force != "true" {
return false, "", err
}
}
}


default: // ex) KeyPair, Disk
_, err = iidRWLock.DeleteIID(iidm.IIDSGROUP, connectionName, rsType, iidInfo.IId)
if err != nil {
Expand Down
18 changes: 9 additions & 9 deletions api-runtime/rest-runtime/ClusterRest.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,13 @@ func attachNameSpaceToName(nameSpace string, clusterInfo *cres.ClusterInfo) {
clusterInfo.Network.VpcIID.NameId = nameSpace + clusterInfo.Network.VpcIID.NameId

// (2) Network's SubnetIIDs
for idx, _ := range clusterInfo.Network.SubnetIIDs {
clusterInfo.Network.SubnetIIDs[idx].NameId = nameSpace + clusterInfo.Network.SubnetIIDs[idx].NameId
}
//for idx, _ := range clusterInfo.Network.SubnetIIDs {
// clusterInfo.Network.SubnetIIDs[idx].NameId = nameSpace + clusterInfo.Network.SubnetIIDs[idx].NameId
//}

// (3) Network's SecurityGroupsIIDs
for idx, _ := range clusterInfo.Network.SubnetIIDs {
clusterInfo.Network.SubnetIIDs[idx].NameId = nameSpace + clusterInfo.Network.SubnetIIDs[idx].NameId
for idx, _ := range clusterInfo.Network.SecurityGroupIIDs {
clusterInfo.Network.SecurityGroupIIDs[idx].NameId = nameSpace + clusterInfo.Network.SecurityGroupIIDs[idx].NameId
}

// (4) NodeGroup's KeyPairIID
Expand Down Expand Up @@ -289,10 +289,10 @@ func detachNameSpaceFromName(nameSpace string, clusterInfo *cres.ClusterInfo) {
clusterInfo.Network.VpcIID.NameId = strings.Replace(clusterInfo.Network.VpcIID.NameId, nameSpace, "", 1)

// (2) Network's SubnetIIDs
for idx, _ := range clusterInfo.Network.SubnetIIDs {
clusterInfo.Network.SubnetIIDs[idx].NameId =
strings.Replace(clusterInfo.Network.SubnetIIDs[idx].NameId, nameSpace, "", 1)
}
//for idx, _ := range clusterInfo.Network.SubnetIIDs {
// clusterInfo.Network.SubnetIIDs[idx].NameId =
// strings.Replace(clusterInfo.Network.SubnetIIDs[idx].NameId, nameSpace, "", 1)
//}

// (3) Network's SecurityGroupsIIDs
for idx, _ := range clusterInfo.Network.SecurityGroupIIDs {
Expand Down

0 comments on commit a02a8de

Please sign in to comment.