Chuyển tới nội dung chính

Update Network Port

Update attributes of an existing network port.

Only mutable fields can be changed. Fields such as id, network_id, project_id / tenant_id, and timestamps are read-only.

Request

PUT /v2.0/ports/{port_id}

Path Parameters

NameInTypeDescription
port_idpathstringID of the port to update.

Body Structure

Top-level JSON object must contain a single port object with one or more updatable attributes.

Updatable Parameters

NameInTypeDescription
portbodyobjectWrapper object containing the fields to update. Provide only the fields you want to change.
name (Optional)bodystringHuman‑readable name of the port.
description (Optional)bodystringHuman‑readable description (empty string by default).
admin_state_up (Optional)bodybooleanAdministrative state: up (true) or down (false).
device_id (Optional)bodystringID of the device (server, router, etc.) using this port.
device_owner (Optional)bodystringEntity type using the port (compute:nova, network:dhcp, network:router_interface, etc.).
security_groups (Optional)bodyarrayList of security group IDs to apply. Replaces the existing list.
fixed_ips (Optional)bodyarrayNew list of fixed IP mappings. Each entry may include subnet_id and/or ip_address. Entire list is replaced if provided. See create docs for allocation logic.
allowed_address_pairs (Optional)bodyarrayList of objects each with ip_address (required) and optional mac_address. Replaces existing list.
extra_dhcp_opts (Optional)bodyarrayList of DHCP option objects (opt_name, opt_value). Replaces existing list.
port_security_enabled (Optional)bodybooleanEnable/disable security group & anti‑spoofing enforcement.
qos_policy_id (Optional)bodystringQoS policy to associate (or null to clear).
binding:host_id (Optional)bodystringHost ID where the port resides. Typically set by the system / scheduler; admin override only.
binding:profile (Optional)bodyobjectBackend‑specific VIF info dict. Use null to reset to {}. May contain device_mac_address for direct-physical binding to override the exposed mac_address.
binding:vnic_type (Optional)bodystringDesired vNIC type (normal, macvtap, direct, baremetal, direct-physical, virtio-forwarder, smart-nic, remote-managed). Changing after initial binding may be restricted by deployment.
mac_address (Optional)bodystringPort MAC address. Usually immutable after creation except in specific binding scenarios (e.g. with direct-physical and device_mac_address).
dns_domain (Optional)bodystringDNS domain to associate.
dns_name (Optional)bodystringDNS name (hostname) to associate.
hints (Optional)bodyobjectAdmin-only mechanism driver hints (e.g. {"openvswitch": {"other_config": {"tx-steering": "hash"}}}). Max length 4095 chars serialized.
numa_affinity_policy (Optional)bodystringNUMA affinity policy: none, required, preferred, or legacy.
propagate_uplink_status (Optional)bodybooleanWhether uplink status propagation is enabled.
mac_learning_enabled (Optional)bodybooleanEnable MAC learning on the port.
port_trusted_vif (Optional)bodybooleanTrusted VIF status. Reflected within binding:profile.
allowed_address_pairs[*].ip_addressbodystringIP address or CIDR.
allowed_address_pairs[*].mac_address (Optional)bodystringMAC address; defaults to port MAC if omitted.

Note: Omitted fields are left unchanged. For list‑type attributes (e.g. security_groups, allowed_address_pairs, fixed_ips), supplying a list replaces the entire existing list.

Example Request

curl -ks -X PUT -H 'Content-Type: application/json' \
-H 'X-Auth-Token: gAAAAA<...>' \
-d '{
"port": {
"name": "dhcp-port",
"device_owner": "network:dhcp",
"device_id": "dhcpe52a9a47-9f6a-5406-9193-a4d7333f9889-f858b8d1-e66b-4a48-bc2e-3f16483b1b58"
}
}' \
https://<node_IP_addr>:9696/v2.0/ports/c85ae844-9ff5-4866-97da-546c3bf0144b

Response

Response Parameters

If successful the API returns a single updated port object with all current attributes.

