Help Center/ ModelArts/ SDK Reference/ Lite Server Lifecycle Management/ Changing the OS Image of a Lite Server
Updated on 2025-12-04 GMT+08:00

Changing the OS Image of a Lite Server

Example Code

In ModelArts Notebook, you do not need to enter authentication parameters for session authentication. For details about session authentication of other development environments, see Session Authentication.

from modelarts.server_mgmt import ServerManagement
from modelarts.session import Session
from modelarts.servers.server_def import ImageBody

change_body = ImageBody(key_pair_name="KeyPair-3d6a",
                          image_id="e16eff65-1899-446e-baf2-0d2b6b5dd8c0")
ServerManagement.change_server_image(session = Session(), server_id = "server_id",change_body = change_body)  #Enter hps_cluster_id.

Parameters

Table 1 URI parameters

Parameter

Mandatory

Type

Description

server_id

Yes

String

Lite Server ID.

session

Yes

Class

Manage the interaction with Lite Server and provide project ID (project_id).

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

admin_pass

No

String

Password for logging in to the server. Note that either admin_pass or key_pair_name must be specified. The new password must comply with the following rules:

  • Contain 8 to 26 characters.
  • Contain at least three types of the following characters: uppercase letters, lowercase letters, digits, and special characters (!@$%^-_=+[{}]:,./?).
  • Cannot be the username or the username backwards.
  • Cannot contain root, administrator, or their reverse.

key_pair_name

No

String

Name of the key pair for logging in to the server. Either admin_pass or key_pair_name must be specified. Note that supernodes support only key_pair_name.

image_id

Yes

String

Server image ID.

user_data

No

String

Data defined by users during server creation.

Table 3 Response body parameters

Parameter

Type

Description

create_at

Long

Creation time.

update_at

Long

Update time.

charging_mode

String

Billing mode.

  • COMMON: Both yearly/monthly and pay-per-use are supported.
  • POST_PAID: pay-per-use
  • PRE_PAID: yearly/monthly

cloud_server

CloudServer object

Cloud service information.

endpoints_response

Array of Endpoints objects

Private IP address of the instance.

flavor

String

Instance flavor.

id

String

Instance ID.

key_pair_name

String

Key pair name.

name

String

Instance name.

order_id

String

Order ID.

server_image_response

ServerImageResponse object

Instance image information.

status

String

Instance status.

  • CREATE_FAILED: Creating the instance failed.
  • CREATING: The instance is being created.
  • DELETED: The instance has been deleted.
  • DELETE_FAILED: Deleting the instance failed.
  • DELETING: The instance is being deleted.
  • ERROR: An error occurs.
  • RUNNING: The instance is running.
  • STARTING: The instance is being started.
  • START_FAILED: Starting the instance failed.
  • STOPPED: The instance has been stopped.
  • STOPPING: The instance is being stopped.
  • STOP_FAILED: Stopping the instance failed.
  • REBOOTING: The instance is being restarted.
  • REBOOT_FAILED: Restarting the instance failed.
  • CHANGINGOS: The OS is being changed.
  • CHANGINGOS_FAILED: Changing the OS failed.
  • REINSTALLINGOS: The OS is being reinstalled.
  • REINSTALLINGOS_FAILED: Reinstalling the OS failed.

vpc_id

String

ID of the VPC where the instance is located.

endpoints

Array of EndpointsRes objects

Private IP address of the server.

image

ServerImageResponse object

Server image information.

category

String

Server type.

  • HPS: supernode server
  • SPOD: entire-rack server
  • SERVER: single server

server_hps

ServerHpsInfo object

Information about the supernode to which the server belongs.

subnet_id

String

ID of the subnet where the instance is located.

Table 4 CloudServer

Parameter

Type

Description

id

String

Server resource ID.

type

String

Lite server type. The value can be:

  • BMS: Bare Metal Server
  • ECS: Elastic Cloud Server
  • HPS: supernode server

hps_id

String

Resource ID of the supernode to which the server belongs.

Table 5 Endpoints

Parameter

Type

Description

allowed_access_ips

Array of strings

Whitelist public IP addresses that are allowed to access notebook instances through SSH. By default, all public IP addresses can access the notebook instances. If IP addresses are specified, only the clients with the specified IP addresses can access the notebook instances.

dev_service

String

Supported service. The value can be:

  • NOTEBOOK: You can access notebook instances using HTTPS.
  • SSH: You can remotely access the notebook instance through SSH.
  • AI_FLOW
  • MA_STUDIO
  • TENSOR_BOARD
  • WEB_IDE

extensions

Map<String,String>

App-specific URL for accessing the remote development mode of the App.

ssh_keys

Array of strings

List of SSH key pairs. You can set multiple key pairs to access an SSH instance at the same time.

Table 6 EndpointsRes

Parameter

Type

Description

allowed_access_ips

Array of strings

Whitelist public IP addresses that are allowed to access notebook instances through SSH. By default, all public IP addresses can access the notebook instances. If IP addresses are specified, only the clients with the specified IP addresses can access the notebook instances.

dev_service

String

Notebook access method. The value can be:

  • NOTEBOOK: You can access notebook instances using HTTPS.
  • SSH: You can remotely access the notebook instance through SSH.

ssh_keys

Array of strings

List of SSH key pairs. You can set multiple key pairs to access an SSH instance at the same time.

service

String

Notebook access method. The value can be:

  • NOTEBOOK: You can access notebook instances using HTTPS.
  • SSH: You can remotely access the notebook instance through SSH.

uri

String

Private IP address of the instance.

Table 7 ServerImageResponse

Parameter

Type

Description

arch

String

Server image architecture type.

  • ARM
  • X86

image_id

String

Server image ID.

name

String

Server image name.

server_type

String

Server type. The value can be:

  • BMS: Bare Metal Server
  • ECS: Elastic Cloud Server
Table 8 ServerHpsInfo

Parameter

Type

Description

id

String

Lite Server supernode instance ID.

name

String

Lite Server supernode name.