Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Power action parameter and method supported #1134

Merged
merged 2 commits into from
May 19, 2021
Merged

Power action parameter and method supported #1134

merged 2 commits into from
May 19, 2021

Conversation

Lance52259
Copy link
Contributor

@Lance52259 Lance52259 commented May 17, 2021

What this PR does / why we need it:

  • Redundancy of the instance status detection method.
  • Power action supports:
    • ON
    • OFF
    • REBOOT
    • FORCE-OFF
    • FORCE-REBOOT

Which issue this PR fixes:
(optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged)
fixes #914
fixes #1044

Special notes for your reviewer:

Release note:

1. Extract the instance status detection method
2. New power state option and method supported.

PR Checklist

  • Tests added/passed.
  • Documentation updated.
  • Schema updated.

Acceptance Steps Performed

make testacc TEST='./huaweicloud' TESTARGS='-run=TestAccComputeV2Instance_powerAction'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./huaweicloud -v -run=TestAccComputeV2Instance_powerAction -timeout 360m -parallel 4
=== RUN   TestAccComputeV2Instance_powerAction
=== PAUSE TestAccComputeV2Instance_powerAction
=== CONT  TestAccComputeV2Instance_powerAction
--- PASS: TestAccComputeV2Instance_powerAction (523.11s)
PASS
ok      github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud       523.172s

@Lance52259 Lance52259 changed the title Br power active Power option and method supported May 17, 2021
@Lance52259 Lance52259 changed the title Power option and method supported Power action parameter and method supported May 17, 2021
// If you want to support more actions, please update powerActionMap simultaneously.
ValidateFunc: validation.StringInSlice([]string{
"ON", "OFF", "REBOOT", "FORCE-OFF", "FORCE-REBOOT",
}, true),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems the ignoreCase shoud be false.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

case ignore is set false now

@@ -631,6 +639,17 @@ func resourceComputeInstanceV2Create(d *schema.ResourceData, meta interface{}) e
}
}

// Create an instance in the shutdown state.
if action, ok := d.GetOk("power_action"); ok {
if action.(string) != "OFF" {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FORCE-OFF should also be valid during the creation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx, the FORCE-OFF has added

log.Printf("[WARN] The power action (%s) is invalid after instance created", action.(string))
} else {
if err = doPowerAction(ecsClient, d, action.(string)); err != nil {
return fmt.Errorf("Unable to close the huaweicloud compute instance (%s): %s", d.Id(), err)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the error message shoud be updated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The message has updated.

@@ -283,6 +283,10 @@ The following arguments are supported:
* `agency_name` - (Optional, String, ForceNew) Specifies the IAM agency name which is created on IAM to provide
temporary credentials for ECS to access cloud services. Changing this creates a new instance.

* `power_action` - (Optional, String) Specifies what action needs to be done for the instance.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specifies the power action to be done for ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description has updated, and the note info The power_action is a one-time action. is better than The power_action parameter specifies a one-time action.?

@ShiChangkuo ShiChangkuo merged commit e362fd0 into huaweicloud:master May 19, 2021
@Lance52259 Lance52259 deleted the br_power_active branch June 22, 2021 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Poweroff/poweron on addition ECS to huaweicloud_compute_servergroup PowerOn state for ECS
2 participants