九章智算云
开机 / 变配

开机与变配共用本接口:请求体不携带 skuCode 为纯开机,沿用实例当前规格;携带 skuCode 即变配(换规格),实例切换到目标规格,计费随切换时点按新规格计价,订阅号不变。

接口为同步受理:成功返回后实例进入启动中(STARTING;GPU 资源紧张排队时为 QUEUED),可通过查询实例列表或获取实例详情轮询 status 字段,变为 RUNNING 表示启动完成。纯开机要求实例处于未开机(STOPPED)或失败(FAILED)状态;变配要求目标规格在售且计费方式一致。

POSThttps://api.alayanew.com/api/osm/v1/cci/instance/{id}/start

鉴权(Authorizations)

AuthorizationString必填

用户获取Authorization请求头后,通过该请求头完成身份认证。例如:Authorization: [your-auth-header]。

Path Parameters

idString必填

实例 ID(来自查询实例列表的 id)。例如:2006a5d0-0a55-4e8f-9d3c-b7a1f20c5d88。

Request body

skuCodeString

目标规格编码。变配时必传,纯开机不传。

imageString

镜像地址。开机或变配时更换镜像用,不传沿用当前镜像。

storageConfigEnableBoolean

是否启用存储挂载配置。为 true 时按 storageConfigs 重挂存储,两种场景均按需传。

storageConfigsArray

存储挂载配置,启用存储配置时传。

显示 properties
storageIdString

挂载的存储 ID。

mountPathString

容器内挂载路径。

priorityInteger

开机调度优先级,1~3,数值越小优先级越高。不传沿用实例当前值。

computeResourceTypeString

计算资源类型:ELASTIC / EXCLUSIVE。不传沿用实例当前值。

exclusiveResourceIdString

独占资源 ID,选择独占类型时传。不传沿用实例当前值。

instanceEnvsObject

本次开机新增或覆盖的环境变量,key 为变量名,value 为变量值。不传保持已有环境变量。

Response

statusInteger

业务状态码,200 表示开机请求已受理;失败时为错误码。

messageString

响应信息,成功为 "OK";失败时为错误描述。

纯开机(沿用当前规格)

curl -X 'POST' \
  'https://api.alayanew.com/api/osm/v1/cci/instance/2006a5d0-0a55-4e8f-9d3c-b7a1f20c5d88/start' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: [your-auth-header]' \
  -d '{}'

变配开机(更换规格)

curl -X 'POST' \
  'https://api.alayanew.com/api/osm/v1/cci/instance/2006a5d0-0a55-4e8f-9d3c-b7a1f20c5d88/start' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: [your-auth-header]' \
  -d '{
  "skuCode": "cci.gpu.g16xlarge",
  "image": "hub.example.com/public/pytorch:2.4-cuda12.4",
  "priority": 1
}'

纯开机(沿用当前规格)

import requests

instance_id = "2006a5d0-0a55-4e8f-9d3c-b7a1f20c5d88"
url = f"https://api.alayanew.com/api/osm/v1/cci/instance/{instance_id}/start"
headers = {
    "accept": "application/json",
    "Content-Type": "application/json",
    "Authorization": "[your-auth-header]"
}

response = requests.post(url, headers=headers, json={})
print(response.json())

变配开机(更换规格)

import requests

instance_id = "2006a5d0-0a55-4e8f-9d3c-b7a1f20c5d88"
url = f"https://api.alayanew.com/api/osm/v1/cci/instance/{instance_id}/start"
headers = {
    "accept": "application/json",
    "Content-Type": "application/json",
    "Authorization": "[your-auth-header]"
}
payload = {
    "skuCode": "cci.gpu.g16xlarge",
    "image": "hub.example.com/public/pytorch:2.4-cuda12.4",
    "priority": 1
}

response = requests.post(url, headers=headers, json=payload)
print(response.json())

纯开机(沿用当前规格)

const instanceId = '2006a5d0-0a55-4e8f-9d3c-b7a1f20c5d88';

fetch(`https://api.alayanew.com/api/osm/v1/cci/instance/${instanceId}/start`, {
  method: 'POST',
  headers: {
    'accept': 'application/json',
    'Content-Type': 'application/json',
    'Authorization': '[your-auth-header]'
  },
  body: JSON.stringify({})
})
  .then(res => res.json())
  .then(console.log)
  .catch(console.error);

变配开机(更换规格)

const instanceId = '2006a5d0-0a55-4e8f-9d3c-b7a1f20c5d88';

fetch(`https://api.alayanew.com/api/osm/v1/cci/instance/${instanceId}/start`, {
  method: 'POST',
  headers: {
    'accept': 'application/json',
    'Content-Type': 'application/json',
    'Authorization': '[your-auth-header]'
  },
  body: JSON.stringify({
    skuCode: 'cci.gpu.g16xlarge',
    image: 'hub.example.com/public/pytorch:2.4-cuda12.4',
    priority: 1
  })
})
  .then(res => res.json())
  .then(console.log)
  .catch(console.error);
{
  "status": 200,
  "message": "OK"
}

最后更新于