RebootInstances
Restart multiple Alibaba Cloud ECS instances simultaneously using this tool, ideal for managing instance lifecycle in bulk and ensuring consistent system performance.
Instructions
批量重启ECS实例,适用于需要同时管理和重启多台ECS实例的场景。
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ForeceStop | No | 是否强制关机 | |
| InstanceIds | Yes | AlibabaCloud ECS instance ID List | |
| RegionId | No | AlibabaCloud region ID | cn-hangzhou |
Implementation Reference
- The handler function for the 'OOS_RebootInstances' tool (matching 'RebootInstances'), which orchestrates rebooting multiple Alibaba Cloud ECS instances using OOS template 'ACS-ECS-BulkyRebootInstances'.@tools.append def OOS_RebootInstances( InstanceIds: List[str] = Field(description='AlibabaCloud ECS instance ID List'), RegionId: str = Field(description='AlibabaCloud region ID', default='cn-hangzhou'), ForeceStop: bool = Field(description='Is forced shutdown required', default=False) ): """批量重启ECS实例,适用于需要同时管理和重启多台ECS实例的场景。""" parameters = { 'regionId': RegionId, 'resourceType': 'ALIYUN::ECS::Instance', 'targets': { 'ResourceIds': InstanceIds, 'RegionId': RegionId, 'Type': 'ResourceIds' }, 'forceStop': ForeceStop } return _start_execution_sync(region_id=RegionId, template_name='ACS-ECS-BulkyRebootInstances', parameters=parameters)
- src/alibaba_cloud_ops_mcp_server/server.py:82-83 (registration)Registration loop that adds all tools from oos_tools (including OOS_RebootInstances) to the FastMCP server.for tool in oos_tools.tools: mcp.tool(tool)
- Helper function _start_execution_sync that starts an OOS execution and polls until it reaches an end status, used by OOS_RebootInstances.def _start_execution_sync(region_id: str, template_name: str, parameters: dict): client = create_client(region_id=region_id) start_execution_request = oos_20190601_models.StartExecutionRequest( region_id=region_id, template_name=template_name, parameters=json.dumps(parameters) ) start_execution_resp = client.start_execution(start_execution_request) execution_id = start_execution_resp.body.execution.execution_id while True: list_executions_request = oos_20190601_models.ListExecutionsRequest( region_id=region_id, execution_id=execution_id ) list_executions_resp = client.list_executions(list_executions_request) status = list_executions_resp.body.executions[0].status if status == FAILED: status_message = list_executions_resp.body.executions[0].status_message raise exception.OOSExecutionFailed(reason=status_message) elif status in END_STATUSES: return list_executions_resp.body time.sleep(1)
- Pydantic input schema definitions for the OOS_RebootInstances tool parameters.InstanceIds: List[str] = Field(description='AlibabaCloud ECS instance ID List'), RegionId: str = Field(description='AlibabaCloud region ID', default='cn-hangzhou'), ForeceStop: bool = Field(description='Is forced shutdown required', default=False)