-
Notifications
You must be signed in to change notification settings - Fork 712
do-not-merge: ## [R][D] vPMEM #6561
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
Open
michaelkad
wants to merge
6
commits into
IBM-Cloud:master
Choose a base branch
from
powervs-ibm:vpmem
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f2439de
## [R][D] vPMEM
michaelkad b22ab71
Fix doc to address review
michaelkad 25a5573
Fix doc to address review 2
michaelkad 270d68e
Fix doc to address review 3: reason
michaelkad 1466ab1
Fix doc to address review 4
michaelkad a254ee0
Fix go.sum
michaelkad 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
148 changes: 148 additions & 0 deletions
148
ibm/service/power/data_source_ibm_pi_instance_vpmem_volume.go
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,148 @@ | ||
| // Copyright IBM Corp. 2025 All Rights Reserved. | ||
| // Licensed under the Mozilla Public License v2.0 | ||
|
|
||
| package power | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| "log" | ||
|
|
||
| "github.com/hashicorp/terraform-plugin-sdk/v2/diag" | ||
| "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
| "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" | ||
|
|
||
| "github.com/IBM-Cloud/power-go-client/clients/instance" | ||
| "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" | ||
| "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" | ||
| ) | ||
|
|
||
| func DataSourceIBMPIInstanceVpmemVolume() *schema.Resource { | ||
| return &schema.Resource{ | ||
| ReadContext: dataSourceIBMPIInstanceVpmemVolumeRead, | ||
|
|
||
| Schema: map[string]*schema.Schema{ | ||
| // Arguments | ||
| Arg_CloudInstanceID: { | ||
| Description: "The GUID of the service instance associated with an account.", | ||
| Required: true, | ||
| Type: schema.TypeString, | ||
| ValidateFunc: validation.NoZeroValues, | ||
| }, | ||
| Arg_PVMInstanceID: { | ||
| Description: "PCloud PVM instance ID.", | ||
| Required: true, | ||
| Type: schema.TypeString, | ||
| }, | ||
| Arg_VPMEMVolumeID: { | ||
| Description: "vPMEM volume ID.", | ||
| Required: true, | ||
| Type: schema.TypeString, | ||
| }, | ||
|
|
||
| // Attributes | ||
| Attr_CreationDate: { | ||
| Computed: true, | ||
| Description: "The date and time when the volume was created.", | ||
| Type: schema.TypeString, | ||
| }, | ||
| Attr_CRN: { | ||
| Computed: true, | ||
| Description: "The CRN for this resource.", | ||
| Type: schema.TypeString, | ||
| }, | ||
| Attr_ErrorCode: { | ||
| Computed: true, | ||
| Description: "Error code for the vPMEM volume.", | ||
| Type: schema.TypeString, | ||
| }, | ||
| Attr_Href: { | ||
| Computed: true, | ||
| Description: "Link to vPMEM volume resource.", | ||
| Type: schema.TypeString, | ||
| }, | ||
| Attr_Name: { | ||
| Computed: true, | ||
| Description: "Volume name.", | ||
| Type: schema.TypeString, | ||
| }, | ||
| Attr_PVMInstanceID: { | ||
| Computed: true, | ||
| Description: "PVM Instance ID which the volume is attached to.", | ||
| Type: schema.TypeString, | ||
| }, | ||
| Attr_Reason: { | ||
| Computed: true, | ||
| Description: "Reason for error.", | ||
| Type: schema.TypeString, | ||
| }, | ||
| Attr_Size: { | ||
| Computed: true, | ||
| Description: "Volume size (GB).", | ||
| Type: schema.TypeFloat, | ||
| }, | ||
| Attr_Status: { | ||
| Computed: true, | ||
| Description: "Status of the volume.", | ||
| Type: schema.TypeString, | ||
| }, | ||
| Attr_UpdatedDate: { | ||
| Computed: true, | ||
| Description: "The date and time when the volume was updated.", | ||
| Type: schema.TypeString, | ||
| }, | ||
| Attr_UserTags: { | ||
| Computed: true, | ||
| Description: "List of user tags.", | ||
| Elem: &schema.Schema{ | ||
| Type: schema.TypeString, | ||
| }, | ||
| Set: schema.HashString, | ||
| Type: schema.TypeSet, | ||
| }, | ||
| }, | ||
| } | ||
| } | ||
|
|
||
| func dataSourceIBMPIInstanceVpmemVolumeRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { | ||
| sess, err := meta.(conns.ClientSession).IBMPISession() | ||
| if err != nil { | ||
| tfErr := flex.TerraformErrorf(err, fmt.Sprintf("IBMPISession failed: %s", err.Error()), "(Data) ibm_pi_instance_vpmem_volume", "read") | ||
| log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) | ||
| return tfErr.GetDiag() | ||
| } | ||
| cloudInstanceID := d.Get(Arg_CloudInstanceID).(string) | ||
| pvmInstanceID := d.Get(Arg_PVMInstanceID).(string) | ||
| vpmemVolumeID := d.Get(Arg_VPMEMVolumeID).(string) | ||
|
|
||
| client := instance.NewIBMPIVPMEMClient(ctx, sess, cloudInstanceID) | ||
| vpmemVolume, err := client.GetPvmVpmemVolume(pvmInstanceID, vpmemVolumeID) | ||
| if err != nil { | ||
| tfErr := flex.TerraformErrorf(err, fmt.Sprintf("GetPvmVpmemVolume failed: %s", err.Error()), "(Data) ibm_pi_instance_vpmem_volume", "read") | ||
| log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) | ||
| return tfErr.GetDiag() | ||
| } | ||
|
|
||
| d.SetId(*vpmemVolume.UUID) | ||
| d.Set(Attr_CreationDate, vpmemVolume.CreationDate.String()) | ||
| if vpmemVolume.Crn != "" { | ||
| d.Set(Attr_CRN, vpmemVolume.Crn) | ||
| tags, err := flex.GetGlobalTagsUsingCRN(meta, string(vpmemVolume.Crn), "", UserTagType) | ||
| if err != nil { | ||
| log.Printf("Error on get of vpmem(%s) user_tags: %s", *vpmemVolume.UUID, err) | ||
| } | ||
| d.Set(Attr_UserTags, tags) | ||
| } | ||
| d.Set(Attr_ErrorCode, vpmemVolume.ErrorCode) | ||
| d.Set(Attr_Href, vpmemVolume.Href) | ||
| d.Set(Attr_Name, vpmemVolume.Name) | ||
| d.Set(Attr_PVMInstanceID, vpmemVolume.PvmInstanceID) | ||
| d.Set(Attr_Reason, vpmemVolume.Reason) | ||
| d.Set(Attr_Size, vpmemVolume.Size) | ||
| d.Set(Attr_Status, vpmemVolume.Status) | ||
| if vpmemVolume.UpdatedDate != nil { | ||
michaelkad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| d.Set(Attr_UpdatedDate, vpmemVolume.UpdatedDate.String()) | ||
| } | ||
|
|
||
| return nil | ||
| } | ||
44 changes: 44 additions & 0 deletions
44
ibm/service/power/data_source_ibm_pi_instance_vpmem_volume_test.go
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,44 @@ | ||
| // Copyright IBM Corp. 2025 All Rights Reserved. | ||
| // Licensed under the Mozilla Public License v2.0 | ||
|
|
||
| package power_test | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "testing" | ||
|
|
||
| "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
|
|
||
| acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" | ||
| ) | ||
|
|
||
| func TestAccIBMPIInstanceVpmemVolumeDataSourceBasic(t *testing.T) { | ||
| resource.Test(t, resource.TestCase{ | ||
| PreCheck: func() { acc.TestAccPreCheck(t) }, | ||
| Providers: acc.TestAccProviders, | ||
| Steps: []resource.TestStep{ | ||
| { | ||
| Config: testAccCheckIBMPIInstanceVpmemVolumeDataSourceConfigBasic(), | ||
| Check: resource.ComposeTestCheckFunc( | ||
| resource.TestCheckResourceAttrSet("data.ibm_pi_instance_vpmem_volume.instance_vpmem_volume_instance", "id"), | ||
| resource.TestCheckResourceAttrSet("data.ibm_pi_instance_vpmem_volume.instance_vpmem_volume_instance", "creation_date"), | ||
| resource.TestCheckResourceAttrSet("data.ibm_pi_instance_vpmem_volume.instance_vpmem_volume_instance", "crn"), | ||
| resource.TestCheckResourceAttrSet("data.ibm_pi_instance_vpmem_volume.instance_vpmem_volume_instance", "href"), | ||
| resource.TestCheckResourceAttrSet("data.ibm_pi_instance_vpmem_volume.instance_vpmem_volume_instance", "name"), | ||
| resource.TestCheckResourceAttrSet("data.ibm_pi_instance_vpmem_volume.instance_vpmem_volume_instance", "size"), | ||
| resource.TestCheckResourceAttrSet("data.ibm_pi_instance_vpmem_volume.instance_vpmem_volume_instance", "status"), | ||
| ), | ||
| }, | ||
| }, | ||
| }) | ||
| } | ||
|
|
||
| func testAccCheckIBMPIInstanceVpmemVolumeDataSourceConfigBasic() string { | ||
| return fmt.Sprintf(` | ||
| data "ibm_pi_instance_vpmem_volume" "instance_vpmem_volume_instance" { | ||
| pi_cloud_instance_id = "%[1]s" | ||
| pi_pvm_instance_id = "%[2]s" | ||
| pi_vpmem_volume_id = "%[3]s" | ||
| } | ||
| `, acc.Pi_cloud_instance_id, acc.Pi_instance_id, acc.Pi_volume_id) | ||
| } |
Oops, something went wrong.
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.