Skip to content

Commit

Permalink
Merge pull request #12 from dharaneeshvrd/update-region
Browse files Browse the repository at this point in the history
Add VPCZones
  • Loading branch information
Power Cloud Robot authored Jun 10, 2024
2 parents 5884530 + 2d1707a commit 6bdc07d
Showing 1 changed file with 52 additions and 12 deletions.
64 changes: 52 additions & 12 deletions region.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ func GetRegion(zone string) (region string, err error) {
region = "mad"
case strings.HasPrefix(zone, "wdc"):
region = "wdc"
case strings.HasPrefix(zone, "tor"):
region = "tor"
default:
return "", fmt.Errorf("region not found for the zone, talk to the developer to add the support into the tool: %s", zone)
}
Expand All @@ -47,6 +49,7 @@ type Region struct {
COSRegion string
Zones []string
SysTypes []string
VPCZones []string
}

// Regions provides a mapping between Power VS and IBM Cloud VPC and IBM COS regions.
Expand All @@ -60,6 +63,7 @@ var Regions = map[string]Region{
"dal12",
},
SysTypes: []string{"s922", "e980"},
VPCZones: []string{"us-south-1", "us-south-2", "us-south-3"},
},
"eu-de": {
Description: "Frankfurt, Germany",
Expand All @@ -70,6 +74,7 @@ var Regions = map[string]Region{
"eu-de-2",
},
SysTypes: []string{"s922", "e980"},
VPCZones: []string{"eu-de-1", "eu-de-2", "eu-de-3"},
},
"lon": {
Description: "London, UK.",
Expand All @@ -80,6 +85,7 @@ var Regions = map[string]Region{
"lon06",
},
SysTypes: []string{"s922", "e980"},
VPCZones: []string{"eu-gb-1", "eu-gb-2", "eu-gb-3"},
},
"mad": {
Description: "Madrid, Spain",
Expand All @@ -90,30 +96,23 @@ var Regions = map[string]Region{
"mad04",
},
SysTypes: []string{"s1022"},
VPCZones: []string{"eu-es-1", "eu-es-2", "eu-es-3"},
},
"mon": {
Description: "Montreal, Canada",
VPCRegion: "ca-tor",
VPCRegion: "",
COSRegion: "ca-tor",
Zones: []string{"mon01"},
SysTypes: []string{"s922", "e980"},
VPCZones: []string{},
},
"osa": {
Description: "Osaka, Japan",
VPCRegion: "jp-osa",
COSRegion: "jp-osa",
Zones: []string{"osa21"},
SysTypes: []string{"s922", "e980"},
},
"syd": {
Description: "Sydney, Australia",
VPCRegion: "au-syd",
COSRegion: "au-syd",
Zones: []string{
"syd04",
"syd05",
},
SysTypes: []string{"s922", "e980"},
VPCZones: []string{"jp-osa-1", "jp-osa-2", "jp-osa-3"},
},
"sao": {
Description: "São Paulo, Brazil",
Expand All @@ -124,20 +123,52 @@ var Regions = map[string]Region{
"sao04",
},
SysTypes: []string{"s922", "e980"},
VPCZones: []string{"br-sao-1", "br-sao-2", "br-sao-3"},
},
"syd": {
Description: "Sydney, Australia",
VPCRegion: "au-syd",
COSRegion: "au-syd",
Zones: []string{
"syd04",
"syd05",
},
SysTypes: []string{"s922", "e980"},
VPCZones: []string{"au-syd-1", "au-syd-2", "au-syd-3"},
},
"tok": {
Description: "Tokyo, Japan",
VPCRegion: "jp-tok",
COSRegion: "jp-tok",
Zones: []string{"tok04"},
SysTypes: []string{"s922", "e980"},
VPCZones: []string{"jp-tok-1", "jp-tok-2", "jp-tok-3"},
},
"tor": {
Description: "Toronto, Canada",
VPCRegion: "ca-tor",
COSRegion: "ca-tor",
Zones: []string{"tor01"},
SysTypes: []string{"s922", "e980"},
VPCZones: []string{"ca-tor-1", "ca-tor-2", "ca-tor-3"},
}, // Keeping us-east and us-south zones as individual entries to easily map the respective VPC and COS regions by matching the prefix of the zone like in GetRegion()
"us-east": {
Description: "Washington DC, USA",
VPCRegion: "us-east",
COSRegion: "us-east",
Zones: []string{"us-east"},
SysTypes: []string{}, // Missing
SysTypes: []string{"s922", "e980"},
VPCZones: []string{"us-east-1", "us-east-2", "us-east-3"},
},
"us-south": {
Description: "Dallas, USA",
VPCRegion: "us-south",
COSRegion: "us-south",
Zones: []string{
"us-south",
},
SysTypes: []string{"s922", "e980"},
VPCZones: []string{"us-south-1", "us-south-2", "us-south-3"},
},
"wdc": {
Description: "Washington DC, USA",
Expand All @@ -148,6 +179,7 @@ var Regions = map[string]Region{
"wdc07",
},
SysTypes: []string{"s922", "e980"},
VPCZones: []string{"us-east-1", "us-east-2", "us-east-3"},
},
}

Expand Down Expand Up @@ -252,3 +284,11 @@ func AvailableSysTypes(region string) ([]string, error) {
}
return knownRegion.SysTypes, nil
}

// IsGlobalRoutingRequiredForTG returns true when powervs and vpc regions are different.
func IsGlobalRoutingRequiredForTG(powerVSRegion string, vpcRegion string) bool {
if r, ok := Regions[powerVSRegion]; ok && r.VPCRegion == vpcRegion {
return false
}
return true
}

0 comments on commit 6bdc07d

Please sign in to comment.