Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
18 changes: 17 additions & 1 deletion ibm/service/power/data_source_ibm_pi_catalog_images.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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.",
Expand Down Expand Up @@ -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
Expand Down
104 changes: 97 additions & 7 deletions ibm/service/power/data_source_ibm_pi_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,50 @@ 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: {
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_Hypervisor: {
Computed: true,
Description: "Hypervision Type.",
Expand All @@ -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.",
Expand Down Expand Up @@ -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,
},
},
}
}
Expand All @@ -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())
Expand All @@ -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)
Expand All @@ -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
}
6 changes: 3 additions & 3 deletions ibm/service/power/data_source_ibm_pi_image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
58 changes: 50 additions & 8 deletions ibm/service/power/data_source_ibm_pi_images.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand All @@ -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.",
Expand Down Expand Up @@ -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
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 @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion website/docs/d/pi_catalog_images.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,15 @@ 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.
- `image_type` - (String) The identifier of this image type.
- `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.
Loading
Loading