This section explains how to retrieve the port ID of a virtual server, required for assigning global IP addresses to the virtual server.
-
Set the environment variable below as follows:
$ SERVER_ID=<virtualServerIdToRetrievePortFrom>
-
Execute the following API to retrieve the port:
$ curl -Ss $COMPUTE/v2/$PROJECT_ID/servers/$SERVER_ID/os-interface \
-X GET -H "X-Auth-Token: $OS_AUTH_TOKEN" | jq .
A response is output in a format such as the following:
{
"interfaceAttachments": [
{
"port_state": "<status>",
"fixed_ips": [
{
"subnet_id": "<virtualServerId>",
"ip_address": "<privateIpAddr>"
}
],
"port_id": "<portId>",
"net_id": "<networkIdThatVirtualServerIsConnectedTo>",
"mac_addr": "<macAddr>"
}
]
}