Skip to main content

Changing the power state of servers

Uses this definition to perform a power action on servers that are managed by Lenovo XClarity Orchestrator and then return the power status of that server.

Usage

resource "lxco_server" "power_action" {
group_ids = array of strings
power_action = string
resource_ids = array of strings
}

output "power_action" {
value = lxco_server.power_action
}

Example

The following example restarts two server and powers on a group of servers.
terraform {
required_providers {
lxco = {
version = "0.1"
source = "lenovo.com/xclarity/lxco"
}
}
}

provider "lxco" {
host = "192.0.2.0"
# username = ""
# password = ""
}

# Power on specific servers, and return the results
resource "lxco_server" "power_action" {
group_ids = [],
resource_ids = [
"80CE6AB8FF7D11E685CB819F6B26BCF8-AC2E339A942446F4A246BB55B56FB18F"
"00632D78DE644E23B712E200FE449787-97E61EA441F3491B9CC971E68D2D8BCD"
],
power_action = "PowerOn"
}
output "power_action" {
value = lxco_server.power_action
}

# Restart a group of servers, and return the results
resource "lxco_server" "power_action" {
group_ids = ["G_36898672B78D4A93B2829123E7728925"]
resource_ids = [],
power_action = "Restart"
}
output "power_action" {
value = lxco_server.power_action
}

Inputs

NameRequired / OptionalTypeDescription
group_idsRequiredArray of stringsList of device group IDs

Specify an empty array if the resource_ids attribute is specified.

power_actionRequiredStringPower action. This can be one of the following values.
  • PowerOn. Powers on the resource.
  • PowerOff. Powers off the resource immediately.
  • PowerOffSoft. Shuts down the operating system and powers off the resource.
  • Restart. Restarts the resource immediately.
  • RestartSoft. Shuts down the operating system and restarts the resource.
  • RestartBMC. Restarts the baseboard management controller.
  • Restart2Boot. Restarts the resource to BIOS/UEFI (F1) Setup. This is supported for non-ThinkServer servers that are supported without limitations.
resource_idsRequiredArray of stringsList of resources IDs

Specify an empty array if the group_ids attribute is specified.

Outputs

NameTypeDescription
idStringJob ID
power_actionStringPower action that was performed
resource_idsArray of stringsList of IDs of resources on which the power action was performed
statusIntegerMessage about the status of the action
The following example is returned if the request is successful.
{
"id":"0349DC28D0C411E7B5A47ED30AE32DCF",
"power_action": "PowerOn",
"resource_ids": [
"80CE6AB8FF7D11E685CB819F6B26BCF8-AC2E339A942446F4A246BB55B56FB18F"
"00632D78DE644E23B712E200FE449787-97E61EA441F3491B9CC971E68D2D8BCD"
],
"status": "The power action job launched successfully. The power action job was launched in the
orchestrator server and will be executed asynchronously. Job ID: 125"
}