華為云計(jì)算 云知識(shí) 添加云服務(wù)器網(wǎng)卡NovaAttachInterface
添加云服務(wù)器網(wǎng)卡NovaAttachInterface

 

功能介紹

云服務(wù)器 添加一張網(wǎng)卡。

添加云服務(wù)器網(wǎng)卡應(yīng)用示例請(qǐng)參考彈性云服務(wù)器掛載網(wǎng)卡。

調(diào)試

您可以在API Explorer中調(diào)試該接口。

URI

POST /v2.1/{project_id}/servers/{server_id}/os-interface

參數(shù)說(shuō)明請(qǐng)參見(jiàn)表1。
表1 參數(shù)說(shuō)明

參數(shù)

是否必選

描述

project_id

項(xiàng)目ID。

獲取方法請(qǐng)參見(jiàn)獲取項(xiàng)目ID。

server_id

云服務(wù)器ID。

請(qǐng)求消息

請(qǐng)求參數(shù)如表2所示。
表2 請(qǐng)求參數(shù)

參數(shù)

是否必選

參數(shù)類型

描述

interfaceAttachment

Object

需要添加的網(wǎng)卡參數(shù)列表,詳情請(qǐng)參見(jiàn)表3。

表3 interfaceAttachment字段數(shù)據(jù)結(jié)構(gòu)說(shuō)明

參數(shù)

是否必選

參數(shù)類型

描述

port_id

String

Port ID。

port_id和net_id不能同時(shí)傳入。

net_id

String

Network ID。

port_id和net_id不能同時(shí)傳入。

fixed_ips

Array of objects

私有IP。

使用port_id時(shí),不能指定該參數(shù)。

該參數(shù)必須與net_id配合使用。

只有列表中第一個(gè)元素有效。傳入兩個(gè)及以上元素會(huì)報(bào)錯(cuò)。詳情請(qǐng)參見(jiàn)表4。

表4 fixed_ips字段數(shù)據(jù)結(jié)構(gòu)說(shuō)明

參數(shù)

是否必選

參數(shù)類型

描述

ip_address

String

IP地址。

響應(yīng)消息

響應(yīng)參數(shù)如表5所示。
表5 響應(yīng)參數(shù)

參數(shù)

參數(shù)類型

描述

interfaceAttachment

Object

云服務(wù)器網(wǎng)卡信息列表,詳情請(qǐng)參見(jiàn)表6。

表6 interfaceAttachment字段數(shù)據(jù)結(jié)構(gòu)說(shuō)明

參數(shù)

參數(shù)類型

描述

port_state

String

端口狀態(tài)。

fixed_ips

Array of objects

網(wǎng)卡IP信息列表,請(qǐng)參見(jiàn)表7。

port_id

String

Port ID。

net_id

String

Network ID。

mac_addr

String

Mac地址。

表7 fixed_ips字段數(shù)據(jù)結(jié)構(gòu)說(shuō)明

參數(shù)

參數(shù)類型

描述

subnet_id

String

網(wǎng)卡所屬子網(wǎng)ID。

ip_address

String

網(wǎng)卡IP地址。

請(qǐng)求示例

  • 為指定云服務(wù)器添加一張網(wǎng)卡,Network ID為“3cb9bc59-5699-4588-a4b1-b87f96708bc6”。
    POST https://{endpoint}/v2.1/{project_id}/servers/{server_id}/os-interface
    
    {
        "interfaceAttachment" : {
            "fixed_ips" : [ 
                {
                    "ip_address" : "192.168.1.3"
                } 
             ],
        "net_id" : "3cb9bc59-5699-4588-a4b1-b87f96708bc6"
        }
    }
  • 為指定云服務(wù)器添加一張網(wǎng)卡,Port ID為“ce531f90-199f-48c0-816c-13e38010b442”。
    POST https://{endpoint}/v2.1/{project_id}/servers/{server_id}/os-interface
    
    {
        "interfaceAttachment" : {
            "fixed_ips" : [ 
                {
                    "ip_address" : "192.168.1.3"
                } 
             ],
        "port_id" : "ce531f90-199f-48c0-816c-13e38010b442"
        }
    }

響應(yīng)示例

{
    "interfaceAttachment": {
        "port_state": "DOWN",
        "fixed_ips": [
            {
                "subnet_id": "d9cfef77-0151-4c2a-9ed5-d951ada8adf3",
                "ip_address": "10.0.1.11"
            }
        ],
        "port_id": " ce531f90-199f-48c0-816c-13e38010b442",
        "net_id": "0dc714fa-9022-4a03-bb22-9821a396bb9d",
        "mac_addr": "fa:16:3e:63:75:b2"
    }
}

返回值

請(qǐng)參考通用請(qǐng)求返回值。