Listing virtual routers

GET /v2.0/routers

Lists virtual routers that the project who submits the request can access.

Default policy settings return only those routers that the project who submits the request owns, unless an administrative user submits the request.

Source: https://docs.openstack.org/api-ref/network/v2/index.html?expanded=list-routers-detail#list-routers

Request

Parameters

Name In Type Description
id (Optional) query string Filter the list result by the ID of the router.
tenant_id (Optional) query string Filter the list result by the ID of the project that owns the resource.
project_id (Optional) query string Filter the list result by the ID of the project that owns the resource.
name (Optional) query string Filter the list result by the human-readable name of the resource.
description (Optional) query string Filter the list result by the human-readable description of the resource.
admin_state_up (Optional) query boolean Filter the list result by the administrative state of the resource, which is up (true) or down (false).
revision_number (Optional) query integer Filter the list result by the revision number of the resource.
sort_dir (Optional) query string Sort direction. A valid value is asc (ascending) or desc (descending). You can specify multiple pairs of sort key and sort direction query parameters.
sort_key (Optional) query string

Sorts by a router attribute. You can specify multiple pairs of sort key and sort direction query parameters. The sort keys are limited to:

  • admin_state_up
  • flavor_id
  • id
  • name
  • status
  • tenant_id
  • project_id
tags (Optional) query string A list of tags to filter the list result by. Resources that match all tags in this list will be returned. Tags in query must be separated by comma.
tags-any (Optional) query string A list of tags to filter the list result by. Resources that match any tag in this list will be returned. Tags in query must be separated by comma.
not-tags (Optional) query string A list of tags to filter the list result by. Resources that match all tags in this list will be excluded. Tags in query must be separated by comma.
not-tags-any (Optional) query string A list of tags to filter the list result by. Resources that match any tag in this list will be excluded. Tags in query must be separated by comma.
fields (Optional) query string The fields that you want the server to return. If no fields query parameter is specified, the networking API returns all attributes allowed by the policy settings. By using the fields parameter, the API returns only the requested set of attributes. The fields parameter can be specified multiple times. For example, if you specify fields=id&fields=name in the request URL, only the id and name attributes will be returned.

Example

# curl -ks -H 'Content-Type: application/json' -H 'X-Auth-Token: gAAAAA<...>' \
https://<node_IP_addr>:9696/v2.0/routers

Response

Parameters

Name In Type Description
routers body array A list of router objects.
id body string The ID of the router.
tenant_id body string The ID of the project.
project_id body string The ID of the project.
name body string Human-readable name of the resource.
description body string A human-readable description for the resource.
admin_state_up body boolean The administrative state of the resource, which is up (true) or down (false).
status body string The router status.
external_gateway_info body object The external gateway information of the router. If the router has an external gateway, this would be a dictionary of network_id, enable_snat and external_fixed_ips. Otherwise, this would be null.
network_id body string Network ID which the router gateway is connected to.
enable_snat body boolean Enable Source NAT (SNAT) attribute. true means Network Address Translation (NAT) is enabled for traffic generated by subnets attached to the router when the traffic is sent to/received from the external network. false means no NAT is applied for traffic from/to the external network. It is available when ext-gw-mode extension is enabled.
external_fixed_ips body array IP address(es) of the external gateway of the router. It is a list of IP addresses. Each element of the list is a dictionary of ip_address and subnet_id.
revision_number body integer The revision number of the resource.
routes body array The extra routes configuration for L3 router. A list of dictionaries with destination and nexthop parameters. It is available when extraroute extension is enabled.
destination body string The destination CIDR.
nexthop body string The IP address of the next hop for the corresponding destination. The next hop IP address must be a part of one of the subnets to which the router interfaces are connected.
distributed body boolean true indicates a distributed router. It is available when dvr extension is enabled.
ha body boolean true indicates a highly-available router. It is available when l3-ha extension is enabled.
availability_zone_hints body array The availability zone candidates for the router. It is available when router_availability_zone extension is enabled.
availability_zones body array The availability zone(s) for the router. It is available when router_availability_zone extension is enabled.
service_type_id body string The ID of the service type associated with the router.
flavor_id body string The ID of the flavor associated with the router.
created_at body string

The date and time when the resource was created.

The date and time stamp format is ISO 8601:

CCYY-MM-DDThh:mm:ss±hh:mm

For example, 2015-08-27T09:49:58-05:00.

The ±hh:mm value, if included, is the time zone as an offset from UTC. In this example, the offset value is -05:00.

updated_at body string

The date and time when the resource was updated. If the resource has not been updated, this field will be null.

The date and time stamp format is ISO 8601:

CCYY-MM-DDThh:mm:ss±hh:mm

For example, 2015-08-27T09:49:58-05:00.

The ±hh:mm value, if included, is the time zone as an offset from UTC. In this example, the offset value is -05:00.

tags body array The list of tags on the router.
conntrack_helpers body array The associated conntrack helper resources for the router. If the router has multiple conntrack helper resources, this field has multiple entries. Each entry consists of netfilter conntrack helper (helper), the network protocol (protocol), the network port (port).

Status codes

Success

Code Reason
200 - OK Request was successful.

Error

Code Reason
401 - Unauthorized

User must authenticate before making a request.

Example

{
  "routers": [
    {
      "status": "ACTIVE",
      "external_gateway_info": {
        "network_id": "b4907761-8c0f-447e-9cfe-c688ca6e44a0",
        "enable_snat": true,
        "external_fixed_ips": [
          {
            "subnet_id": "351884c7-ee37-4a7d-9dcb-4cff4a1bba27",
            "ip_address": "10.94.139.172"
          }
        ]
      },
      "availability_zone_hints": [],
      "availability_zones": [
        "nova"
      ],
      "description": "",
      "tags": [],
      "tenant_id": "f5d834d636c642c7bfe8af86139c6f26",
      "created_at": "2020-03-04T15:22:40Z",
      "admin_state_up": true,
      "distributed": false,
      "updated_at": "2020-03-04T15:22:44Z",
      "project_id": "f5d834d636c642c7bfe8af86139c6f26",
      "flavor_id": null,
      "revision_number": 4,
      "routes": [],
      "ha": false,
      "id": "ce996632-45a2-4c6b-a951-a624eba74621",
      "name": "router1"
    }
  ]
}