Go to main content

Oracle® ZFS Storage Appliance RESTful API 指南,发行版 OS8.8.0

退出打印视图

更新时间: 2018 年 11 月
 
 

网络路由

这些命令管理网络路由。

表 41  管理网络路由
请求
附加到路径 /api/network/v1
说明
POST
/routes
创建新的网络路由
GET
/routes/route
获取指定的网络路由属性
GET
/routes
列出所有网络路由对象
DELETE
/routes/route
销毁指定的路由对象
GET
/routing
获取网络路由属性
PUT
/routing
修改网络路由属性
表 42  管理网络路由属性
属性
说明
type
路由类型,例如 "system" 或 "static"(不可变)
family
地址族(IPv4 或 IPv6)
destination
路由目标地址
gateway
网关地址
interface
网络数据链路接口

各个路由的 href 路径都使用在 CLI 中设置的路由 ID 集,但当修改路由时,这些值也会发生变化。API 支持使用路由中的唯一属性选择单个路由。语法为 routes/name=value,对应于 routes/route-###

列出路由

列出在设备上创建的所有网络路由。

请求示例:

GET /api/network/v1/routes HTTP/1.1
Authorization: Basic abcd1234MWE=
Host: zfs-storage.example.com:215
Accept: application/json

结果示例:

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 192

{
    "routes": [{
        "destination": "ipaddr-0",
        "family": "IPv4",
        "gateway": "ipaddr-1",
        "href": "/api/network/v1/routing/route-000",
        "interface": "ixgbe0",
        "mask": 0,
        "route": "route-000",
        "type": "static"
    }, {
        "destination": "ipaddr-2",
        "family": "IPv4",
        "gateway": "ipaddr-3",
        "href": "/api/network/v1/routes/route-001",
        "interface": "ixgbe0",
        "mask": 24,
        "route": "route-001",
        "type": "system"
    }]
}

获取路由

获取单个路由的属性。

请求示例:

GET /api/network/v1/routes/destination=ipaddr-1 HTTP/1.1
Authorization: Basic abcd1234MWE=
Host: zfs-storage.example.com:215
Accept: application/json

结果示例:

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 192

{
    "route": {
        "destination": "ipaddr-1",
        "family": "IPv4",
        "gateway": "ipaddr-2",
        "href": "/api/network/v1/routes/route-001",
        "interface": "ixgbe0",
        "mask": 24,
        "route": "route-001",
        "type": "system"
    }
}

添加路由

创建新的网络路由。如果向系统添加其他路由,则路由 href 值会发生更改。创建路由时将不会返回路由信息,因为返回的属性将与输入属性相同。成功创建路由后会返回 HTTP 状态 204 (Created)。

创建静态路由的请求示例:

POST /api/network/v1/routes HTTP/1.1
Authorization: Basic abcd1234MWE=
Host: zfs-storage.example.com:215
Content-Type: application/json
Content-Length: 164

{
    "family": "IPv4",
    "destination": "ipaddr-0",
    "mask": "0",
    "gateway": "ipaddr-1",
    "interface": "ixgbe0"
}

结果示例:

HTTP/1.1 201 Created

删除路由

删除现有网络路由。

请求示例:

DELETE /api/network/v1/routes/route-001 HTTP/1.1
Authorization: Basic abcd1234MWE=
Host: zfs-storage.example.com:215

结果示例:

HTTP/1.1 204 No Content