NameInTypeDescription
portbodyobjectPort object wrapper.
idbodystringPort ID.
namebodystringPort name.
network_idbodystringID of the attached network.
tenant_idbodystringProject ID (legacy field).
project_idbodystringOwning project ID.
mac_addressbodystringMAC address (may be overridden for direct-physical).
admin_state_upbodybooleanAdministrative state.
statusbodystringPort status: ACTIVE, DOWN, BUILD, or ERROR.
device_idbodystringID of the attached device.
device_ownerbodystringEntity type using the port.
fixed_ipsbodyarrayList of {subnet_id, ip_address} for the port.
allowed_address_pairsbodyarrayAllowed address pairs.
extra_dhcp_optsbodyarrayExtra DHCP option objects.
security_groupsbodyarraySecurity group IDs.
descriptionbodystringDescription.
binding:vnic_typebodystringvNIC type.
binding:profilebodyobjectBackend-specific VIF info ( {} if none ).
binding:host_idbodystringHost ID where the port resides.
binding:vif_typebodystringMechanism driver type or unbound / binding_failed.
binding:vif_detailsbodyobjectAdditional info (port_filter, ovs_hybrid_plug, etc.).
port_security_enabledbodybooleanWhether port security is enabled.
qos_policy_idbodystringQoS policy applied directly (or null).
qos_network_policy_idbodystringQoS policy of the network (or null).
resource_request (Optional)bodyobjectPlacement resource groups / traits requested.
tagsbodyarrayTag list.
created_atbodystringCreation timestamp (ISO 8601).
updated_atbodystringLast update timestamp (ISO 8601) or null.
revision_numberbodyintegerRevision number.
ip_allocationbodystringAllocation mode (immediate, deferred, or none).
dns_assignmentbodyobjectInternal DNS assignment (hostname, ip_address, fqdn).
dns_domainbodystringDNS domain.
dns_namebodystringDNS name.
hintsbodyobjectOVS Userspace Tx packet steering hints (admin-only) if present.
numa_affinity_policy (Optional)bodystringNUMA affinity policy.
propagate_uplink_statusbodybooleanUplink status propagation flag.
mac_learning_enabled (Optional)bodybooleanWhether MAC learning is enabled.
port_trusted_vifbodybooleanTrusted VIF status.
data_plane_statusbodystringUnderlying data plane status if reported.

Status Codes

Success

CodeReason
200 - OKRequest was successful.

Error

CodeReason
400 - Bad RequestSome content in the request was invalid.
401 - UnauthorizedUser must authenticate before making a request.
403 - ForbiddenPolicy does not allow current user to do this operation.
404 - Not FoundThe requested resource could not be found.
409 - ConflictOperation conflicted with another operation on this resource.
412 - Precondition FailedA request precondition (header) was not met.

Example Response

{
"port": {
"id": "2d74fa0c-3e43-4fd9-a234-cbb4996cc684",
"name": "dhcp-port",
"network_id": "f858b8d1-e66b-4a48-bc2e-3f16483b1b58",
"tenant_id": "f33507157a634f1cac71e06a70fb558e",
"mac_address": "fa:16:3e:7f:ae:b2",
"admin_state_up": true,
"status": "DOWN",
"device_id": "dhcpe52a9a47-9f6a-5406-9193-a4d7333f9889-f858b8d1-e66b-4a48-bc2e-3f16483b1b58",
"device_owner": "network:dhcp",
"fixed_ips": [
{
"subnet_id": "adffaac8-2261-43f7-9e4f-6044230f65f1",
"ip_address": "192.168.1.12"
}
],
"allowed_address_pairs": [],
"extra_dhcp_opts": [],
"security_groups": [
"e1c1aa83-7302-4493-9cf4-43c2407e8074"
],
"description": "",
"binding:vnic_type": "normal",
"port_security_enabled": true,
"qos_policy_id": null,
"qos_network_policy_id": "dfc42ced-02c8-4b1f-bbe6-14cc014f259d",
"tags": [],
"created_at": "2025-10-08T08:05:12Z",
"updated_at": "2025-10-08T08:21:32Z",
"revision_number": 3,
"project_id": "f33507157a634f1cac71e06a70fb558e"
}
}

See Also