Skip to content

Commit

Permalink
Fix get subnet csp id for vm provisioning
Browse files Browse the repository at this point in the history
  • Loading branch information
seokho-son committed Sep 2, 2024
1 parent 5e015f9 commit 26d2dca
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
1 change: 0 additions & 1 deletion src/core/common/utility.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ func GenResourceKey(nsId string, resourceType string, resourceId string) string
resourceType == model.StrVNet ||
resourceType == model.StrSecurityGroup ||
resourceType == model.StrDataDisk {
//resourceType == "subnet" ||
//resourceType == "publicIp" ||
//resourceType == "vNic" {
return "/ns/" + nsId + "/resources/" + resourceType + "/" + resourceId
Expand Down
10 changes: 8 additions & 2 deletions src/core/infra/provisioning.go
Original file line number Diff line number Diff line change
Expand Up @@ -1318,8 +1318,14 @@ func CreateVm(nsId string, mciId string, vmInfoData *model.TbVmInfo, option stri
return err
}

// TODO: needs to be enhnaced to use GetCspResourceId (GetCspResourceId needs to be updated as well)
requestBody.ReqInfo.SubnetName = vmInfoData.SubnetId //resource.GetCspResourceId(nsId, model.StrVNet, vmInfoData.SubnetId)
// retrieve csp subnet id
subnetInfo, err := resource.GetSubnet(nsId, vmInfoData.VNetId, vmInfoData.SubnetId)
if err != nil {
log.Error().Err(err).Msg("Cannot find the Subnet ID: " + vmInfoData.SubnetId)
return err
}

requestBody.ReqInfo.SubnetName = subnetInfo.CspSubnetName
if requestBody.ReqInfo.SubnetName == "" {
log.Error().Err(err).Msg("")
return err
Expand Down
10 changes: 4 additions & 6 deletions src/core/resource/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -2115,6 +2115,8 @@ type resourceIds struct { // Tumblebug
CspVNicName string
CspDataDiskId string
CspDataDiskName string
CspSubnetId string
CspSubnetName string

ConnectionName string
}
Expand Down Expand Up @@ -2170,14 +2172,10 @@ func GetCspResourceId(nsId string, resourceType string, resourceId string) (stri
// content := resourceIds{}
// json.Unmarshal([]byte(keyValue.Value), &content)
// return content.CspSpecName, nil
case model.StrVNet:
case model.StrSubnet:
content := resourceIds{}
json.Unmarshal([]byte(keyValue.Value), &content)
return content.CspVNetName, nil // contains CspSubnetId
// case "subnet":
// content := subnetInfo{}
// json.Unmarshal([]byte(keyValue.Value), &content)
// return content.CspSubnetId
return content.CspSubnetName, nil
case model.StrSecurityGroup:
content := resourceIds{}
json.Unmarshal([]byte(keyValue.Value), &content)
Expand Down

0 comments on commit 26d2dca

Please sign in to comment.