Updated on 2025-12-04 GMT+08:00

Creating 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 Volume, ChargingInfo, Network, RootVolume, DataVolume, Server, Tag, ImageBody, BindIP

network = Network(
    security_group_id="150a2c76-1334-45f6-b28f-419f9b1d1742",
    subnet_id="38cf274a-98f9-4f6f-b622-5ed0e4a3db54",
    vpc_id="05982b48-a70f-43a1-a2b0-1fe36a236172")
rootvolume = RootVolume(
    root_type="SSD",
    size="200")
charginginfo = ChargingInfo(
    charging_mode="POST_PAID",
    period_num=1,
    period_type="MONTH")
server = Server(
    name="server_test",
    flavor="s7.small.1",
    image_id="e16eff65-1899-446e-baf2-0d2b6b5dd8c0",
    key_pair_name = "KeyPair-3d6a",
    network=network,
    root_volume=rootvolume,
    charging_info=charginginfo,
    arch="X86")
ServerManagement.create(session=Session(),server=server)

Parameters

Table 1 URI parameter

Parameter

Mandatory

Type

Description

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.

arch

No

String

Server specification architecture type.

  • ARM
  • X86

availability_zone

No

String

AZ.

charging_info

No

ChargingInfo object

Billing information of the server.

count

No

Integer

Number of servers purchased at a time.

enterprise_project_id

No

String

Enterprise ID.

flavor

Yes

String

Server specification name.

image_id

Yes

String

Server image ID.

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.

name

Yes

String

Server name.

network

Yes

ServerNetwork object

Server network information.

root_volume

No

EvsVolume object

System disk information of the server.

data_volume

No

ServerDataVolume object

Data disk information of the server.

server_type

No

String

Server type. The value can be:

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

userdata

No

String

Data defined by users during server creation.

hps_cluster_id

No

String

Network information of the supernode cluster. This parameter is required only for creating a supernode.

Table 3 ChargingInfo

Parameter

Mandatory

Type

Description

charging_mode

Yes

String

Payment type. The value can be:

  • COMMON: prepaid and postpaid
  • POST_PAID: postpaid
  • PRE_PAID: prepaid

is_auto_pay

No

Boolean

is auto pay

is_auto_renew

No

Boolean

is auto renew

period_num

Yes

Integer

period num

period_type

Yes

String

Period type.

  • ABSOLUTE
  • DAY
  • HOUR
  • MONTH
  • WEEK
  • YEAR
Table 4 ServerNetwork

Parameter

Mandatory

Type

Description

ipv6_enable

No

Boolean

Whether to enable IPv6 for the server to be created.

roce_id

No

String

RoCE network ID of the server.

security_group_id

Yes

String

ID of security group to which the server belongs.

subnet_id

Yes

String

ID of the subnet where the server is located.

vpc_id

Yes

String

ID of the VPC to which the server belongs.

Table 5 EvsVolume

Parameter

Mandatory

Type

Description

size

No

Integer

System disk size.

type

No

String

System disk type.

  • ESSD
  • GPSSD
  • SAS
  • SATA
  • SSD
Table 6 ServerDataVolume

Parameter

Mandatory

Type

Description

size

Yes

Integer

Data disk size.

type

Yes

String

System disk type.

ESSD

GPSSD

SAS

SATA

SSD

count

Yes

Integer

Number of data disks. The value ranges from 1 to 8.

Table 7 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 8 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 9 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 10 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 11 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 12 ServerHpsInfo

Parameter

Type

Description

id

String

Lite Server supernode instance ID.

name

String

Lite Server supernode name.