• Native OpenStack API

noa
  1. Help Center
  2. Native OpenStack API
  3. API Reference
  4. Nova
  5. Interfaces
  6. Adding an NIC

Adding an NIC

Function Description

This interface is used to add a NIC to an ECS.

Interface Format

Method

URI

Description

POST

/v2/{tenant_id}/servers/{server_id}/os-interface

/v2.1/{tenant_id}/servers/{server_id}/os-interface

Adds a NIC to a created ECS.

Restrictions

If an ECS has no NIC attached, when you attach the primary NIC to the ECS, ensure that the VPC of the NIC to be attached to the ECS is the same as the VPC of the NIC that has been detached from the ECS.

Expanded Interface

N/A

Request Parameter

Table 1 Request Parameter

Parameter

Type

Mandatory

Description

port_id

UUID

No

Specifies the port ID. This parameter cannot be used with net_id.

net_id

UUID

No

Specifies the network ID. This parameter cannot be used with port_id.

fixed_ips

List

Example:

[
    {
        "ip_address": "192.168.1.3"
    }
]

No

Specifies the private IP address.

If this parameter is configured, net_id must be configured. The IP address must be a valid one on the subnet of the specified net_id. Only the first one in the list is valid.

Response Parameter

Table 2 Response Parameter

Parameter

Type

Mandatory

Description

port_state

String

Yes

Specifies the port status.

fixed_ips

List(Fixed_ip)

Yes

Includes subnet_id and ip_address

port_id

UUID

Yes

Specifies the port ID

net_id

UUID

Yes

Specifies the network ID

mac_addr

String

Yes

Specifies the MAC address.

Request Example

POST /v2/6fbe9263116a4b68818cf1edce16bc4f/servers/9149af93-bb0e-4b38-845e-9cdc5fa02eca/os-interface
POST /v2.1/6fbe9263116a4b68818cf1edce16bc4f/servers/9149af93-bb0e-4b38-845e-9cdc5fa02eca/os-interface
{ 
    "interfaceAttachment": {
"port_id": "ce531f90-199f-48c0-816c-13e38010b442"
}
}

Response Example

{ 
"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

For details, see section General Request Returned Values.

Error Code

Table 3 Task error code

Error Code

Description

404

Instance could not be found.

The target ECS does not exist.