A collegue approached me with a customer request that concerned the NSX-T APIs. More specifically the customer is already using the NSX-T API in management mode but didn’t find the equivalent in the policy API.
Doing my own research, I also failed to find the API right away. This post is basicially a reminder to check on the “realized” state and get the head around the desired state of the NSX-T policy API.

For those who are not familar with the idea behind the policy API, I recommend this blog for a quick overview.

So, what are we trying to find?
From the Tier-1 perspective, we are looking for the IPv4 address of the “Router Link”.
That means, we need to find the status of an object which we declared via desired state.

Quoting from the VMware documentation, a quick re-cap on the router-link:

When you attach a tier-1 logical router to a tier-0 logical router, a router-link switch between the two routers is created. This switch is labeled as system-generated in the topology. The default address space assigned for these tier-0-to-tier-1 connections is 100.64.0.0/16. Each tier-0-to-tier-1 peer connection is provided a /31 subnet within the 100.64.0.0/16 address space.

Relating it to the UI, you can find the information in the Tier-1 details:

Image Caption
NSX-T Router Link

In the management API, the customer used the list of Logical Router Ports to identify the link:

https://vdc-repo.vmware.com/vmwb-repository/dcr-public/612caf56-5bb1-4a0b-8d2b-12ccd8981904/37be75ba-aa56-42f4-99c3-f6c989ddbe57/api_includes/method_ListLogicalRouterPorts.html

In the policy API, anything around Policy > Networking > Connectivity > Tier-1 Gateways didn’t turn up any useful output.
Coming back to the initial stament, we provide the NSX-T policy API with an idea around our desired state. Therefore, we need to check on the “realized objects associated with intent object”.
Long story short, this is the API path which contained the information:

https://<NSX MANAGER>/policy/api/v1/infra/realized-state/realized-entities?intent_path=/infra/tier-1s/<TIER-1>

Breaking it down with jq and curl:

curl -k --location 'https://10.0.0.30/policy/api/v1/infra/realized-state/realized-entities?intent_path=%2Finfra%2Ftier-1s%2Ft1' --header 'Authorization: Basic XXX' --header 'Cookie: JSESSIONID=XXX' | jq -r '.results[2].extended_attributes[0].values[0]'

This is my NSX-T manager with the IP 10.0.0.30 and a Tier-1 called “t1” (creative, right?).

To give you an idea of what else you can get, here is the full output:

{
    "results": [
        {
            "extended_attributes": [
                {
                    "data_type": "STRING",
                    "multivalue": false,
                    "values": [
                        "02:50:56:56:44:52"
                    ],
                    "key": "MacAddress"
                }
            ],
            "entity_type": "RealizedLogicalRouterPort",
            "intent_paths": [
                "/infra/segments/s1",
                "/infra/tier-1s/t1"
            ],
            "resource_type": "GenericPolicyRealizedResource",
            "id": "infra-s1-dlrp",
            "display_name": "infra-s1-dlrp",
            "path": "/infra/realized-state/enforcement-points/default/logical-ports/infra-s1-dlrp",
            "relative_path": "infra-s1-dlrp",
            "parent_path": "/infra/realized-state/enforcement-points/default",
            "remote_path": "",
            "unique_id": "cc77e44d-a5b0-4aff-8fa4-09a2ed53cec4",
            "realization_id": "cc77e44d-a5b0-4aff-8fa4-09a2ed53cec4",
            "owner_id": "29c53ab7-787b-440d-91b8-e3f069f6dce4",
            "intent_reference": [
                "/infra/tier-1s/t1",
                "/infra/segments/s1"
            ],
            "realization_specific_identifier": "1609dcfe-4930-4426-9c49-3c9c40eb2908",
            "realization_api": "/api/v1/logical-router-ports/1609dcfe-4930-4426-9c49-3c9c40eb2908",
            "state": "REALIZED",
            "alarms": [],
            "runtime_status": "UNINITIALIZED",
            "publish_status": "UNINITIALIZED",
            "_create_time": 1695021529148,
            "_create_user": "system",
            "_last_modified_time": 1695021529548,
            "_last_modified_user": "system",
            "_system_owned": false,
            "_protection": "NOT_PROTECTED",
            "_revision": 1
        },
        {
            "entity_type": "AdvertisementConfig",
            "intent_paths": [
                "/infra/tier-1s/t1"
            ],
            "resource_type": "GenericPolicyRealizedResource",
            "id": "t1-network-rtadv",
            "display_name": "t1-network-rtadv",
            "path": "/infra/realized-state/enforcement-points/default/routing-advertisements/t1-network-rtadv",
            "relative_path": "t1-network-rtadv",
            "parent_path": "/infra/realized-state/enforcement-points/default",
            "remote_path": "",
            "unique_id": "94f99fbc-060a-443b-b488-ca2899df7d4e",
            "realization_id": "94f99fbc-060a-443b-b488-ca2899df7d4e",
            "owner_id": "29c53ab7-787b-440d-91b8-e3f069f6dce4",
            "intent_reference": [
                "/infra/tier-1s/t1"
            ],
            "realization_specific_identifier": "a72eae16-efe8-419f-8ef4-23f7a55a5bb1",
            "realization_api": "/api/v1/logical-routers//a72eae16-efe8-419f-8ef4-23f7a55a5bb1/routing/advertisement",
            "state": "REALIZED",
            "alarms": [],
            "runtime_status": "SUCCESS",
            "publish_status": "SUCCESS",
            "operational_status": "STATUS_GREEN",
            "publish_time": 1695021542601,
            "_create_time": 1695021411817,
            "_create_user": "system",
            "_last_modified_time": 1695021438807,
            "_last_modified_user": "system",
            "_system_owned": false,
            "_protection": "NOT_PROTECTED",
            "_revision": 2
        },
        {
            "extended_attributes": [
                {
                    "data_type": "STRING",
                    "multivalue": true,
                    "values": [
                        "100.64.0.1/31",
                        "fc8c:827d:837:400::2/64"
                    ],
                    "key": "IpAddresses"
                },
                {
                    "data_type": "STRING",
                    "multivalue": false,
                    "values": [
                        "02:50:56:56:44:55"
                    ],
                    "key": "MacAddress"
                }
            ],
            "entity_type": "RealizedLogicalRouterPort",
            "intent_paths": [
                "/infra/tier-1s/t1"
            ],
            "resource_type": "GenericPolicyRealizedResource",
            "id": "t0-t1-t1_lrp",
            "display_name": "t0-t1-t1_lrp",
            "path": "/infra/realized-state/enforcement-points/default/logical-ports/t0-t1-t1_lrp",
            "relative_path": "t0-t1-t1_lrp",
            "parent_path": "/infra/realized-state/enforcement-points/default",
            "remote_path": "",
            "unique_id": "4408a0bc-5d76-4511-a343-4266b741c038",
            "realization_id": "4408a0bc-5d76-4511-a343-4266b741c038",
            "owner_id": "29c53ab7-787b-440d-91b8-e3f069f6dce4",
            "intent_reference": [
                "/infra/tier-1s/t1"
            ],
            "realization_specific_identifier": "bd83c9c2-1854-4c81-a285-a9a507153b61",
            "realization_api": "/api/v1/logical-router-ports/bd83c9c2-1854-4c81-a285-a9a507153b61",
            "state": "REALIZED",
            "alarms": [],
            "runtime_status": "UNINITIALIZED",
            "publish_status": "UNINITIALIZED",
            "_create_time": 1695021413422,
            "_create_user": "system",
            "_last_modified_time": 1695021413978,
            "_last_modified_user": "system",
            "_system_owned": false,
            "_protection": "NOT_PROTECTED",
            "_revision": 2
        },
        {
            "extended_attributes": [
                {
                    "data_type": "STRING",
                    "multivalue": false,
                    "values": [
                        "ROUTING"
                    ],
                    "key": "alloc_pool"
                },
                {
                    "data_type": "STRING",
                    "multivalue": true,
                    "values": [
                        "0"
                    ],
                    "key": "EdgeIndexes"
                },
                {
                    "data_type": "BOOLEAN",
                    "multivalue": false,
                    "values": [
                        "false"
                    ],
                    "key": "disable_firewall"
                },
                {
                    "data_type": "STRING",
                    "multivalue": true,
                    "values": [
                        "/infra/sites/default/enforcement-points/default/edge-clusters/22156556-e7c6-4785-b6fd-2302985e0ed2/edge-nodes/0"
                    ],
                    "key": "preferred_edgenodes"
                },
                {
                    "data_type": "STRING",
                    "multivalue": false,
                    "values": [
                        "/infra/tier-0s/t0"
                    ],
                    "key": "tier0_path"
                },
                {
                    "data_type": "STRING",
                    "multivalue": false,
                    "values": [
                        "AUTO"
                    ],
                    "key": "edge-alloc-mode"
                }
            ],
            "entity_type": "RealizedLogicalRouter",
            "intent_paths": [
                "/infra/tier-1s/t1"
            ],
            "resource_type": "GenericPolicyRealizedResource",
            "id": "t1-t1",
            "display_name": "t1-t1",
            "path": "/infra/realized-state/enforcement-points/default/tier-1-logical-routers/t1-t1",
            "relative_path": "t1-t1",
            "parent_path": "/infra/realized-state/enforcement-points/default",
            "remote_path": "",
            "unique_id": "73a6d4c6-4823-4e4c-8099-ad65a173b7b1",
            "realization_id": "73a6d4c6-4823-4e4c-8099-ad65a173b7b1",
            "owner_id": "29c53ab7-787b-440d-91b8-e3f069f6dce4",
            "intent_reference": [
                "/infra/tier-1s/t1"
            ],
            "realization_specific_identifier": "a72eae16-efe8-419f-8ef4-23f7a55a5bb1",
            "realization_api": "/api/v1/logical-routers/a72eae16-efe8-419f-8ef4-23f7a55a5bb1",
            "state": "REALIZED",
            "alarms": [],
            "runtime_status": "SUCCESS",
            "publish_status": "SUCCESS",
            "operational_status": "STATUS_GREEN",
            "publish_time": 1695021421890,
            "_create_time": 1695021411107,
            "_create_user": "system",
            "_last_modified_time": 1695021438577,
            "_last_modified_user": "system",
            "_system_owned": false,
            "_protection": "NOT_PROTECTED",
            "_revision": 3
        },
        {
            "extended_attributes": [
                {
                    "data_type": "STRING",
                    "multivalue": true,
                    "values": [
                        "100.64.0.0/31",
                        "fc8c:827d:837:400::1/64"
                    ],
                    "key": "IpAddresses"
                },
                {
                    "data_type": "STRING",
                    "multivalue": false,
                    "values": [
                        "02:50:56:56:44:52"
                    ],
                    "key": "MacAddress"
                }
            ],
            "entity_type": "RealizedLogicalRouterPort",
            "intent_paths": [
                "/infra/tier-0s/t0",
                "/infra/tier-1s/t1"
            ],
            "resource_type": "GenericPolicyRealizedResource",
            "id": "t0-t1-t0_lrp",
            "display_name": "t0-t1-t0_lrp",
            "path": "/infra/realized-state/enforcement-points/default/logical-ports/t0-t1-t0_lrp",
            "relative_path": "t0-t1-t0_lrp",
            "parent_path": "/infra/realized-state/enforcement-points/default",
            "remote_path": "",
            "unique_id": "f32b3066-13cd-48fd-bbba-11e37bd93750",
            "realization_id": "f32b3066-13cd-48fd-bbba-11e37bd93750",
            "owner_id": "29c53ab7-787b-440d-91b8-e3f069f6dce4",
            "intent_reference": [
                "/infra/tier-0s/t0",
                "/infra/tier-1s/t1"
            ],
            "realization_specific_identifier": "37325b69-9bf7-5f61-b59d-4a23458ddbe6",
            "realization_api": "/api/v1/logical-router-ports/37325b69-9bf7-5f61-b59d-4a23458ddbe6",
            "state": "REALIZED",
            "alarms": [],
            "runtime_status": "UNINITIALIZED",
            "publish_status": "UNINITIALIZED",
            "_create_time": 1695021412236,
            "_create_user": "system",
            "_last_modified_time": 1695021413362,
            "_last_modified_user": "system",
            "_system_owned": false,
            "_protection": "NOT_PROTECTED",
            "_revision": 2
        }
    ],
    "result_count": 5
}