Skip to content

Commit

Permalink
Terraform Support for EPIC offering Create flow
Browse files Browse the repository at this point in the history
  • Loading branch information
bhagyagkwd committed Aug 10, 2022
1 parent dcdcef7 commit 6f7efaf
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 5 deletions.
6 changes: 6 additions & 0 deletions ibm/acctest/acctest.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ var Pi_network_name string
var Pi_cloud_instance_id string
var Pi_instance_name string
var Pi_dhcp_id string
var Pi_instance_deployment_type string
var PiCloudConnectionName string
var PiSAPProfileID string
var Pi_placement_group_name string
Expand Down Expand Up @@ -637,6 +638,11 @@ func init() {
fmt.Println("[INFO] Set the environment variable PI_PVM_INSTANCE_ID for testing Pi_instance_name resource else it is set to default value 'terraform-test-power'")
}

Pi_instance_deployment_type = os.Getenv("PI_INSTANCE_DEPLOYMENT_TYPE")
if Pi_instance_deployment_type == "" {
fmt.Println("[INFO] Set the environment variable PI_INSTANCE_DEPLOYMENT_TYPE for testing ibm_pi_instance resource else tests will fail if this is not set correctly")
}

Pi_dhcp_id = os.Getenv("PI_DHCP_ID")
if Pi_dhcp_id == "" {
Pi_dhcp_id = "terraform-test-power"
Expand Down
1 change: 1 addition & 0 deletions ibm/service/power/ibm_pi_constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const (
activeTimeOut = 2 * time.Minute
// power service instance capabilities
CUSTOM_VIRTUAL_CORES = "custom-virtualcores"
PIInstanceDeploymentType = "pi_deployment_type"
PIInstanceNetwork = "pi_network"
PIInstanceStoragePool = "pi_storage_pool"
PISAPInstanceProfileID = "pi_sap_profile_id"
Expand Down
9 changes: 9 additions & 0 deletions ibm/service/power/resource_ibm_pi_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,11 @@ func ResourceIBMPIInstance() *schema.Resource {
ConflictsWith: []string{PISAPInstanceProfileID},
Description: "Memory size",
},
PIInstanceDeploymentType: {
Type: schema.TypeString,
Optional: true,
Description: "Custom Deployment Type Information",
},
PISAPInstanceProfileID: {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -1222,6 +1227,10 @@ func createPVMInstance(d *schema.ResourceData, client *st.IBMPIInstanceClient, i
body.StoragePool = sp.(string)
}

if dt, ok := d.GetOk(PIInstanceDeploymentType); ok {
body.DeploymentType = dt.(string)
}

if ap, ok := d.GetOk(PIAffinityPolicy); ok {
policy := ap.(string)
affinity := &models.StorageAffinity{
Expand Down
9 changes: 5 additions & 4 deletions ibm/service/power/resource_ibm_pi_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,22 @@ func testAccCheckIBMPIInstanceConfig(name, instanceHealthStatus string) string {
}
resource "ibm_pi_instance" "power_instance" {
pi_memory = "2"
pi_processors = "0.25"
pi_processors = "1"
pi_instance_name = "%[2]s"
pi_proc_type = "shared"
pi_proc_type = "dedicated"
pi_image_id = data.ibm_pi_image.power_image.id
pi_key_pair_name = ibm_pi_key.key.key_id
pi_sys_type = "s922"
pi_sys_type = "e980"
pi_cloud_instance_id = "%[1]s"
pi_storage_pool = data.ibm_pi_image.power_image.storage_pool
pi_health_status = "%[5]s"
pi_volume_ids = [ibm_pi_volume.power_volume.volume_id]
pi_network {
network_id = data.ibm_pi_network.power_networks.id
}
pi_deployment_type = "%[6]s"
}
`, acc.Pi_cloud_instance_id, name, acc.Pi_image, acc.Pi_network_name, instanceHealthStatus)
`, acc.Pi_cloud_instance_id, name, acc.Pi_image, acc.Pi_network_name, instanceHealthStatus, acc.Pi_instance_deployment_type)
}

func testAccIBMPIInstanceNetworkConfig(name, privateNetIP string) string {
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/pi_instance.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ Review the argument references that you can specify for your resource.
- `pi_anti_affinity_instances` - (Optional, String) List of pvmInstances to base storage anti-affinity policy against; required if requesting `anti-affinity` and `pi_anti_affinity_volumes` is not provided.
- `pi_anti_affinity_volumes`- (Optional, String) List of volumes to base storage anti-affinity policy against; required if requesting `anti-affinity` and `pi_anti_affinity_instances` is not provided.
- `pi_cloud_instance_id` - (Required, String) The GUID of the service instance associated with an account.
- `pi_deployment_type` - (Optional, String) Custom deployment type information (For Internal Use Only).
- `pi_health_status` - (Optional, String) Specifies if Terraform should poll for the health status to be `OK` or `WARNING`. The default value is `OK`.
- `pi_image_id` - (Required, String) The ID of the image that you want to use for your Power Systems Virtual Server instance. The image determines the operating system that is installed in your instance. To list available images, run the `ibmcloud pi images` command.
- `pi_instance_name` - (Required, String) The name of the Power Systems Virtual Server instance.
Expand Down Expand Up @@ -99,7 +100,6 @@ Review the argument references that you can specify for your resource.
- `pi_user_data` - (Optional, String) The base64 encoded form of the user data `cloud-init` to pass to the instance during creation.
- `pi_virtual_cores_assigned` - (Optional, Integer) Specify the number of virtual cores to be assigned.
- `pi_volume_ids` - (Optional, List of String) The list of volume IDs that you want to attach to the instance during creation.

## Attribute reference
In addition to all argument reference list, you can access the following attribute reference after your resource is created.

Expand Down

0 comments on commit 6f7efaf

Please sign in to comment.