Skip to content
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

[Datasource][Resource] Add dedicated host id to instance #194

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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 @@ -7,7 +7,7 @@ toolchain go1.23.4
require (
github.com/IBM-Cloud/bluemix-go v0.0.0-20241117121028-a3be206688b3
github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20240725064144-454a2ae23113
github.com/IBM-Cloud/power-go-client v1.9.0
github.com/IBM-Cloud/power-go-client v1.10.0-beta7
github.com/IBM/apigateway-go-sdk v0.0.0-20210714141226-a5d5d49caaca
github.com/IBM/appconfiguration-go-admin-sdk v0.4.4
github.com/IBM/appid-management-go-sdk v0.0.0-20210908164609-dd0e0eaf732f
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ github.com/IBM-Cloud/bluemix-go v0.0.0-20241117121028-a3be206688b3/go.mod h1:/7h
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/ibm-cloud-cli-sdk v0.5.3/go.mod h1:RiUvKuHKTBmBApDMUQzBL14pQUGKcx/IioKQPIcRQjs=
github.com/IBM-Cloud/power-go-client v1.9.0 h1:nnErpb/7TJQe8P7OfIlJPhSJVq5oyuCJlMje9Ry6XEY=
github.com/IBM-Cloud/power-go-client v1.9.0/go.mod h1:UDyXeIKEp6r7yWUXYu3r0ZnFSlNZ2YeQTHwM2Tmlgv0=
github.com/IBM-Cloud/power-go-client v1.10.0-beta7 h1:nxAuY/0axYwOq2jb2jVZqu3nmPP/7/sFC6HCi8RhMUA=
github.com/IBM-Cloud/power-go-client v1.10.0-beta7/go.mod h1:UDyXeIKEp6r7yWUXYu3r0ZnFSlNZ2YeQTHwM2Tmlgv0=
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/apigateway-go-sdk v0.0.0-20210714141226-a5d5d49caaca h1:crniVcf+YcmgF03NmmfonXwSQ73oJF+IohFYBwknMxs=
Expand Down
6 changes: 6 additions & 0 deletions ibm/service/power/data_source_ibm_pi_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ func DataSourceIBMPIInstance() *schema.Resource {
Description: "The CRN of this resource.",
Type: schema.TypeString,
},
Attr_DedicatedHostID: {
Computed: true,
Description: "The dedicated host ID where the shared processor pool resides.",
Type: schema.TypeString,
},
Attr_DeploymentType: {
Computed: true,
Description: "The custom deployment type.",
Expand Down Expand Up @@ -285,6 +290,7 @@ func dataSourceIBMPIInstancesRead(ctx context.Context, d *schema.ResourceData, m
}
d.Set(Attr_UserTags, tags)
}
d.Set(Attr_DedicatedHostID, powervmdata.DedicatedHostID)
d.Set(Attr_DeploymentType, powervmdata.DeploymentType)
d.Set(Attr_LicenseRepositoryCapacity, powervmdata.LicenseRepositoryCapacity)
d.Set(Attr_MaxMem, powervmdata.Maxmem)
Expand Down
6 changes: 6 additions & 0 deletions ibm/service/power/data_source_ibm_pi_instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ func DataSourceIBMPIInstances() *schema.Resource {
Description: "The CRN of this resource.",
Type: schema.TypeString,
},
Attr_DedicatedHostID: {
Computed: true,
Description: "The dedicated host ID where the shared processor pool resides.",
Type: schema.TypeString,
},
Attr_Fault: {
Computed: true,
Description: "Fault information.",
Expand Down Expand Up @@ -267,6 +272,7 @@ func flattenPvmInstances(list []*models.PVMInstanceReference, meta interface{})
result := make([]map[string]interface{}, 0, len(list))
for _, i := range list {
l := map[string]interface{}{
Attr_DedicatedHostID: i.DedicatedHostID,
Attr_LicenseRepositoryCapacity: i.LicenseRepositoryCapacity,
Attr_MaxMem: i.Maxmem,
Attr_MaxProc: i.Maxproc,
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 @@ -216,6 +216,7 @@ const (
Attr_DatacenterStatus = "pi_datacenter_status"
Attr_DatacenterType = "pi_datacenter_type"
Attr_Dedicated = "dedicated"
Attr_DedicatedHostID = "dedicated_host_id"
Attr_Default = "default"
Attr_DeleteOnTermination = "delete_on_termination"
Attr_DeploymentType = "deployment_type"
Expand Down
43 changes: 24 additions & 19 deletions ibm/service/power/resource_ibm_pi_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,16 @@ func ResourceIBMPIInstance() *schema.Resource {
Description: "The CRN of this resource.",
Type: schema.TypeString,
},
Attr_DedicatedHostID: {
Computed: true,
Description: "The dedicated host ID where the shared processor pool resides.",
Type: schema.TypeString,
},
Attr_Fault: {
Computed: true,
Description: "Fault information.",
Type: schema.TypeMap,
},
Attr_HealthStatus: {
Computed: true,
Description: "PI Instance health status",
Expand Down Expand Up @@ -460,11 +470,6 @@ func ResourceIBMPIInstance() *schema.Resource {
Description: "PI instance status",
Type: schema.TypeString,
},
Attr_Fault: {
Computed: true,
Description: "Fault information.",
Type: schema.TypeMap,
},
},
}
}
Expand Down Expand Up @@ -598,18 +603,15 @@ func resourceIBMPIInstanceRead(ctx context.Context, d *schema.ResourceData, meta
if powervmdata.Status != nil {
d.Set(Attr_Status, powervmdata.Status)
}
d.Set(Arg_CloudInstanceID, cloudInstanceID)
d.Set(Arg_ImageID, powervmdata.ImageID)
d.Set(Arg_InstanceName, powervmdata.ServerName)
d.Set(Arg_ProcType, powervmdata.ProcType)
d.Set(Attr_MinProcessors, powervmdata.Minproc)
d.Set(Attr_Progress, powervmdata.Progress)
if powervmdata.StorageType != nil && *powervmdata.StorageType != "" {
d.Set(Arg_StorageType, powervmdata.StorageType)
}
d.Set(Arg_StoragePool, powervmdata.StoragePool)
d.Set(Arg_StoragePoolAffinity, powervmdata.StoragePoolAffinity)
d.Set(Arg_CloudInstanceID, cloudInstanceID)
d.Set(Attr_InstanceID, powervmdata.PvmInstanceID)
d.Set(Arg_InstanceName, powervmdata.ServerName)
d.Set(Arg_ImageID, powervmdata.ImageID)
d.Set(Attr_MinProcessors, powervmdata.Minproc)
d.Set(Attr_Progress, powervmdata.Progress)
if *powervmdata.PlacementGroup != None {
d.Set(Arg_PlacementGroupID, powervmdata.PlacementGroup)
}
Expand Down Expand Up @@ -638,6 +640,7 @@ func resourceIBMPIInstanceRead(ctx context.Context, d *schema.ResourceData, meta
d.Set(Arg_SAPProfileID, powervmdata.SapProfile.ProfileID)
}
d.Set(Arg_SysType, powervmdata.SysType)
d.Set(Attr_DedicatedHostID, powervmdata.DedicatedHostID)
d.Set(Attr_MinMemory, powervmdata.Minmem)
d.Set(Attr_MaxProcessors, powervmdata.Maxproc)
d.Set(Attr_MaxMemory, powervmdata.Maxmem)
Expand All @@ -653,8 +656,8 @@ func resourceIBMPIInstanceRead(ctx context.Context, d *schema.ResourceData, meta
d.Set(Attr_MaxVirtualCores, powervmdata.VirtualCores.Max)
d.Set(Attr_MinVirtualCores, powervmdata.VirtualCores.Min)
}
d.Set(Arg_LicenseRepositoryCapacity, powervmdata.LicenseRepositoryCapacity)
d.Set(Arg_DeploymentType, powervmdata.DeploymentType)
d.Set(Arg_LicenseRepositoryCapacity, powervmdata.LicenseRepositoryCapacity)
if powervmdata.SoftwareLicenses != nil {
d.Set(Arg_IBMiCSS, powervmdata.SoftwareLicenses.IbmiCSS)
d.Set(Arg_IBMiPHA, powervmdata.SoftwareLicenses.IbmiPHA)
Expand All @@ -681,7 +684,6 @@ func resourceIBMPIInstanceRead(ctx context.Context, d *schema.ResourceData, meta
}

func resourceIBMPIInstanceUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {

name := d.Get(Arg_InstanceName).(string)
mem := d.Get(Arg_Memory).(float64)
procs := d.Get(Arg_Processors).(float64)
Expand Down Expand Up @@ -1531,7 +1533,6 @@ func checkCloudInstanceCapability(cloudInstance *models.CloudInstance, custom_ca
}

func createSAPInstance(d *schema.ResourceData, sapClient *instance.IBMPISAPInstanceClient) (*models.PVMInstanceList, error) {

name := d.Get(Arg_InstanceName).(string)
profileID := d.Get(Arg_SAPProfileID).(string)
imageid := d.Get(Arg_ImageID).(string)
Expand Down Expand Up @@ -1727,7 +1728,7 @@ func createPVMInstance(d *schema.ResourceData, client *instance.IBMPIInstanceCli
SysType: systype,
ImageID: flex.PtrToString(imageid),
ProcType: flex.PtrToString(processortype),
Replicants: replicants,
Replicants: &replicants,
UserData: encodeBase64(userData),
ReplicantNamingScheme: flex.PtrToString(replicationNamingScheme),
ReplicantAffinityPolicy: flex.PtrToString(replicationpolicy),
Expand Down Expand Up @@ -1864,7 +1865,7 @@ func createPVMInstance(d *schema.ResourceData, client *instance.IBMPIInstanceCli
}
if vsn, ok := d.GetOk(Arg_VirtualSerialNumber); ok {
vsnListType := vsn.([]interface{})
vsnCreateModel := vsnSetToCreateModel(vsnListType, d)
vsnCreateModel := vsnSetToCreateModel(vsnListType)
body.VirtualSerialNumber = vsnCreateModel
}

Expand All @@ -1879,6 +1880,7 @@ func createPVMInstance(d *schema.ResourceData, client *instance.IBMPIInstanceCli

return pvmList, nil
}

func expandDeploymentTarget(dt []interface{}) *models.DeploymentTarget {
dtexpanded := &models.DeploymentTarget{}
for _, v := range dt {
Expand All @@ -1888,6 +1890,7 @@ func expandDeploymentTarget(dt []interface{}) *models.DeploymentTarget {
}
return dtexpanded
}

func splitID(id string) (id1, id2 string, err error) {
parts, err := flex.IdParts(id)
if err != nil {
Expand All @@ -1897,7 +1900,8 @@ func splitID(id string) (id1, id2 string, err error) {
id2 = parts[1]
return
}
func vsnSetToCreateModel(vsnSetList []interface{}, d *schema.ResourceData) *models.CreateServerVirtualSerialNumber {

func vsnSetToCreateModel(vsnSetList []interface{}) *models.CreateServerVirtualSerialNumber {
vsnItemMap := vsnSetList[0].(map[string]interface{})
serialString := vsnItemMap[Attr_Serial].(string)
model := &models.CreateServerVirtualSerialNumber{
Expand All @@ -1910,6 +1914,7 @@ func vsnSetToCreateModel(vsnSetList []interface{}, d *schema.ResourceData) *mode

return model
}

func flattenVirtualSerialNumberToList(vsn *models.GetServerVirtualSerialNumber) []map[string]interface{} {
v := make([]map[string]interface{}, 1)
v[0] = map[string]interface{}{
Expand Down
Loading
Loading