Adding a NIC to an ECS
Function
This API is used to add a NIC to an ECS.
To view application examples about ECS NIC applications, see Attaching a NIC to an ECS.
URI
POST /v2.1/{project_id}/servers/{server_id}/os-interface
| Parameter | Mandatory | Description | 
|---|---|---|
| project_id | Yes | Specifies the project ID. For details about how to obtain the ID, see Obtaining a Project ID. | 
| server_id | Yes | Specifies the ECS ID. | 
Request
| Parameter | Mandatory | Type | Description | 
|---|---|---|---|
| interfaceAttachment | Yes | Object | Specifies the NICs to be added. For details, see Table 3. | 
| Parameter | Mandatory | Type | Description | 
|---|---|---|---|
| port_id | No | String | Specifies the port ID. The port_id and net_id cannot be specified at the same time. | 
| net_id | No | String | Specifies the network ID. The port_id and net_id cannot be specified at the same time. | 
| fixed_ips | No | Array of objects | Specifies a private IP address. This parameter cannot be specified when port_id is used. This parameter must be used with net_id. Only the first element in the list is valid. If two or more elements are used, an error will be reported. For details, see Table 4. | 
Response
| Parameter | Type | Description | 
|---|---|---|
| interfaceAttachment | Object | Specifies ECS NICs. For details, see Table 6. | 
| Parameter | Type | Description | 
|---|---|---|
| port_state | String | Specifies the port state. | 
| fixed_ips | Array of objects | Specifies IP addresses for NICs. For details, see Table 7. | 
| port_id | String | Specifies the port ID. | 
| net_id | String | Specifies the network ID. | 
| mac_addr | String | Specifies the MAC address. | 
Example Request
- Add a NIC whose network ID is 3cb9bc59-5699-4588-a4b1-b87f96708bc6 to a specified ECS.
    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" } }
- Add a NIC whose port ID is ce531f90-199f-48c0-816c-13e38010b442 to a specified ECS.
    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" } }
Example Response
{
    "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"
    }
}
 Returned Values
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.
 
    