Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add region mapping config for PowerVS cloud
This is to keep the region mapping of PowerVS in common package
- Loading branch information
1 parent
24668b1
commit 979bb31
Showing
1 changed file
with
107 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
package powervs | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
// Since there is no API to query these, we have to hard-code them here. | ||
|
||
// Region describes resources associated with a region in Power VS. | ||
// We're using a few items from the IBM Cloud VPC offering. The region names | ||
// for VPC are different so another function of this is to correlate those. | ||
type Region struct { | ||
Description string | ||
VPCRegion string | ||
Zones []string | ||
} | ||
|
||
// Regions holds the regions for IBM Power VS, and descriptions used during the survey. | ||
var Regions = map[string]Region{ | ||
"dal": { | ||
Description: "Dallas, USA", | ||
VPCRegion: "us-south", | ||
Zones: []string{"dal12"}, | ||
}, | ||
"eu-de": { | ||
Description: "Frankfurt, Germany", | ||
VPCRegion: "eu-de", | ||
Zones: []string{ | ||
"eu-de-1", | ||
"eu-de-2", | ||
}, | ||
}, | ||
"lon": { | ||
Description: "London, UK.", | ||
VPCRegion: "eu-gb", | ||
Zones: []string{ | ||
"lon04", | ||
"lon06", | ||
}, | ||
}, | ||
"mon": { | ||
Description: "Montreal, Canada", | ||
VPCRegion: "ca-tor", | ||
Zones: []string{"mon01"}, | ||
}, | ||
"osa": { | ||
Description: "Osaka, Japan", | ||
VPCRegion: "jp-osa", | ||
Zones: []string{"osa21"}, | ||
}, | ||
"syd": { | ||
Description: "Sydney, Australia", | ||
VPCRegion: "au-syd", | ||
Zones: []string{ | ||
"syd04", | ||
"syd05", | ||
}, | ||
}, | ||
"sao": { | ||
Description: "São Paulo, Brazil", | ||
VPCRegion: "br-sao", | ||
Zones: []string{"sao01"}, | ||
}, | ||
"tor": { | ||
Description: "Toronto, Canada", | ||
VPCRegion: "ca-tor", | ||
Zones: []string{"tor01"}, | ||
}, | ||
"tok": { | ||
Description: "Tokyo, Japan", | ||
VPCRegion: "jp-tok", | ||
Zones: []string{"tok04"}, | ||
}, | ||
"us-east": { | ||
Description: "Washington DC, USA", | ||
VPCRegion: "us-east", | ||
Zones: []string{"us-east"}, | ||
}, | ||
} | ||
|
||
// VPCRegionForPowerVSRegion returns the VPC region for the specified PowerVS region. | ||
func VPCRegionForPowerVSRegion(region string) (string, error) { | ||
if r, ok := Regions[region]; ok { | ||
return r.VPCRegion, nil | ||
} | ||
|
||
return "", fmt.Errorf("VPC region corresponding to a PowerVS region %s not found ", region) | ||
} | ||
|
||
// RegionShortNames returns the list of region names | ||
func RegionShortNames() []string { | ||
keys := []string{} | ||
for r := range Regions { | ||
keys = append(keys, r) | ||
} | ||
return keys | ||
} | ||
|
||
// ValidateVPCRegion validates that given VPC region is known/tested. | ||
func ValidateVPCRegion(region string) bool { | ||
for r := range Regions { | ||
if region == Regions[r].VPCRegion { | ||
return true | ||
} | ||
} | ||
return false | ||
} |