From a1c8988db6ee5c1533d0a3c928c8871645d74cf1 Mon Sep 17 00:00:00 2001 From: michaelkad Date: Mon, 6 Nov 2023 11:29:14 -0600 Subject: [PATCH 01/25] Initial ibmi --- .../power/data_source_ibm_pi_instance.go | 40 +++++++++++++++++++ ibm/service/power/resource_ibm_pi_instance.go | 40 +++++++++++++++++++ website/docs/d/pi_instance.html.markdown | 6 +++ 3 files changed, 86 insertions(+) diff --git a/ibm/service/power/data_source_ibm_pi_instance.go b/ibm/service/power/data_source_ibm_pi_instance.go index 354cfe951b..8f0e5c469d 100644 --- a/ibm/service/power/data_source_ibm_pi_instance.go +++ b/ibm/service/power/data_source_ibm_pi_instance.go @@ -195,6 +195,37 @@ func DataSourceIBMPIInstance() *schema.Resource { Type: schema.TypeString, Computed: true, }, + + "ibmi_css": { + Type: schema.TypeBool, + Optional: true, + Computed: true, + Description: "IBMi Cloud Storage Solution", + }, + "ibmi_dbq": { + Type: schema.TypeBool, + Optional: true, + Computed: true, + Description: "IBMi DBQ", + }, + "ibmi_pha": { + Type: schema.TypeBool, + Optional: true, + Computed: true, + Description: "IBMi Power High Availability", + }, + "ibmi_rds": { + Type: schema.TypeBool, + Optional: true, + Computed: true, + Description: "IBMi Rational Dev Studio", + }, + "ibmi_rds_users": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "IBMi Rational Dev Studio Number of User Licenses", + }, }, } } @@ -262,5 +293,14 @@ func dataSourceIBMPIInstancesRead(ctx context.Context, d *schema.ResourceData, m d.Set("health_status", powervmdata.Health.Status) } + if powervmdata.SoftwareLicenses != nil { + + d.Set("ibmi_css", powervmdata.SoftwareLicenses.IbmiCSS) + d.Set("ibmi_dbq", powervmdata.SoftwareLicenses.IbmiDBQ) + d.Set("ibmi_pha", powervmdata.SoftwareLicenses.IbmiPHA) + d.Set("ibmi_rds", powervmdata.SoftwareLicenses.IbmiRDS) + d.Set("ibmi_rds_users", powervmdata.SoftwareLicenses.IbmiRDSUsers) + } + return nil } diff --git a/ibm/service/power/resource_ibm_pi_instance.go b/ibm/service/power/resource_ibm_pi_instance.go index 37236ed8ae..23669a2f01 100644 --- a/ibm/service/power/resource_ibm_pi_instance.go +++ b/ibm/service/power/resource_ibm_pi_instance.go @@ -352,6 +352,46 @@ func ResourceIBMPIInstance() *schema.Resource { Computed: true, Description: "Minimum Virtual Cores Assigned to the PVMInstance", }, + "pi_software_licenses": { + Type: schema.TypeList, + Computed: true, + Optional: true, + Description: "List of software licenses", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "ibmiCSS": { + Type: schema.TypeBool, + Optional: true, + Computed: true, + Description: "IBMi Cloud Storage Solution", + }, + "ibmiDBQ": { + Type: schema.TypeBool, + Optional: true, + Computed: true, + Description: "IBMi DBQ", + }, + "ibmiPHA": { + Type: schema.TypeBool, + Optional: true, + Computed: true, + Description: "IBMi Power High Availability", + }, + "ibmiRDS": { + Type: schema.TypeBool, + Optional: true, + Computed: true, + Description: "IBMi Rational Dev Studio", + }, + "ibmiRDSUsers": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "IBMi Rational Dev Studio Number of User Licenses", + }, + }, + }, + }, }, } } diff --git a/website/docs/d/pi_instance.html.markdown b/website/docs/d/pi_instance.html.markdown index 75fecd8d53..53df9d02d3 100644 --- a/website/docs/d/pi_instance.html.markdown +++ b/website/docs/d/pi_instance.html.markdown @@ -84,3 +84,9 @@ In addition to all argument reference list, you can access the following attribu - `storage_type` - (String) The storage type where server is deployed. - `virtual_cores_assigned` - (Integer) The virtual cores that are assigned to the instance. - `volumes` - (List of strings) The list of volume IDs that are attached to the instance. +Ibmi software licenses for IBMi virtual server instances +- `ibm_css` - (String) IBMi Cloud Storage Solution. +- `ibmi_dbq` - (String) IBMi DBQ. +- `ibmi_pha` - (String) IBMi Power High Availability. +- `ibmi_rds` - (String) IBMi Rational Dev Studio. +- `ibmi_rds_users` - (Integer) IBMi Rational Dev Studio Number of User Licenses. From 96e6e56b8fe0e6d77000841a2cab51003372fdd7 Mon Sep 17 00:00:00 2001 From: michaelkad Date: Thu, 16 Nov 2023 22:52:32 -0500 Subject: [PATCH 02/25] ibmi initial, and sync with master --- go.mod | 6 + go.sum | 12 + ibm/service/power/ibm_pi_constants.go | 5 + ibm/service/power/resource_ibm_pi_instance.go | 208 +++++++++++++----- website/docs/d/pi_instance.html.markdown | 11 +- website/docs/r/pi_instance.html.markdown | 11 + 6 files changed, 198 insertions(+), 55 deletions(-) diff --git a/go.mod b/go.mod index 55a52d0104..7f79dae451 100644 --- a/go.mod +++ b/go.mod @@ -71,6 +71,7 @@ require ( require ( cloud.google.com/go/kms v1.10.1 // indirect cloud.google.com/go/monitoring v1.13.0 // indirect + github.com/Bowery/prompt v0.0.0-20190916142128-fa8279994f75 // indirect github.com/Logicalis/asn1 v0.0.0-20190312173541-d60463189a56 // indirect github.com/PromonLogicalis/asn1 v0.0.0-20190312173541-d60463189a56 // indirect github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect @@ -89,6 +90,7 @@ require ( github.com/coreos/pkg v0.0.0-20220810130054-c7d1c02cb6cf // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/dchest/bcrypt_pbkdf v0.0.0-20150205184540-83f37f9c154a // indirect + github.com/dchest/safefile v0.0.0-20151022103144-855e8d98f185 // indirect github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect github.com/eapache/go-resiliency v1.4.0 // indirect github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 // indirect @@ -121,6 +123,7 @@ require ( github.com/google/gnostic v0.6.9 // indirect github.com/google/go-querystring v1.1.0 // indirect github.com/google/gofuzz v1.2.0 // indirect + github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-checkpoint v0.5.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect @@ -161,6 +164,7 @@ require ( github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect + github.com/kardianos/govendor v1.0.9 // indirect github.com/klauspost/compress v1.16.7 // indirect github.com/kube-object-storage/lib-bucket-provisioner v0.0.0-20221122204822-d1a8c34382f1 // indirect github.com/leodido/go-urn v1.2.4 // indirect @@ -172,6 +176,8 @@ require ( github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/go-wordwrap v1.0.0 // indirect + github.com/mitchellh/gox v1.0.1 // indirect + github.com/mitchellh/iochan v1.0.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/moby/spdystream v0.2.0 // indirect diff --git a/go.sum b/go.sum index b1db6b42b2..f9865299d1 100644 --- a/go.sum +++ b/go.sum @@ -94,6 +94,8 @@ github.com/Azure/go-autorest/logger v0.2.1/go.mod h1:T9E3cAhj2VqvPOtCYAvby9aBXkZ github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk= github.com/Azure/go-autorest/tracing v0.6.0 h1:TYi4+3m5t6K48TGI9AUdb+IzbnSxvnvUMfuitfgcfuo= github.com/Azure/go-autorest/tracing v0.6.0/go.mod h1:+vhtPC754Xsa23ID7GlGsrdKBpUA79WCAKPPZVC2DeU= +github.com/Bowery/prompt v0.0.0-20190916142128-fa8279994f75 h1:xGHheKK44eC6K0u5X+DZW/fRaR1LnDdqPHMZMWx5fv8= +github.com/Bowery/prompt v0.0.0-20190916142128-fa8279994f75/go.mod h1:4/6eNcqZ09BZ9wLK3tZOjBA1nDj+B0728nlX5YRlSmQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= @@ -360,6 +362,8 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1 github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dchest/bcrypt_pbkdf v0.0.0-20150205184540-83f37f9c154a h1:saTgr5tMLFnmy/yg3qDTft4rE5DY2uJ/cCxCe3q0XTU= github.com/dchest/bcrypt_pbkdf v0.0.0-20150205184540-83f37f9c154a/go.mod h1:Bw9BbhOJVNR+t0jCqx2GC6zv0TGBsShs56Y3gfSCvl0= +github.com/dchest/safefile v0.0.0-20151022103144-855e8d98f185 h1:3T8ZyTDp5QxTx3NU48JVb2u+75xc040fofcBaN+6jPA= +github.com/dchest/safefile v0.0.0-20151022103144-855e8d98f185/go.mod h1:cFRxtTwTOJkz2x3rQUNCYKWC93yP1VKjR8NUhqFxZNU= github.com/denisenkom/go-mssqldb v0.0.0-20190412130859-3b1d194e553a/go.mod h1:zAg7JM8CkOJ43xKXIj7eRO9kmWm/TW578qo+oDO6tuM= github.com/denverdino/aliyungo v0.0.0-20190125010748-a747050bb1ba h1:p6poVbjHDkKa+wtC8frBMwQtT3BmqGYBjzMwJ63tuR4= github.com/dgryski/go-metro v0.0.0-20180109044635-280f6062b5bc h1:8WFBn63wegobsYAX0YjD+8suexZDga5CctH4CCTx2+8= @@ -724,6 +728,8 @@ github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLe github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20230510103437-eeec1cb781c3 h1:2XF1Vzq06X+inNqgJ9tRnGuw+ZVCB3FazXODD6JE1R8= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= +github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -874,6 +880,7 @@ github.com/hashicorp/go-uuid v1.0.2-0.20191001231223-f32f5fe8d6a8/go.mod h1:6SBZ github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-version v1.0.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= @@ -1054,6 +1061,8 @@ github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVY github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= +github.com/kardianos/govendor v1.0.9 h1:WOH3FcVI9eOgnIZYg96iwUwrL4eOVx+aQ66oyX2R8Yc= +github.com/kardianos/govendor v1.0.9/go.mod h1:yvmR6q9ZZ7nSF5Wvh40v0wfP+3TwwL8zYQp+itoZSVM= github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4= github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA= github.com/kelseyhightower/envconfig v1.3.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg= @@ -1164,7 +1173,10 @@ github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4= github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= +github.com/mitchellh/gox v1.0.1 h1:x0jD3dcHk9a9xPSDN6YEL4xL6Qz0dvNYm8yZqui5chI= +github.com/mitchellh/gox v1.0.1/go.mod h1:ED6BioOGXMswlXa2zxfh/xdd5QhwYliBFn9V18Ap4z4= github.com/mitchellh/hashstructure v1.0.0/go.mod h1:QjSHrPWS+BGUVBYkbTZWEnOh3G1DutKwClXU/ABz6AQ= +github.com/mitchellh/iochan v1.0.0 h1:C+X3KsSTLFVBr/tK1eYN/vs4rJcvsiLU338UhYPJWeY= github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= diff --git a/ibm/service/power/ibm_pi_constants.go b/ibm/service/power/ibm_pi_constants.go index 8e66a4bd83..c83faa09c4 100644 --- a/ibm/service/power/ibm_pi_constants.go +++ b/ibm/service/power/ibm_pi_constants.go @@ -46,6 +46,11 @@ const ( Arg_PVMInstanceId = "pi_instance_id" Arg_PVMInstanceActionType = "pi_action" Arg_PVMInstanceHealthStatus = "pi_health_status" + PIInstanceSoftwareLicenses = "pi_software_licenses" + PIInstanceIbmiCSS = "pi_ibmi_css" + PIInstanceIbmiPHA = "pi_ibmi_pha" + PIInstanceIbmiRDS = "pi_ibmi_rds" + PIInstanceIbmiRDSUsers = "pi_ibmi_rds_users" Attr_Status = "status" Attr_Progress = "progress" diff --git a/ibm/service/power/resource_ibm_pi_instance.go b/ibm/service/power/resource_ibm_pi_instance.go index 23669a2f01..c15c6203d8 100644 --- a/ibm/service/power/resource_ibm_pi_instance.go +++ b/ibm/service/power/resource_ibm_pi_instance.go @@ -182,7 +182,7 @@ func ResourceIBMPIInstance() *schema.Resource { Computed: true, }, "external_ip": { - Type: schema.TypeString, + Type: schema.TypeInt, Computed: true, }, }, @@ -352,46 +352,71 @@ func ResourceIBMPIInstance() *schema.Resource { Computed: true, Description: "Minimum Virtual Cores Assigned to the PVMInstance", }, - "pi_software_licenses": { - Type: schema.TypeList, - Computed: true, - Optional: true, - Description: "List of software licenses", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "ibmiCSS": { - Type: schema.TypeBool, - Optional: true, - Computed: true, - Description: "IBMi Cloud Storage Solution", - }, - "ibmiDBQ": { - Type: schema.TypeBool, - Optional: true, - Computed: true, - Description: "IBMi DBQ", - }, - "ibmiPHA": { - Type: schema.TypeBool, - Optional: true, - Computed: true, - Description: "IBMi Power High Availability", - }, - "ibmiRDS": { - Type: schema.TypeBool, - Optional: true, - Computed: true, - Description: "IBMi Rational Dev Studio", - }, - "ibmiRDSUsers": { - Type: schema.TypeInt, - Optional: true, - Computed: true, - Description: "IBMi Rational Dev Studio Number of User Licenses", - }, - }, - }, + PIInstanceIbmiCSS: { + Type: schema.TypeBool, + Optional: true, + // Computed: true, + Description: "IBMi Cloud Storage Solution", + }, + + PIInstanceIbmiPHA: { + Type: schema.TypeBool, + Optional: true, + // Computed: true, + Description: "IBMi Power High Availability", }, + PIInstanceIbmiRDS: { + Type: schema.TypeBool, + Optional: true, + // Computed: true, + Description: "IBMi Rational Dev Studio", + }, + PIInstanceIbmiRDSUsers: { + Type: schema.TypeInt, + Optional: true, + // Computed: true, + Description: "IBMi Rational Dev Studio Number of User Licenses", + }, + // "pi_software_licenses": { + // Type: schema.TypeList, + // Computed: true, + // Optional: true, + // Description: "List of software licenses", + // Elem: &schema.Resource{ + // Schema: map[string]*schema.Schema{ + // "ibmiCSS": { + // Type: schema.TypeBool, + // Optional: true, + // Computed: true, + // Description: "IBMi Cloud Storage Solution", + // }, + // "ibmiDBQ": { + // Type: schema.TypeBool, + // Optional: true, + // Computed: true, + // Description: "IBMi DBQ", + // }, + // "ibmiPHA": { + // Type: schema.TypeBool, + // Optional: true, + // Computed: true, + // Description: "IBMi Power High Availability", + // }, + // "ibmiRDS": { + // Type: schema.TypeBool, + // Optional: true, + // Computed: true, + // Description: "IBMi Rational Dev Studio", + // }, + // "ibmiRDSUsers": { + // Type: schema.TypeInt, + // Optional: true, + // Computed: true, + // Description: "IBMi Rational Dev Studio Number of User Licenses", + // }, + // }, + // }, + // }, }, } } @@ -536,6 +561,12 @@ func resourceIBMPIInstanceRead(ctx context.Context, d *schema.ResourceData, meta } d.Set(helpers.PIInstanceLicenseRepositoryCapacity, powervmdata.LicenseRepositoryCapacity) d.Set(PIInstanceDeploymentType, powervmdata.DeploymentType) + if powervmdata.SoftwareLicenses != nil { + d.Set(PIInstanceIbmiCSS, powervmdata.SoftwareLicenses.IbmiCSS) + d.Set(PIInstanceIbmiPHA, powervmdata.SoftwareLicenses.IbmiPHA) + d.Set(PIInstanceIbmiRDS, powervmdata.SoftwareLicenses.IbmiRDS) + d.Set(PIInstanceIbmiRDSUsers, powervmdata.SoftwareLicenses.IbmiRDSUsers) + } return nil } @@ -794,6 +825,51 @@ func resourceIBMPIInstanceUpdate(ctx context.Context, d *schema.ResourceData, me } } } + if d.HasChanges(PIInstanceIbmiCSS, PIInstanceIbmiPHA, PIInstanceIbmiRDS, PIInstanceIbmiRDSUsers) { + if d.Get("status") != "ACTIVE" { + return diag.Errorf("software licenses change requires the lpar to be in an active state") + } + var license bool + sl := &models.SoftwareLicenses{} + if d.HasChange(PIInstanceIbmiCSS) { + if ibmiCSS, ok := d.GetOk(PIInstanceIbmiCSS); ok { + license = ibmiCSS.(bool) + sl.IbmiCSS = &license + } + } + if d.HasChange(PIInstanceIbmiPHA) { + if ibmiPHA, ok := d.GetOk(PIInstanceIbmiPHA); ok { + license = ibmiPHA.(bool) + sl.IbmiPHA = &license + } + } + if d.HasChange(PIInstanceIbmiRDS) { + if ibmRDS, ok := d.GetOk(PIInstanceIbmiRDS); ok { + if ibmRDS == true { + if ibmrdsUsers, ok := d.GetOk(PIInstanceIbmiRDSUsers); ok { + if ibmrdsUsers.(int) < 1 { + return diag.Errorf("request with IBMi Rational Dev Studio property requires IBMi Rational Dev Studio number of users") + } + license = ibmRDS.(bool) + sl.IbmiRDS = &license + sl.IbmiRDSUsers = ibmrdsUsers.(int64) + } + } + } + } + updatebody := &models.PVMInstanceUpdate{SoftwareLicenses: sl} + _, err = client.Update(instanceID, updatebody) + if err != nil { + return diag.FromErr(err) + } + _, err = isWaitForPIInstanceAvailable(ctx, client, instanceID, "OK") + if err != nil { + return diag.FromErr(err) + } + + log.Printf("software license %s", PIInstanceIbmiCSS) + return diag.Errorf("software licenses change requires the lpar to be in an active state") + } return resourceIBMPIInstanceRead(ctx, d, meta) @@ -1325,18 +1401,15 @@ func createPVMInstance(d *schema.ResourceData, client *st.IBMPIInstanceClient, i if spp, ok := d.GetOk(Arg_PIInstanceSharedProcessorPool); ok { body.SharedProcessorPool = spp.(string) } - - if lrc, ok := d.GetOk(helpers.PIInstanceLicenseRepositoryCapacity); ok { - // check if using vtl image - // check if vtl image is stock image - imageData, err := imageClient.GetStockImage(imageid) + imageData, err := imageClient.GetStockImage(imageid) + if err != nil { + // check if vtl image is cloud instance image + imageData, err = imageClient.Get(imageid) if err != nil { - // check if vtl image is cloud instance image - imageData, err = imageClient.Get(imageid) - if err != nil { - return nil, fmt.Errorf("image doesn't exist. %e", err) - } + return nil, fmt.Errorf("image doesn't exist. %e", err) } + } + if lrc, ok := d.GetOk(helpers.PIInstanceLicenseRepositoryCapacity); ok { if imageData.Specifications.ImageType == "stock-vtl" { body.LicenseRepositoryCapacity = int64(lrc.(int)) @@ -1345,6 +1418,41 @@ func createPVMInstance(d *schema.ResourceData, client *st.IBMPIInstanceClient, i } } + if imageData.Specifications.OperatingSystem == "ibmi" { + // Default value + falseBool := false + var license bool + sl := &models.SoftwareLicenses{ + IbmiCSS: &falseBool, + IbmiPHA: &falseBool, + IbmiRDS: &falseBool, + IbmiRDSUsers: 0, + } + if ibmiCSS, ok := d.GetOk(PIInstanceIbmiCSS); ok { + license = ibmiCSS.(bool) + sl.IbmiCSS = &license + } + if ibmiPHA, ok := d.GetOk(PIInstanceIbmiPHA); ok { + license = ibmiPHA.(bool) + sl.IbmiPHA = &license + } + + if ibmRDS, ok := d.GetOk(PIInstanceIbmiRDS); ok { + if ibmRDS == true { + if ibmrdsUsers, ok := d.GetOk(PIInstanceIbmiRDSUsers); ok { + if ibmrdsUsers.(int) < 1 { + return nil, fmt.Errorf("request with IBMi Rational Dev Studio property requires IBMi Rational Dev Studio number of users") + } + license = ibmRDS.(bool) + sl.IbmiRDS = &license + sl.IbmiRDSUsers = ibmrdsUsers.(int64) + } + } + } + body.SoftwareLicenses = sl + + } + pvmList, err := client.Create(body) if err != nil { diff --git a/website/docs/d/pi_instance.html.markdown b/website/docs/d/pi_instance.html.markdown index 53df9d02d3..e3aa046791 100644 --- a/website/docs/d/pi_instance.html.markdown +++ b/website/docs/d/pi_instance.html.markdown @@ -84,9 +84,10 @@ In addition to all argument reference list, you can access the following attribu - `storage_type` - (String) The storage type where server is deployed. - `virtual_cores_assigned` - (Integer) The virtual cores that are assigned to the instance. - `volumes` - (List of strings) The list of volume IDs that are attached to the instance. -Ibmi software licenses for IBMi virtual server instances -- `ibm_css` - (String) IBMi Cloud Storage Solution. -- `ibmi_dbq` - (String) IBMi DBQ. -- `ibmi_pha` - (String) IBMi Power High Availability. -- `ibmi_rds` - (String) IBMi Rational Dev Studio. + + **Notes** Ibmi software licenses for IBMi virtual server instances --software licenses currently only supports IBMi instances +- `ibm_css` - (Bool) IBMi Cloud Storage Solution. +- `ibmi_dbq` - (Bool) IBMi DBQ. +- `ibmi_pha` - (Bool) IBMi Power High Availability. +- `ibmi_rds` - (Bool) IBMi Rational Dev Studio. - `ibmi_rds_users` - (Integer) IBMi Rational Dev Studio Number of User Licenses. diff --git a/website/docs/r/pi_instance.html.markdown b/website/docs/r/pi_instance.html.markdown index 429320d53d..a0f60d94f7 100644 --- a/website/docs/r/pi_instance.html.markdown +++ b/website/docs/r/pi_instance.html.markdown @@ -66,6 +66,11 @@ Review the argument references that you can specify for your resource. - `pi_cloud_instance_id` - (Required, String) The GUID of the service instance associated with an account. - `pi_deployment_type` - (Optional, String) Custom deployment type; Allowable value: `EPIC`. - `pi_health_status` - (Optional, String) Specifies if Terraform should poll for the health status to be `OK` or `WARNING`. The default value is `OK`. + **Notes** Ibmi software licenses for IBMi virtual server instances --software licenses currently only supports IBMi instances. Default to `false` and `0` if no values provided +- `pi_ibm_css` - (Optional, Bool) IBMi Cloud Storage Solution. +- `pi_ibmi_pha` - (Optional, Bool) IBMi Power High Availability. +- `pi_ibmi_rds` - (Optional, Bool) IBMi Rational Dev Studio. +- `pi_ibmi_rds_users` - (Optional, Integer) IBMi Rational Dev Studio Number of User Licenses. Required if `pi_ibmi_rds` is provided - `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. - **Note**: only images belonging to your project can be used image for deploying a Power Systems Virtual Server instance. To import an images to your project, see [ibm_pi_image](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/pi_image). - `pi_instance_name` - (Required, String) The name of the Power Systems Virtual Server instance. @@ -102,6 +107,7 @@ Review the argument references that you can specify for your resource. - `pi_user_data` - (Optional, String) The user data `cloud-init` to pass to the instance during creation. It can be a base64 encoded or an unencoded string. If it is an unencoded string, the provider will encode it before it passing it down. - `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. @@ -126,6 +132,11 @@ In addition to all argument reference list, you can access the following attribu - `progress` - (Float) - Specifies the overall progress of the instance deployment process in percentage. - `shared_processor_pool_id` - (String) The ID of the shared processor pool for the instance. - `status` - (String) The status of the instance. +- `ibm_css` - (Bool) IBMi Cloud Storage Solution. +- `ibmi_dbq` - (Bool) IBMi DBQ. +- `ibmi_pha` - (Bool) IBMi Power High Availability. +- `ibmi_rds` - (Bool) IBMi Rational Dev Studio. +- `ibmi_rds_users` - (Integer) IBMi Rational Dev Studio Number of User Licenses. ## Import The `ibm_pi_instance` can be imported using `power_instance_id` and `instance_id`. From b8a1e9caee75406ff062baa459476bfb455adb80 Mon Sep 17 00:00:00 2001 From: michael kad Date: Wed, 10 Jan 2024 13:40:16 -0600 Subject: [PATCH 03/25] sync go.mod and go.sum --- go.mod | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 7f79dae451..260e5a7167 100644 --- a/go.mod +++ b/go.mod @@ -71,7 +71,6 @@ require ( require ( cloud.google.com/go/kms v1.10.1 // indirect cloud.google.com/go/monitoring v1.13.0 // indirect - github.com/Bowery/prompt v0.0.0-20190916142128-fa8279994f75 // indirect github.com/Logicalis/asn1 v0.0.0-20190312173541-d60463189a56 // indirect github.com/PromonLogicalis/asn1 v0.0.0-20190312173541-d60463189a56 // indirect github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect @@ -90,7 +89,6 @@ require ( github.com/coreos/pkg v0.0.0-20220810130054-c7d1c02cb6cf // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/dchest/bcrypt_pbkdf v0.0.0-20150205184540-83f37f9c154a // indirect - github.com/dchest/safefile v0.0.0-20151022103144-855e8d98f185 // indirect github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect github.com/eapache/go-resiliency v1.4.0 // indirect github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 // indirect @@ -123,7 +121,6 @@ require ( github.com/google/gnostic v0.6.9 // indirect github.com/google/go-querystring v1.1.0 // indirect github.com/google/gofuzz v1.2.0 // indirect - github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-checkpoint v0.5.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect @@ -164,7 +161,6 @@ require ( github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect - github.com/kardianos/govendor v1.0.9 // indirect github.com/klauspost/compress v1.16.7 // indirect github.com/kube-object-storage/lib-bucket-provisioner v0.0.0-20221122204822-d1a8c34382f1 // indirect github.com/leodido/go-urn v1.2.4 // indirect @@ -176,8 +172,6 @@ require ( github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/go-wordwrap v1.0.0 // indirect - github.com/mitchellh/gox v1.0.1 // indirect - github.com/mitchellh/iochan v1.0.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/moby/spdystream v0.2.0 // indirect @@ -187,6 +181,7 @@ require ( github.com/nicksnyder/go-i18n v1.10.0 // indirect github.com/oklog/run v1.1.0 // indirect github.com/oklog/ulid v1.3.1 // indirect + github.com/onsi/gomega v1.30.0 // indirect github.com/opentracing/opentracing-go v1.2.1-0.20220228012449-10b1cf09e00b // indirect github.com/patrickmn/go-cache v2.1.0+incompatible // indirect github.com/pelletier/go-toml v1.7.0 // indirect From 6da86d8ca81b90f30e6fff8795311e58abba32bf Mon Sep 17 00:00:00 2001 From: michael kad Date: Wed, 10 Jan 2024 13:52:49 -0600 Subject: [PATCH 04/25] sync go.mod and go.sum --- go.mod | 1 - go.sum | 12 ------------ 2 files changed, 13 deletions(-) diff --git a/go.mod b/go.mod index 260e5a7167..55a52d0104 100644 --- a/go.mod +++ b/go.mod @@ -181,7 +181,6 @@ require ( github.com/nicksnyder/go-i18n v1.10.0 // indirect github.com/oklog/run v1.1.0 // indirect github.com/oklog/ulid v1.3.1 // indirect - github.com/onsi/gomega v1.30.0 // indirect github.com/opentracing/opentracing-go v1.2.1-0.20220228012449-10b1cf09e00b // indirect github.com/patrickmn/go-cache v2.1.0+incompatible // indirect github.com/pelletier/go-toml v1.7.0 // indirect diff --git a/go.sum b/go.sum index f9865299d1..b1db6b42b2 100644 --- a/go.sum +++ b/go.sum @@ -94,8 +94,6 @@ github.com/Azure/go-autorest/logger v0.2.1/go.mod h1:T9E3cAhj2VqvPOtCYAvby9aBXkZ github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk= github.com/Azure/go-autorest/tracing v0.6.0 h1:TYi4+3m5t6K48TGI9AUdb+IzbnSxvnvUMfuitfgcfuo= github.com/Azure/go-autorest/tracing v0.6.0/go.mod h1:+vhtPC754Xsa23ID7GlGsrdKBpUA79WCAKPPZVC2DeU= -github.com/Bowery/prompt v0.0.0-20190916142128-fa8279994f75 h1:xGHheKK44eC6K0u5X+DZW/fRaR1LnDdqPHMZMWx5fv8= -github.com/Bowery/prompt v0.0.0-20190916142128-fa8279994f75/go.mod h1:4/6eNcqZ09BZ9wLK3tZOjBA1nDj+B0728nlX5YRlSmQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= @@ -362,8 +360,6 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1 github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dchest/bcrypt_pbkdf v0.0.0-20150205184540-83f37f9c154a h1:saTgr5tMLFnmy/yg3qDTft4rE5DY2uJ/cCxCe3q0XTU= github.com/dchest/bcrypt_pbkdf v0.0.0-20150205184540-83f37f9c154a/go.mod h1:Bw9BbhOJVNR+t0jCqx2GC6zv0TGBsShs56Y3gfSCvl0= -github.com/dchest/safefile v0.0.0-20151022103144-855e8d98f185 h1:3T8ZyTDp5QxTx3NU48JVb2u+75xc040fofcBaN+6jPA= -github.com/dchest/safefile v0.0.0-20151022103144-855e8d98f185/go.mod h1:cFRxtTwTOJkz2x3rQUNCYKWC93yP1VKjR8NUhqFxZNU= github.com/denisenkom/go-mssqldb v0.0.0-20190412130859-3b1d194e553a/go.mod h1:zAg7JM8CkOJ43xKXIj7eRO9kmWm/TW578qo+oDO6tuM= github.com/denverdino/aliyungo v0.0.0-20190125010748-a747050bb1ba h1:p6poVbjHDkKa+wtC8frBMwQtT3BmqGYBjzMwJ63tuR4= github.com/dgryski/go-metro v0.0.0-20180109044635-280f6062b5bc h1:8WFBn63wegobsYAX0YjD+8suexZDga5CctH4CCTx2+8= @@ -728,8 +724,6 @@ github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLe github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20230510103437-eeec1cb781c3 h1:2XF1Vzq06X+inNqgJ9tRnGuw+ZVCB3FazXODD6JE1R8= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= -github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -880,7 +874,6 @@ github.com/hashicorp/go-uuid v1.0.2-0.20191001231223-f32f5fe8d6a8/go.mod h1:6SBZ github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-version v1.0.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= @@ -1061,8 +1054,6 @@ github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVY github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= -github.com/kardianos/govendor v1.0.9 h1:WOH3FcVI9eOgnIZYg96iwUwrL4eOVx+aQ66oyX2R8Yc= -github.com/kardianos/govendor v1.0.9/go.mod h1:yvmR6q9ZZ7nSF5Wvh40v0wfP+3TwwL8zYQp+itoZSVM= github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4= github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA= github.com/kelseyhightower/envconfig v1.3.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg= @@ -1173,10 +1164,7 @@ github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4= github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= -github.com/mitchellh/gox v1.0.1 h1:x0jD3dcHk9a9xPSDN6YEL4xL6Qz0dvNYm8yZqui5chI= -github.com/mitchellh/gox v1.0.1/go.mod h1:ED6BioOGXMswlXa2zxfh/xdd5QhwYliBFn9V18Ap4z4= github.com/mitchellh/hashstructure v1.0.0/go.mod h1:QjSHrPWS+BGUVBYkbTZWEnOh3G1DutKwClXU/ABz6AQ= -github.com/mitchellh/iochan v1.0.0 h1:C+X3KsSTLFVBr/tK1eYN/vs4rJcvsiLU338UhYPJWeY= github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= From 4080e04199711389a1b107c7d5c745948d32f99e Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Thu, 11 Jan 2024 17:06:11 -0600 Subject: [PATCH 05/25] Update instance data source with IBMi licenses --- ibm/service/power/data_source_ibm_pi_instance.go | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/ibm/service/power/data_source_ibm_pi_instance.go b/ibm/service/power/data_source_ibm_pi_instance.go index 8f0e5c469d..1da0adbc20 100644 --- a/ibm/service/power/data_source_ibm_pi_instance.go +++ b/ibm/service/power/data_source_ibm_pi_instance.go @@ -198,31 +198,21 @@ func DataSourceIBMPIInstance() *schema.Resource { "ibmi_css": { Type: schema.TypeBool, - Optional: true, Computed: true, Description: "IBMi Cloud Storage Solution", }, - "ibmi_dbq": { - Type: schema.TypeBool, - Optional: true, - Computed: true, - Description: "IBMi DBQ", - }, "ibmi_pha": { Type: schema.TypeBool, - Optional: true, Computed: true, Description: "IBMi Power High Availability", }, "ibmi_rds": { Type: schema.TypeBool, - Optional: true, Computed: true, Description: "IBMi Rational Dev Studio", }, "ibmi_rds_users": { Type: schema.TypeInt, - Optional: true, Computed: true, Description: "IBMi Rational Dev Studio Number of User Licenses", }, @@ -294,9 +284,7 @@ func dataSourceIBMPIInstancesRead(ctx context.Context, d *schema.ResourceData, m } if powervmdata.SoftwareLicenses != nil { - d.Set("ibmi_css", powervmdata.SoftwareLicenses.IbmiCSS) - d.Set("ibmi_dbq", powervmdata.SoftwareLicenses.IbmiDBQ) d.Set("ibmi_pha", powervmdata.SoftwareLicenses.IbmiPHA) d.Set("ibmi_rds", powervmdata.SoftwareLicenses.IbmiRDS) d.Set("ibmi_rds_users", powervmdata.SoftwareLicenses.IbmiRDSUsers) From cada08f9ac20394835b17b1a667bbe8549463de6 Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Thu, 11 Jan 2024 17:06:32 -0600 Subject: [PATCH 06/25] Update instance resource with IBMi licenses --- ibm/service/power/resource_ibm_pi_instance.go | 102 +++++------------- 1 file changed, 25 insertions(+), 77 deletions(-) diff --git a/ibm/service/power/resource_ibm_pi_instance.go b/ibm/service/power/resource_ibm_pi_instance.go index c15c6203d8..4956e70cd3 100644 --- a/ibm/service/power/resource_ibm_pi_instance.go +++ b/ibm/service/power/resource_ibm_pi_instance.go @@ -182,7 +182,7 @@ func ResourceIBMPIInstance() *schema.Resource { Computed: true, }, "external_ip": { - Type: schema.TypeInt, + Type: schema.TypeString, Computed: true, }, }, @@ -353,70 +353,27 @@ func ResourceIBMPIInstance() *schema.Resource { Description: "Minimum Virtual Cores Assigned to the PVMInstance", }, PIInstanceIbmiCSS: { - Type: schema.TypeBool, - Optional: true, - // Computed: true, + Type: schema.TypeBool, + Optional: true, Description: "IBMi Cloud Storage Solution", }, - PIInstanceIbmiPHA: { - Type: schema.TypeBool, - Optional: true, - // Computed: true, + Type: schema.TypeBool, + Optional: true, Description: "IBMi Power High Availability", }, PIInstanceIbmiRDS: { - Type: schema.TypeBool, - Optional: true, - // Computed: true, + Type: schema.TypeBool, + Optional: false, + Required: false, + Computed: true, Description: "IBMi Rational Dev Studio", }, PIInstanceIbmiRDSUsers: { - Type: schema.TypeInt, - Optional: true, - // Computed: true, + Type: schema.TypeInt, + Optional: true, Description: "IBMi Rational Dev Studio Number of User Licenses", }, - // "pi_software_licenses": { - // Type: schema.TypeList, - // Computed: true, - // Optional: true, - // Description: "List of software licenses", - // Elem: &schema.Resource{ - // Schema: map[string]*schema.Schema{ - // "ibmiCSS": { - // Type: schema.TypeBool, - // Optional: true, - // Computed: true, - // Description: "IBMi Cloud Storage Solution", - // }, - // "ibmiDBQ": { - // Type: schema.TypeBool, - // Optional: true, - // Computed: true, - // Description: "IBMi DBQ", - // }, - // "ibmiPHA": { - // Type: schema.TypeBool, - // Optional: true, - // Computed: true, - // Description: "IBMi Power High Availability", - // }, - // "ibmiRDS": { - // Type: schema.TypeBool, - // Optional: true, - // Computed: true, - // Description: "IBMi Rational Dev Studio", - // }, - // "ibmiRDSUsers": { - // Type: schema.TypeInt, - // Optional: true, - // Computed: true, - // Description: "IBMi Rational Dev Studio Number of User Licenses", - // }, - // }, - // }, - // }, }, } } @@ -825,7 +782,7 @@ func resourceIBMPIInstanceUpdate(ctx context.Context, d *schema.ResourceData, me } } } - if d.HasChanges(PIInstanceIbmiCSS, PIInstanceIbmiPHA, PIInstanceIbmiRDS, PIInstanceIbmiRDSUsers) { + if d.HasChanges(PIInstanceIbmiCSS, PIInstanceIbmiPHA, PIInstanceIbmiRDSUsers) { if d.Get("status") != "ACTIVE" { return diag.Errorf("software licenses change requires the lpar to be in an active state") } @@ -843,18 +800,14 @@ func resourceIBMPIInstanceUpdate(ctx context.Context, d *schema.ResourceData, me sl.IbmiPHA = &license } } - if d.HasChange(PIInstanceIbmiRDS) { - if ibmRDS, ok := d.GetOk(PIInstanceIbmiRDS); ok { - if ibmRDS == true { - if ibmrdsUsers, ok := d.GetOk(PIInstanceIbmiRDSUsers); ok { - if ibmrdsUsers.(int) < 1 { - return diag.Errorf("request with IBMi Rational Dev Studio property requires IBMi Rational Dev Studio number of users") - } - license = ibmRDS.(bool) - sl.IbmiRDS = &license - sl.IbmiRDSUsers = ibmrdsUsers.(int64) - } + if d.HasChange(PIInstanceIbmiRDSUsers) { + if ibmrdsUsers, ok := d.GetOk(PIInstanceIbmiRDSUsers); ok { + if ibmrdsUsers.(int) < 0 { + return diag.Errorf("request with IBMi Rational Dev Studio property requires IBMi Rational Dev Studio number of users") } + license = ibmrdsUsers.(int) > 0 + sl.IbmiRDS = &license + sl.IbmiRDSUsers = int64(ibmrdsUsers.(int)) } } updatebody := &models.PVMInstanceUpdate{SoftwareLicenses: sl} @@ -1436,18 +1389,13 @@ func createPVMInstance(d *schema.ResourceData, client *st.IBMPIInstanceClient, i license = ibmiPHA.(bool) sl.IbmiPHA = &license } - - if ibmRDS, ok := d.GetOk(PIInstanceIbmiRDS); ok { - if ibmRDS == true { - if ibmrdsUsers, ok := d.GetOk(PIInstanceIbmiRDSUsers); ok { - if ibmrdsUsers.(int) < 1 { - return nil, fmt.Errorf("request with IBMi Rational Dev Studio property requires IBMi Rational Dev Studio number of users") - } - license = ibmRDS.(bool) - sl.IbmiRDS = &license - sl.IbmiRDSUsers = ibmrdsUsers.(int64) - } + if ibmrdsUsers, ok := d.GetOk(PIInstanceIbmiRDSUsers); ok { + if ibmrdsUsers.(int) < 0 { + return nil, fmt.Errorf("request with IBMi Rational Dev Studio property requires IBMi Rational Dev Studio number of users") } + license = ibmrdsUsers.(int) > 0 + sl.IbmiRDS = &license + sl.IbmiRDSUsers = int64(ibmrdsUsers.(int)) } body.SoftwareLicenses = sl From 5128fad9570296959df246731479f0b9a1717474 Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Thu, 11 Jan 2024 17:07:18 -0600 Subject: [PATCH 07/25] Add instance resource IBMi license acceptance test --- .../power/resource_ibm_pi_instance_test.go | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/ibm/service/power/resource_ibm_pi_instance_test.go b/ibm/service/power/resource_ibm_pi_instance_test.go index d28e294322..09f041ec33 100644 --- a/ibm/service/power/resource_ibm_pi_instance_test.go +++ b/ibm/service/power/resource_ibm_pi_instance_test.go @@ -139,6 +139,47 @@ func testAccCheckIBMPIInstanceDeploymentTypeConfig(name, instanceHealthStatus st `, acc.Pi_cloud_instance_id, name, acc.Pi_image, acc.Pi_network_name, instanceHealthStatus) } +func testAccCheckIBMPIInstanceIBMiLicense(name, instanceHealthStatus string, IBMiCSS bool, IBMiRDSUsers int) string { + return fmt.Sprintf(` + resource "ibm_pi_key" "key" { + pi_cloud_instance_id = "%[1]s" + pi_key_name = "%[2]s" + pi_ssh_key = "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEArb2aK0mekAdbYdY9rwcmeNSxqVCwez3WZTYEq+1Nwju0x5/vQFPSD2Kp9LpKBbxx3OVLN4VffgGUJznz9DAr7veLkWaf3iwEil6U4rdrhBo32TuDtoBwiczkZ9gn1uJzfIaCJAJdnO80Kv9k0smbQFq5CSb9H+F5VGyFue/iVd5/b30MLYFAz6Jg1GGWgw8yzA4Gq+nO7HtyuA2FnvXdNA3yK/NmrTiPCdJAtEPZkGu9LcelkQ8y90ArlKfjtfzGzYDE4WhOufFxyWxciUePh425J2eZvElnXSdGha+FCfYjQcvqpCVoBAG70U4fJBGjB+HL/GpCXLyiYXPrSnzC9w==" + } + data "ibm_pi_image" "power_image" { + pi_cloud_instance_id = "%[1]s" + pi_image_name = "%[3]s" + } + data "ibm_pi_network" "power_networks" { + pi_cloud_instance_id = "%[1]s" + pi_network_name = "%[4]s" + } + resource "ibm_pi_volume" "power_volume" { + pi_cloud_instance_id = "%[1]s" + pi_volume_size = 1 + pi_volume_name = "%[2]s" + pi_volume_type = "tier3" + } + resource "ibm_pi_instance" "power_instance" { + pi_memory = "2" + pi_processors = "0.25" + pi_instance_name = "%[2]s" + pi_proc_type = "shared" + pi_image_id = data.ibm_pi_image.power_image.id + pi_sys_type = "s922" + 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_ibmi_css = %[6]t + pi_ibmi_rds_users = %[7]d + } + `, acc.Pi_cloud_instance_id, name, acc.Pi_image, acc.Pi_network_name, instanceHealthStatus, IBMiCSS, IBMiRDSUsers) +} + func testAccIBMPIInstanceNetworkConfig(name, privateNetIP string) string { return fmt.Sprintf(` resource "ibm_pi_key" "key" { @@ -319,6 +360,41 @@ func TestAccIBMPIInstanceDeploymentType(t *testing.T) { }) } +func TestAccIBMPIInstanceIBMiLicense(t *testing.T) { + instanceRes := "ibm_pi_instance.power_instance" + name := fmt.Sprintf("tf-pi-instance-%d", acctest.RandIntRange(10, 100)) + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheck(t) }, + Providers: acc.TestAccProviders, + CheckDestroy: testAccCheckIBMPIInstanceDestroy, + Steps: []resource.TestStep{ + { + Config: testAccCheckIBMPIInstanceIBMiLicense(name, helpers.PIInstanceHealthOk, true, 2), + Check: resource.ComposeTestCheckFunc( + testAccCheckIBMPIInstanceExists(instanceRes), + resource.TestCheckResourceAttr(instanceRes, "pi_instance_name", name), + resource.TestCheckResourceAttr(instanceRes, "status", "ACTIVE"), + resource.TestCheckResourceAttr(instanceRes, "pi_ibmi_css", "true"), + resource.TestCheckResourceAttr(instanceRes, "pi_ibmi_rds", "true"), + resource.TestCheckResourceAttr(instanceRes, "pi_ibmi_rds_users", "2"), + ), + }, + { + Config: testAccCheckIBMPIInstanceIBMiLicense(name, helpers.PIInstanceHealthOk, false, 0), + Check: resource.ComposeTestCheckFunc( + testAccCheckIBMPIInstanceExists(instanceRes), + testAccCheckIBMPIInstanceStatus(instanceRes, "ACTIVE"), + resource.TestCheckResourceAttr(instanceRes, "pi_instance_name", name), + resource.TestCheckResourceAttr(instanceRes, "pi_ibmi_css", "false"), + resource.TestCheckResourceAttr(instanceRes, "pi_ibmi_rds", "false"), + resource.TestCheckResourceAttr(instanceRes, "pi_ibmi_rds_users", "0"), + ), + ExpectNonEmptyPlan: true, + }, + }, + }) +} + func TestAccIBMPIInstanceNetwork(t *testing.T) { instanceRes := "ibm_pi_instance.power_instance" name := fmt.Sprintf("tf-pi-instance-%d", acctest.RandIntRange(10, 100)) From 656af92ce346b1dc1980b1dc44cf88b2a0621c2d Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Fri, 12 Jan 2024 13:22:45 -0600 Subject: [PATCH 08/25] Add active check for instance update --- ibm/service/power/resource_ibm_pi_instance.go | 18 ++++++++---------- .../power/resource_ibm_pi_instance_test.go | 3 +-- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/ibm/service/power/resource_ibm_pi_instance.go b/ibm/service/power/resource_ibm_pi_instance.go index 4956e70cd3..9b8ee6333d 100644 --- a/ibm/service/power/resource_ibm_pi_instance.go +++ b/ibm/service/power/resource_ibm_pi_instance.go @@ -574,7 +574,6 @@ func resourceIBMPIInstanceUpdate(ctx context.Context, d *schema.ResourceData, me } if d.HasChange(helpers.PIInstanceProcType) { - // Stop the lpar if d.Get("status") == "SHUTOFF" { log.Printf("the lpar is in the shutoff state. Nothing to do . Moving on ") @@ -627,7 +626,6 @@ func resourceIBMPIInstanceUpdate(ctx context.Context, d *schema.ResourceData, me // Start of the change for Memory and Processors if d.HasChange(helpers.PIInstanceMemory) || d.HasChange(helpers.PIInstanceProcessors) || d.HasChange("pi_migratable") { - maxMemLpar := d.Get("max_memory").(float64) maxCPULpar := d.Get("max_processors").(float64) //log.Printf("the required memory is set to [%d] and current max memory is set to [%d] ", int(mem), int(maxMemLpar)) @@ -687,7 +685,6 @@ func resourceIBMPIInstanceUpdate(ctx context.Context, d *schema.ResourceData, me // License repository capacity will be updated only if service instance is a vtl instance // might need to check if lrc was set if d.HasChange(helpers.PIInstanceLicenseRepositoryCapacity) { - lrc := d.Get(helpers.PIInstanceLicenseRepositoryCapacity).(int64) body := &models.PVMInstanceUpdate{ LicenseRepositoryCapacity: lrc, @@ -748,7 +745,6 @@ func resourceIBMPIInstanceUpdate(ctx context.Context, d *schema.ResourceData, me } if d.HasChange(helpers.PIPlacementGroupID) { - pgClient := st.NewIBMPIPlacementGroupClient(ctx, sess, cloudInstanceID) oldRaw, newRaw := d.GetChange(helpers.PIPlacementGroupID) @@ -783,9 +779,15 @@ func resourceIBMPIInstanceUpdate(ctx context.Context, d *schema.ResourceData, me } } if d.HasChanges(PIInstanceIbmiCSS, PIInstanceIbmiPHA, PIInstanceIbmiRDSUsers) { - if d.Get("status") != "ACTIVE" { - return diag.Errorf("software licenses change requires the lpar to be in an active state") + if d.Get("status") == "ACTIVE" { + log.Printf("the lpar is in the Active state, continuing with update") + } else { + _, err = isWaitForPIInstanceAvailable(ctx, client, instanceID, "OK") + if err != nil { + return diag.FromErr(err) + } } + var license bool sl := &models.SoftwareLicenses{} if d.HasChange(PIInstanceIbmiCSS) { @@ -819,13 +821,9 @@ func resourceIBMPIInstanceUpdate(ctx context.Context, d *schema.ResourceData, me if err != nil { return diag.FromErr(err) } - - log.Printf("software license %s", PIInstanceIbmiCSS) - return diag.Errorf("software licenses change requires the lpar to be in an active state") } return resourceIBMPIInstanceRead(ctx, d, meta) - } func resourceIBMPIInstanceDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { diff --git a/ibm/service/power/resource_ibm_pi_instance_test.go b/ibm/service/power/resource_ibm_pi_instance_test.go index 09f041ec33..f4d26bfc12 100644 --- a/ibm/service/power/resource_ibm_pi_instance_test.go +++ b/ibm/service/power/resource_ibm_pi_instance_test.go @@ -176,8 +176,7 @@ func testAccCheckIBMPIInstanceIBMiLicense(name, instanceHealthStatus string, IBM } pi_ibmi_css = %[6]t pi_ibmi_rds_users = %[7]d - } - `, acc.Pi_cloud_instance_id, name, acc.Pi_image, acc.Pi_network_name, instanceHealthStatus, IBMiCSS, IBMiRDSUsers) + }`, acc.Pi_cloud_instance_id, name, acc.Pi_image, acc.Pi_network_name, instanceHealthStatus, IBMiCSS, IBMiRDSUsers) } func testAccIBMPIInstanceNetworkConfig(name, privateNetIP string) string { From 317bbfe75310630ca36fc5b219401c25e9363343 Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Fri, 12 Jan 2024 17:06:09 -0600 Subject: [PATCH 09/25] Fix updating licenses --- ibm/service/power/resource_ibm_pi_instance.go | 42 +++++++++---------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/ibm/service/power/resource_ibm_pi_instance.go b/ibm/service/power/resource_ibm_pi_instance.go index 9b8ee6333d..60d099cd34 100644 --- a/ibm/service/power/resource_ibm_pi_instance.go +++ b/ibm/service/power/resource_ibm_pi_instance.go @@ -788,30 +788,27 @@ func resourceIBMPIInstanceUpdate(ctx context.Context, d *schema.ResourceData, me } } - var license bool + var licenseCSS bool + var licensePHA bool + var licenseRDS bool sl := &models.SoftwareLicenses{} - if d.HasChange(PIInstanceIbmiCSS) { - if ibmiCSS, ok := d.GetOk(PIInstanceIbmiCSS); ok { - license = ibmiCSS.(bool) - sl.IbmiCSS = &license - } - } - if d.HasChange(PIInstanceIbmiPHA) { - if ibmiPHA, ok := d.GetOk(PIInstanceIbmiPHA); ok { - license = ibmiPHA.(bool) - sl.IbmiPHA = &license - } - } - if d.HasChange(PIInstanceIbmiRDSUsers) { - if ibmrdsUsers, ok := d.GetOk(PIInstanceIbmiRDSUsers); ok { - if ibmrdsUsers.(int) < 0 { - return diag.Errorf("request with IBMi Rational Dev Studio property requires IBMi Rational Dev Studio number of users") - } - license = ibmrdsUsers.(int) > 0 - sl.IbmiRDS = &license - sl.IbmiRDSUsers = int64(ibmrdsUsers.(int)) - } + + ibmiCSS := d.Get(PIInstanceIbmiCSS) + licenseCSS = ibmiCSS.(bool) + sl.IbmiCSS = &licenseCSS + + ibmiPHA := d.Get(PIInstanceIbmiPHA) + licensePHA = ibmiPHA.(bool) + sl.IbmiPHA = &licensePHA + + ibmrdsUsers := d.Get(PIInstanceIbmiRDSUsers) + if ibmrdsUsers.(int) < 0 { + return diag.Errorf("request with IBMi Rational Dev Studio property requires IBMi Rational Dev Studio number of users") } + licenseRDS = ibmrdsUsers.(int) > 0 + sl.IbmiRDS = &licenseRDS + sl.IbmiRDSUsers = int64(ibmrdsUsers.(int)) + updatebody := &models.PVMInstanceUpdate{SoftwareLicenses: sl} _, err = client.Update(instanceID, updatebody) if err != nil { @@ -1396,7 +1393,6 @@ func createPVMInstance(d *schema.ResourceData, client *st.IBMPIInstanceClient, i sl.IbmiRDSUsers = int64(ibmrdsUsers.(int)) } body.SoftwareLicenses = sl - } pvmList, err := client.Create(body) From f8e43d3832852eb045473137cb202ad718a35834 Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Fri, 19 Jan 2024 15:38:04 -0600 Subject: [PATCH 10/25] Update IBMi terraform documentation --- website/docs/d/pi_instance.html.markdown | 7 +++---- website/docs/r/pi_instance.html.markdown | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/website/docs/d/pi_instance.html.markdown b/website/docs/d/pi_instance.html.markdown index e3aa046791..7c29a8d72b 100644 --- a/website/docs/d/pi_instance.html.markdown +++ b/website/docs/d/pi_instance.html.markdown @@ -86,8 +86,7 @@ In addition to all argument reference list, you can access the following attribu - `volumes` - (List of strings) The list of volume IDs that are attached to the instance. **Notes** Ibmi software licenses for IBMi virtual server instances --software licenses currently only supports IBMi instances -- `ibm_css` - (Bool) IBMi Cloud Storage Solution. -- `ibmi_dbq` - (Bool) IBMi DBQ. -- `ibmi_pha` - (Bool) IBMi Power High Availability. -- `ibmi_rds` - (Bool) IBMi Rational Dev Studio. +- `ibm_css` - (Boolean) IBMi Cloud Storage Solution. +- `ibmi_pha` - (Boolean) IBMi Power High Availability. +- `ibmi_rds` - (Boolean) IBMi Rational Dev Studio. - `ibmi_rds_users` - (Integer) IBMi Rational Dev Studio Number of User Licenses. diff --git a/website/docs/r/pi_instance.html.markdown b/website/docs/r/pi_instance.html.markdown index a0f60d94f7..1733169483 100644 --- a/website/docs/r/pi_instance.html.markdown +++ b/website/docs/r/pi_instance.html.markdown @@ -132,10 +132,9 @@ In addition to all argument reference list, you can access the following attribu - `progress` - (Float) - Specifies the overall progress of the instance deployment process in percentage. - `shared_processor_pool_id` - (String) The ID of the shared processor pool for the instance. - `status` - (String) The status of the instance. -- `ibm_css` - (Bool) IBMi Cloud Storage Solution. -- `ibmi_dbq` - (Bool) IBMi DBQ. -- `ibmi_pha` - (Bool) IBMi Power High Availability. -- `ibmi_rds` - (Bool) IBMi Rational Dev Studio. +- `ibm_css` - (Boolean) IBMi Cloud Storage Solution. +- `ibmi_pha` - (Boolean) IBMi Power High Availability. +- `ibmi_rds` - (Boolean) IBMi Rational Dev Studio. - `ibmi_rds_users` - (Integer) IBMi Rational Dev Studio Number of User Licenses. ## Import From 4554254a6f8a62ad1f1642ebc0ee70810243c0b7 Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Thu, 25 Jan 2024 14:19:50 -0600 Subject: [PATCH 11/25] Add wait software licenses update function --- ibm/service/power/resource_ibm_pi_instance.go | 61 ++++++++++++++++++- 1 file changed, 59 insertions(+), 2 deletions(-) diff --git a/ibm/service/power/resource_ibm_pi_instance.go b/ibm/service/power/resource_ibm_pi_instance.go index 60d099cd34..02c42aca24 100644 --- a/ibm/service/power/resource_ibm_pi_instance.go +++ b/ibm/service/power/resource_ibm_pi_instance.go @@ -522,7 +522,11 @@ func resourceIBMPIInstanceRead(ctx context.Context, d *schema.ResourceData, meta d.Set(PIInstanceIbmiCSS, powervmdata.SoftwareLicenses.IbmiCSS) d.Set(PIInstanceIbmiPHA, powervmdata.SoftwareLicenses.IbmiPHA) d.Set(PIInstanceIbmiRDS, powervmdata.SoftwareLicenses.IbmiRDS) - d.Set(PIInstanceIbmiRDSUsers, powervmdata.SoftwareLicenses.IbmiRDSUsers) + if *powervmdata.SoftwareLicenses.IbmiRDS { + d.Set(PIInstanceIbmiRDSUsers, powervmdata.SoftwareLicenses.IbmiRDSUsers) + } else { + d.Set(PIInstanceIbmiRDSUsers, 0) + } } return nil } @@ -814,7 +818,7 @@ func resourceIBMPIInstanceUpdate(ctx context.Context, d *schema.ResourceData, me if err != nil { return diag.FromErr(err) } - _, err = isWaitForPIInstanceAvailable(ctx, client, instanceID, "OK") + _, err = isWaitForPIInstanceSoftwareLicenses(ctx, client, instanceID, sl) if err != nil { return diag.FromErr(err) } @@ -920,6 +924,59 @@ func isPIInstanceRefreshFunc(client *st.IBMPIInstanceClient, id, instanceReadySt } } +func isWaitForPIInstanceSoftwareLicenses(ctx context.Context, client *st.IBMPIInstanceClient, id string, softwareLicenses *models.SoftwareLicenses) (interface{}, error) { + log.Printf("Waiting for PIInstance Software Licenses (%s) to be updated ", id) + + queryTimeOut := activeTimeOut + + stateConf := &resource.StateChangeConf{ + Pending: []string{"notdone"}, + Target: []string{"done"}, + Refresh: isPIInstanceSoftwareLicensesRefreshFunc(client, id, softwareLicenses), + Delay: 90 * time.Second, + MinTimeout: queryTimeOut, + Timeout: 120 * time.Minute, + } + + return stateConf.WaitForStateContext(ctx) +} + +func isPIInstanceSoftwareLicensesRefreshFunc(client *st.IBMPIInstanceClient, id string, softwareLicenses *models.SoftwareLicenses) resource.StateRefreshFunc { + return func() (interface{}, string, error) { + + pvm, err := client.Get(id) + if err != nil { + return nil, "", err + } + + // Check that each software license we modified has been updated + if softwareLicenses.IbmiCSS != nil { + if *softwareLicenses.IbmiCSS != *pvm.SoftwareLicenses.IbmiCSS { + return pvm, "notdone", nil + } + } + + if softwareLicenses.IbmiPHA != nil { + if *softwareLicenses.IbmiPHA != *pvm.SoftwareLicenses.IbmiPHA { + return pvm, "notdone", nil + } + } + + if softwareLicenses.IbmiRDS != nil { + // If the update set IBMiRDS to false, don't check IBMiRDSUsers as it will be updated on the terraform side on the read + if !*softwareLicenses.IbmiRDS { + if *pvm.SoftwareLicenses.IbmiRDS != *softwareLicenses.IbmiRDS { + return pvm, "notdone", nil + } + } else if (*pvm.SoftwareLicenses.IbmiRDS != *softwareLicenses.IbmiRDS) || (pvm.SoftwareLicenses.IbmiRDSUsers != softwareLicenses.IbmiRDSUsers) { + return pvm, "notdone", nil + } + } + + return pvm, "done", nil + } +} + // This function takes the input string and encodes into base64 if isn't already encoded func encodeBase64(userData string) string { _, err := base64.StdEncoding.DecodeString(userData) From 9b4713cfe6bb6540ff4e5028e2cd3b2ac2f9e958 Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Fri, 26 Jan 2024 11:52:22 -0600 Subject: [PATCH 12/25] Update IBMi license test --- ibm/service/power/resource_ibm_pi_instance.go | 4 ++-- ibm/service/power/resource_ibm_pi_instance_test.go | 6 ------ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/ibm/service/power/resource_ibm_pi_instance.go b/ibm/service/power/resource_ibm_pi_instance.go index 02c42aca24..6852b93683 100644 --- a/ibm/service/power/resource_ibm_pi_instance.go +++ b/ibm/service/power/resource_ibm_pi_instance.go @@ -965,10 +965,10 @@ func isPIInstanceSoftwareLicensesRefreshFunc(client *st.IBMPIInstanceClient, id if softwareLicenses.IbmiRDS != nil { // If the update set IBMiRDS to false, don't check IBMiRDSUsers as it will be updated on the terraform side on the read if !*softwareLicenses.IbmiRDS { - if *pvm.SoftwareLicenses.IbmiRDS != *softwareLicenses.IbmiRDS { + if *softwareLicenses.IbmiRDS != *pvm.SoftwareLicenses.IbmiRDS { return pvm, "notdone", nil } - } else if (*pvm.SoftwareLicenses.IbmiRDS != *softwareLicenses.IbmiRDS) || (pvm.SoftwareLicenses.IbmiRDSUsers != softwareLicenses.IbmiRDSUsers) { + } else if (*softwareLicenses.IbmiRDS != *pvm.SoftwareLicenses.IbmiRDS) || (softwareLicenses.IbmiRDSUsers != pvm.SoftwareLicenses.IbmiRDSUsers) { return pvm, "notdone", nil } } diff --git a/ibm/service/power/resource_ibm_pi_instance_test.go b/ibm/service/power/resource_ibm_pi_instance_test.go index f4d26bfc12..862d96d7dc 100644 --- a/ibm/service/power/resource_ibm_pi_instance_test.go +++ b/ibm/service/power/resource_ibm_pi_instance_test.go @@ -141,11 +141,6 @@ func testAccCheckIBMPIInstanceDeploymentTypeConfig(name, instanceHealthStatus st func testAccCheckIBMPIInstanceIBMiLicense(name, instanceHealthStatus string, IBMiCSS bool, IBMiRDSUsers int) string { return fmt.Sprintf(` - resource "ibm_pi_key" "key" { - pi_cloud_instance_id = "%[1]s" - pi_key_name = "%[2]s" - pi_ssh_key = "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEArb2aK0mekAdbYdY9rwcmeNSxqVCwez3WZTYEq+1Nwju0x5/vQFPSD2Kp9LpKBbxx3OVLN4VffgGUJznz9DAr7veLkWaf3iwEil6U4rdrhBo32TuDtoBwiczkZ9gn1uJzfIaCJAJdnO80Kv9k0smbQFq5CSb9H+F5VGyFue/iVd5/b30MLYFAz6Jg1GGWgw8yzA4Gq+nO7HtyuA2FnvXdNA3yK/NmrTiPCdJAtEPZkGu9LcelkQ8y90ArlKfjtfzGzYDE4WhOufFxyWxciUePh425J2eZvElnXSdGha+FCfYjQcvqpCVoBAG70U4fJBGjB+HL/GpCXLyiYXPrSnzC9w==" - } data "ibm_pi_image" "power_image" { pi_cloud_instance_id = "%[1]s" pi_image_name = "%[3]s" @@ -388,7 +383,6 @@ func TestAccIBMPIInstanceIBMiLicense(t *testing.T) { resource.TestCheckResourceAttr(instanceRes, "pi_ibmi_rds", "false"), resource.TestCheckResourceAttr(instanceRes, "pi_ibmi_rds_users", "0"), ), - ExpectNonEmptyPlan: true, }, }, }) From 63fc536c7b00786bae9d2c767b8b6be2146e44c4 Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Fri, 26 Jan 2024 11:55:00 -0600 Subject: [PATCH 13/25] Update instance data source --- .../power/data_source_ibm_pi_instance.go | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/ibm/service/power/data_source_ibm_pi_instance.go b/ibm/service/power/data_source_ibm_pi_instance.go index 1da0adbc20..a8c470b8b7 100644 --- a/ibm/service/power/data_source_ibm_pi_instance.go +++ b/ibm/service/power/data_source_ibm_pi_instance.go @@ -195,23 +195,22 @@ func DataSourceIBMPIInstance() *schema.Resource { Type: schema.TypeString, Computed: true, }, - - "ibmi_css": { + PIInstanceIbmiCSS: { Type: schema.TypeBool, Computed: true, Description: "IBMi Cloud Storage Solution", }, - "ibmi_pha": { + PIInstanceIbmiPHA: { Type: schema.TypeBool, Computed: true, Description: "IBMi Power High Availability", }, - "ibmi_rds": { + PIInstanceIbmiRDS: { Type: schema.TypeBool, Computed: true, Description: "IBMi Rational Dev Studio", }, - "ibmi_rds_users": { + PIInstanceIbmiRDSUsers: { Type: schema.TypeInt, Computed: true, Description: "IBMi Rational Dev Studio Number of User Licenses", @@ -284,10 +283,14 @@ func dataSourceIBMPIInstancesRead(ctx context.Context, d *schema.ResourceData, m } if powervmdata.SoftwareLicenses != nil { - d.Set("ibmi_css", powervmdata.SoftwareLicenses.IbmiCSS) - d.Set("ibmi_pha", powervmdata.SoftwareLicenses.IbmiPHA) - d.Set("ibmi_rds", powervmdata.SoftwareLicenses.IbmiRDS) - d.Set("ibmi_rds_users", powervmdata.SoftwareLicenses.IbmiRDSUsers) + d.Set(PIInstanceIbmiCSS, powervmdata.SoftwareLicenses.IbmiCSS) + d.Set(PIInstanceIbmiPHA, powervmdata.SoftwareLicenses.IbmiPHA) + d.Set(PIInstanceIbmiRDS, powervmdata.SoftwareLicenses.IbmiRDS) + if *powervmdata.SoftwareLicenses.IbmiRDS { + d.Set(PIInstanceIbmiRDSUsers, powervmdata.SoftwareLicenses.IbmiRDSUsers) + } else { + d.Set(PIInstanceIbmiRDSUsers, 0) + } } return nil From 38c6c2ded605277881aa96e3b19759ee92f8d7e7 Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Fri, 26 Jan 2024 12:08:10 -0600 Subject: [PATCH 14/25] Update instance update license markdown --- website/docs/d/pi_instance.html.markdown | 8 ++++---- website/docs/r/pi_instance.html.markdown | 19 +++++++++---------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/website/docs/d/pi_instance.html.markdown b/website/docs/d/pi_instance.html.markdown index 7c29a8d72b..5a21953dd5 100644 --- a/website/docs/d/pi_instance.html.markdown +++ b/website/docs/d/pi_instance.html.markdown @@ -86,7 +86,7 @@ In addition to all argument reference list, you can access the following attribu - `volumes` - (List of strings) The list of volume IDs that are attached to the instance. **Notes** Ibmi software licenses for IBMi virtual server instances --software licenses currently only supports IBMi instances -- `ibm_css` - (Boolean) IBMi Cloud Storage Solution. -- `ibmi_pha` - (Boolean) IBMi Power High Availability. -- `ibmi_rds` - (Boolean) IBMi Rational Dev Studio. -- `ibmi_rds_users` - (Integer) IBMi Rational Dev Studio Number of User Licenses. +- `pi_ibmi_css` - (Boolean) IBMi Cloud Storage Solution. +- `pi_ibmi_pha` - (Boolean) IBMi Power High Availability. +- `pi_ibmi_rds` - (Boolean) IBMi Rational Dev Studio. +- `pi_ibmi_rds_users` - (Integer) IBMi Rational Dev Studio Number of User Licenses. diff --git a/website/docs/r/pi_instance.html.markdown b/website/docs/r/pi_instance.html.markdown index 1733169483..bda74d64f5 100644 --- a/website/docs/r/pi_instance.html.markdown +++ b/website/docs/r/pi_instance.html.markdown @@ -67,10 +67,9 @@ Review the argument references that you can specify for your resource. - `pi_deployment_type` - (Optional, String) Custom deployment type; Allowable value: `EPIC`. - `pi_health_status` - (Optional, String) Specifies if Terraform should poll for the health status to be `OK` or `WARNING`. The default value is `OK`. **Notes** Ibmi software licenses for IBMi virtual server instances --software licenses currently only supports IBMi instances. Default to `false` and `0` if no values provided -- `pi_ibm_css` - (Optional, Bool) IBMi Cloud Storage Solution. -- `pi_ibmi_pha` - (Optional, Bool) IBMi Power High Availability. -- `pi_ibmi_rds` - (Optional, Bool) IBMi Rational Dev Studio. -- `pi_ibmi_rds_users` - (Optional, Integer) IBMi Rational Dev Studio Number of User Licenses. Required if `pi_ibmi_rds` is provided +- `pi_ibmi_css` - (Optional, Boolean) IBMi Cloud Storage Solution. +- `pi_ibmi_pha` - (Optional, Boolean) IBMi Power High Availability. +- `pi_ibmi_rds_users` - (Optional, Integer) IBMi Rational Dev Studio Number of User Licenses. - `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. - **Note**: only images belonging to your project can be used image for deploying a Power Systems Virtual Server instance. To import an images to your project, see [ibm_pi_image](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/pi_image). - `pi_instance_name` - (Required, String) The name of the Power Systems Virtual Server instance. @@ -79,7 +78,7 @@ Review the argument references that you can specify for your resource. - **Note**: Provisioning VTL instances is temporarily disabled. - `pi_memory` - (Optional, Float) The amount of memory that you want to assign to your instance in gigabytes. - Required when not creating SAP instances. Conflicts with `pi_sap_profile_id`. -- `pi_migratable`- (Optional, Bool) Indicates the VM is migrated or not. +- `pi_migratable`- (Optional, Boolean) Indicates the VM is migrated or not. - `pi_network` - (Required, List of Map) List of one or more networks to attach to the instance. The `pi_network` block supports: @@ -99,7 +98,7 @@ Review the argument references that you can specify for your resource. - `pi_sap_deployment_type` - (Optional, String) Custom SAP deployment type information (For Internal Use Only). - `pi_shared_processor_pool` - (Optional, String) The shared processor pool for instance deployment. Conflicts with `pi_sap_profile_id`. - `pi_storage_pool` - (Optional, String) Storage Pool for server deployment; if provided then `pi_affinity_policy` will be ignored; Only valid when you deploy one of the IBM supplied stock images. Storage pool for a custom image (an imported image or an image that is created from a VM capture) defaults to the storage pool the image was created in. -- `pi_storage_pool_affinity` - (Optional, Bool) Indicates if all volumes attached to the server must reside in the same storage pool. The default value is `true`. To attach data volumes from a different storage pool (mixed storage) set to `false` and use `pi_volume_attach` resource. Once set to `false`, cannot be set back to `true` unless all volumes attached reside in the same storage type and pool. +- `pi_storage_pool_affinity` - (Optional, Boolean) Indicates if all volumes attached to the server must reside in the same storage pool. The default value is `true`. To attach data volumes from a different storage pool (mixed storage) set to `false` and use `pi_volume_attach` resource. Once set to `false`, cannot be set back to `true` unless all volumes attached reside in the same storage type and pool. - `pi_storage_type` - (Optional, String) - Storage type for server deployment; If storage type is not provided the storage type will default to `tier3`. - `pi_storage_connection` - (Optional, String) - Storage Connectivity Group (SCG) for server deployment. Only supported value is `vSCSI`. - `pi_sys_type` - (Optional, String) The type of system on which to create the VM (s922/e880/e980/s1022). @@ -132,10 +131,10 @@ In addition to all argument reference list, you can access the following attribu - `progress` - (Float) - Specifies the overall progress of the instance deployment process in percentage. - `shared_processor_pool_id` - (String) The ID of the shared processor pool for the instance. - `status` - (String) The status of the instance. -- `ibm_css` - (Boolean) IBMi Cloud Storage Solution. -- `ibmi_pha` - (Boolean) IBMi Power High Availability. -- `ibmi_rds` - (Boolean) IBMi Rational Dev Studio. -- `ibmi_rds_users` - (Integer) IBMi Rational Dev Studio Number of User Licenses. +- `pi_ibmi_css` - (Boolean) IBMi Cloud Storage Solution. +- `pi_ibmi_pha` - (Boolean) IBMi Power High Availability. +- `pi_ibmi_rds` - (Boolean) IBMi Rational Dev Studio. +- `pi_ibmi_rds_users` - (Integer) IBMi Rational Dev Studio Number of User Licenses. ## Import The `ibm_pi_instance` can be imported using `power_instance_id` and `instance_id`. From 9bcd4f3412f0e9efaff0e789b8ca2e72ea501761 Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Fri, 26 Jan 2024 12:17:45 -0600 Subject: [PATCH 15/25] Remove duplicate markdown definitions --- website/docs/r/pi_instance.html.markdown | 3 --- 1 file changed, 3 deletions(-) diff --git a/website/docs/r/pi_instance.html.markdown b/website/docs/r/pi_instance.html.markdown index bda74d64f5..b7e8b018b6 100644 --- a/website/docs/r/pi_instance.html.markdown +++ b/website/docs/r/pi_instance.html.markdown @@ -131,10 +131,7 @@ In addition to all argument reference list, you can access the following attribu - `progress` - (Float) - Specifies the overall progress of the instance deployment process in percentage. - `shared_processor_pool_id` - (String) The ID of the shared processor pool for the instance. - `status` - (String) The status of the instance. -- `pi_ibmi_css` - (Boolean) IBMi Cloud Storage Solution. -- `pi_ibmi_pha` - (Boolean) IBMi Power High Availability. - `pi_ibmi_rds` - (Boolean) IBMi Rational Dev Studio. -- `pi_ibmi_rds_users` - (Integer) IBMi Rational Dev Studio Number of User Licenses. ## Import The `ibm_pi_instance` can be imported using `power_instance_id` and `instance_id`. From f636d6dbb3e7d1da68f3343ee366f0e2a99acd44 Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Mon, 29 Jan 2024 10:17:14 -0600 Subject: [PATCH 16/25] Refactor ibmi license code --- ibm/service/power/ibm_pi_constants.go | 1 + ibm/service/power/resource_ibm_pi_instance.go | 18 ++++++++---------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/ibm/service/power/ibm_pi_constants.go b/ibm/service/power/ibm_pi_constants.go index 4bacfe115c..bf4b57ccdb 100644 --- a/ibm/service/power/ibm_pi_constants.go +++ b/ibm/service/power/ibm_pi_constants.go @@ -51,6 +51,7 @@ const ( PIInstanceIbmiPHA = "pi_ibmi_pha" PIInstanceIbmiRDS = "pi_ibmi_rds" PIInstanceIbmiRDSUsers = "pi_ibmi_rds_users" + OS_IBMI = "ibmi" Attr_Status = "status" Attr_Progress = "progress" diff --git a/ibm/service/power/resource_ibm_pi_instance.go b/ibm/service/power/resource_ibm_pi_instance.go index 6852b93683..abd6f5e163 100644 --- a/ibm/service/power/resource_ibm_pi_instance.go +++ b/ibm/service/power/resource_ibm_pi_instance.go @@ -792,25 +792,23 @@ func resourceIBMPIInstanceUpdate(ctx context.Context, d *schema.ResourceData, me } } - var licenseCSS bool - var licensePHA bool - var licenseRDS bool + var license bool sl := &models.SoftwareLicenses{} ibmiCSS := d.Get(PIInstanceIbmiCSS) - licenseCSS = ibmiCSS.(bool) - sl.IbmiCSS = &licenseCSS + license = ibmiCSS.(bool) + sl.IbmiCSS = &license ibmiPHA := d.Get(PIInstanceIbmiPHA) - licensePHA = ibmiPHA.(bool) - sl.IbmiPHA = &licensePHA + license = ibmiPHA.(bool) + sl.IbmiPHA = &license ibmrdsUsers := d.Get(PIInstanceIbmiRDSUsers) if ibmrdsUsers.(int) < 0 { return diag.Errorf("request with IBMi Rational Dev Studio property requires IBMi Rational Dev Studio number of users") } - licenseRDS = ibmrdsUsers.(int) > 0 - sl.IbmiRDS = &licenseRDS + license = ibmrdsUsers.(int) > 0 + sl.IbmiRDS = &license sl.IbmiRDSUsers = int64(ibmrdsUsers.(int)) updatebody := &models.PVMInstanceUpdate{SoftwareLicenses: sl} @@ -1423,7 +1421,7 @@ func createPVMInstance(d *schema.ResourceData, client *st.IBMPIInstanceClient, i } } - if imageData.Specifications.OperatingSystem == "ibmi" { + if imageData.Specifications.OperatingSystem == OS_IBMI { // Default value falseBool := false var license bool From 11f7b22e9e7deb2119f3b1f390488ddd71b38809 Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Mon, 29 Jan 2024 13:40:47 -0600 Subject: [PATCH 17/25] Refactor ibmi license code --- ibm/service/power/resource_ibm_pi_instance.go | 31 ++++++------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/ibm/service/power/resource_ibm_pi_instance.go b/ibm/service/power/resource_ibm_pi_instance.go index abd6f5e163..cb518b8c3b 100644 --- a/ibm/service/power/resource_ibm_pi_instance.go +++ b/ibm/service/power/resource_ibm_pi_instance.go @@ -792,24 +792,15 @@ func resourceIBMPIInstanceUpdate(ctx context.Context, d *schema.ResourceData, me } } - var license bool sl := &models.SoftwareLicenses{} - - ibmiCSS := d.Get(PIInstanceIbmiCSS) - license = ibmiCSS.(bool) - sl.IbmiCSS = &license - - ibmiPHA := d.Get(PIInstanceIbmiPHA) - license = ibmiPHA.(bool) - sl.IbmiPHA = &license - - ibmrdsUsers := d.Get(PIInstanceIbmiRDSUsers) - if ibmrdsUsers.(int) < 0 { + sl.IbmiCSS = flex.PtrToBool(d.Get(PIInstanceIbmiCSS).(bool)) + sl.IbmiPHA = flex.PtrToBool(d.Get(PIInstanceIbmiPHA).(bool)) + ibmrdsUsers := d.Get(PIInstanceIbmiRDSUsers).(int) + if ibmrdsUsers < 0 { return diag.Errorf("request with IBMi Rational Dev Studio property requires IBMi Rational Dev Studio number of users") } - license = ibmrdsUsers.(int) > 0 - sl.IbmiRDS = &license - sl.IbmiRDSUsers = int64(ibmrdsUsers.(int)) + sl.IbmiRDS = flex.PtrToBool(ibmrdsUsers > 0) + sl.IbmiRDSUsers = int64(ibmrdsUsers) updatebody := &models.PVMInstanceUpdate{SoftwareLicenses: sl} _, err = client.Update(instanceID, updatebody) @@ -1424,7 +1415,6 @@ func createPVMInstance(d *schema.ResourceData, client *st.IBMPIInstanceClient, i if imageData.Specifications.OperatingSystem == OS_IBMI { // Default value falseBool := false - var license bool sl := &models.SoftwareLicenses{ IbmiCSS: &falseBool, IbmiPHA: &falseBool, @@ -1432,19 +1422,16 @@ func createPVMInstance(d *schema.ResourceData, client *st.IBMPIInstanceClient, i IbmiRDSUsers: 0, } if ibmiCSS, ok := d.GetOk(PIInstanceIbmiCSS); ok { - license = ibmiCSS.(bool) - sl.IbmiCSS = &license + sl.IbmiCSS = flex.PtrToBool(ibmiCSS.(bool)) } if ibmiPHA, ok := d.GetOk(PIInstanceIbmiPHA); ok { - license = ibmiPHA.(bool) - sl.IbmiPHA = &license + sl.IbmiPHA = flex.PtrToBool(ibmiPHA.(bool)) } if ibmrdsUsers, ok := d.GetOk(PIInstanceIbmiRDSUsers); ok { if ibmrdsUsers.(int) < 0 { return nil, fmt.Errorf("request with IBMi Rational Dev Studio property requires IBMi Rational Dev Studio number of users") } - license = ibmrdsUsers.(int) > 0 - sl.IbmiRDS = &license + sl.IbmiRDS = flex.PtrToBool(ibmrdsUsers.(int) > 0) sl.IbmiRDSUsers = int64(ibmrdsUsers.(int)) } body.SoftwareLicenses = sl From 093c1e4b4a836d3e0640098709c9947eab573f83 Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Mon, 5 Feb 2024 14:03:34 -0600 Subject: [PATCH 18/25] Update IBMi documentation --- website/docs/d/pi_instance.html.markdown | 2 +- website/docs/r/pi_instance.html.markdown | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/website/docs/d/pi_instance.html.markdown b/website/docs/d/pi_instance.html.markdown index 5a21953dd5..5af207fdce 100644 --- a/website/docs/d/pi_instance.html.markdown +++ b/website/docs/d/pi_instance.html.markdown @@ -85,7 +85,7 @@ In addition to all argument reference list, you can access the following attribu - `virtual_cores_assigned` - (Integer) The virtual cores that are assigned to the instance. - `volumes` - (List of strings) The list of volume IDs that are attached to the instance. - **Notes** Ibmi software licenses for IBMi virtual server instances --software licenses currently only supports IBMi instances + **Notes** Ibmi software licenses for IBMi virtual server instances -- only for IBMi instances - `pi_ibmi_css` - (Boolean) IBMi Cloud Storage Solution. - `pi_ibmi_pha` - (Boolean) IBMi Power High Availability. - `pi_ibmi_rds` - (Boolean) IBMi Rational Dev Studio. diff --git a/website/docs/r/pi_instance.html.markdown b/website/docs/r/pi_instance.html.markdown index b7e8b018b6..3b5914b6de 100644 --- a/website/docs/r/pi_instance.html.markdown +++ b/website/docs/r/pi_instance.html.markdown @@ -66,7 +66,7 @@ Review the argument references that you can specify for your resource. - `pi_cloud_instance_id` - (Required, String) The GUID of the service instance associated with an account. - `pi_deployment_type` - (Optional, String) Custom deployment type; Allowable value: `EPIC`. - `pi_health_status` - (Optional, String) Specifies if Terraform should poll for the health status to be `OK` or `WARNING`. The default value is `OK`. - **Notes** Ibmi software licenses for IBMi virtual server instances --software licenses currently only supports IBMi instances. Default to `false` and `0` if no values provided + **Notes** Ibmi software licenses for IBMi virtual server instances -- only for IBMi instances. Default to `false` and `0` if no values provided - `pi_ibmi_css` - (Optional, Boolean) IBMi Cloud Storage Solution. - `pi_ibmi_pha` - (Optional, Boolean) IBMi Power High Availability. - `pi_ibmi_rds_users` - (Optional, Integer) IBMi Rational Dev Studio Number of User Licenses. From 8fd5882d5421bb48df4146f22c54c8320ef733e1 Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Tue, 6 Feb 2024 18:01:48 -0600 Subject: [PATCH 19/25] Fix duplicate constants --- ibm/service/power/ibm_pi_constants.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/ibm/service/power/ibm_pi_constants.go b/ibm/service/power/ibm_pi_constants.go index 20806f6ee1..d1b345705d 100644 --- a/ibm/service/power/ibm_pi_constants.go +++ b/ibm/service/power/ibm_pi_constants.go @@ -287,9 +287,6 @@ const ( PIInstanceIbmiRDSUsers = "pi_ibmi_rds_users" OS_IBMI = "ibmi" - Attr_Status = "status" - Attr_Progress = "progress" - Attr_HealthStatus = "health_status" Arg_PIInstanceSharedProcessorPool = "pi_shared_processor_pool" PVMInstanceHealthOk = "OK" From 3ad81bbe6fa8a73e015687dfdfbe361398369908 Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Wed, 14 Feb 2024 08:04:52 -0600 Subject: [PATCH 20/25] Fix formatting --- ibm/service/power/resource_ibm_pi_network.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ibm/service/power/resource_ibm_pi_network.go b/ibm/service/power/resource_ibm_pi_network.go index 941731b8fe..9c3515ce6d 100644 --- a/ibm/service/power/resource_ibm_pi_network.go +++ b/ibm/service/power/resource_ibm_pi_network.go @@ -75,12 +75,12 @@ func ResourceIBMPINetwork() *schema.Resource { Description: "PI network gateway", }, helpers.PINetworkJumbo: { - Type: schema.TypeBool, - Optional: true, - Computed: true, - Deprecated: "This field is deprecated, use pi_network_mtu instead.", + Type: schema.TypeBool, + Optional: true, + Computed: true, + Deprecated: "This field is deprecated, use pi_network_mtu instead.", ConflictsWith: []string{helpers.PINetworkMtu, helpers.PINetworkJumbo}, - Description: "PI network enable MTU Jumbo option", + Description: "PI network enable MTU Jumbo option", }, helpers.PINetworkMtu: { Type: schema.TypeInt, From a92033e1002c7c1b519da4b6d5195e07227fce33 Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Wed, 14 Feb 2024 08:16:50 -0600 Subject: [PATCH 21/25] Fix formatting --- ibm/service/power/resource_ibm_pi_instance.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ibm/service/power/resource_ibm_pi_instance.go b/ibm/service/power/resource_ibm_pi_instance.go index 21e0b84867..7e75edad6c 100644 --- a/ibm/service/power/resource_ibm_pi_instance.go +++ b/ibm/service/power/resource_ibm_pi_instance.go @@ -1025,7 +1025,7 @@ func isPIInstanceShutoffRefreshFunc(client *st.IBMPIInstanceClient, id, instance return pvm, helpers.PIInstanceBuilding, nil } } - + // This function takes the input string and encodes into base64 if isn't already encoded func encodeBase64(userData string) string { _, err := base64.StdEncoding.DecodeString(userData) From d62aa7f52636b23469fd3682ac01679ebb13137b Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Thu, 15 Feb 2024 15:25:03 -0600 Subject: [PATCH 22/25] Fix typo from merge conflict --- ibm/service/power/resource_ibm_pi_network.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ibm/service/power/resource_ibm_pi_network.go b/ibm/service/power/resource_ibm_pi_network.go index 9c3515ce6d..51006a68a3 100644 --- a/ibm/service/power/resource_ibm_pi_network.go +++ b/ibm/service/power/resource_ibm_pi_network.go @@ -79,7 +79,7 @@ func ResourceIBMPINetwork() *schema.Resource { Optional: true, Computed: true, Deprecated: "This field is deprecated, use pi_network_mtu instead.", - ConflictsWith: []string{helpers.PINetworkMtu, helpers.PINetworkJumbo}, + ConflictsWith: []string{helpers.PINetworkMtu}, Description: "PI network enable MTU Jumbo option", }, helpers.PINetworkMtu: { From 45840c204beaf01d4d1549e43f2deb9fdddeb9de Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Thu, 15 Feb 2024 15:33:20 -0600 Subject: [PATCH 23/25] Refactor variable names --- .../power/data_source_ibm_pi_instance.go | 18 +++++------ ibm/service/power/ibm_pi_constants.go | 9 +++--- ibm/service/power/resource_ibm_pi_instance.go | 32 +++++++++---------- 3 files changed, 29 insertions(+), 30 deletions(-) diff --git a/ibm/service/power/data_source_ibm_pi_instance.go b/ibm/service/power/data_source_ibm_pi_instance.go index 8c2c4e382a..c490e07c0a 100644 --- a/ibm/service/power/data_source_ibm_pi_instance.go +++ b/ibm/service/power/data_source_ibm_pi_instance.go @@ -162,22 +162,22 @@ func DataSourceIBMPIInstance() *schema.Resource { Type: schema.TypeString, Computed: true, }, - PIInstanceIbmiCSS: { + PIInstanceIBMiCSS: { Type: schema.TypeBool, Computed: true, Description: "IBMi Cloud Storage Solution", }, - PIInstanceIbmiPHA: { + PIInstanceIBMiPHA: { Type: schema.TypeBool, Computed: true, Description: "IBMi Power High Availability", }, - PIInstanceIbmiRDS: { + PIInstanceIBMiRDS: { Type: schema.TypeBool, Computed: true, Description: "IBMi Rational Dev Studio", }, - PIInstanceIbmiRDSUsers: { + PIInstanceIBMiRDSUsers: { Type: schema.TypeInt, Computed: true, Description: "IBMi Rational Dev Studio Number of User Licenses", @@ -235,13 +235,13 @@ func dataSourceIBMPIInstancesRead(ctx context.Context, d *schema.ResourceData, m } if powervmdata.SoftwareLicenses != nil { - d.Set(PIInstanceIbmiCSS, powervmdata.SoftwareLicenses.IbmiCSS) - d.Set(PIInstanceIbmiPHA, powervmdata.SoftwareLicenses.IbmiPHA) - d.Set(PIInstanceIbmiRDS, powervmdata.SoftwareLicenses.IbmiRDS) + d.Set(PIInstanceIBMiCSS, powervmdata.SoftwareLicenses.IbmiCSS) + d.Set(PIInstanceIBMiPHA, powervmdata.SoftwareLicenses.IbmiPHA) + d.Set(PIInstanceIBMiRDS, powervmdata.SoftwareLicenses.IbmiRDS) if *powervmdata.SoftwareLicenses.IbmiRDS { - d.Set(PIInstanceIbmiRDSUsers, powervmdata.SoftwareLicenses.IbmiRDSUsers) + d.Set(PIInstanceIBMiRDSUsers, powervmdata.SoftwareLicenses.IbmiRDSUsers) } else { - d.Set(PIInstanceIbmiRDSUsers, 0) + d.Set(PIInstanceIBMiRDSUsers, 0) } } diff --git a/ibm/service/power/ibm_pi_constants.go b/ibm/service/power/ibm_pi_constants.go index 568a220700..e816440950 100644 --- a/ibm/service/power/ibm_pi_constants.go +++ b/ibm/service/power/ibm_pi_constants.go @@ -280,11 +280,10 @@ const ( Arg_PVMInstanceId = "pi_instance_id" Arg_PVMInstanceActionType = "pi_action" Arg_PVMInstanceHealthStatus = "pi_health_status" - PIInstanceSoftwareLicenses = "pi_software_licenses" - PIInstanceIbmiCSS = "pi_ibmi_css" - PIInstanceIbmiPHA = "pi_ibmi_pha" - PIInstanceIbmiRDS = "pi_ibmi_rds" - PIInstanceIbmiRDSUsers = "pi_ibmi_rds_users" + PIInstanceIBMiCSS = "pi_ibmi_css" + PIInstanceIBMiPHA = "pi_ibmi_pha" + PIInstanceIBMiRDS = "pi_ibmi_rds" + PIInstanceIBMiRDSUsers = "pi_ibmi_rds_users" OS_IBMI = "ibmi" Arg_PIInstanceSharedProcessorPool = "pi_shared_processor_pool" diff --git a/ibm/service/power/resource_ibm_pi_instance.go b/ibm/service/power/resource_ibm_pi_instance.go index 7e75edad6c..a7fb7d815f 100644 --- a/ibm/service/power/resource_ibm_pi_instance.go +++ b/ibm/service/power/resource_ibm_pi_instance.go @@ -353,24 +353,24 @@ func ResourceIBMPIInstance() *schema.Resource { Computed: true, Description: "Minimum Virtual Cores Assigned to the PVMInstance", }, - PIInstanceIbmiCSS: { + PIInstanceIBMiCSS: { Type: schema.TypeBool, Optional: true, Description: "IBMi Cloud Storage Solution", }, - PIInstanceIbmiPHA: { + PIInstanceIBMiPHA: { Type: schema.TypeBool, Optional: true, Description: "IBMi Power High Availability", }, - PIInstanceIbmiRDS: { + PIInstanceIBMiRDS: { Type: schema.TypeBool, Optional: false, Required: false, Computed: true, Description: "IBMi Rational Dev Studio", }, - PIInstanceIbmiRDSUsers: { + PIInstanceIBMiRDSUsers: { Type: schema.TypeInt, Optional: true, Description: "IBMi Rational Dev Studio Number of User Licenses", @@ -537,13 +537,13 @@ func resourceIBMPIInstanceRead(ctx context.Context, d *schema.ResourceData, meta d.Set(helpers.PIInstanceLicenseRepositoryCapacity, powervmdata.LicenseRepositoryCapacity) d.Set(PIInstanceDeploymentType, powervmdata.DeploymentType) if powervmdata.SoftwareLicenses != nil { - d.Set(PIInstanceIbmiCSS, powervmdata.SoftwareLicenses.IbmiCSS) - d.Set(PIInstanceIbmiPHA, powervmdata.SoftwareLicenses.IbmiPHA) - d.Set(PIInstanceIbmiRDS, powervmdata.SoftwareLicenses.IbmiRDS) + d.Set(PIInstanceIBMiCSS, powervmdata.SoftwareLicenses.IbmiCSS) + d.Set(PIInstanceIBMiPHA, powervmdata.SoftwareLicenses.IbmiPHA) + d.Set(PIInstanceIBMiRDS, powervmdata.SoftwareLicenses.IbmiRDS) if *powervmdata.SoftwareLicenses.IbmiRDS { - d.Set(PIInstanceIbmiRDSUsers, powervmdata.SoftwareLicenses.IbmiRDSUsers) + d.Set(PIInstanceIBMiRDSUsers, powervmdata.SoftwareLicenses.IbmiRDSUsers) } else { - d.Set(PIInstanceIbmiRDSUsers, 0) + d.Set(PIInstanceIBMiRDSUsers, 0) } } return nil @@ -801,7 +801,7 @@ func resourceIBMPIInstanceUpdate(ctx context.Context, d *schema.ResourceData, me } } } - if d.HasChanges(PIInstanceIbmiCSS, PIInstanceIbmiPHA, PIInstanceIbmiRDSUsers) { + if d.HasChanges(PIInstanceIBMiCSS, PIInstanceIBMiPHA, PIInstanceIBMiRDSUsers) { if d.Get("status") == "ACTIVE" { log.Printf("the lpar is in the Active state, continuing with update") } else { @@ -812,9 +812,9 @@ func resourceIBMPIInstanceUpdate(ctx context.Context, d *schema.ResourceData, me } sl := &models.SoftwareLicenses{} - sl.IbmiCSS = flex.PtrToBool(d.Get(PIInstanceIbmiCSS).(bool)) - sl.IbmiPHA = flex.PtrToBool(d.Get(PIInstanceIbmiPHA).(bool)) - ibmrdsUsers := d.Get(PIInstanceIbmiRDSUsers).(int) + sl.IbmiCSS = flex.PtrToBool(d.Get(PIInstanceIBMiCSS).(bool)) + sl.IbmiPHA = flex.PtrToBool(d.Get(PIInstanceIBMiPHA).(bool)) + ibmrdsUsers := d.Get(PIInstanceIBMiRDSUsers).(int) if ibmrdsUsers < 0 { return diag.Errorf("request with IBMi Rational Dev Studio property requires IBMi Rational Dev Studio number of users") } @@ -1473,13 +1473,13 @@ func createPVMInstance(d *schema.ResourceData, client *st.IBMPIInstanceClient, i IbmiRDS: &falseBool, IbmiRDSUsers: 0, } - if ibmiCSS, ok := d.GetOk(PIInstanceIbmiCSS); ok { + if ibmiCSS, ok := d.GetOk(PIInstanceIBMiCSS); ok { sl.IbmiCSS = flex.PtrToBool(ibmiCSS.(bool)) } - if ibmiPHA, ok := d.GetOk(PIInstanceIbmiPHA); ok { + if ibmiPHA, ok := d.GetOk(PIInstanceIBMiPHA); ok { sl.IbmiPHA = flex.PtrToBool(ibmiPHA.(bool)) } - if ibmrdsUsers, ok := d.GetOk(PIInstanceIbmiRDSUsers); ok { + if ibmrdsUsers, ok := d.GetOk(PIInstanceIBMiRDSUsers); ok { if ibmrdsUsers.(int) < 0 { return nil, fmt.Errorf("request with IBMi Rational Dev Studio property requires IBMi Rational Dev Studio number of users") } From daaf139189b54d2804c0ad7f9598187d9876fd16 Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Fri, 16 Feb 2024 12:07:35 -0600 Subject: [PATCH 24/25] Fix ibmi documentation --- website/docs/d/pi_instance.html.markdown | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/website/docs/d/pi_instance.html.markdown b/website/docs/d/pi_instance.html.markdown index f3c3fc4cb9..02accecec3 100644 --- a/website/docs/d/pi_instance.html.markdown +++ b/website/docs/d/pi_instance.html.markdown @@ -64,6 +64,12 @@ In addition to all argument reference list, you can access the following attribu - `network_id` - (String) The network ID of the instance. - `network_name` - (String) The network name of the instance. - `type` - (String) The type of the network. + +**Notes** IBMi software licenses for IBMi virtual server instances -- only for IBMi instances +- `pi_ibmi_css` - (Boolean) IBMi Cloud Storage Solution. +- `pi_ibmi_pha` - (Boolean) IBMi Power High Availability. +- `pi_ibmi_rds` - (Boolean) IBMi Rational Dev Studio. +- `pi_ibmi_rds_users` - (Integer) IBMi Rational Dev Studio Number of User Licenses. - `placement_group_id`- (String) The ID of the placement group that the instance is a member. - `processors` - (Float) The number of processors that are allocated to the instance. - `proctype` - (String) The procurement type of the instance. Supported values are `shared` and `dedicated`. @@ -75,9 +81,3 @@ In addition to all argument reference list, you can access the following attribu - `storage_type` - (String) The storage type where server is deployed. - `virtual_cores_assigned` - (Integer) The virtual cores that are assigned to the instance. - `volumes` - (List of strings) The list of volume IDs that are attached to the instance. - - **Notes** Ibmi software licenses for IBMi virtual server instances -- only for IBMi instances -- `pi_ibmi_css` - (Boolean) IBMi Cloud Storage Solution. -- `pi_ibmi_pha` - (Boolean) IBMi Power High Availability. -- `pi_ibmi_rds` - (Boolean) IBMi Rational Dev Studio. -- `pi_ibmi_rds_users` - (Integer) IBMi Rational Dev Studio Number of User Licenses. From ed52a74335e1896f6639652b5bd4339c92a7ab14 Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Mon, 19 Feb 2024 11:10:22 -0600 Subject: [PATCH 25/25] Separate ibmi attribute in data source form ibmi argument in resource --- .../power/data_source_ibm_pi_instance.go | 18 +++++------ ibm/service/power/ibm_pi_constants.go | 11 ++++--- ibm/service/power/resource_ibm_pi_instance.go | 32 +++++++++---------- website/docs/d/pi_instance.html.markdown | 11 ++++--- website/docs/r/pi_instance.html.markdown | 5 +-- 5 files changed, 41 insertions(+), 36 deletions(-) diff --git a/ibm/service/power/data_source_ibm_pi_instance.go b/ibm/service/power/data_source_ibm_pi_instance.go index c490e07c0a..0c77d7a78a 100644 --- a/ibm/service/power/data_source_ibm_pi_instance.go +++ b/ibm/service/power/data_source_ibm_pi_instance.go @@ -162,22 +162,22 @@ func DataSourceIBMPIInstance() *schema.Resource { Type: schema.TypeString, Computed: true, }, - PIInstanceIBMiCSS: { + Attr_IBMiCSS: { Type: schema.TypeBool, Computed: true, Description: "IBMi Cloud Storage Solution", }, - PIInstanceIBMiPHA: { + Attr_IBMiPHA: { Type: schema.TypeBool, Computed: true, Description: "IBMi Power High Availability", }, - PIInstanceIBMiRDS: { + Attr_IBMiRDS: { Type: schema.TypeBool, Computed: true, Description: "IBMi Rational Dev Studio", }, - PIInstanceIBMiRDSUsers: { + Attr_IBMiRDSUsers: { Type: schema.TypeInt, Computed: true, Description: "IBMi Rational Dev Studio Number of User Licenses", @@ -235,13 +235,13 @@ func dataSourceIBMPIInstancesRead(ctx context.Context, d *schema.ResourceData, m } if powervmdata.SoftwareLicenses != nil { - d.Set(PIInstanceIBMiCSS, powervmdata.SoftwareLicenses.IbmiCSS) - d.Set(PIInstanceIBMiPHA, powervmdata.SoftwareLicenses.IbmiPHA) - d.Set(PIInstanceIBMiRDS, powervmdata.SoftwareLicenses.IbmiRDS) + d.Set(Attr_IBMiCSS, powervmdata.SoftwareLicenses.IbmiCSS) + d.Set(Attr_IBMiPHA, powervmdata.SoftwareLicenses.IbmiPHA) + d.Set(Attr_IBMiRDS, powervmdata.SoftwareLicenses.IbmiRDS) if *powervmdata.SoftwareLicenses.IbmiRDS { - d.Set(PIInstanceIBMiRDSUsers, powervmdata.SoftwareLicenses.IbmiRDSUsers) + d.Set(Attr_IBMiRDSUsers, powervmdata.SoftwareLicenses.IbmiRDSUsers) } else { - d.Set(PIInstanceIBMiRDSUsers, 0) + d.Set(Attr_IBMiRDSUsers, 0) } } diff --git a/ibm/service/power/ibm_pi_constants.go b/ibm/service/power/ibm_pi_constants.go index e816440950..c252378050 100644 --- a/ibm/service/power/ibm_pi_constants.go +++ b/ibm/service/power/ibm_pi_constants.go @@ -280,10 +280,13 @@ const ( Arg_PVMInstanceId = "pi_instance_id" Arg_PVMInstanceActionType = "pi_action" Arg_PVMInstanceHealthStatus = "pi_health_status" - PIInstanceIBMiCSS = "pi_ibmi_css" - PIInstanceIBMiPHA = "pi_ibmi_pha" - PIInstanceIBMiRDS = "pi_ibmi_rds" - PIInstanceIBMiRDSUsers = "pi_ibmi_rds_users" + Arg_IBMiCSS = "pi_ibmi_css" + Arg_IBMiPHA = "pi_ibmi_pha" + Arg_IBMiRDSUsers = "pi_ibmi_rds_users" + Attr_IBMiCSS = "ibmi_css" + Attr_IBMiPHA = "ibmi_pha" + Attr_IBMiRDS = "ibmi_rds" + Attr_IBMiRDSUsers = "ibmi_rds_users" OS_IBMI = "ibmi" Arg_PIInstanceSharedProcessorPool = "pi_shared_processor_pool" diff --git a/ibm/service/power/resource_ibm_pi_instance.go b/ibm/service/power/resource_ibm_pi_instance.go index a7fb7d815f..5fb5f876fd 100644 --- a/ibm/service/power/resource_ibm_pi_instance.go +++ b/ibm/service/power/resource_ibm_pi_instance.go @@ -353,24 +353,24 @@ func ResourceIBMPIInstance() *schema.Resource { Computed: true, Description: "Minimum Virtual Cores Assigned to the PVMInstance", }, - PIInstanceIBMiCSS: { + Arg_IBMiCSS: { Type: schema.TypeBool, Optional: true, Description: "IBMi Cloud Storage Solution", }, - PIInstanceIBMiPHA: { + Arg_IBMiPHA: { Type: schema.TypeBool, Optional: true, Description: "IBMi Power High Availability", }, - PIInstanceIBMiRDS: { + Attr_IBMiRDS: { Type: schema.TypeBool, Optional: false, Required: false, Computed: true, Description: "IBMi Rational Dev Studio", }, - PIInstanceIBMiRDSUsers: { + Arg_IBMiRDSUsers: { Type: schema.TypeInt, Optional: true, Description: "IBMi Rational Dev Studio Number of User Licenses", @@ -537,13 +537,13 @@ func resourceIBMPIInstanceRead(ctx context.Context, d *schema.ResourceData, meta d.Set(helpers.PIInstanceLicenseRepositoryCapacity, powervmdata.LicenseRepositoryCapacity) d.Set(PIInstanceDeploymentType, powervmdata.DeploymentType) if powervmdata.SoftwareLicenses != nil { - d.Set(PIInstanceIBMiCSS, powervmdata.SoftwareLicenses.IbmiCSS) - d.Set(PIInstanceIBMiPHA, powervmdata.SoftwareLicenses.IbmiPHA) - d.Set(PIInstanceIBMiRDS, powervmdata.SoftwareLicenses.IbmiRDS) + d.Set(Arg_IBMiCSS, powervmdata.SoftwareLicenses.IbmiCSS) + d.Set(Arg_IBMiPHA, powervmdata.SoftwareLicenses.IbmiPHA) + d.Set(Attr_IBMiRDS, powervmdata.SoftwareLicenses.IbmiRDS) if *powervmdata.SoftwareLicenses.IbmiRDS { - d.Set(PIInstanceIBMiRDSUsers, powervmdata.SoftwareLicenses.IbmiRDSUsers) + d.Set(Arg_IBMiRDSUsers, powervmdata.SoftwareLicenses.IbmiRDSUsers) } else { - d.Set(PIInstanceIBMiRDSUsers, 0) + d.Set(Arg_IBMiRDSUsers, 0) } } return nil @@ -801,7 +801,7 @@ func resourceIBMPIInstanceUpdate(ctx context.Context, d *schema.ResourceData, me } } } - if d.HasChanges(PIInstanceIBMiCSS, PIInstanceIBMiPHA, PIInstanceIBMiRDSUsers) { + if d.HasChanges(Arg_IBMiCSS, Arg_IBMiPHA, Arg_IBMiRDSUsers) { if d.Get("status") == "ACTIVE" { log.Printf("the lpar is in the Active state, continuing with update") } else { @@ -812,9 +812,9 @@ func resourceIBMPIInstanceUpdate(ctx context.Context, d *schema.ResourceData, me } sl := &models.SoftwareLicenses{} - sl.IbmiCSS = flex.PtrToBool(d.Get(PIInstanceIBMiCSS).(bool)) - sl.IbmiPHA = flex.PtrToBool(d.Get(PIInstanceIBMiPHA).(bool)) - ibmrdsUsers := d.Get(PIInstanceIBMiRDSUsers).(int) + sl.IbmiCSS = flex.PtrToBool(d.Get(Arg_IBMiCSS).(bool)) + sl.IbmiPHA = flex.PtrToBool(d.Get(Arg_IBMiPHA).(bool)) + ibmrdsUsers := d.Get(Arg_IBMiRDSUsers).(int) if ibmrdsUsers < 0 { return diag.Errorf("request with IBMi Rational Dev Studio property requires IBMi Rational Dev Studio number of users") } @@ -1473,13 +1473,13 @@ func createPVMInstance(d *schema.ResourceData, client *st.IBMPIInstanceClient, i IbmiRDS: &falseBool, IbmiRDSUsers: 0, } - if ibmiCSS, ok := d.GetOk(PIInstanceIBMiCSS); ok { + if ibmiCSS, ok := d.GetOk(Arg_IBMiCSS); ok { sl.IbmiCSS = flex.PtrToBool(ibmiCSS.(bool)) } - if ibmiPHA, ok := d.GetOk(PIInstanceIBMiPHA); ok { + if ibmiPHA, ok := d.GetOk(Arg_IBMiPHA); ok { sl.IbmiPHA = flex.PtrToBool(ibmiPHA.(bool)) } - if ibmrdsUsers, ok := d.GetOk(PIInstanceIBMiRDSUsers); ok { + if ibmrdsUsers, ok := d.GetOk(Arg_IBMiRDSUsers); ok { if ibmrdsUsers.(int) < 0 { return nil, fmt.Errorf("request with IBMi Rational Dev Studio property requires IBMi Rational Dev Studio number of users") } diff --git a/website/docs/d/pi_instance.html.markdown b/website/docs/d/pi_instance.html.markdown index 02accecec3..590cc12fbd 100644 --- a/website/docs/d/pi_instance.html.markdown +++ b/website/docs/d/pi_instance.html.markdown @@ -46,6 +46,12 @@ In addition to all argument reference list, you can access the following attribu - `deployment_type` - (String) The custom deployment type. - `health_status` - (String) The health of the instance. + +**Notes** IBMi software licenses for IBMi virtual server instances -- only for IBMi instances +- `ibmi_css` - (Boolean) IBMi Cloud Storage Solution. +- `ibmi_pha` - (Boolean) IBMi Power High Availability. +- `ibmi_rds` - (Boolean) IBMi Rational Dev Studio. +- `ibmi_rds_users` - (Integer) IBMi Rational Dev Studio Number of User Licenses. - `id` - (String) The unique identifier of the instance. - `license_repository_capacity` - The VTL license repository capacity TB value. Only available with VTL instances. - `memory` - (Float) The amount of memory that is allocated to the instance. @@ -65,11 +71,6 @@ In addition to all argument reference list, you can access the following attribu - `network_name` - (String) The network name of the instance. - `type` - (String) The type of the network. -**Notes** IBMi software licenses for IBMi virtual server instances -- only for IBMi instances -- `pi_ibmi_css` - (Boolean) IBMi Cloud Storage Solution. -- `pi_ibmi_pha` - (Boolean) IBMi Power High Availability. -- `pi_ibmi_rds` - (Boolean) IBMi Rational Dev Studio. -- `pi_ibmi_rds_users` - (Integer) IBMi Rational Dev Studio Number of User Licenses. - `placement_group_id`- (String) The ID of the placement group that the instance is a member. - `processors` - (Float) The number of processors that are allocated to the instance. - `proctype` - (String) The procurement type of the instance. Supported values are `shared` and `dedicated`. diff --git a/website/docs/r/pi_instance.html.markdown b/website/docs/r/pi_instance.html.markdown index bef5361782..1b79b56f62 100644 --- a/website/docs/r/pi_instance.html.markdown +++ b/website/docs/r/pi_instance.html.markdown @@ -66,7 +66,8 @@ Review the argument references that you can specify for your resource. - `pi_cloud_instance_id` - (Required, String) The GUID of the service instance associated with an account. - `pi_deployment_type` - (Optional, String) Custom deployment type; Allowable value: `EPIC` or `VMNoStorage`. - `pi_health_status` - (Optional, String) Specifies if Terraform should poll for the health status to be `OK` or `WARNING`. The default value is `OK`. - **Notes** Ibmi software licenses for IBMi virtual server instances -- only for IBMi instances. Default to `false` and `0` if no values provided + +**Notes** Ibmi software licenses for IBMi virtual server instances -- only for IBMi instances. Default to `false` and `0` if no values provided - `pi_ibmi_css` - (Optional, Boolean) IBMi Cloud Storage Solution. - `pi_ibmi_pha` - (Optional, Boolean) IBMi Power High Availability. - `pi_ibmi_rds_users` - (Optional, Integer) IBMi Rational Dev Studio Number of User Licenses. @@ -111,6 +112,7 @@ Review the argument references that you can specify for your resource. In addition to all argument reference list, you can access the following attribute reference after your resource is created. - `health_status` - (String) The health status of the VM. +- `ibmi_rds` - (Boolean) IBMi Rational Dev Studio. - `id` - (String) The unique identifier of the instance. The ID is composed of `/`. - `instance_id` - (String) The unique identifier of the instance. - `max_processors`- (Float) The maximum number of processors that can be allocated to the instance with shutting down or rebooting the `LPAR`. @@ -131,7 +133,6 @@ In addition to all argument reference list, you can access the following attribu - `progress` - (Float) - Specifies the overall progress of the instance deployment process in percentage. - `shared_processor_pool_id` - (String) The ID of the shared processor pool for the instance. - `status` - (String) The status of the instance. -- `pi_ibmi_rds` - (Boolean) IBMi Rational Dev Studio. ## Import The `ibm_pi_instance` can be imported using `power_instance_id` and `instance_id`.