-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add IBM Power VS: tfvars #5615
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
Merged
openshift-merge-robot
merged 2 commits into
openshift:master
from
clnperez:new-tfvars-pkg
Apr 11, 2022
Merged
Add IBM Power VS: tfvars #5615
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,17 @@ | ||
| package powervs | ||
|
|
||
| import ( | ||
| "github.com/openshift/installer/pkg/terraform" | ||
| "github.com/openshift/installer/pkg/terraform/providers" | ||
| "github.com/openshift/installer/pkg/terraform/stages" | ||
| ) | ||
|
|
||
| // PlatformStages are the stages to run to provision the infrastructure in PowerVS. | ||
| var PlatformStages = []terraform.Stage{ | ||
| stages.NewStage("powervs", | ||
| "cluster", | ||
| []providers.Provider{providers.IBM, providers.Ignition}), | ||
| stages.NewStage("powervs", | ||
| "post-install", | ||
| []providers.Provider{providers.IBM}), | ||
| } |
This file contains hidden or 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,87 @@ | ||
| // Package powervs contains Power Virtual Servers-specific Terraform-variable logic. | ||
| package powervs | ||
|
|
||
| import ( | ||
| "encoding/json" | ||
| "fmt" | ||
| "math/rand" | ||
| "time" | ||
|
|
||
| "github.com/openshift/installer/pkg/types/powervs" | ||
| "github.com/openshift/machine-api-provider-powervs/pkg/apis/powervsprovider/v1alpha1" | ||
| ) | ||
|
|
||
| type config struct { | ||
| ServiceInstanceID string `json:"powervs_cloud_instance_id"` | ||
| APIKey string `json:"powervs_api_key"` | ||
| SSHKey string `json:"powervs_ssh_key"` | ||
| PowerVSRegion string `json:"powervs_region"` | ||
| PowerVSZone string `json:"powervs_zone"` | ||
| VPCRegion string `json:"powervs_vpc_region"` | ||
| VPCZone string `json:"powervs_vpc_zone"` | ||
| PowerVSResourceGroup string `json:"powervs_resource_group"` | ||
| CISInstanceCRN string `json:"powervs_cis_crn"` | ||
| ImageBucketFileName string `json:"powervs_image_bucket_file_name"` | ||
| NetworkName string `json:"powervs_network_name"` | ||
| VPCName string `json:"powervs_vpc_name"` | ||
| VPCSubnetName string `json:"powervs_vpc_subnet_name"` | ||
| BootstrapMemory string `json:"powervs_bootstrap_memory"` | ||
| BootstrapProcessors string `json:"powervs_bootstrap_processors"` | ||
| MasterMemory string `json:"powervs_master_memory"` | ||
| MasterProcessors string `json:"powervs_master_processors"` | ||
| ProcType string `json:"powervs_proc_type"` | ||
| SysType string `json:"powervs_sys_type"` | ||
| } | ||
|
|
||
| // TFVarsSources contains the parameters to be converted into Terraform variables | ||
| type TFVarsSources struct { | ||
| MasterConfigs []*v1alpha1.PowerVSMachineProviderConfig | ||
| APIKey string | ||
| SSHKey string | ||
| Region string | ||
| Zone string | ||
| ImageBucketFileName string | ||
| NetworkName string | ||
| PowerVSResourceGroup string | ||
| CISInstanceCRN string | ||
| VPCName string | ||
| VPCSubnetName string | ||
| } | ||
|
|
||
| // TFVars generates Power VS-specific Terraform variables launching the cluster. | ||
| func TFVars(sources TFVarsSources) ([]byte, error) { | ||
| masterConfig := sources.MasterConfigs[0] | ||
| // TODO(mjturek): Allow user to specify vpcRegion in install config like we're doing for vpcZone | ||
| vpcRegion := powervs.Regions[sources.Region].VPCRegion | ||
|
|
||
| // Randomly select a zone in the VPC region. | ||
| // @TODO: Align this with a region later. | ||
| rand.Seed(time.Now().UnixNano()) | ||
| // All supported Regions are MZRs and have Zones named "region-[1-3]" | ||
| vpcZone := fmt.Sprintf("%s-%d", vpcRegion, rand.Intn(3)) | ||
|
|
||
| //@TODO: Add resource group to platform | ||
| cfg := &config{ | ||
| ServiceInstanceID: masterConfig.ServiceInstanceID, | ||
| APIKey: sources.APIKey, | ||
| SSHKey: sources.SSHKey, | ||
| PowerVSRegion: sources.Region, | ||
| PowerVSZone: sources.Zone, | ||
| VPCRegion: vpcRegion, | ||
| VPCZone: vpcZone, | ||
| PowerVSResourceGroup: sources.PowerVSResourceGroup, | ||
| CISInstanceCRN: sources.CISInstanceCRN, | ||
| ImageBucketFileName: sources.ImageBucketFileName, | ||
| NetworkName: *masterConfig.Network.Name, | ||
| VPCName: sources.VPCName, | ||
| VPCSubnetName: sources.VPCSubnetName, | ||
| BootstrapMemory: masterConfig.Memory, | ||
| BootstrapProcessors: masterConfig.Processors, | ||
| MasterMemory: masterConfig.Memory, | ||
| MasterProcessors: masterConfig.Processors, | ||
| ProcType: masterConfig.ProcType, | ||
| SysType: masterConfig.SysType, | ||
| } | ||
|
|
||
| return json.MarshalIndent(cfg, "", " ") | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.