九章智算云
查询容器组已开放端口

查询指定容器组当前已开放的端口列表,含系统端口与自定义端口。同步返回。

GEThttps://api.alayanew.com/api/osm/v1/training/instance/{id}/{podName}/open-port/list

鉴权(Authorizations)

AuthorizationString必填

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

Path Parameters

idString必填

训练任务 ID(来自任务列表的 id)。例如:a3c8f6d1-7b42-4e95-9d20-8f1a4c6b3e58。

podNameString必填

容器组名称(来自容器组列表的 podName)。例如:train-job-01-worker-0。

Response

statusInteger

业务状态码,200 表示成功。

messageString

接口响应信息。例如:"OK"。

dataObject

开放端口信息。

显示 properties
portsArray

系统开放端口列表。

显示 properties
protocolString

协议。例如:"TCP"。

portInteger

容器端口。例如:22。

externalHostString

外部访问地址。例如:"train-job-01-worker-0.example.com"。

externalPortInteger

外部访问端口。例如:30022。

customPortsArray

自定义开放端口列表。

显示 properties
protocolString

协议。例如:"TCP"。

portInteger

容器端口。例如:7778。

externalHostString

外部访问地址。例如:"train-job-01-worker-0.example.com"。

externalPortInteger

外部访问端口。例如:37778。

curl -X 'GET' \
  'https://api.alayanew.com/api/osm/v1/training/instance/a3c8f6d1-7b42-4e95-9d20-8f1a4c6b3e58/train-job-01-worker-0/open-port/list' \
  -H 'accept: application/json' \
  -H 'Authorization: [your-auth-header]'
import requests

task_id = "a3c8f6d1-7b42-4e95-9d20-8f1a4c6b3e58"
pod_name = "train-job-01-worker-0"
url = f"https://api.alayanew.com/api/osm/v1/training/instance/{task_id}/{pod_name}/open-port/list"
headers = {
    "accept": "application/json",
    "Authorization": "[your-auth-header]"
}

response = requests.get(url, headers=headers)
print(response.json())
const taskId = 'a3c8f6d1-7b42-4e95-9d20-8f1a4c6b3e58';
const podName = 'train-job-01-worker-0';

fetch(`https://api.alayanew.com/api/osm/v1/training/instance/${taskId}/${podName}/open-port/list`, {
  method: 'GET',
  headers: {
    'accept': 'application/json',
    'Authorization': '[your-auth-header]'
  }
})
  .then(res => res.json())
  .then(console.log)
  .catch(console.error);
{
  "status": 200,
  "message": "OK",
  "data": {
    "ports": [
      {
        "protocol": "TCP",
        "port": 22,
        "externalHost": "train-job-01-worker-0.example.com",
        "externalPort": 30022
      }
    ],
    "customPorts": [
      {
        "protocol": "TCP",
        "port": 7778,
        "externalHost": "train-job-01-worker-0.example.com",
        "externalPort": 37778
      }
    ]
  }
}

最后更新于