Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update site-to-site VPN #1884

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/api/rest/server/infra/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,19 +142,26 @@ func ExtractSitesInfoFromMciInfo(nsId, mciId string) (*networkSiteModel.SitesInf

// Get the last subnet
subnetCount := len(vNetInfo.SubnetInfoList)
if subnetCount == 0 {
log.Warn().Msgf("No subnets found for VNet ID: %s", vNetId)
continue
}
lastSubnet := vNetInfo.SubnetInfoList[subnetCount-1]
lastSubnetIdFromCSP := lastSubnet.CspResourceId

// Set VNet and the last subnet IDs
site.VNet = vm.CspVNetId
site.Subnet = lastSubnetIdFromCSP
site.Subnet = lastSubnet.CspResourceId

sitesInAws = append(sitesInAws, site)

case "azure":
// Parse vNet and resource group names
parts := strings.Split(vm.CspVNetId, "/")
log.Debug().Msgf("parts: %+v", parts)
if len(parts) < 9 {
log.Warn().Msgf("Invalid VNet ID format for Azure VM ID: %s", vm.Id)
continue
}
parsedResourceGroupName := parts[4]
parsedVirtualNetworkName := parts[8]

Expand All @@ -174,6 +181,10 @@ func ExtractSitesInfoFromMciInfo(nsId, mciId string) (*networkSiteModel.SitesInf

// Get the last subnet CIDR block
subnetCount := len(vNetInfo.SubnetInfoList)
if subnetCount == 0 {
log.Warn().Msgf("No subnets found for VNet ID: %s", vNetId)
continue
}
lastSubnet := vNetInfo.SubnetInfoList[subnetCount-1]
lastSubnetCidr := lastSubnet.IPv4_CIDR

Expand Down
6 changes: 3 additions & 3 deletions src/api/rest/server/model/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ var ProviderNames = map[string]string{

// SiteDetail struct represents the structure for detailed site information
type SiteDetail struct {
CSP string `json:"csp" example:"aws"`
Region string `json:"region" example:"ap-northeast-2"`
Zone string `json:"zone,omitempty" example:"ap-northeast-2a"`
CSP string `json:"csp" example:"aws"`
Region string `json:"region" example:"ap-northeast-2"`
// Zone string `json:"zone,omitempty" example:"ap-northeast-2a"`
VNet string `json:"vnet" example:"vpc-xxxxx"`
Subnet string `json:"subnet,omitempty" example:"subnet-xxxxx"`
GatewaySubnetCidr string `json:"gatewaySubnetCidr,omitempty" example:"xxx.xxx.xxx.xxx/xx"`
Expand Down
6 changes: 4 additions & 2 deletions src/core/resource/vnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ func CreateVNet(nsId string, vNetReq *model.TbVNetReq) (model.TbVNetInfo, error)
})
}

log.Debug().Msgf("vNetInfo: %+v", vNetInfo)
log.Debug().Msgf("vNetInfo(initial): %+v", vNetInfo)

// Set a vNetKey for the vNet object
vNetKey := common.GenResourceKey(nsId, resourceType, vNetInfo.Id)
Expand Down Expand Up @@ -541,7 +541,7 @@ func CreateVNet(nsId string, vNetReq *model.TbVNetReq) (model.TbVNetInfo, error)
log.Warn().Msgf("The status of the vNet (%s) is unknown", vNetInfo.Id)
}

log.Debug().Msgf("vNetInfo: %+v", vNetInfo)
log.Debug().Msgf("vNetInfo(filled): %+v", vNetInfo)

// Store vNet object into the key-value store
value, err := json.Marshal(vNetInfo)
Expand Down Expand Up @@ -684,6 +684,8 @@ func GetVNet(nsId string, vNetId string) (model.TbVNetInfo, error) {
return emptyRet, err
}

log.Debug().Msgf("vNetInfo: %+v", vNetInfo)

/*
* Get vNet info
*/
Expand Down