Loading
close

路由器

time 更新时间:2022-04-26 20:29:15

列举路由

功能介绍

列举逻辑路由。

URI

GET /v2.0/routers

请求消息

参数 是否可选 参数类型 描述
all_tenant boolean 获取所有的逻辑路由

请求示例

GET /v2.0/routers?all_tenant=True

响应消息

参数 参数类型 描述
routers array router对象列表
id String router id
tenant_id String 租户id
project_id String 租户id
name String 名字
description String 描述
admin_state_up boolean admin状态,up/down(true/false)
status String 路由器状态
external_gateway_info object 路由网关信息,需要有netwrok_id,enable_snat和external_fixed_ip否则字段为空
revision_number integer The revision number of the resource.
routes array 静态路由配置,内包含destination(目的地址)和nexthop(下一跳地址)
destination String 目的地址
nexthop String 下一跳地址,必须是子网内的一个存在的ip地址
distributed boolean 是否分布式,true则是dvr
ha boolean 是否高可用
availability_zone_hints array 路由可用域范围
availability_zones array 路由所在的可用域
service_type_id String The ID of the service type associated with the router.
flavor_id String The ID of the flavor associated with the router.
created_at String 创建时间
updated_at String 上一次更新时间
tags array 标签
conntrack_helpers array The associated conntrack helper resources for the roter. 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).

响应示例

{
   "routers":[
      {
         "status":"ACTIVE",
         "external_gateway_info":{
            "network_id":"2dd8b394-fa34-44e8-9ea7-0e470ee5bcd9",
            "enable_snat":true,
            "rate_limit":0,
            "external_fixed_ips":[
               {
                  "subnet_id":"92c30207-01f2-4018-81d9-4f7d59abaad4",
                  "ip_address":"172.16.10.137"
               }
            ]
         },
         "availability_zone_hints":[
            
         ],
         "availability_zones":[
            "default-az"
         ],
         "portforwardings":[
            
         ],
         "description":"",
         "admin_state_up":true,
         "tenant_id":"5608307e73d845918339684a78503e78",
         "created_at":"2021-02-17T13:00:58Z",
         "updated_at":"2021-02-17T13:01:24Z",
         "project_id":"5608307e73d845918339684a78503e78",
         "flavor_id":null,
         "revision_number":12,
         "routes":[
            
         ],
         "ha":true,
         "id":"64b3e621-e1c6-4f7f-a2d8-272df53d42d4",
         "name":"share_router"
      },
      {
         "status":"ACTIVE",
         "external_gateway_info":null,
         "availability_zone_hints":[
            "default-az"
         ],
         "availability_zones":[
            "default-az"
         ],
         "portforwardings":[
            
         ],
         "description":"",
         "admin_state_up":true,
         "tenant_id":"870c5414baee43a4ba7adfb253e46018",
         "created_at":"2021-02-24T07:53:09Z",
         "updated_at":"2021-02-24T07:53:20Z",
         "project_id":"870c5414baee43a4ba7adfb253e46018",
         "flavor_id":null,
         "revision_number":8,
         "routes":[
            
         ],
         "ha":true,
         "id":"95405096-26e5-4f68-a952-5533c5f08292",
         "name":"test2"
      },
   ]
}

创建路由

功能介绍

创建逻辑路由。

URI

GET /v2.0/routers

请求消息

参数 是否可选 参数类型 描述
router object 逻辑路由对象,name为路由器名称

请求示例

POST /v2.0/routers
{
    "router":{
        "name":"test_router",
        "admin_state_up":true
    }
}

响应消息

参数 参数类型 描述
id String router id
tenant_id String 租户id
project_id String 租户id
name String 名字
description String 描述
admin_state_up boolean admin状态,up/down(true/false)
status String 路由器状态
external_gateway_info object 路由网关信息,需要有netwrok_id,enable_snat和external_fixed_ip否则字段为空
revision_number integer The revision number of the resource.
routes array 静态路由配置,内包含destination(目的地址)和nexthop(下一跳地址)
destination String 目的地址
nexthop String 下一跳地址,必须是子网内的一个存在的ip地址
distributed boolean 是否分布式,true则是dvr
ha boolean 是否高可用
availability_zone_hints array 路由可用域范围
availability_zones array 路由所在的可用域
service_type_id String The ID of the service type associated with the router.
flavor_id String The ID of the flavor associated with the router.
created_at String 创建时间
updated_at String 上一次更新时间
tags array 标签
conntrack_helpers array The associated conntrack helper resources for the roter. 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).

响应示例

{
   "router":{
      "status":"ACTIVE",
      "external_gateway_info":null,
      "availability_zone_hints":[
         
      ],
      "availability_zones":[
         
      ],
      "portforwardings":[
         
      ],
      "description":"",
      "admin_state_up":true,
      "tenant_id":"89f60564953c48068513503e4cf4b12f",
      "created_at":"2021-02-24T08:17:05Z",
      "updated_at":"2021-02-24T08:17:05Z",
      "project_id":"89f60564953c48068513503e4cf4b12f",
      "flavor_id":null,
      "revision_number":3,
      "routes":[
         
      ],
      "ha":true,
      "id":"646df665-df48-4f01-a72d-5ef49c47feb0",
      "name":"test_router"
   }
}

