• Elastic Cloud Server

ecs
  1. Help Center
  2. Elastic Cloud Server
  3. API Reference
  4. OpenStack Nova APIs
  5. NIC Management
  6. Adding a NIC to an ECS

Adding a NIC to an ECS

Function Description

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

URI

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

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

Table 1 describes the parameters in the URI.
Table 1 Parameter description

Parameter

Mandatory

Description

project_id

Yes

Specifies the project ID.

server_id

Yes

Specifies the ECS ID.

Request

Request parameters

Table 2 describes the request parameters.
Table 2 Request parameters

Parameter

Mandatory

Type

Description

interfaceAttachment

Yes

Dictionary data structure

Specifies the NICs to be added. For details, see Table 3.

Table 3 interfaceAttachment field description

Parameter

Mandatory

Type

Description

port_id

No

String

Specifies the port ID.

Either port_id or net_id is used each time.

net_id

No

String

Specifies the network ID.

This parameter is invalid if parameter port_id is specified.

fixed_ips

No

List data structure

Specifies a private IP address.

This parameter is invalid if port_id has been specified. This parameter must be specified together 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.

Table 4 fixed_ips field description

Parameter

Mandatory

Type

Description

ip_address

No

String

Specifies the IP address.

Response

Response parameters

Table 5 describes the response parameters.
Table 5 Response parameters

Parameter

Type

Description

interfaceAttachment

Dictionary data structure

Specifies ECS NICs. For details, see Table 6.

Table 6 interfaceAttachment field description

Parameter

Type

Description

port_state

String

Specifies the port state.

fixed_ips

List data structure

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.

Table 7 fixed_ips field description

Parameter

Type

Description

subnet_id

String

Specifies the ID of the subnet used by the NIC.

ip_address

String

Specifies the NIC IP address.

Examples

  • Example request
    {
        "interfaceAttachment" : {
            "fixed_ips" : [ 
                {
                    "ip_address" : "192.168.1.3"
                } 
             ],
        "net_id" : "3cb9bc59-5699-4588-a4b1-b87f96708bc6"
        }
    }
    {
        "interfaceAttachment" : {
        "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

See General Request Returned Values.