Skip to content

Commit

Permalink
VMRM
Browse files Browse the repository at this point in the history
- Add VM no storage to deployment type

Fixed catalog service extensions and values metadata params of workspace ds (#4957)

update CHANGELOG

Bump up version to 1.60.0

feat(Cloud Databases): Database user password complexity validation (#4931)

* feat(Cloud Databases): Database user password complexity validation
* update tests to conform to new complexity rules
* fix password validation edgecases
* add test case for password beginning with special char
* fix regexp
* refactor of db users
* delete and create ops manager users when updating
* validate adminpassword, update docs

Add new service Logs Router to IBM Terraform Provider (#4945)

* Added new service Logs Router to IBM Terraform Provider

* Ran detect-secrets and re-generated secrets.baseline

* Added emptycredentialsError check for Logs Router Client Error

Signed-off-by: Ian Reyes <[email protected]>

* Removed redundant general provider set up information. Fixed Service Subcategories

Signed-off-by: Ian Reyes <[email protected]>

---------

Signed-off-by: Ian Reyes <[email protected]>

add virtual optical device

update err msg

Add missing changes

Update go.mod (#4963)

- Update go.mod: bluemix-go version

Fix IBM i documentation bug (#4969)

* Fix IBM i documentation bug

On several documentation pages, it incorrectly implied that
IBMi was the only usable OS for that resource/data source.

* Update help URLs

Regenerate Projects TF to fix generated doc and samples (#4961)

* fix integration test

* fix integration test

* fix integration test

* fix name

* pr comments

* pr comments

* fix doc

* fix doc

* new version

* new version

* new version

* new version

* update code to the latest SDK level

* fix integration tests

* fix integration tests

* fix integration tests

* fix integration tests

* address PR comment

* typo

* typo

* terraform

* terraform

* terraform

* terraform

* terraform

* terraform

* terraform

* terraform

* terraform

* terraform

* add wait for create and delete

* add wait for create and delete

* .

* fix integration tests

* fix integration tests

* fix integration tests

* fix integration tests

* fix integration tests

* regenerate

* new code generation

* new generated code

* point to latest sdk

* point to latest sdk

* adjust test cases and doc

* adjust samples

* update to latest node sdk

* merge with master

* Update project_instance.html.markdown

Fixing formatting issues

* Update project_event_notification.html.markdown

* Update README.md

* Update variables.tf

* Update project_event_notification.html.markdown

* new version

* terraform

* terraform

* terraform

* terraform

* terraform

* terraform

* terraform

* terraform

* terraform

* terraform

* feat: projects graph fragment pattern

* align with origin/master

* update test cases

* restore README.md and versions.tf to master branch

* remove duplicated entries

* feat: graph fragment pattern poc

* feat: restore definition blocks

* regenerate the terraform code based on latest YAML

* regenerate the terraform code based on latest YAML

* regenerate the terraform code based on latest YAML

* update doc

* update doc

* fix test cases

* commit generated code

* commit fix

* commit fix

* test cases

* test cases

* test cases

* test cases

* updates

* upgrade to latest go sdk

* update generated doc

* update generated code

* updated secrets baseline

* update code to latest API changes

* secrets

* fix secrets

* update samples with real values

* update secrets

* update secrets

* update generated code to the latest API definition

* update secrets baseline

* merge with master

* merge with master

* merge with master

* update code to the latest SDK level

* address some review comments

* address PR comments

* address PR comments

* update to latest sdk level

* update to latest sdk level

* update to latest sdk level

* merge with master

* update to the latest sdk level

* format test case

* regenerate the code with generator fixes

* regenerate code

* fix "inputs" and "settings" properties

---------

Co-authored-by: dvesperini <[email protected]>
Co-authored-by: knee-na <[email protected]>
Co-authored-by: Mark-Kulube <[email protected]>

Removed Logs Router Provider

Signed-off-by: Ian Reyes <[email protected]>

Update pi_user_data to accept string input (#4974)

* Add string support for pi_user_data field in instance creation

* Add new user data test

* Updated pi_user_data documentation

* Remove duplicate import

dependabot: bump actions/setup-go from 4 to 5

Bumps [actions/setup-go](https://github.com/actions/setup-go) from 4 to 5.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](actions/setup-go@v4...v5)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>

new host link endpoint commits (#4970)

* new host link endpoint commits

* add host link agent argument and example. Fixed RHEL7 repos to RHEL8

---------

Co-authored-by: Justin Kanz <[email protected]>

Add mtu and accessConfig flags to subnet create commands for terraform (#4690)

* Add mtu and accessConfig flags to subnet create commands for terraform

* Fix terraform compile errors

* Fix terraform compile error from yaml changes

* Clean up warnings in powervs provider

* Fix bug checking region instead of zone for satellite check

* Hide shared processor pool and IBMi license arguments from being set in satellite location

* Fix typing issues in MTU and access config

Three issues here:
- There is no schema.TypeInt64, so I have to set this field to schema.TypeInt.
Pretend this value is an int and then cast it back to an int64. This an
issue with the terraform sdk.
- I accidentally set schema.Int on access config where it should be
schema.TypeString
- All passed in variables by the user need to be set or else the sdk
and/or service broker can't safeguard against bad values correctly

* Update new network field satellite documentation

* Revert nullable name change

Due to incompatibility between to the two service brokers,
this change has to be undone to maintain consistency.

* Update go mod files for new sdk version

* Add satellite network acceptance test

* Update mtu and jumbo descriptions

* Add access-config validation to terraform

feat: add new service mqcloud

Service Credentials secret addition (#4926)

* SC addition

* SC addition

* SC addition

* update function updated

* SC unit tests added

* SC unit tests added

* d

* tests fixes

* tests fixes

* update sdk

* .secrets.baseline update

* .secrets.baseline update

* .secrets.baseline update

* Update sm_service_credentials_secret_metadata.html.markdown

---------

Co-authored-by: Yonathan-Yellin <[email protected]>
Co-authored-by: Avi Ribchinsky <[email protected]>
Co-authored-by: Tatyana <[email protected]>
Co-authored-by: Idan Adar <[email protected]>

Feature is snapshot consistency group and Migration PR (#4973)

* GO-SDK Updated

* ibm_is_snapshot_consistency_group development

* Consistency Group changes to Snapshot

* Documentation changes for snapshot

* SDK changes

* Bankup Policy Jobs Changes

* included_content  development

* match_resource_type development

* Implemented Documentation Fix

* PR review comments incorporated

* SDK update

* Updated to released SDK

Fix typo in filename

fix detect secret marking false positive

feat(Cloud Databases): Redis Database User RBAC support (#4982)

Update version to 1.5.6

fix(Cloud Databases): fix Unwrap return value for go 1.18 compat (#4991)

Signed-off-by: Alex Hemard <[email protected]>

Address comments

update power version

update issue fixed ibm_is_subnet_reserved_ip (#4988)

Adding Flexible IOPS (#4992)

* - Add IOPs to volume
- Update documentation
- Make strorageType required for COS import
- Update Volume Create Disk Type Required
- Update Create Instance Storeage Type to Required
- vol_upd_iops_level

* Update version to 1.5.6

* update documentation

* update power version

---------

Co-authored-by: michael kad <michaelkad>

Removing Support For Power VPN Create (#4993)

* Add Deprectated for VPN Create

* Update text

* Update version to 1.5.6

* Update version to 1.5.6

* update power version

---------

Co-authored-by: michael kad <michaelkad>

Feature(share-crr): Share cross region replication (#4995)

* feature(share-crr): Share cross region replication

* sdk updates

* updated last sync options

* updated sdk and latest_sync

* updated schema and doc

* tf example

* doc and schema correction

* acceptance test

* sdk changes

* updated sdk

* added nil check

* doc link added

* remove common folder sdk

* doc update

Add variable to ok

address review comments

dependabot: bump golang.org/x/crypto from 0.16.0 to 0.17.0

Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.16.0 to 0.17.0.
- [Commits](golang/crypto@v0.16.0...v0.17.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>

Enhancement: Added operating system attributes to is images data sources (#4998)

* Enhancement: Added operating system attributes to is images data sources

* set the values

* test and doc changes

added enhancement to one step delegate resolver in is_vpc

resolved delete issue for the floated nics on bm server

Bump up versio to 1.61.0-beta0

Regenerate projects provider based off the latest go sdk (#5003)

* new version

* new version

* new version

* update code to the latest SDK level

* fix integration tests

* fix integration tests

* fix integration tests

* fix integration tests

* address PR comment

* typo

* typo

* terraform

* terraform

* terraform

* terraform

* terraform

* terraform

* terraform

* terraform

* terraform

* terraform

* add wait for create and delete

* add wait for create and delete

* .

* fix integration tests

* fix integration tests

* fix integration tests

* fix integration tests

* fix integration tests

* regenerate

* new code generation

* new generated code

* point to latest sdk

* point to latest sdk

* adjust test cases and doc

* adjust samples

* update to latest node sdk

* merge with master

* Update project_instance.html.markdown

Fixing formatting issues

* Update project_event_notification.html.markdown

* Update README.md

* Update variables.tf

* Update project_event_notification.html.markdown

* new version

* terraform

* terraform

* terraform

* terraform

* terraform

* terraform

* terraform

* terraform

* terraform

* terraform

* feat: projects graph fragment pattern

* align with origin/master

* update test cases

* restore README.md and versions.tf to master branch

* remove duplicated entries

* feat: graph fragment pattern poc

* feat: restore definition blocks

* regenerate the terraform code based on latest YAML

* regenerate the terraform code based on latest YAML

* regenerate the terraform code based on latest YAML

* update doc

* update doc

* fix test cases

* commit generated code

* commit fix

* commit fix

* test cases

* test cases

* test cases

* test cases

* updates

* upgrade to latest go sdk

* update generated doc

* update generated code

* updated secrets baseline

* update code to latest API changes

* secrets

* fix secrets

* update samples with real values

* update secrets

* update secrets

* update generated code to the latest API definition

* update secrets baseline

* merge with master

* merge with master

* merge with master

* update code to the latest SDK level

* address some review comments

* address PR comments

* address PR comments

* update to latest sdk level

* update to latest sdk level

* update to latest sdk level

* merge with master

* update to the latest sdk level

* format test case

* regenerate the code with generator fixes

* regenerate code

* fix "inputs" and "settings" properties

* regenerated doc and samples

* fix samples

* terraform

* terraform

* terraform

* terraform

* terraform

---------

Co-authored-by: dvesperini <[email protected]>
Co-authored-by: knee-na <[email protected]>
Co-authored-by: Mark-Kulube <[email protected]>

Feature(vpc Advertise routes): Support route advertising in vpc (#5005)

* added advertised route support

* doc updates for routing table/s

* Change advertise_routes_to from List to HashSet and modify create, update and read methods accordingly

* Add latest generated go sdk

* update with latest sdk

* add beta maturity to sdk

* corrected docs as per review comment

* updated go mod

* Update resource_ibm_is_bare_metal_server.go

* rm common

---------

Co-authored-by: Bhavesh Shrivastav <[email protected]>
Co-authored-by: Ujjwal Kumar <[email protected]>

Bugs fixes for Secrets Manager (#5008)

* SC addition

* SC addition

* SC addition

* update function updated

* SC unit tests added

* SC unit tests added

* d

* tests fixes

* tests fixes

* update sdk

* .secrets.baseline update

* .secrets.baseline update

* .secrets.baseline update

* Update sm_service_credentials_secret_metadata.html.markdown

* bugs fixes

* bugs fixes

* bugs fixes

---------

Co-authored-by: Yonathan-Yellin <[email protected]>
Co-authored-by: Avi Ribchinsky <[email protected]>
Co-authored-by: Tatyana <[email protected]>
Co-authored-by: Idan Adar <[email protected]>

dependabot: bump crazy-max/ghaction-import-gpg from 6.0.0 to 6.1.0

Bumps [crazy-max/ghaction-import-gpg](https://github.com/crazy-max/ghaction-import-gpg) from 6.0.0 to 6.1.0.
- [Release notes](https://github.com/crazy-max/ghaction-import-gpg/releases)
- [Commits](crazy-max/ghaction-import-gpg@v6.0.0...v6.1.0)

---
updated-dependencies:
- dependency-name: crazy-max/ghaction-import-gpg
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

fix: add multipart support for mqcloud service (#5010)

* fix: multipart fix for mqcloud

(cherry picked from commit e7253421db30943d3582ce07d9504a2117f30ce1)

* enable enforceReservedDeploymentPlan

---------

Co-authored-by: Shuaib Bapputty <[email protected]>

added a nil check for boottarget of bms

Delete wait logic changes

Changes wrt latest schematics sdk

Revert VPN Changes, will go in at end Q1

SM docs bug fix (#5018)

* SC addition

* SC addition

* SC addition

* update function updated

* SC unit tests added

* SC unit tests added

* d

* tests fixes

* tests fixes

* update sdk

* .secrets.baseline update

* .secrets.baseline update

* .secrets.baseline update

* Update sm_service_credentials_secret_metadata.html.markdown

* bugs fixes

* bugs fixes

* bugs fixes

* docs bugs fixes

---------

Co-authored-by: Yonathan-Yellin <[email protected]>
Co-authored-by: Avi Ribchinsky <[email protected]>
Co-authored-by: Tatyana <[email protected]>
Co-authored-by: Idan Adar <[email protected]>

fix(docs): UI-33634: mention correct image name in image data source example

Bump up version to 1.61.0

update go version to 1.19

CD scc doc updates

Latest SCC description updates

dependabot: bump github.com/cloudflare/circl from 1.3.3 to 1.3.7

Bumps [github.com/cloudflare/circl](https://github.com/cloudflare/circl) from 1.3.3 to 1.3.7.
- [Release notes](https://github.com/cloudflare/circl/releases)
- [Commits](cloudflare/circl@v1.3.3...v1.3.7)

---
updated-dependencies:
- dependency-name: github.com/cloudflare/circl
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Fix mtu requirement bug

There a bug with the MTU field in terraform where ExactlyOneOf
requires Jumbo or MTU to be set, but the intent was to allow
at most one of those fields to be set, but are optional.

Add satellite features and add support to the user can direct which security groups are added to their workers

Add volume clone resource and data source (#5019)

* Add volume clone resource and data source

* Docs improved

* power-go-client update in go.mod

* feedback resolved

* testcase func renamed

* Resolved conflicts

* feedback resolved renamed targetReplicationEnabled to replicationEnabled

* Alphabetically sorted documentation attributes.

* Improved minor naming convention & docs

* Added some use case scenarios

* Feedback resolved

* Fix: Document formatting

* Making use of the correct cloudInstanceId constant

add resource instance sample config code part in the website doc

listing all the connection for transit gateway over the pagination set

SCC Update Jan 2024 (#5032)

* init commit

* Updates:

- Added ENV_VARS needed to run ACC tests
- Added a validator for the resource scc_instance_settings
- Allow the ability for the scc_instance_settings to be imported
- Completed the functional testing for resource
  ibm_scc_instance_settings
- Added documentation for scc_instance
- Added documentation for scc_instance_settings

* adding updates to scc_instance docs

* Changed the format of the website documentation

* Change the details of the NOTE for scc_instance

* Modifying scc test runs

---------

Co-authored-by: Timothy-Yao <[email protected]>

fix(vpc-routing-table): support removing of  advertise routes and accept routes from array (#5039)

* fix(vpc-routing-table): support removing of  advertise routes and accept routes from arrays

* updated test cases

Projects issue #2672 - "Terraform sees inputs as changed when they have not" (#5042)

* typo

* typo

* terraform

* terraform

* terraform

* terraform

* terraform

* terraform

* terraform

* terraform

* terraform

* terraform

* add wait for create and delete

* add wait for create and delete

* .

* fix integration tests

* fix integration tests

* fix integration tests

* fix integration tests

* fix integration tests

* regenerate

* new code generation

* new generated code

* point to latest sdk

* point to latest sdk

* adjust test cases and doc

* adjust samples

* update to latest node sdk

* merge with master

* Update project_instance.html.markdown

Fixing formatting issues

* Update project_event_notification.html.markdown

* Update README.md

* Update variables.tf

* Update project_event_notification.html.markdown

* new version

* terraform

* terraform

* terraform

* terraform

* terraform

* terraform

* terraform

* terraform

* terraform

* terraform

* feat: projects graph fragment pattern

* align with origin/master

* update test cases

* restore README.md and versions.tf to master branch

* remove duplicated entries

* feat: graph fragment pattern poc

* feat: restore definition blocks

* regenerate the terraform code based on latest YAML

* regenerate the terraform code based on latest YAML

* regenerate the terraform code based on latest YAML

* update doc

* update doc

* fix test cases

* commit generated code

* commit fix

* commit fix

* test cases

* test cases

* test cases

* test cases

* updates

* upgrade to latest go sdk

* update generated doc

* update generated code

* updated secrets baseline

* update code to latest API changes

* secrets

* fix secrets

* update samples with real values

* update secrets

* update secrets

* update generated code to the latest API definition

* update secrets baseline

* merge with master

* merge with master

* merge with master

* update code to the latest SDK level

* address some review comments

* address PR comments

* address PR comments

* update to latest sdk level

* update to latest sdk level

* update to latest sdk level

* merge with master

* update to the latest sdk level

* format test case

* regenerate the code with generator fixes

* regenerate code

* fix "inputs" and "settings" properties

* regenerated doc and samples

* fix samples

* terraform

* terraform

* terraform

* terraform

* terraform

* fix marshal strings

* secrets

* resolve conflicts

---------

Co-authored-by: knee-na <[email protected]>
Co-authored-by: Mark-Kulube <[email protected]>

added a nil check on data source of bm servers

Soft remove the datasources for secretManager v1

Schematics agent related fixes for GA (#5041)

* increased timeout of agent deploy to 30min

* Fix for agent and policy tags crash issue

* removed x-feature-agents header references

* added refresh_token for agent update

* Updated agent resource doc with latest

* enchanced agent update

* Modified wait logic of agent deploy with latest agent status code

* Minor edits to agent testcases

support parameters for resource instance datasource

remove forcenew from workerpool fields in cluster resource and added ApplyOnce (#4955)

* remove forcenew from workerpool fields in cluster resource and added ApplyOnce

* doc update

* remove ForceNew lines, added ApplyOnce in vpc taints, Doc Update

* import on create

* log and error change

* remove some deprecated code, updated create and update funcs.

* id vars

* tains not availble in read, no point making it computed

* remove irrelevant update for worker_num in doc related to applyonce

* review comments and vpc testcase

* test import_on_create in classic

* Update ibm/service/kubernetes/resource_ibm_container_vpc_worker_pool.go

Co-authored-by: Zoltán Illés <[email protected]>

* Update ibm/service/kubernetes/resource_ibm_container_vpc_worker_pool.go

Co-authored-by: Zoltán Illés <[email protected]>

* review

* Update ibm/service/kubernetes/resource_ibm_container_vpc_cluster.go

Co-authored-by: Zoltán Illés <[email protected]>

* Update ibm/service/kubernetes/resource_ibm_container_vpc_cluster.go

Co-authored-by: Zoltán Illés <[email protected]>

* Update ibm/service/kubernetes/resource_ibm_container_vpc_cluster.go

Co-authored-by: Zoltán Illés <[email protected]>

* labels apply once in classic cluster resource

* more test steps for classic wp

* more test steps for vpc wp

* kms in create cluster

* comment header year

* conflict fix

* call update after create terrafrom to apply rest of the modifications

* update after cluster creation

* remove enable kms from create, as it is present in update too

---------

Co-authored-by: Zoltán Illés <[email protected]>

Update terraform example (#5050)

* Update powervs terraform example with workspace creation

* Update workspace creation construct

* Update datacenter location comment

* Remove explicit depends on text from example

SM fixes (#5045)

* SC addition

* SC addition

* SC addition

* update function updated

* SC unit tests added

* SC unit tests added

* d

* tests fixes

* tests fixes

* update sdk

* .secrets.baseline update

* .secrets.baseline update

* .secrets.baseline update

* Update sm_service_credentials_secret_metadata.html.markdown

* bugs fixes

* bugs fixes

* bugs fixes

* docs bugs fixes

* preferred_chain added for public cert lets encrypt configuration

* support for creating secret version for username password & version_custom_metadata for all

* support for creating secret version for username password & version_custom_metadata for all

* support for creating secret version for username password & version_custom_metadata for all

* support for creating secret version for username password & version_custom_metadata for all

* support for creating secret version for username password & version_custom_metadata for all

* support for creating secret version for username password & version_custom_metadata for all

---------

Co-authored-by: Yonathan-Yellin <[email protected]>
Co-authored-by: Avi Ribchinsky <[email protected]>
Co-authored-by: Tatyana <[email protected]>
Co-authored-by: Idan Adar <[email protected]>

Bump up version to 1.62.0-beta0

add isWaitForPIInstanceShutoff

modify update vopt
  • Loading branch information
michaelkad committed Jan 23, 2024
1 parent 6a8f00c commit e7ab1a1
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 84 deletions.
2 changes: 2 additions & 0 deletions ibm/service/power/ibm_pi_constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,6 @@ const (
PIWorkspaceDatacenter = "pi_datacenter"
PIWorkspaceResourceGroup = "pi_resource_group_id"
PIWorkspacePlan = "pi_plan"

PIVirtualOpticalDevice = "pi_virtual_optical_device"
)
106 changes: 89 additions & 17 deletions ibm/service/power/resource_ibm_pi_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,10 @@ func ResourceIBMPIInstance() *schema.Resource {
Description: "Memory size",
},
PIInstanceDeploymentType: {
Type: schema.TypeString,
Optional: true,
Description: "Custom Deployment Type Information",
Type: schema.TypeString,
Optional: true,
ValidateFunc: validate.ValidateAllowedStringValues([]string{"EPIC", "VMNoStorage"}),
Description: "Custom Deployment Type Information",
},
PISAPInstanceProfileID: {
Type: schema.TypeString,
Expand All @@ -275,6 +276,12 @@ func ResourceIBMPIInstance() *schema.Resource {
Optional: true,
Description: "Custom SAP Deployment Type Information",
},
PIVirtualOpticalDevice: {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validate.ValidateAllowedStringValues([]string{"attach"}),
Description: "Virtual Machine's Cloud Initialization Virtual Optical Device",
},
helpers.PIInstanceSystemType: {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -385,10 +392,18 @@ func resourceIBMPIInstanceCreate(ctx context.Context, d *schema.ResourceData, me
d.SetId(fmt.Sprintf("%s/%s", cloudInstanceID, *(*pvmList)[0].PvmInstanceID))

for _, s := range *pvmList {
_, err = isWaitForPIInstanceAvailable(ctx, client, *s.PvmInstanceID, instanceReadyStatus)
if err != nil {
return diag.FromErr(err)
if dt, ok := d.GetOk(PIInstanceDeploymentType); ok && dt.(string) == "VMNoStorage" {
_, err = isWaitForPIInstanceShutoff(ctx, client, *s.PvmInstanceID, instanceReadyStatus)
if err != nil {
return diag.FromErr(err)
}
} else {
_, err = isWaitForPIInstanceAvailable(ctx, client, *s.PvmInstanceID, instanceReadyStatus)
if err != nil {
return diag.FromErr(err)
}
}

}

// If Storage Pool Affinity is given as false we need to update the vm instance.
Expand All @@ -407,6 +422,20 @@ func resourceIBMPIInstanceCreate(ctx context.Context, d *schema.ResourceData, me
}
}
}
// If virtual optical device provided then update cloud initialization
if vod, ok := d.GetOk(PIVirtualOpticalDevice); ok {
for _, s := range *pvmList {
body := &models.PVMInstanceUpdate{
CloudInitialization: &models.CloudInitialization{
VirtualOpticalDevice: vod.(string),
},
}
_, err = client.Update(*s.PvmInstanceID, body)
if err != nil {
return diag.FromErr(err)
}
}
}

return resourceIBMPIInstanceRead(ctx, d, meta)

Expand Down Expand Up @@ -440,7 +469,7 @@ func resourceIBMPIInstanceRead(ctx context.Context, d *schema.ResourceData, meta
}
d.Set("min_processors", powervmdata.Minproc)
d.Set(helpers.PIInstanceProgress, powervmdata.Progress)
if powervmdata.StorageType != nil {
if powervmdata.StorageType != nil && *powervmdata.StorageType != "" {
d.Set(helpers.PIInstanceStorageType, powervmdata.StorageType)
}
d.Set(PIInstanceStoragePool, powervmdata.StoragePool)
Expand Down Expand Up @@ -482,9 +511,7 @@ func resourceIBMPIInstanceRead(ctx context.Context, d *schema.ResourceData, meta
d.Set("max_memory", powervmdata.Maxmem)
d.Set("pin_policy", powervmdata.PinPolicy)
d.Set("operating_system", powervmdata.OperatingSystem)
if powervmdata.OsType != nil {
d.Set("os_type", powervmdata.OsType)
}
d.Set("os_type", powervmdata.OsType)

if powervmdata.Health != nil {
d.Set("health_status", powervmdata.Health.Status)
Expand All @@ -495,7 +522,7 @@ func resourceIBMPIInstanceRead(ctx context.Context, d *schema.ResourceData, meta
d.Set("min_virtual_cores", powervmdata.VirtualCores.Min)
}
d.Set(helpers.PIInstanceLicenseRepositoryCapacity, powervmdata.LicenseRepositoryCapacity)
d.Set(PIInstanceDeploymentType, powervmdata.DeploymentType)

return nil
}

Expand Down Expand Up @@ -531,13 +558,17 @@ func resourceIBMPIInstanceUpdate(ctx context.Context, d *schema.ResourceData, me
}
cores_enabled := checkCloudInstanceCapability(cloudInstance, CUSTOM_VIRTUAL_CORES)

if d.HasChange(helpers.PIInstanceName) {
body := &models.PVMInstanceUpdate{
ServerName: name,
if d.HasChanges(helpers.PIInstanceName, PIVirtualOpticalDevice) {
body := &models.PVMInstanceUpdate{}
if d.HasChange(helpers.PIInstanceName) {
body.ServerName = name
}
if d.HasChange(PIVirtualOpticalDevice) {
body.CloudInitialization.VirtualOpticalDevice = d.Get(PIVirtualOpticalDevice).(string)
}
_, err = client.Update(instanceID, body)
if err != nil {
return diag.Errorf("failed to update the lpar with the change for name: %v", err)
return diag.Errorf("failed to update the lpar: %v", err)
}
_, err = isWaitForPIInstanceAvailable(ctx, client, instanceID, "OK")
if err != nil {
Expand Down Expand Up @@ -754,7 +785,6 @@ func resourceIBMPIInstanceUpdate(ctx context.Context, d *schema.ResourceData, me
}
}
}

return resourceIBMPIInstanceRead(ctx, d, meta)

}
Expand Down Expand Up @@ -822,7 +852,7 @@ func isWaitForPIInstanceAvailable(ctx context.Context, client *st.IBMPIInstanceC

stateConf := &resource.StateChangeConf{
Pending: []string{"PENDING", helpers.PIInstanceBuilding, helpers.PIInstanceHealthWarning},
Target: []string{helpers.PIInstanceAvailable, helpers.PIInstanceHealthOk, "ERROR", ""},
Target: []string{helpers.PIInstanceAvailable, helpers.PIInstanceHealthOk, "ERROR", "", "SHUTOFF"},
Refresh: isPIInstanceRefreshFunc(client, id, instanceReadyStatus),
Delay: 30 * time.Second,
MinTimeout: queryTimeOut,
Expand Down Expand Up @@ -856,6 +886,48 @@ func isPIInstanceRefreshFunc(client *st.IBMPIInstanceClient, id, instanceReadySt
}
}

func isWaitForPIInstanceShutoff(ctx context.Context, client *st.IBMPIInstanceClient, id string, instanceReadyStatus string) (interface{}, error) {
log.Printf("Waiting for PIInstance (%s) to be shutoff and health active ", id)

queryTimeOut := activeTimeOut
if instanceReadyStatus == helpers.PIInstanceHealthWarning {
queryTimeOut = warningTimeOut
}

stateConf := &resource.StateChangeConf{
Pending: []string{StatusPending, helpers.PIInstanceBuilding, helpers.PIInstanceHealthWarning},
Target: []string{helpers.PIInstanceHealthOk, StatusError, "", StatusShutoff},
Refresh: isPIInstanceShutoffRefreshFunc(client, id, instanceReadyStatus),
Delay: 30 * time.Second,
MinTimeout: queryTimeOut,
Timeout: 120 * time.Minute,
}

return stateConf.WaitForStateContext(ctx)
}
func isPIInstanceShutoffRefreshFunc(client *st.IBMPIInstanceClient, id, instanceReadyStatus string) resource.StateRefreshFunc {
return func() (interface{}, string, error) {

pvm, err := client.Get(id)
if err != nil {
return nil, "", err
}
if *pvm.Status == StatusShutoff && (pvm.Health.Status == instanceReadyStatus || pvm.Health.Status == helpers.PIInstanceHealthOk) {
return pvm, StatusShutoff, nil
}
if *pvm.Status == StatusError {
if pvm.Fault != nil {
err = fmt.Errorf("failed to create the lpar: %s", pvm.Fault.Message)
} else {
err = fmt.Errorf("failed to create the lpar")
}
return pvm, *pvm.Status, err
}

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)
Expand Down
91 changes: 25 additions & 66 deletions ibm/service/power/resource_ibm_pi_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,48 +64,7 @@ func testAccCheckIBMPIInstanceConfig(name, instanceHealthStatus string) string {
`, acc.Pi_cloud_instance_id, name, acc.Pi_image, acc.Pi_network_name, instanceHealthStatus, acc.PiStorageType)
}

func testAccCheckIBMPIInstanceUserDataConfig(name, instanceHealthStatus string) 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_image_name = "%[3]s"
pi_cloud_instance_id = "%[1]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_volume_size = 20
pi_volume_name = "%[2]s"
pi_volume_shareable = true
pi_volume_pool = data.ibm_pi_image.power_image.storage_pool
pi_cloud_instance_id = "%[1]s"
}
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_user_data = "this is test user data"
}
`, acc.Pi_cloud_instance_id, name, acc.Pi_image, acc.Pi_network_name, instanceHealthStatus)
}

func testAccCheckIBMPIInstanceDeploymentTypeConfig(name, instanceHealthStatus string) string {
func testAccCheckIBMPIInstanceDeploymentTypeConfig(name, instanceHealthStatus, epic, systype string) string {
return fmt.Sprintf(`
resource "ibm_pi_key" "key" {
pi_cloud_instance_id = "%[1]s"
Expand All @@ -127,16 +86,16 @@ func testAccCheckIBMPIInstanceDeploymentTypeConfig(name, instanceHealthStatus st
pi_proc_type = "dedicated"
pi_image_id = data.ibm_pi_image.power_image.id
pi_key_pair_name = ibm_pi_key.key.key_id
pi_sys_type = "e980"
pi_sys_type = "%[7]s"
pi_cloud_instance_id = "%[1]s"
pi_storage_type = "tier1"
pi_storage_type = "%[8]s"
pi_health_status = "%[5]s"
pi_network {
network_id = data.ibm_pi_network.power_networks.id
}
pi_deployment_type = "EPIC"
pi_deployment_type = "%[6]s"
}
`, acc.Pi_cloud_instance_id, name, acc.Pi_image, acc.Pi_network_name, instanceHealthStatus)
`, acc.Pi_cloud_instance_id, name, acc.Pi_image, acc.Pi_network_name, instanceHealthStatus, epic, systype, acc.PiStorageType)
}

func testAccIBMPIInstanceNetworkConfig(name, privateNetIP string) string {
Expand Down Expand Up @@ -281,25 +240,6 @@ func TestAccIBMPIInstanceBasic(t *testing.T) {
})
}

func TestAccIBMPIInstanceUserData(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: testAccCheckIBMPIInstanceUserDataConfig(name, helpers.PIInstanceHealthWarning),
Check: resource.ComposeTestCheckFunc(
testAccCheckIBMPIInstanceExists(instanceRes),
resource.TestCheckResourceAttr(instanceRes, "pi_instance_name", name),
),
},
},
})
}

func TestAccIBMPIInstanceDeploymentType(t *testing.T) {
instanceRes := "ibm_pi_instance.power_instance"
name := fmt.Sprintf("tf-pi-instance-%d", acctest.RandIntRange(10, 100))
Expand All @@ -309,7 +249,7 @@ func TestAccIBMPIInstanceDeploymentType(t *testing.T) {
CheckDestroy: testAccCheckIBMPIInstanceDestroy,
Steps: []resource.TestStep{
{
Config: testAccCheckIBMPIInstanceDeploymentTypeConfig(name, helpers.PIInstanceHealthWarning),
Config: testAccCheckIBMPIInstanceDeploymentTypeConfig(name, helpers.PIInstanceHealthOk, "EPIC", "e980"),
Check: resource.ComposeTestCheckFunc(
testAccCheckIBMPIInstanceExists(instanceRes),
resource.TestCheckResourceAttr(instanceRes, "pi_instance_name", name),
Expand Down Expand Up @@ -646,3 +586,22 @@ func testAccCheckIBMPIInstanceStatus(n, status string) resource.TestCheckFunc {
return nil
}
}

func TestAccIBMPIInstanceDeploymentTypeNoStorage(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: testAccCheckIBMPIInstanceDeploymentTypeConfig(name, helpers.PIInstanceHealthOk, "VMNoStorage", "s922"),
Check: resource.ComposeTestCheckFunc(
testAccCheckIBMPIInstanceExists(instanceRes),
resource.TestCheckResourceAttr(instanceRes, "pi_instance_name", name),
),
},
},
})
}
3 changes: 2 additions & 1 deletion website/docs/r/pi_instance.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Review the argument references that you can specify for your resource.
- `pi_anti_affinity_instances` - (Optional, String) List of pvmInstances to base storage anti-affinity policy against; required if requesting `anti-affinity` and `pi_anti_affinity_volumes` is not provided.
- `pi_anti_affinity_volumes`- (Optional, String) List of volumes to base storage anti-affinity policy against; required if requesting `anti-affinity` and `pi_anti_affinity_instances` is not provided.
- `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_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`.
- `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).
Expand Down Expand Up @@ -101,6 +101,7 @@ Review the argument references that you can specify for your resource.
- Supported SAP system types are (e880/e980).
- `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_virtual_optical_device` - (Optional, String) Virtual Machine's Cloud Initialization Virtual Optical Device.
- `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.
Expand Down

0 comments on commit e7ab1a1

Please sign in to comment.