ResetPassword
Reset passwords for AlibabaCloud ECS instances in bulk. Requires instance restart after password update to ensure security and synchronization across resources.
Instructions
批量修改ECS实例的密码,请注意,本操作将会重启ECS实例
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| InstanceIds | Yes | AlibabaCloud ECS instance ID List | |
| Password | Yes | The password of the ECS instance must be 8-30 characters and must contain only the following characters: lowercase letters, uppercase letters, numbers, and special characters only.()~!@#$%^&*-_+=(40:<>,?/ | |
| RegionId | No | AlibabaCloud region ID | cn-hangzhou |
Implementation Reference
- Handler for the 'OOS_ResetPassword' tool, which resets the password for multiple Alibaba Cloud ECS instances using the OOS template 'ACS-ECS-BulkyResetPassword'. Note: This matches 'ResetPassword' functionality.@tools.append def OOS_ResetPassword( InstanceIds: List[str] = Field(description='AlibabaCloud ECS instance ID List'), Password: str = Field(description='The password of the ECS instance must be 8-30 characters and must contain only the following characters: lowercase letters, uppercase letters, numbers, and special characters only.()~!@#$%^&*-_+=(40:<>,?/'), RegionId: str = Field(description='AlibabaCloud region ID', default='cn-hangzhou'), ): """批量修改ECS实例的密码,请注意,本操作将会重启ECS实例""" parameters = { 'regionId': RegionId, 'resourceType': 'ALIYUN::ECS::Instance', 'targets': { 'ResourceIds': InstanceIds, 'RegionId': RegionId, 'Type': 'ResourceIds' }, 'password': Password } return _start_execution_sync(region_id=RegionId, template_name='ACS-ECS-BulkyResetPassword', parameters=parameters)
- Input schema defined by Pydantic Field descriptions in the handler function parameters.@tools.append def OOS_ResetPassword( InstanceIds: List[str] = Field(description='AlibabaCloud ECS instance ID List'), Password: str = Field(description='The password of the ECS instance must be 8-30 characters and must contain only the following characters: lowercase letters, uppercase letters, numbers, and special characters only.()~!@#$%^&*-_+=(40:<>,?/'), RegionId: str = Field(description='AlibabaCloud region ID', default='cn-hangzhou'), ): """批量修改ECS实例的密码,请注意,本操作将会重启ECS实例""" parameters = { 'regionId': RegionId, 'resourceType': 'ALIYUN::ECS::Instance', 'targets': { 'ResourceIds': InstanceIds, 'RegionId': RegionId, 'Type': 'ResourceIds' }, 'password': Password } return _start_execution_sync(region_id=RegionId, template_name='ACS-ECS-BulkyResetPassword', parameters=parameters)
- src/alibaba_cloud_ops_mcp_server/server.py:82-83 (registration)Registration loop that adds all tools from oos_tools.tools (including OOS_ResetPassword) to the FastMCP server.for tool in oos_tools.tools: mcp.tool(tool)
- Shared helper function used by OOS_ResetPassword and other OOS tools to start an execution and poll until completion.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) @tools.append