更新路由

功能介绍

更新逻辑路由。

添加静态路由: routes字段中配置

{
    "router":{
        "routes":{
            "destination":"192.168.112.0/24",
            "nexthop":"192.168.111.7"
        }
    }
}

端口转发: portforwardings字段中配置

{
    "router":{
        "portforwardings":{
            "inside_addr":"192.168.111.7",
            "protocol":"TCP",
            "outside_port":2222,
            "inside_port":22
        }
    }
}

URI

PUT /v2.0/[router id]

请求消息

参数 是否可选 参数类型 描述
router object 逻辑路由对象

请求示例

PUT /v2.0/routers/646df665-df48-4f01-a72d-5ef49c47feb0

{
    "router":{
        "name":"test_router_rename"
    }
}

响应消息

参数 参数类型 描述
id String router id
tenant_id String 租户id
project_id String 租户id
name String 名字
description String 描述
admin_state_up boolean admin状态,up/down(true/false)
status String 路由器状态
external_gateway_info object 路由网关信息,需要有netwrok_id,enable_snat和external_fixed_ip否则字段为空
revision_number integer The revision number of the resource.
routes array 静态路由配置,内包含destination(目的地址)和nexthop(下一跳地址)
destination String 目的地址
nexthop String 下一跳地址,必须是子网内的一个存在的ip地址
distributed boolean 是否分布式,true则是dvr
ha boolean 是否高可用
availability_zone_hints array 路由可用域范围
availability_zones array 路由所在的可用域
service_type_id String The ID of the service type associated with the router.
flavor_id String The ID of the flavor associated with the router.
created_at String 创建时间
updated_at String 上一次更新时间
tags array 标签
conntrack_helpers array The associated conntrack helper resources for the roter. 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).

响应示例

{
   "router":{
      "status":"ACTIVE",
      "external_gateway_info":null,
      "availability_zone_hints":[
         
      ],
      "availability_zones":[
         "default-az"
      ],
      "portforwardings":[
         
      ],
      "description":"",
      "admin_state_up":true,
      "tenant_id":"89f60564953c48068513503e4cf4b12f",
      "created_at":"2021-02-24T08:17:05Z",
      "updated_at":"2021-02-24T08:25:22Z",
      "project_id":"89f60564953c48068513503e4cf4b12f",
      "flavor_id":null,
      "revision_number":9,
      "routes":[
         
      ],
      "ha":true,
      "id":"646df665-df48-4f01-a72d-5ef49c47feb0",
      "name":"test_router_rename"
   }
}

显示路由详情

功能介绍

现实逻辑路由详情。

URI

GET /v2.0/routers

请求消息

参数 是否可选 参数类型 描述
router_id String 路由器uuid

请求示例

GET /routers/646df665-df48-4f01-a72d-5ef49c47feb0

响应消息

参数 参数类型 描述
id String router id
tenant_id String 租户id
project_id String 租户id
name String 名字
description String 描述
admin_state_up boolean admin状态,up/down(true/false)
status String 路由器状态
external_gateway_info object 路由网关信息,需要有netwrok_id,enable_snat和external_fixed_ip否则字段为空
revision_number integer The revision number of the resource.
routes array 静态路由配置,内包含destination(目的地址)和nexthop(下一跳地址)
destination String 目的地址
nexthop String 下一跳地址,必须是子网内的一个存在的ip地址
distributed boolean 是否分布式,true则是dvr
ha boolean 是否高可用
availability_zone_hints array 路由可用域范围
availability_zones array 路由所在的可用域
service_type_id String The ID of the service type associated with the router.
flavor_id String The ID of the flavor associated with the router.
created_at String 创建时间
updated_at String 上一次更新时间
tags array 标签
conntrack_helpers array The associated conntrack helper resources for the roter. 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).

响应示例

{
   "router":{
      "status":"ACTIVE",
      "external_gateway_info":null,
      "availability_zone_hints":[
         
      ],
      "availability_zones":[
         "default-az"
      ],
      "portforwardings":[
         
      ],
      "description":"",
      "admin_state_up":true,
      "tenant_id":"89f60564953c48068513503e4cf4b12f",
      "created_at":"2021-02-24T08:17:05Z",
      "updated_at":"2021-02-24T08:25:22Z",
      "project_id":"89f60564953c48068513503e4cf4b12f",
      "flavor_id":null,
      "revision_number":9,
      "routes":[
         
      ],
      "ha":true,
      "id":"646df665-df48-4f01-a72d-5ef49c47feb0",
      "name":"test_router_rename"
   }
}

删除路由

功能介绍

删除逻辑路由。

URI

DELETE /v2.0/routers

请求消息

参数 是否可选 参数类型 描述
router_id String 路由器uuid

请求示例

DELETE /v2.0/routers/646df665-df48-4f01-a72d-5ef49c47feb0

响应示例

204 No Content

给路由设置网关

功能介绍

