diff --git a/go.mod b/go.mod index f0d0da5c6a..69767b424c 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.24.2 require ( github.com/IBM-Cloud/bluemix-go v0.0.0-20251001005609-37dbcddbe871 github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20240725064144-454a2ae23113 - github.com/IBM-Cloud/power-go-client v1.13.0 + github.com/IBM-Cloud/power-go-client v1.14.0-beta15 github.com/IBM/appconfiguration-go-admin-sdk v0.5.1 github.com/IBM/appid-management-go-sdk v0.0.0-20210908164609-dd0e0eaf732f github.com/IBM/cloud-databases-go-sdk v0.8.1 diff --git a/go.sum b/go.sum index c8c9b45ceb..e76a915845 100644 --- a/go.sum +++ b/go.sum @@ -93,8 +93,8 @@ github.com/IBM-Cloud/bluemix-go v0.0.0-20251001005609-37dbcddbe871 h1:0NrvGUWBoG github.com/IBM-Cloud/bluemix-go v0.0.0-20251001005609-37dbcddbe871/go.mod h1:lU1/3aolIs4y062yTTokFEiIEssAZqqjdj/5qvkBeq8= github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20240725064144-454a2ae23113 h1:f2Erqfea1dKpaTFagTJM6W/wnD3JGq/Vn9URh8nuRwk= github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20240725064144-454a2ae23113/go.mod h1:xUQL9SGAjoZFd4GNjrjjtEpjpkgU7RFXRyHesbKTjiY= -github.com/IBM-Cloud/power-go-client v1.13.0 h1:TqxPlkJe0VkNdV9hYOD5NRepxEFhhyKXWXfg22x2zhU= -github.com/IBM-Cloud/power-go-client v1.13.0/go.mod h1:SpTK1ttW8bfMNUVQS8qOEuWn2KOkzaCLyzfze8MG1JE= +github.com/IBM-Cloud/power-go-client v1.14.0-beta15 h1:lN5Fc3hHncZSaRWelY7A4ViPrZWSBEGQ5Oa3qfIKAG0= +github.com/IBM-Cloud/power-go-client v1.14.0-beta15/go.mod h1:SpTK1ttW8bfMNUVQS8qOEuWn2KOkzaCLyzfze8MG1JE= github.com/IBM-Cloud/softlayer-go v1.0.5-tf h1:koUAyF9b6X78lLLruGYPSOmrfY2YcGYKOj/Ug9nbKNw= github.com/IBM-Cloud/softlayer-go v1.0.5-tf/go.mod h1:6HepcfAXROz0Rf63krk5hPZyHT6qyx2MNvYyHof7ik4= github.com/IBM/appconfiguration-go-admin-sdk v0.5.1 h1:EAotl3yQ/u5u/uBryySJMm0COgsYhtNzQ1g2IChtlE0= diff --git a/ibm/service/power/data_source_ibm_pi_catalog_images.go b/ibm/service/power/data_source_ibm_pi_catalog_images.go index 710ab13a21..130cbc816a 100644 --- a/ibm/service/power/data_source_ibm_pi_catalog_images.go +++ b/ibm/service/power/data_source_ibm_pi_catalog_images.go @@ -78,7 +78,7 @@ func DataSourceIBMPICatalogImages() *schema.Resource { }, Attr_Endianness: { Computed: true, - Description: "The Endianness order.", + Description: "The endianness order.", Type: schema.TypeString, }, Attr_Href: { @@ -116,6 +116,16 @@ func DataSourceIBMPICatalogImages() *schema.Resource { Description: "Operating System.", Type: schema.TypeString, }, + Attr_Shared: { + Computed: true, + Description: "Indicates whether the image is shared.", + Type: schema.TypeBool, + }, + Attr_SourceChecksum: { + Computed: true, + Description: "Checksum of the image.", + Type: schema.TypeString, + }, Attr_State: { Computed: true, Description: "The state of an Operating System.", @@ -202,6 +212,12 @@ func dataSourceIBMPICatalogImagesRead(ctx context.Context, d *schema.ResourceDat if s.OperatingSystem != "" { image[Attr_OperatingSystem] = s.OperatingSystem } + if s.Shared != nil { + image[Attr_Shared] = *s.Shared + } + if s.SourceChecksum != "" { + image[Attr_SourceChecksum] = s.SourceChecksum + } } if i.State != nil { image[Attr_State] = *i.State diff --git a/ibm/service/power/data_source_ibm_pi_image.go b/ibm/service/power/data_source_ibm_pi_image.go index 35ebc44c4f..9a6bba53dc 100644 --- a/ibm/service/power/data_source_ibm_pi_image.go +++ b/ibm/service/power/data_source_ibm_pi_image.go @@ -27,17 +27,28 @@ func DataSourceIBMPIImage() *schema.Resource { Type: schema.TypeString, ValidateFunc: validation.NoZeroValues, }, + Arg_ImageID: { + AtLeastOneOf: []string{Arg_ImageID, Arg_ImageName}, + ConflictsWith: []string{Arg_ImageName}, + Description: "The image ID.", + Optional: true, + Type: schema.TypeString, + ValidateFunc: validation.NoZeroValues, + }, Arg_ImageName: { - Description: "The ID of the image.", - Required: true, - Type: schema.TypeString, - ValidateFunc: validation.NoZeroValues, + AtLeastOneOf: []string{Arg_ImageID, Arg_ImageName}, + ConflictsWith: []string{Arg_ImageID}, + Deprecated: "The pi_image_name field is deprecated. Please use pi_image_id instead", + Description: "The name of the image.", + Optional: true, + Type: schema.TypeString, + ValidateFunc: validation.NoZeroValues, }, // Attributes Attr_Architecture: { Computed: true, - Description: "The CPU architecture that the image is designed for. ", + Description: "The CPU architecture that the image is designed for.", Type: schema.TypeString, }, Attr_CRN: { @@ -45,6 +56,21 @@ func DataSourceIBMPIImage() *schema.Resource { Description: "The CRN of this resource.", Type: schema.TypeString, }, + Attr_ContainerFormat: { + Computed: true, + Description: "The container format.", + Type: schema.TypeString, + }, + Attr_DiskFormat: { + Computed: true, + Description: "The disk format.", + Type: schema.TypeString, + }, + Attr_Endianness: { + Computed: true, + Description: "The endianness order.", + Type: schema.TypeString, + }, Attr_Hypervisor: { Computed: true, Description: "Hypervision Type.", @@ -55,11 +81,21 @@ func DataSourceIBMPIImage() *schema.Resource { Description: "The identifier of this image type.", Type: schema.TypeString, }, + Attr_Name: { + Computed: true, + Description: "The name of an image.", + Type: schema.TypeString, + }, Attr_OperatingSystem: { Computed: true, Description: "The operating system that is installed with the image.", Type: schema.TypeString, }, + Attr_Shared: { + Computed: true, + Description: "Indicates whether the image is shared.", + Type: schema.TypeBool, + }, Attr_Size: { Computed: true, Description: "The size of the image in megabytes.", @@ -92,6 +128,35 @@ func DataSourceIBMPIImage() *schema.Resource { Set: schema.HashString, Type: schema.TypeSet, }, + Attr_Volumes: { + Computed: true, + Description: "List of image volumes.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + Attr_Bootable: { + Computed: true, + Description: "Indicates if the volume is boot capable.", + Type: schema.TypeBool, + }, + Attr_Name: { + Computed: true, + Description: "The volume name of the image.", + Type: schema.TypeString, + }, + Attr_Size: { + Computed: true, + Description: "The volume size of the image.", + Type: schema.TypeFloat, + }, + Attr_VolumeID: { + Computed: true, + Description: "The volume ID of the image.", + Type: schema.TypeString, + }, + }, + }, + Type: schema.TypeList, + }, }, } } @@ -105,9 +170,15 @@ func dataSourceIBMPIImagesRead(ctx context.Context, d *schema.ResourceData, meta } cloudInstanceID := d.Get(Arg_CloudInstanceID).(string) + var imageID string + if v, ok := d.GetOk(Arg_ImageID); ok { + imageID = v.(string) + } else if v, ok := d.GetOk(Arg_ImageName); ok { + imageID = v.(string) + } imageC := instance.NewIBMPIImageClient(ctx, sess, cloudInstanceID) - imagedata, err := imageC.Get(d.Get(Arg_ImageName).(string)) + imagedata, err := imageC.Get(imageID) if err != nil { tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Get failed: %s", err.Error()), "(Data) ibm_pi_image", "read") log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage()) @@ -116,6 +187,7 @@ func dataSourceIBMPIImagesRead(ctx context.Context, d *schema.ResourceData, meta d.SetId(*imagedata.ImageID) d.Set(Attr_Architecture, imagedata.Specifications.Architecture) + d.Set(Attr_ContainerFormat, imagedata.Specifications.ContainerFormat) if imagedata.Crn != "" { d.Set(Attr_CRN, imagedata.Crn) tags, err := flex.GetGlobalTagsUsingCRN(meta, string(imagedata.Crn), "", UserTagType) @@ -124,14 +196,32 @@ func dataSourceIBMPIImagesRead(ctx context.Context, d *schema.ResourceData, meta } d.Set(Attr_UserTags, tags) } + d.Set(Attr_DiskFormat, imagedata.Specifications.DiskFormat) + d.Set(Attr_Endianness, imagedata.Specifications.Endianness) d.Set(Attr_Hypervisor, imagedata.Specifications.HypervisorType) d.Set(Attr_ImageType, imagedata.Specifications.ImageType) + d.Set(Attr_Name, imagedata.Name) d.Set(Attr_OperatingSystem, imagedata.Specifications.OperatingSystem) + d.Set(Attr_Shared, imagedata.Specifications.Shared) d.Set(Attr_Size, imagedata.Size) d.Set(Attr_SourceChecksum, imagedata.Specifications.SourceChecksum) d.Set(Attr_State, imagedata.State) d.Set(Attr_StoragePool, imagedata.StoragePool) d.Set(Attr_StorageType, imagedata.StorageType) - + volumeMap := []map[string]any{} + if imagedata.Volumes != nil { + for _, n := range imagedata.Volumes { + if n != nil { + v := map[string]any{ + Attr_Bootable: n.Bootable, + Attr_Name: n.Name, + Attr_Size: n.Size, + Attr_VolumeID: n.VolumeID, + } + volumeMap = append(volumeMap, v) + } + } + } + d.Set(Attr_Volumes, volumeMap) return nil } diff --git a/ibm/service/power/data_source_ibm_pi_image_test.go b/ibm/service/power/data_source_ibm_pi_image_test.go index 734d3b71b7..f1431ca57c 100644 --- a/ibm/service/power/data_source_ibm_pi_image_test.go +++ b/ibm/service/power/data_source_ibm_pi_image_test.go @@ -30,7 +30,7 @@ func TestAccIBMPIImageDataSource_basic(t *testing.T) { func testAccCheckIBMPIImageDataSourceConfig() string { return fmt.Sprintf(` data "ibm_pi_image" "testacc_ds_image" { - pi_image_name = "%s" - pi_cloud_instance_id = "%s" - }`, acc.Pi_image, acc.Pi_cloud_instance_id) + pi_cloud_instance_id = "%[1]s" + pi_image_id = "%[2]s" + }`, acc.Pi_cloud_instance_id, acc.Pi_image) } diff --git a/ibm/service/power/data_source_ibm_pi_images.go b/ibm/service/power/data_source_ibm_pi_images.go index 60aa896dd2..13a8d69a0a 100644 --- a/ibm/service/power/data_source_ibm_pi_images.go +++ b/ibm/service/power/data_source_ibm_pi_images.go @@ -37,16 +37,41 @@ func DataSourceIBMPIImages() *schema.Resource { Description: "List of all supported images.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ + Attr_Architecture: { + Computed: true, + Description: "The CPU architecture that the image is designed for.", + Type: schema.TypeString, + }, Attr_CRN: { Computed: true, Description: "The CRN of this resource.", Type: schema.TypeString, }, + Attr_ContainerFormat: { + Computed: true, + Description: "The container format.", + Type: schema.TypeString, + }, + Attr_DiskFormat: { + Computed: true, + Description: "The disk format.", + Type: schema.TypeString, + }, + Attr_Endianness: { + Computed: true, + Description: "The endianness order.", + Type: schema.TypeString, + }, Attr_Href: { Computed: true, Description: "The hyper link of an image.", Type: schema.TypeString, }, + Attr_Hypervisor: { + Computed: true, + Description: "Hypervision Type.", + Type: schema.TypeString, + }, Attr_ID: { Computed: true, Description: "The unique identifier of an image.", @@ -62,6 +87,16 @@ func DataSourceIBMPIImages() *schema.Resource { Description: "The name of an image.", Type: schema.TypeString, }, + Attr_OperatingSystem: { + Computed: true, + Description: "The operating system that is installed with the image.", + Type: schema.TypeString, + }, + Attr_Shared: { + Computed: true, + Description: "Indicates whether the image is shared.", + Type: schema.TypeBool, + }, Attr_SourceChecksum: { Computed: true, Description: "Checksum of the image.", @@ -126,14 +161,21 @@ func flattenStockImages(list []*models.ImageReference, meta any) []map[string]an result := make([]map[string]any, 0, len(list)) for _, i := range list { l := map[string]any{ - Attr_Href: *i.Href, - Attr_ID: *i.ImageID, - Attr_ImageType: i.Specifications.ImageType, - Attr_Name: *i.Name, - Attr_SourceChecksum: i.Specifications.SourceChecksum, - Attr_State: *i.State, - Attr_StoragePool: *i.StoragePool, - Attr_StorageType: *i.StorageType, + Attr_Architecture: i.Specifications.Architecture, + Attr_ContainerFormat: i.Specifications.ContainerFormat, + Attr_DiskFormat: i.Specifications.DiskFormat, + Attr_Endianness: i.Specifications.Endianness, + Attr_Href: *i.Href, + Attr_Hypervisor: i.Specifications.HypervisorType, + Attr_ID: *i.ImageID, + Attr_ImageType: i.Specifications.ImageType, + Attr_Name: *i.Name, + Attr_OperatingSystem: i.Specifications.OperatingSystem, + Attr_Shared: i.Specifications.Shared, + Attr_SourceChecksum: i.Specifications.SourceChecksum, + Attr_State: *i.State, + Attr_StoragePool: *i.StoragePool, + Attr_StorageType: *i.StorageType, } if i.Crn != "" { l[Attr_CRN] = i.Crn diff --git a/ibm/service/power/ibm_pi_constants.go b/ibm/service/power/ibm_pi_constants.go index 4c98c95d67..f130403ace 100644 --- a/ibm/service/power/ibm_pi_constants.go +++ b/ibm/service/power/ibm_pi_constants.go @@ -469,6 +469,7 @@ const ( Attr_ServerName = "server_name" Attr_Servers = "servers" Attr_Shareable = "shreable" + Attr_Shared = "shared" Attr_SharedCoreRatio = "shared_core_ratio" Attr_SharedProcessorPool = "shared_processor_pool" Attr_SharedProcessorPoolID = "shared_processor_pool_id" diff --git a/website/docs/d/pi_catalog_images.html.markdown b/website/docs/d/pi_catalog_images.html.markdown index fa172c0c4b..60ba53a601 100644 --- a/website/docs/d/pi_catalog_images.html.markdown +++ b/website/docs/d/pi_catalog_images.html.markdown @@ -57,7 +57,7 @@ In addition to the argument reference list, you can access the following attribu - `crn` - (String) The CRN of this resource. - `description` - (String) The description of an image. - `disk_format` - (String) The disk format. - - `endianness` - (String) The `Endianness` order. + - `endianness` - (String) The endianness order. - `href` - (String) The `href` of an image. - `hypervisor_type` - (String) Hypervisor type. - `image_id` - (String) The unique identifier of an image. @@ -65,6 +65,7 @@ In addition to the argument reference list, you can access the following attribu - `last_update_date` - (String) The last updated date of an image. - `name` - (String) The name of the image. - `operating_system` - (String) Operating System. + - `shared` - (String) Indicates whether the image is shared. - `state` - (String) The state of an Operating System. - `storage_pool` - (String) Storage pool where image resides. - `storage_type` - (String) The storage type of an image. diff --git a/website/docs/d/pi_image.html.markdown b/website/docs/d/pi_image.html.markdown index be2bf3c90d..a9051aeec0 100644 --- a/website/docs/d/pi_image.html.markdown +++ b/website/docs/d/pi_image.html.markdown @@ -14,8 +14,8 @@ Import the details of an existing IBM Power Virtual Server Cloud image as a read ```terraform data "ibm_pi_image" "ds_image" { - pi_image_name = "7200-03-03" pi_cloud_instance_id = "49fba6c9-23f8-40bc-9899-aca322ee7d5b" + pi_image_id = "7f8e2a9d-3b4c-4e4f-8e8d-f7e7e1e23456" } ``` @@ -40,21 +40,34 @@ Example usage: Review the argument references that you can specify for your data source. - `pi_cloud_instance_id` - (Required, String) The GUID of the service instance associated with an account. -- `pi_image_name` - (Required, String) The ID of the image. To find supported images, run the `ibmcloud pi images` command. +- `pi_image_id` - (Optional, String) The ID of the image. To find supported images, run the `ibmcloud pi images` command. +- `pi_image_name` - (Deprecated, Optional, String) The id of the image. Passing the name of the image could fail or fetch stale data. Please pass an id and use `pi_image_id` instead. ## Attribute Reference In addition to all argument reference list, you can access the following attribute references after your data source is created. - `architecture` - (String) The CPU architecture that the image is designed for. +- `container_format` - (String) The container format. - `crn` - (String) The CRN of this resource. +- `disk_format` - (String) The disk format. +- `endianness` - (String) The endianness order. - `hypervisor` - (String) Hypervisor type. - `id` - (String) The unique identifier of the image. - `image_type` - (String) The identifier of this image type. +- `name`- (String) The name of an image. - `operating_system` - (String) The operating system that is installed with the image. +- `shared` - (String) Indicates whether the image is shared. - `size` - (String) The size of the image in megabytes. - `source_checksum` - (String) Checksum of the image. - `state` - (String) The state for this image. - `storage_pool` - (String) Storage pool where image resides. - `storage_type` - (String) The storage type for this image. - `user_tags` - (List) List of user tags attached to the resource. +- `volumes` - (List) List of image volumes. + + The `volumes` block supports: + - `bootable` - (Bool) Indicates if the volume is boot capable. + - `name` - (String) The volume name of the image. + - `size` - (Float) The volume size of the image. + - `volume_id` - (String) The volume size of the image. diff --git a/website/docs/d/pi_images.html.markdown b/website/docs/d/pi_images.html.markdown index 14149f651b..b07a7dd007 100644 --- a/website/docs/d/pi_images.html.markdown +++ b/website/docs/d/pi_images.html.markdown @@ -49,11 +49,18 @@ In addition to all argument reference list, you can access the following attribu - `image_info` - (List) List of all supported images. Nested scheme for `image_info`: + - `architecture` - (String) The CPU architecture that the image is designed for. + - `container_format` - (String) The container format. - `crn` - (String) The CRN of this resource. + - `disk_format` - (String) The disk format. + - `endianness` - (String) The endianness order. - `href` - (String) The hyper link of an image. + - `hypervisor` - (String) Hypervisor type. - `id` - (String) The unique identifier of an image. - `image_type` - (String) The identifier of this image type. - `name`- (String) The name of an image. + - `operating_system` - (String) The operating system that is installed with the image. + - `shared` - (String) Indicates whether the image is shared. - `source_checksum` - (String) Checksum of the image. - `state` - (String) The state of an image. - `storage_pool` - (String) Storage pool where image resides.