Attaching ports

This section explains the procedure for attaching ports created in advance in the business service network to virtual servers. Refer to Creating a port for the procedure for creating ports.
  1. Perform the necessary settings indicated below.
    $SERVER_ID=<ID of the virtual server to attach the port to>
    $PORT_ID=<Port ID of the business service network to attach to the virtual server>
  2. Execute the API.
    $ curl -Ss $COMPUTE/v2/$PROJECT_ID/servers/$SERVER_ID/os-interface -X POST \
                -H "X-Auth-Token: $OS_AUTH_TOKEN" -H "Content-Type: application/json" \
                -d '{ "interfaceAttachment": {"port_id": "'$PORT_ID'" }}' | jq .

    The following response will be returned.

    {
      "interfaceAttachment": {
        "mac_addr": "<MAC address of the interface for the business service network>",
        "net_id": "<Network ID>",
        "port_id": "<Network Port ID for the business service network to attach to the virtual server>",
        "fixed_ips": [
          {
            "ip_address": "<IP address of the port of the business service network>",
            "subnet_id": "<Subnet ID of the business service network>"
          }
        ],
        "port_state": "DOWN"
      }
    }
  3. Execute the following API command to confirm that the interface of the virtual server and the port have been attached.
    $ SERVER_ID=<ID of the virtual server the port was attached to>
    $ curl -Ss $COMPUTE/v2/$PROJECT_ID/servers/$SERVER_ID/os-interface -X GET \
                -H "X-Auth-Token: $OS_AUTH_TOKEN" | jq .

    If the following response is returned, attaching is complete.

    {
      "interfaceAttachments": [
        {
          "mac_addr": "<MAC address of the interface of the business service network>",
          "net_id": "<Network ID>",
          "port_id": "<Port ID of the business service network attached to the virtual server>",
          "fixed_ips": [
            {
              "ip_address": "<IP address of the port of the business service network>",
              "subnet_id": "<Subnet ID of the business service network>"
            }
          ],
          "port_state": "ACTIVE"
        },
        {
          "mac_addr": "<MAC address of the interface>",
          "net_id": "<Network ID>",
          "port_id": "<Port ID of the management network attached to the virtual server>",
          "fixed_ips": [
            {
              "ip_address": "<IP address of the port of the business service network>;",
              "subnet_id": "<Subnet ID of the management network>"
            }
          ],
          "port_state": "ACTIVE"
        }
      ]
    }