给路由器设置公网网关。

URI

PUT /v2.0/routers/[router id]

请求消息

参数 是否可选 参数类型 描述
router_id String 路由器uuid
router object 逻辑路由对象,router对象中需要包含external_gateway_info

请求示例

PUT /v2.0/routers/cd7aef4b-0417-4eeb-ba99-9f50e91b2877

{
    "router":{
        "external_gateway_info":{
            "network_id":"2dd8b394-fa34-44e8-9ea7-0e470ee5bcd9",
            "external_fixed_ips":"172.16.10.130",
            "rate_limit":1024000
        }
    }
}

响应消息

参数 参数类型 描述
id String router id
tenant_id String 租户id
project_id String 租户id
name String 名字
description String 描述
admin_state_up boolean admin状态,up/down(true/false)
status String 路由器状态
external_gateway_info object 路由网关信息,需要有netwrok_id,enable_snat和external_fixed_ip否则字段为空
revision_number integer The revision number of the resource.
routes array 静态路由配置,内包含destination(目的地址)和nexthop(下一跳地址)
destination String 目的地址
nexthop String 下一跳地址,必须是子网内的一个存在的ip地址
distributed boolean 是否分布式,true则是dvr
ha boolean 是否高可用
availability_zone_hints array 路由可用域范围
availability_zones array 路由所在的可用域
service_type_id String The ID of the service type associated with the router.
flavor_id String The ID of the flavor associated with the router.
created_at String 创建时间
updated_at String 上一次更新时间
tags array 标签
conntrack_helpers array The associated conntrack helper resources for the roter. 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).

响应示例

204 No Content

修改路由网关带宽

功能介绍

给路由器网关设置带宽。

URI

PUT /v2.0/routers/[router id]

请求消息

参数 是否可选 参数类型 描述
router_id String 路由器uuid
router object 逻辑路由对象,router对象中需要包含external_gateway_info,其中需要包含rate_limit字段

请求示例

PUT /v2.0/routers/cd7aef4b-0417-4eeb-ba99-9f50e91b2877

{
    "router":{
        "external_gateway_info":{
            "network_id":"2dd8b394-fa34-44e8-9ea7-0e470ee5bcd9",
            "rate_limit":1024000
        }
    }
}

响应示例

204 No Content

清除路由器网关

功能介绍

清楚路由器网关。

URI

PUT /v2.0/routers/[router id]

请求消息

参数 是否可选 参数类型 描述
router_id String 路由器uuid
router object 逻辑路由对象,router对象中external_gateway_info为空字典

请求示例

PUT /v2.0/routers/cd7aef4b-0417-4eeb-ba99-9f50e91b2877

{
    "router":{
        "external_gateway_info":{

        }
    }
}

响应示例

204 No Content

路由器连接子网

功能介绍

路由器连接子网。

URI

PUT /v2.0/routers/[router id]/add_router_interface

请求消息

参数 是否可选 参数类型 描述
router_id String 路由器uuid
subnet_id 是(subnet_id或者port_id两个二选一) String 需要连接的子网的uuid
port_id String 子网中port的uuid

请求示例

PUT /v2.0/routers/cd7aef4b-0417-4eeb-ba99-9f50e91b2877/add_router_interface

{
    "subnet_id":"5b2e01e6-a632-4421-9447-c4413c1f70bb"
}

响应示例

{
   "network_id":"69433884-3208-4b4a-8ae8-936d730167b5",
   "tenant_id":"870c5414baee43a4ba7adfb253e46018",
   "subnet_id":"5b2e01e6-a632-4421-9447-c4413c1f70bb",
   "subnet_ids":[
      "5b2e01e6-a632-4421-9447-c4413c1f70bb"
   ],
   "port_id":"6a20d12a-480c-4c54-9e89-92248b97108b",
   "id":"cd7aef4b-0417-4eeb-ba99-9f50e91b2877"
}

路由器断开子网

功能介绍

路由器断开子网。

URI

PUT /v2.0/routers/[router id]/remove_router_interface

请求消息

参数 是否可选 参数类型 描述
router_id String 路由器uuid
subnet_id 是(subnet_id或者port_id两个二选一) String 需要连接的子网的uuid
port_id String 子网中port的uuid

请求示例

PUT /v2.0/routers/cd7aef4b-0417-4eeb-ba99-9f50e91b2877/add_router_interface

{
    "subnet_id":"5b2e01e6-a632-4421-9447-c4413c1f70bb"
}

响应示例

{
   "network_id":"69433884-3208-4b4a-8ae8-936d730167b5",
   "tenant_id":"870c5414baee43a4ba7adfb253e46018",
   "subnet_id":"5b2e01e6-a632-4421-9447-c4413c1f70bb",
   "subnet_ids":[
      "5b2e01e6-a632-4421-9447-c4413c1f70bb"
   ],
   "port_id":"6a20d12a-480c-4c54-9e89-92248b97108b",
   "id":"cd7aef4b-0417-4eeb-ba99-9f50e91b2877"
}
此篇文章对你是否有帮助?
没帮助
locked-file

您暂无权限访问该产品