文档目录

二层网络资源相关接口

创建VXLAN网络池(CreateL2VxlanNetworkPool)

API请求

URLs
POST zstack/v1/l2-networks/vxlan-pool
Headers
Authorization: OAuth the-session-uuid
Body
{
  "params": {
    "name": "Test-NetPool",
    "description": "Test",
    "zoneUuid": "2de2048daac33068aecac1f5b40d1343",
    "vSwitchType": "LinuxBridge"
  },
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"name":"Test-NetPool","description":"Test","zoneUuid":"2de2048daac33068aecac1f5b40d1343","vSwitchType":"LinuxBridge"}}' \
http://localhost:8080/zstack/v1/l2-networks/vxlan-pool
参数列表
名字 类型 位置 描述 可选值 起始版本
name String body(包含在params结构中) 资源名称 0.6
description (可选) String body(包含在params结构中) 资源的详细描述 0.6
zoneUuid String body(包含在params结构中) 区域UUID 0.6
physicalInterface String body(包含在params结构中) 0.6
type (可选) String body(包含在params结构中) 0.6
resourceUuid (可选) String body(包含在params结构中) 0.6
systemTags (可选) List body 0.6
userTags (可选) List body 0.6
vSwitchType String body(包含在params结构中) 虚拟交换机类型
  • LinuxBridge
  • OvsDpdk
4.8.0
TagUuid(可选) List body(包含在params结构中) 标签UUID列表 3.4.0

API返回

返回示例
{
  "inventory": {
    "name": "Test-NetPool",
    "description": "Test",
    "zoneUuid": "7340dabd00b739e9ab33895edcdc48de",
    "type": "L2VxlanNetwork"
  }
}
名字 类型 描述 起始版本
success boolean 0.6
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 0.6
inventory L2VxlanNetworkPoolInventory 详情参考inventory 0.6
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 0.6
description String 错误的概要描述 0.6
details String 错误的详细信息 0.6
elaboration String 保留字段,默认为null 0.6
opaque LinkedHashMap 保留字段,默认为null 0.6
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 0.6
#inventory
名字 类型 描述 起始版本
attachedCidrs Map 4.8.0
uuid String 资源的UUID,唯一标示该资源 4.8.0
name String 资源名称 4.8.0
description String 资源的详细描述 4.8.0
zoneUuid String 区域UUID 4.8.0
physicalInterface String 4.8.0
type String 4.8.0
createDate Timestamp 创建时间 4.8.0
lastOpDate Timestamp 最后一次修改时间 4.8.0
attachedClusterUuids List 4.8.0
attachedVtepRefs List 详情参考attachedVtepRefs 4.8.0
attachedVxlanNetworkRefs List 详情参考attachedVxlanNetworkRefs 4.8.0
attachedVniRanges List 详情参考attachedVniRanges 4.8.0
#attachedVtepRefs
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 0.6
hostUuid String 物理机UUID 0.6
vtepIp String 0.6
port Integer 0.6
type String 0.6
createDate Timestamp 创建时间 0.6
lastOpDate Timestamp 最后修改时间 0.6
poolUuid String 0.6
#attachedVxlanNetworkRefs
名字 类型 描述 起始版本
vni Integer 0.6
poolUuid String 0.6
uuid String 资源的UUID,唯一标示该资源 0.6
name String 资源名称 0.6
description String 资源的详细描述 0.6
zoneUuid String 区域UUID 0.6
physicalInterface String 0.6
type String 0.6
createDate Timestamp 创建时间 0.6
lastOpDate Timestamp 最后一次修改时间 0.6
attachedClusterUuids List 0.6
#attachedVniRanges
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 0.6
name String 资源名称 0.6
description String 资源的详细描述 0.6
startVni Integer 0.6
endVni Integer 0.6
createDate Timestamp 创建时间 0.6
lastOpDate Timestamp 最后一次修改时间 0.6
l2NetworkUuid String 二层网络UUID 0.6

SDK示例

Java SDK
CreateL2VxlanNetworkPoolAction action = new CreateL2VxlanNetworkPoolAction();
action.name = "Test-NetPool";
action.description = "Test";
action.zoneUuid = "2de2048daac33068aecac1f5b40d1343";
action.vSwitchType = "LinuxBridge";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateL2VxlanNetworkPoolAction.Result res = action.call();
Python SDK
CreateL2VxlanNetworkPoolAction action = CreateL2VxlanNetworkPoolAction()
action.name = "Test-NetPool"
action.description = "Test"
action.zoneUuid = "2de2048daac33068aecac1f5b40d1343"
action.vSwitchType = "LinuxBridge"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateL2VxlanNetworkPoolAction.Result res = action.call()

查询VXLAN网络池(QueryL2VxlanNetworkPool)

API请求

URLs
GET zstack/v1/l2-networks/vxlan-pool
GET zstack/v1/l2-networks/vxlan-pool/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b2132aefec76492cb00aff0a2d97a202" \
-X GET http://localhost:8080/zstack/v1/l2-networks/vxlan-pool
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth 07c093f70f10467e826adc1743a022e6" \
-X GET http://localhost:8080/zstack/v1/l2-networks/vxlan-pool/0576843440c74069b541faa856f71d39

可查询字段

运行CLI命令行工具,输入QueryL2VxlanNetworkPool并按Tab键查看所有可查询字段以及可跨表查询的资源名。

API返回

返回示例
{
"inventories": [
    {
"name": "Test-Net",
"description": "Test",
"zoneUuid": "6199e247f6bf4157a41e51ed7ff2f78c",
"type": "L2VxlanNetworkPool",
"vSwitchType":"LinuxBridge"
    }
  ]
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 0.6
inventories List 详情参考inventories 0.6
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 0.6
description String 错误的概要描述 0.6
details String 错误的详细信息 0.6
elaboration String 保留字段,默认为null 0.6
opaque LinkedHashMap 保留字段,默认为null 0.6
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 0.6
#inventories
名字 类型 描述 起始版本
attachedCidrs Map 0.6
uuid String 资源的UUID,唯一标示该资源 0.6
name String 资源名称 0.6
description String 资源的详细描述 0.6
vSwitchType String 虚拟交换机类型 4.8.0
zoneUuid String 区域UUID 0.6
physicalInterface String 0.6
type String 0.6
createDate Timestamp 创建时间 0.6
lastOpDate Timestamp 最后一次修改时间 0.6
attachedClusterUuids List 0.6
attachedVtepRefs List 详情参考attachedVtepRefs 0.6
attachedVxlanNetworkRefs List 详情参考attachedVxlanNetworkRefs 0.6
attachedVniRanges List 详情参考attachedVniRanges 0.6
#attachedVtepRefs
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 0.6
hostUuid String 物理机UUID 0.6
vtepIp String 0.6
port Integer 0.6
type String 0.6
poolUuid String 0.6
#attachedVxlanNetworkRefs
名字 类型 描述 起始版本
vni Integer 0.6
poolUuid String 0.6
uuid String 资源的UUID,唯一标示该资源 0.6
name String 资源名称 0.6
description String 资源的详细描述 0.6
zoneUuid String 区域UUID 0.6
physicalInterface String 0.6
type String 0.6
createDate Timestamp 创建时间 0.6
lastOpDate Timestamp 最后一次修改时间 0.6
attachedClusterUuids List 0.6
#attachedVniRanges
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 0.6
name String 资源名称 0.6
description String 资源的详细描述 0.6
startVni Integer 0.6
endVni Integer 0.6
createDate Timestamp 创建时间 0.6
lastOpDate Timestamp 最后一次修改时间 0.6
l2NetworkUuid String 二层网络UUID 0.6

SDK示例

Java SDK
QueryL2VxlanNetworkPoolAction action = new QueryL2VxlanNetworkPoolAction();
action.conditions = asList();
action.sessionId = "773c52887a0945c4b5dee525e71f5287";
QueryL2VxlanNetworkPoolAction.Result res = action.call();
Python SDK
QueryL2VxlanNetworkPoolAction action = QueryL2VxlanNetworkPoolAction()
action.conditions = []
action.sessionId = "0fa3249e9dbd48f3951a93a772882f67"
QueryL2VxlanNetworkPoolAction.Result res = action.call()

创建VXLAN网络(CreateL2VxlanNetwork)

API请求

URLs
POST zstack/v1/l2-networks/vxlan
Headers
Authorization: OAuth the-session-uuid
Body
{
  "params": {
    "vni": 10,
    "poolUuid": "c27a329718ed3585a27d227174ed1ace",
    "name": "Test-Net",
    "description": "Test",
    "zoneUuid": "8dd66847fcf930178acc687cb4c1438c",
    "vSwitchType": "LinuxBridge"
  },
  "systemTags": [],
  "userTags": []
}}
Note: 上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"vni":10,"poolUuid":"c27a329718ed3585a27d227174ed1ace","name":"Test-Net","description":"Test","zoneUuid":"8dd66847fcf930178acc687cb4c1438c","vSwitchType":"LinuxBridge"}}' \
http://localhost:8080/zstack/v1/l2-networks/vxlan
参数列表
名字 类型 位置 描述 可选值 起始版本
vni (可选) Integer body(包含在params结构中) 0.6
poolUuid String body(包含在params结构中) Vxlan网络资源池uuid 0.6
name String body(包含在params结构中) 资源名称 0.6
description (可选) String body(包含在params结构中) 资源的详细描述 0.6
zoneUuid String body(包含在params结构中) 区域UUID 0.6
physicalInterface String body(包含在params结构中) 0.6
type (可选) String body(包含在params结构中) 0.6
resourceUuid (可选) String body(包含在params结构中) 0.6
systemTags (可选) List body 0.6
userTags (可选) List body 0.6
vSwitchType (可选) String body(包含在params结构中) 虚拟交换机类型
  • LinuxBridge
  • OvsDpdk
4.8.0
tagUuids (可选) List body(包含在params结构中) 标签UUID列表 3.4.0

API返回

返回示例
{
  "inventory": {
    "vni": 10,
    "poolUuid": "848a93cca6b43a67930af04c70f2abd3",
    "name": "Test-Net",
    "description": "Test",
    "zoneUuid": "1b6c6d39024a3e59ba597cd651fe064f",
    "type": "L2VxlanNetwork"
  }
}
名字 类型 描述 起始版本
success boolean 0.6
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 0.6
inventory L2VxlanNetworkPoolInventory 详情参考inventory 0.6
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 4.8.0
description String 错误的概要描述 4.8.0
details String 错误的详细信息 4.8.0
elaboration String 保留字段,默认为null 4.8.0
opaque LinkedHashMap 保留字段,默认为null 4.8.0
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 4.8.0
#inventory
名字 类型 描述 起始版本
vni Integer 0.6
poolUuid String Vxlan网络资源池uuid 0.6
uuid String 资源的UUID,唯一标示该资源 0.6
name String 资源名称 0.6
description String 资源的详细描述 0.6
zoneUuid String 区域UUID 0.6
physicalInterface String 0.6
type String 0.6
createDate Timestamp 创建时间 0.6
lastOpDate Timestamp 最后一次修改时间 0.6
attachedClusterUuids List 0.6

SDK示例

Java SDK
CreateL2VxlanNetworkAction action = new CreateL2VxlanNetworkAction();
action.vni = 10;
action.poolUuid = "c27a329718ed3585a27d227174ed1ace";
action.name = "Test-Net";
action.description = "Test";
action.zoneUuid = "8dd66847fcf930178acc687cb4c1438c";
action.vSwitchType = "LinuxBridge";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateL2VxlanNetworkAction.Result res = action.call();
Python SDK
CreateL2VxlanNetworkAction action = CreateL2VxlanNetworkAction()
action.vni = 10
action.poolUuid = "c27a329718ed3585a27d227174ed1ace"
action.name = "Test-Net"
action.description = "Test"
action.zoneUuid = "8dd66847fcf930178acc687cb4c1438c"
action.vSwitchType = "LinuxBridge"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateL2VxlanNetworkAction.Result res = action.call()

查询VXLAN网络(QueryL2VxlanNetwork)

API请求

URLs
GET zstack/v1/l2-networks/vxlan
GET zstack/v1/l2-networks/vxlan/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth eff53f15d4ad4f17b3dc13bc15d7f0f6" \
-X GET http://localhost:8080/zstack/v1/l2-networks/vxlan
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth 801edfc2a7f244198ed2f13743c1b232" \
-X GET http://localhost:8080/zstack/v1/l2-networks/vxlan/8dcdd0a8c57a45a5a884887f5a0681c7

可查询字段

运行CLI命令行工具,输入QueryL2VxlanNetwork并按Tab键查看所有可查询字段以及可跨表查询的资源名。

API返回

返回示例
{
"inventories": [
    {
"name": "Test-Net",
"description": "Test",
"zoneUuid": "ef52a71330384e3080c88b243bf3fae2",
"type": "L2VxlanNetwork",
"vSwitchType":"LinuxBridge"
    }
  ]
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 0.6
inventories List 详情参考inventories 0.6
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 0.6
description String 错误的概要描述 0.6
details String 错误的详细信息 0.6
elaboration String 保留字段,默认为null 0.6
opaque LinkedHashMap 保留字段,默认为null 0.6
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 0.6
#inventories
名字 类型 描述 起始版本
vni Integer 0.6
poolUuid String 0.6
uuid String 资源的UUID,唯一标示该资源 0.6
name String 资源名称 0.6
description String 资源的详细描述 0.6
vSwitchType String 虚拟交换机类型 4.8.0
zoneUuid String 区域UUID 0.6
physicalInterface String 0.6
type String 0.6
createDate Timestamp 创建时间 0.6
lastOpDate Timestamp 最后一次修改时间 0.6
attachedClusterUuids List 0.6

SDK示例

Java SDK
QueryL2VxlanNetworkAction action = new QueryL2VxlanNetworkAction();
action.conditions = asList();
action.sessionId = "4a008984bc2844e59b6fa8acf188d587";
QueryL2VxlanNetworkAction.Result res = action.call();
Python SDK
QueryL2VxlanNetworkAction action = QueryL2VxlanNetworkAction()
action.conditions = []
action.sessionId = "c530e08c8ad24dbeb986647100eff212"
QueryL2VxlanNetworkAction.Result res = action.call()

创建普通二层网络(CreateL2NoVlanNetwork)

API请求

URLs
POST zstack/v1/l2-networks/no-vlan
Headers
Authorization: OAuth the-session-uuid
Body
{
  "params": {
    "name": "Test-Net",
    "description": "Test",
    "zoneUuid": "c23ba5023fcb3b4b8c3e76c443005e3d",
    "physicalInterface": "eth0",
    "vSwitchType": "LinuxBridge"
  },
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"name":"Test-Net","description":"Test","zoneUuid":"c23ba5023fcb3b4b8c3e76c443005e3d","physicalInterface":"eth0","vSwitchType":"LinuxBridge"}}' \
http://localhost:8080/zstack/v1/l2-networks/no-vlan
参数列表
名字 类型 位置 描述 可选值 起始版本
name String body(包含在params结构中) 普通二层网络名称 0.6
description (可选) String body(包含在params结构中) 普通二层网络的详细描述 0.6
zoneUuid String body(包含在params结构中) 区域UUID 0.6
physicalInterface String body(包含在params结构中) 物理网卡 0.6
type (可选) String body(包含在params结构中) 二层网络类型 0.6
vSwitchType (可选) String body(包含在params结构中) 虚拟交换机类型 4.8.0
resourceUuid (可选) String body(包含在params结构中) 资源UUID。若指定,二层网络会使用该字段值作为UUID 0.6
systemTags (可选) List body 系统标签 0.6
userTags (可选) List body 用户标签 0.6
tagUuids (可选) List body(包含在params结构中) 标签UUID列表 3.4.0

API返回

返回示例
{
  "inventory": {
    "uuid": "672906b1aeca3a68a24c1b07a4f8deb5",
    "name": "test",
    "zoneUuid": "b478828872db33a4807d90e9f16f39e4",
    "physicalInterface": "eth0"
  }
}
名字 类型 描述 起始版本
success boolean 0.6
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 0.6
inventory L2NetworkInventory 详情参考inventory 0.6
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 0.6
description String 错误的概要描述 0.6
details String 错误的详细信息 0.6
elaboration String 保留字段,默认为null 0.6
opaque LinkedHashMap 保留字段,默认为null 0.6
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 0.6
#inventory
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 0.6
name String 资源名称 0.6
description String 资源的详细描述 0.6
zoneUuid String 区域UUID 0.6
physicalInterface String 0.6
type String 0.6
createDate Timestamp 创建时间 0.6
lastOpDate Timestamp 最后一次修改时间 0.6
attachedClusterUuids List 0.6

SDK示例

Java SDK
CreateL2NoVlanNetworkAction action = new CreateL2NoVlanNetworkAction();
action.name = "Test-Net";
action.description = "Test";
action.zoneUuid = "c23ba5023fcb3b4b8c3e76c443005e3d";
action.physicalInterface = "eth0";
action.vSwitchType = "LinuxBridge";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateL2NoVlanNetworkAction.Result res = action.call();
Python SDK
CreateL2NoVlanNetworkAction action = CreateL2NoVlanNetworkAction()
action.name = "Test-Net"
action.description = "Test"
action.zoneUuid = "c23ba5023fcb3b4b8c3e76c443005e3d"
action.physicalInterface = "eth0"
action.vSwitchType = "LinuxBridge"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateL2NoVlanNetworkAction.Result res = action.call()

创建二层VLAN网络(CreateL2VlanNetwork)

API请求

URLs
POST zstack/v1/l2-networks/vlan
Headers
OAuth: the-session-uuid
Body
{
  "params": {
    "vlan": 10,
    "name": "Test-Net",
    "description": "Test",
    "zoneUuid": "43af355e5eae3ab0b74ee76ca9c19005",
    "physicalInterface": "eth0",
    "vSwitchType": "LinuxBridge"
  },
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"vlan":10.0,"name":"Test-Net","description":"Test","zoneUuid":"43af355e5eae3ab0b74ee76ca9c19005","physicalInterface":"eth0","vSwitchType":"LinuxBridge"}}' \
http://localhost:8080/zstack/v1/l2-networks/vlan
参数列表
名字 类型 位置 描述 可选值 起始版本
vlan Integer body(包含在params结构中) 0.6
name String body(包含在params结构中) 资源名称 0.6
description (可选) String body(包含在params结构中) 资源的详细描述 0.6
zoneUuid String body(包含在params结构中) 区域UUID 0.6
physicalInterface String body(包含在params结构中) 0.6
type (可选) String body(包含在params结构中) 0.6
vSwitchType (可选) String body(包含在params结构中) 虚拟交换机类型 4.8.0
resourceUuid (可选) String body(包含在params结构中) 0.6
systemTags (可选) List body 0.6
userTags (可选) List body 0.6
tagUuids (可选) List body(包含在params结构中) 4.8.0

API返回

返回示例
{
  "inventory": {
    "vlan": 10,
    "name": "Test-Net",
    "description": "Test",
    "zoneUuid": "75aea7e72b5a3ce7a1f87efb70ac6339",
    "physicalInterface": "eth0",
    "type": "L2VlanNetwork"
  }
}
名字 类型 描述 起始版本
success boolean 0.6
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 0.6
inventory L2NetworkInventory 详情参考inventory 0.6
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 4.8.0
description String 错误的概要描述 4.8.0
details String 错误的详细信息 4.8.0
elaboration String 保留字段,默认为null 4.8.0
opaque LinkedHashMap 保留字段,默认为null 4.8.0
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 4.8.0
#inventory
名字 类型 描述 起始版本
vlan Integer 0.6
uuid String 资源的UUID,唯一标示该资源 0.6
name String 资源名称 0.6
description String 资源的详细描述 0.6
zoneUuid String 区域UUID 0.6
physicalInterface String 0.6
type String 0.6
createDate Timestamp 创建时间 0.6
lastOpDate Timestamp 最后一次修改时间 0.6
attachedClusterUuids List 0.6

SDK示例

Java SDK
CreateL2VlanNetworkAction action = new CreateL2VlanNetworkAction();
action.vlan = 10;
action.name = "Test-Net";
action.description = "Test";
action.zoneUuid = "43af355e5eae3ab0b74ee76ca9c19005";
action.physicalInterface = "eth0";
action.vSwitchType = "LinuxBridge";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateL2VlanNetworkAction.Result res = action.call();
Python SDK
CreateL2VlanNetworkAction action = CreateL2VlanNetworkAction()
action.vlan = 10
action.name = "Test-Net"
action.description = "Test"
action.zoneUuid = "43af355e5eae3ab0b74ee76ca9c19005"
action.physicalInterface = "eth0"
action.vSwitchType = "LinuxBridge"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateL2VlanNetworkAction.Result res = action.call()

查询二层VLAN网络(QueryL2VlanNetwork)

API请求

URLs
GET zstack/v1/l2-networks/vlan
GET zstack/v1/l2-networks/vlan/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth 1456f654cfcb46889ff24bd83da741f4" \
-X GET http://localhost:8080/zstack/v1/l2-networks/vlan
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth 3ad0ef4e609e43829cde6fcaac60d90d" \
-X GET http://localhost:8080/zstack/v1/l2-networks/vlan/d1eefa849cc84978bacd10ef5e1da12f

可查询字段

运行CLI命令行工具,输入QueryL2VlanNetwork并按Tab键查看所有可查询字段以及可跨表查询的资源名。

API返回

返回示例
{
"inventories": [
    {
"vlan": 10.0,
"name": "Test-Net",
"description": "Test",
"zoneUuid": "02681829852848e6b25d6a11aa673f0c",
"physicalInterface": "eth0",
"type": "L2VlanNetwork"
    }
  ]
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 0.6
inventories List 详情参考inventories 0.6
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 0.6
description String 错误的概要描述 0.6
details String 错误的详细信息 0.6
elaboration String 保留字段,默认为null 0.6
opaque LinkedHashMap 保留字段,默认为null 0.6
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 0.6
#inventories
名字 类型 描述 起始版本
vlan Integer 0.6
uuid String 资源的UUID,唯一标示该资源 0.6
name String 资源名称 0.6
description String 资源的详细描述 0.6
zoneUuid String 区域UUID 0.6
physicalInterface String 0.6
type String 0.6
createDate Timestamp 创建时间 0.6
lastOpDate Timestamp 最后一次修改时间 0.6
attachedClusterUuids List 0.6

SDK示例

Java SDK
QueryL2VlanNetworkAction action = new QueryL2VlanNetworkAction();
action.conditions = asList();
action.sessionId = "9ae1447a4dce41f9835c2a89ed7e7eba";
QueryL2VlanNetworkAction.Result res = action.call();
Python SDK
QueryL2VlanNetworkAction action = QueryL2VlanNetworkAction()
action.conditions = []
action.sessionId = "3e20ec335a82447e9e39c10b371de1b3"
QueryL2VlanNetworkAction.Result res = action.call()

删除二层网络(DeleteL2Network)

API请求

URLs
DELETE zstack/v1/l2-networks/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth ff3445cd125b4f67b6fc551133852726" \
-X DELETE http://localhost:8080/zstack/v1/l2-networks/254811ac54a04835a8f82871f96ab86f?deleteMode=Permissive
参数列表
名字 类型 位置 描述 可选值 起始版本
uuid String url 资源的UUID,唯一标示该资源 4.8.0
deleteMode (可选) String body 删除模式 4.8.0
systemTags (可选) List body 系统标签 4.8.0
userTags (可选) List body 用户标签 4.8.0

API返回

该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{
    "error": {
        "code": "SYS.1001",
        "description": "A message or a operation timeout",
        "details": "Create VM on KVM timeout after 300s"
    }
}/9

SDK示例

Java SDK
DeleteL2NetworkAction action = new DeleteL2NetworkAction();
action.uuid = "8952ecc352fc49b9a0b22286772e74e2";
action.deleteMode = "Permissive";
action.sessionId = "1bece9d1092e47e7ba176ac2e3b03793";
DeleteL2NetworkAction.Result res = action.call();
Python SDK
DeleteL2NetworkAction action = DeleteL2NetworkAction()
action.uuid = "f1f6deb480d44b77b53b74784c17a1d9"
action.deleteMode = "Permissive"
action.sessionId = "9b914d6dc4d64c8f8f45452bad140f9f"
DeleteL2NetworkAction.Result res = action.call()

查询二层网络(QueryL2Network)

API请求

URLs
GET zstack/v1/l2-networks
GET zstack/v1/l2-networks/{uuid}
Headers
OAuth: the-session-uuid
Curl示例
curl
-H "Content-Type: application/json;charset=UTF-8" \
-H "OAuth: 9bdaea2355c6417b9e6f3acff94fe731"\
-X GET http://localhost:8080/zstack/v1/l2-networks
curl
-H "Content-Type: application/json;charset=UTF-8" \
-H "OAuth: 0469a0dfcb7343abb2eb08d876ad3209" \
-X GET http://localhost:8080/zstack/v1/l2-networks/a523215c60b14236869d249176fb328d

可查询字段

运行CLI命令行工具,输入QueryL2Network并按Tab键查看所有可查询字段以及可跨表查询的资源名。

API返回

返回示例
{
"inventories": [
    {
"vlan": 10.0,
"name": "Test-Net",
"description": "Test",
"zoneUuid": "a5af85a0db3a4433b58ff429eea1e9a3",
"physicalInterface": "eth0",
"type": "L2VlanNetwork"
    }
  ]
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 0.6
inventories List 详情参考inventories 0.6
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 0.6
description String 错误的概要描述 0.6
details String 错误的详细信息 0.6
elaboration String 保留字段,默认为null 0.6
opaque LinkedHashMap 保留字段,默认为null 0.6
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 0.6
#inventories
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 0.6
name String 资源名称 0.6
description String 资源的详细描述 0.6
zoneUuid String 区域UUID 0.6
physicalInterface String 0.6
type String 0.6
createDate Timestamp 创建时间 0.6
lastOpDate Timestamp 最后一次修改时间 0.6
attachedClusterUuids List 0.6

SDK示例

Java SDK
QueryL2NetworkAction action = new QueryL2NetworkAction();
action.conditions = asList();
action.sessionId = "c9c0aa502c3d4bdd8cf480364a17fe67";
QueryL2NetworkAction.Result res = action.call();
Python SDK
QueryL2NetworkAction action = QueryL2NetworkAction()
action.conditions = []
action.sessionId = "2170549725174f5f9eb390d314f86f8b"
QueryL2NetworkAction.Result res = action.call()

更新二层网络(UpdateL2Network)

AI请求

URLs
PUT zstack/v1/l2-networks/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
"updateL2Network": {
"name": "Test-Net",
"description": "Test"
  },
"systemTags": [],
"userTags": []
}
Note: 上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updateL2Network":{"name":"Test-Net","description":"Test"}}' \
http://localhost:8080/zstack/v1/l2-networks/8a44ece25f973842b841591a554f5fee/actions
参数列表
名字 类型 位置 描述 可选值 起始版本
uuid String url 资源的UUID,唯一标示该资源 0.6
name (可选) String body(包含在updateL2Network结构中) 普通二层网络名称 0.6
description (可选) String body(包含在updateL2Network结构中) 普通二层网络的详细描述 0.6
systemTags (可选) List body 系统标签 0.6
userTags (可选) List body 用户标签 0.6
API返回
返回示例
{
"inventory": {
"vlan": 10.0,
"name": "Test-Net",
"description": "Test",
"zoneUuid": "95bb5b1156ff49caacaf9acc2eda0058",
"physicalInterface": "eth0",
"type": "L2VlanNetwork"
  }
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 0.6
inventory L2NetworkInventory 详情参考inventory 0.6
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 0.6
description String 错误的概要描述 0.6
details String 错误的详细信息 0.6
elaboration String 保留字段,默认为null 0.6
opaque LinkedHashMap 保留字段,默认为null 0.6
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 0.6
#inventory
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 0.6
name String 资源名称 0.6
description String 资源的详细描述 0.6
zoneUuid String 区域UUID 0.6
physicalInterface String 0.6
type String 0.6
createDate Timestamp 创建时间 0.6
lastOpDate Timestamp 最后一次修改时间 0.6
attachedClusterUuids List 0.6

SDK示例

Java SDK
UpdateL2NetworkAction action = new UpdateL2NetworkAction();
action.uuid = "f7ea5335fcab4d438069879d62384b0e";
action.name = "Test-Net";
action.description = "Test";
action.sessionId = "05627ec42486449cb6b422ef927829f1";
UpdateL2NetworkAction.Result res = action.call();
Python SDK
UpdateL2NetworkAction action = UpdateL2NetworkAction()
action.uuid = "7dc08ad01b8a4d578aab2ae0ad750f1b"
action.name = "Test-Net"
action.description = "Test"
action.sessionId = "130b064e63204a479857ced03f550cf2"
UpdateL2NetworkAction.Result res = action.call()

获取二层网络类型(GetL2NetworkTypes)

API请求

URLs
GET zstack/v1/l2-networks/types
Headers
OAuth: the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "OAuth: 76514d7cdcf44b57bc26ff7b4ae0be63" \
-X GET http://localhost:8080/zstack/v1/l2-networks/types
参数列表
名字 类型 位置 描述 可选值 起始版本
systemTags (可选) List query 0.6
userTags (可选) List query 0.6

API返回

返回示例
{
"l2NetworkTypes": [
"L2VlanNetwork",
"L2NoVlanNetwork"
  ]
}
名字 类型 描述 起始版本
types List 0.6
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 0.6
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 0.6
description String 错误的概要描述 0.6
details String 错误的详细信息 0.6
elaboration String 保留字段,默认为null 0.6
opaque LinkedHashMap 保留字段,默认为null 0.6
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 0.6

SDK示例

Java SDK
GetL2NetworkTypesAction action = new GetL2NetworkTypesAction();
action.sessionId = "485005865e744e19a12ad2f9af2ea997";
GetL2NetworkTypesAction.Result res = action.call();
Python SDK
GetL2NetworkTypesAction action = GetL2NetworkTypesAction()
action.sessionId = "b34f3c756aa542789f35bc1774845bc1"
GetL2NetworkTypesAction.Result res = action.call()

挂载二层网络到集群(AttachL2NetworkToCluster)

API请求

URLs
POST zstack/v1/l2-networks/{l2NetworkUuid}/clusters/{clusterUuid}
Headers
OAuth: the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST http://localhost:8080/zstack/v1/l2-networks/e852ba6eb4c03f2fafdb73ce838d8980/clusters/112816423a1a3b50a58d54fd1f6a8665
参数列表
名字 类型 位置 描述 可选值 起始版本
l2NetworkUuid String url 二层网络UUID 0.6
clusterUuid String url 集群UUID 0.6
l2ProviderType (可选) String body 二层网络实现类型
  • LinuxBridge
4.8.0
systemTags (可选) List body 系统标签 0.6
userTags (可选) List body 用户标签 0.6

API返回

返回示例
{
"inventory": {
"vlan": 10.0,
"name": "Test-Net",
"description": "Test",
"zoneUuid": "95ab67ece21e3ce39896b9b391a21a94",
"physicalInterface": "eth0",
"type": "L2VlanNetwork"
  }
}
名字 类型 描述 起始版本
success boolean 4.8.0
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 0,6
inventory L2NetworkInventory 详情参考inventory 0.6
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 0.6
description String 错误的概要描述 0.6
details String 错误的详细信息 0.6
elaboration String 保留字段,默认为null 0.6
opaque LinkedHashMap 保留字段,默认为null 0.6
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 0.6
#inventory
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 0.6
name String 资源名称 0.6
description String 资源的详细描述 0.6
zoneUuid String 区域UUID 0.6
physicalInterface String 0.6
type String 0.6
createDate Timestamp 创建时间 0.6
lastOpDate Timestamp 最后一次修改时间 0.6
attachedClusterUuids List 0.6

SDK示例

Java SDK
AttachL2NetworkToClusterAction action = new AttachL2NetworkToClusterAction();
action.l2NetworkUuid = "e852ba6eb4c03f2fafdb73ce838d8980";
action.clusterUuid = "112816423a1a3b50a58d54fd1f6a8665";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
AttachL2NetworkToClusterAction.Result res = action.call();
Python SDK
AttachL2NetworkToClusterAction action = AttachL2NetworkToClusterAction()
action.l2NetworkUuid = "e852ba6eb4c03f2fafdb73ce838d8980"
action.clusterUuid = "112816423a1a3b50a58d54fd1f6a8665"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
AttachL2NetworkToClusterAction.Result res = action.call()

从集群上卸载二层网络(DetachL2NetworkFromCluster)

API请求

URLs
DELETE/v1/l2-networks/{l2NetworkUuid}/clusters/{clusterUuid}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/l2-networks/baef7db345553050846947bb2d818be0/clusters/2fb51e7e35d339c4bac77819a9c4fea1?
参数列表
名字 类型 位置 描述 可选值 起始版本
l2NetworkUuid String url 二层网络UUID 0.6
clusterUuid String url 集群UUID 0.6
systemTags (可选) List body 系统标签 0.6
userTags (可选) List body 用户标签 0.6

API返回

返回示例
{
  "inventory": {
    "vlan": 10,
    "name": "Test-Net",
    "description": "Test",
    "zoneUuid": "7a531508c19d396d84abeda34b83d946",
    "physicalInterface": "eth0",
    "type": "L2VlanNetwork"
  }
}
名字 类型 描述 起始版本
success boolean 4.8.0
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 0.6
inventory L2NetworkInventory 详情参考inventory 0.6
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 0.6
description String 错误的概要描述 0.6
details String 错误的详细信息 0.6
elaboration String 保留字段,默认为null 0.6
opaque LinkedHashMap 保留字段,默认为null 0.6
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 0.6
#inventory
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 0.6
name String 资源名称 0.6
description String 资源的详细描述 0.6
zoneUuid String 区域UUID 0.6
physicalInterface String 0.6
type String 0.6
createDate Timestamp 创建时间 0.6
lastOpDate Timestamp 最后一次修改时间 0.6
attachedClusterUuids List 0.6

SDK示例

Java SDK
DetachL2NetworkFromClusterAction action = new DetachL2NetworkFromClusterAction();
action.l2NetworkUuid = "baef7db345553050846947bb2d818be0";
action.clusterUuid = "2fb51e7e35d339c4bac77819a9c4fea1";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DetachL2NetworkFromClusterAction.Result res = action.call();
Python SDK
DetachL2NetworkFromClusterAction action = DetachL2NetworkFromClusterAction()
action.l2NetworkUuid = "baef7db345553050846947bb2d818be0"
action.clusterUuid = "2fb51e7e35d339c4bac77819a9c4fea1"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DetachL2NetworkFromClusterAction.Result res = action.call()

创建VNI Range(CreateVniRange)

API请求

URLs
POST zstack/v1/l2-networks/vxlan-pool/{l2NetworkUuid}/vni-ranges
Headers
Authorization: OAuth the-session-uuid
Body
{
  "params": {
    "name": "TestVniRange",
    "description": "Here is a Vni Range",
    "startVni": 10.0,
    "endVni": 5000.0
  },
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"name":"TestVniRange","description":"Here is a Vni Range","startVni":10.0,"endVni":5000.0}}' \
http://localhost:8080/zstack/v1/l2-networks/vxlan-pool/66b7ddcebeea33eaaa39a2b4667267ab/vni-ranges
参数列表
名字 类型 位置 描述 可选值 起始版本
name String body(包含在params结构中) 资源名称 0.6
description (可选) String body(包含在params结构中) 资源的详细描述 0.6
startVni Integer body(包含在params结构中) 0.6
endVni Integer body(包含在params结构中) 0.6
l2NetworkUuid String url 二层Vxlan网络资源池uuid 0.6
resourceUuid (可选) String body(包含在params结构中) 0.6
systemTags (可选) List body 0.6
userTags (可选) List body 0.6

API返回

返回示例
{
"inventory": {
"name": "TestVniRange",
"description": "Here is a Vni Range",
"startVni": 10.0,
"endVni": 5000.0,
"l2NetworkUuid": "252d938da43a48c98ce93fe7163f14df"
  }
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 0.6
inventory VniRangeInventory 详情参考inventory 0.6
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 0.6
description String 错误的概要描述 0.6
details String 错误的详细信息 0.6
elaboration String 保留字段,默认为null 0.6
opaque LinkedHashMap 保留字段,默认为null 0.6
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 0.6
#inventory
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 0.6
name String 资源名称 0.6
description String 资源的详细描述 0.6
startVni Integer 0.6
endVni Integer 0.6
createDate Timestamp 创建时间 0.6
lastOpDate Timestamp 最后一次修改时间 0.6
l2NetworkUuid String 二层网络UUID 0.6

SDK示例

Java SDK
CreateVniRangeAction action = new CreateVniRangeAction();
action.name = "TestVniRange";
action.description = "Here is a Vni Range";
action.startVni = 10.0;
action.endVni = 5000.0;
action.l2NetworkUuid = "9548ed5fc8434782890d5c6ae24d87a7";
action.sessionId = "977eac0795364c5995c20120e9e35ca1";
CreateVniRangeAction.Result res = action.call();
Python SDK
CreateVniRangeAction action = CreateVniRangeAction()
action.name = "TestVniRange"
action.description = "Here is a Vni Range"
action.startVni = 10.0
action.endVni = 5000.0
action.l2NetworkUuid = "d55172d6e90e403da46074d53c680838"
action.sessionId = "dfacd10f07444a99bca68426cc19f079"
CreateVniRangeAction.Result res = action.call()

查询VNI Range(QueryVniRange)

API请求

URLs
GET zstack/v1/l2-networks/vxlan-pool/vni-range
GET zstack/v1/l2-networks/vxlan-pool/vni-range/{uuid}
Headers
Authorization: OAuth the-session-uuid

Curl示例

curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth 337c51002a0f4fec9b9ced4cdd9ca08d" \
-X GET http://localhost:8080/zstack/v1/l2-networks/vxlan-pool/vni-range
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth 69245fbe344f4adf95454deb1bfe74fb" \
-X GET http://localhost:8080/zstack/v1/l2-networks/vxlan-pool/vni-range/4397921aaa5d45c7ba9bbde764b89389

可查询字段

运行CLI命令行工具,输入QueryVniRange并按Tab键查看所有可查询字段以及可跨表查询的资源名。

API返回

返回示例
{
"inventories": [
    {
"name": "Test-Range",
"description": "Test",
"startVni": 10.0,
"endVni": 10000.0,
"l2NetworkUuid": "32e0539245504a22a474ea2f34db16d0"
    }
  ]
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 0.6
inventories List 详情参考inventories 0.6
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 0.6
description String 错误的概要描述 0.6
details String 错误的详细信息 0.6
elaboration String 保留字段,默认为null 0.6
opaque LinkedHashMap 保留字段,默认为null 0.6
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 0.6
#inventories
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 0.6
name String 资源名称 0.6
description String 资源的详细描述 0.6
startVni Integer 0.6
endVni Integer 0.6
createDate Timestamp 创建时间 0.6
lastOpDate Timestamp 最后一次修改时间 0.6
l2NetworkUuid String 二层网络UUID 0.6

SDK示例

Java SDK
QueryVniRangeAction action = new QueryVniRangeAction();
action.conditions = asList();
action.sessionId = "eb1c573c6d4240ecb746321b12f9e1d3";
QueryVniRangeAction.Result res = action.call();
Python SDK
QueryVniRangeAction action = QueryVniRangeAction()
action.conditions = []
action.sessionId = "89f7a520087049dcbd87f91aa20994fa"
QueryVniRangeAction.Result res = action.call()

删除VNI Range(DeleteVniRange)

API请求

URLs
DELETE/v1/l2-networks/vxlan-pool/vni-ranges/{uuid}?deleteMode={deleteMode}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth 49bf51476d4f49e3b6322688a4c02027" \
-X DELETE http://localhost:8080/zstack/v1/l2-networks/vxlan-pool/vni-ranges/57aae81f5ed248e3bea4509843ab919f?deleteMode=Permissive
参数列表
名字 类型 位置 描述 可选值 起始版本
uuid String url 资源的UUID,唯一标示该资源 0.6
deleteMode (可选) String body 0.6
systemTags (可选) List body 0.6
userTags (可选) List body 0.6

API返回

该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
    }
}

SDK示例

Java SDK
DeleteVniRangeAction action = new DeleteVniRangeAction();
action.uuid = "8ad0e38ae63d4f2d86b9cd2283c5df03";
action.deleteMode = "Permissive";
action.sessionId = "85100440f4f94c68ba0884e09c7429dc";
DeleteVniRangeAction.Result res = action.call();
Python SDK
DeleteVniRangeAction action = DeleteVniRangeAction()
action.uuid = "4aef50ec1f784e66ab79ef021216389d"
action.deleteMode = "Permissive"
action.sessionId = "dfbae4e4897f497a9803a2a5dc23f848"
DeleteVniRangeAction.Result res = action.call()

修改VNI Range(UpdateVniRange)

API请求

URLs
PUT zstack/v1/l2-networks/vxlan-pool/vni-ranges/{uuid}
Headers
Authorization: OAuth the-session-uuid
Body
{
  "updateVniRange": {
    "name": "VNI-NEW"
  },
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updateVniRange":{"name":"VNI-NEW"}}' http://localhost:8080/zstack/v1/l2-networks/vxlan-pool/vni-ranges/f85dd9a8fcdc33c6a55f4786e0ffae52
参数列表
名字 类型 位置 描述 可选值 起始版本
uuid String url 资源的UUID,唯一标示该资源 3.3.0
name (可选) String body 3.3.0
systemTags (可选) List body 3.3.0
userTags (可选) List body 3.3.0

API返回

返回示例
{
  "inventory": {
    "name": "Test-Range",
    "description": "Test",
    "startVni": 10.0,
    "endVni": 10000.0,
    "l2NetworkUuid": "73f29ba3afd83876830ab1794046e47a"
  }
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 3.3.0
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 3.3.0
description String 错误的概要描述 3.3.0
details String 错误的详细信息 3.3.0
elaboration String 保留字段,默认为null 3.3.0
opaque LinkedHashMap 保留字段,默认为null 3.3.0
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 3.3.0

SDK示例

Java SDK
UpdateVniRangeAction action = new UpdateVniRangeAction();
action.uuid = "f85dd9a8fcdc33c6a55f4786e0ffae52";
action.name = "VNI-NEW";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateVniRangeAction.Result res = action.call();
Python SDK
UpdateVniRangeAction action = UpdateVniRangeAction()
action.uuid = "f85dd9a8fcdc33c6a55f4786e0ffae52"
action.name = "VNI-NEW"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateVniRangeAction.Result res = action.call()

创建硬件VXLAN网络(CreateL2HardwareVxlanNetwork)

API请求

URLs
POST zstack/v1/l2-networks/hardware-vxlan
Headers
Authorization: OAuth the-session-uuid
Body
{
  "params": {
    "vni": 10,
    "poolUuid": "772ca51845273486bd60aeb13c545050",
    "name": "Test-Net",
    "description": "Test",
    "zoneUuid": "79c1192d59303c218de085a48666cffa",
    "vSwitchType": "LinuxBridge"
  },
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"vni":10,"poolUuid":"772ca51845273486bd60aeb13c545050","name":"Test-Net","description":"Test","zoneUuid":"79c1192d59303c218de085a48666cffa","vSwitchType":"LinuxBridge"}}' \
http://localhost:8080/zstack/v1/l2-networks/hardware-vxlan
参数列表
名字 类型 位置 描述 可选值 起始版本
vni (可选) Integer body(包含在params结构中) VNI号 4.8.0
poolUuid String body(包含在params结构中) 资源池UUID 4.8.0
name String body(包含在params结构中) 资源名称 4.8.0
description (可选) String body(包含在params结构中) 资源的详细描述 4.8.0
zoneUuid String body(包含在params结构中) 区域UUID 4.8.0
physicalInterface String body(包含在params结构中) 物理网卡 4.8.0
type (可选) String body(包含在params结构中) 资源类型 4.8.0
resourceUuid (可选) String body(包含在params结构中) 资源UUID 4.8.0
tagUuids (可选) List body(包含在params结构中) 标签UUID列表 4.8.0
systemTags (可选) List body 系统标签 4.8.0
userTags (可选) List body 用户标签 4.8.0
vSwitchType (可选) String body(包含在params结构中) 虚拟交换机类型
  • LinuxBridge
  • OvsDpdk
4.8.0

API返回

返回示例
{
  "inventory": {
    "vni": 10,
    "poolUuid": "7b3b9aaa42d3364d846a598cce125174",
    "name": "Test-Net",
    "description": "Test",
    "zoneUuid": "e88a75173e193288b9a51c35f7c8e1ac",
    "type": "L2VxlanNetwork"
  }
}
名字 类型 描述 起始版本
success boolean 4.8.0
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 4.8.0
inventory L2VxlanNetworkInventory 详情参考inventory 4.8.0
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 4.8.0
description String 错误的概要描述 4.8.0
details String 错误的详细信息 4.8.0
elaboration String 保留字段,默认为null 4.8.0
opaque LinkedHashMap 保留字段,默认为null 4.8.0
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 4.8.0
#inventory
名字 类型 描述 起始版本
vni Integer VNI号 4.8.0
poolUuid String Vxlan网络资源池uuid 4.8.0
uuid String 资源的UUID,唯一标示该资源 4.8.0
name String 资源名称 4.8.0
description String 资源的详细描述 4.8.0
zoneUuid String 区域UUID 4.8.0
physicalInterface String 物理网卡 4.8.0
type String 资源类型 4.8.0
createDate Timestamp 创建时间 4.8.0
lastOpDate Timestamp 最后一次修改时间 4.8.0
attachedClusterUuids List 已加载集群UUID 4.8.0

SDK示例

Java SDK
CreateL2HardwareVxlanNetworkAction action = new CreateL2HardwareVxlanNetworkAction();
action.vni = 10;
action.poolUuid = "772ca51845273486bd60aeb13c545050";
action.name = "Test-Net";
action.description = "Test";
action.zoneUuid = "79c1192d59303c218de085a48666cffa";
action.vSwitchType = "LinuxBridge";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateL2HardwareVxlanNetworkAction.Result res = action.call();
Python SDK
CreateL2HardwareVxlanNetworkAction action = CreateL2HardwareVxlanNetworkAction()
action.vni = 10
action.poolUuid = "772ca51845273486bd60aeb13c545050"
action.name = "Test-Net"
action.description = "Test"
action.zoneUuid = "79c1192d59303c218de085a48666cffa"
action.vSwitchType = "LinuxBridge"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateL2HardwareVxlanNetworkAction.Result res = action.call()

创建硬件VXLAN资源池(CreateL2HardwareVxlanNetworkPool)

API请求

URLs
POST zstack/v1/l2-networks/hardware-vxlan-pool
Headers
Authorization: OAuth the-session-uuid
Body
{
  "params": {
    "sdnControllerUuid": "0b2231798a5c3971811ca4c9647776b8",
    "name": "Test-NetPool",
    "description": "Test",
    "zoneUuid": "0198cfa1482e31c2bc99512d1aa5b29b",
    "physicalInterface": "bond0",
    "vSwitchType": "LinuxBridge"
  },
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"sdnControllerUuid":"0b2231798a5c3971811ca4c9647776b8","name":"Test-NetPool","description":"Test","zoneUuid":"0198cfa1482e31c2bc99512d1aa5b29b","physicalInterface":"bond0","vSwitchType":"LinuxBridge"}}'}' \
http://localhost:8080/zstack/v1/l2-networks/hardware-vxlan-pool
参数列表
名字 类型 位置 描述 可选值 起始版本
sdnControllerUuid String body(包含在params结构中) SDN控制器UUID 4.8.0
name String body(包含在params结构中) 资源名称 4.8.0
description (可选) String body(包含在params结构中) 资源的详细描述 4.8.0
zoneUuid String body(包含在params结构中) 区域UUID 4.8.0
physicalInterface String body(包含在params结构中) 物理网卡 4.8.0
type (可选) String body(包含在params结构中) 资源类型 4.8.0
resourceUuid (可选) String body(包含在params结构中) 资源UUID 4.8.0
tagUuids (可选) List body(包含在params结构中) 标签UUID列表 4.8.0
systemTags (可选) List body 系统标签 4.8.0
userTags (可选) List body 用户标签 4.8.0
vSwitchType (可选) String body(包含在params结构中) 虚拟交换机类型
  • LinuxBridge
  • OvsDpdk
4.8.0

API返回

返回示例
{
  "inventory": {
    "sdnControllerUuid": "359216656f7f3f8681b76e52a0f11429",
    "name": "Test-NetPool",
    "description": "Test",
    "zoneUuid": "7d07d7a4ebfa340da32ac686f77edd4e",
    "type": "HardwareVxlanNetworkPool"
  }
}
名字 类型 描述 起始版本
success boolean 4.8.0
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 4.8.0
inventory HardwareL2VxlanNetworkPoolInventory 详情参考inventory 4.8.0
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 4.8.0
description String 错误的概要描述 4.8.0
details String 错误的详细信息 4.8.0
elaboration String 保留字段,默认为null 4.8.0
opaque LinkedHashMap 保留字段,默认为null 4.8.0
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 4.8.0
#inventory
名字 类型 描述 起始版本
sdnControllerUuid String SDN控制器UUID 4.8.0
attachedCidrs Map 已加载CIDR映射表 4.8.0
uuid String 资源的UUID,唯一标示该资源 4.8.0
name String 资源名称 4.8.0
description String 资源的详细描述 4.8.0
zoneUuid String 区域UUID 4.8.0
physicalInterface String 物理网卡 4.8.0
type String 资源类型 4.8.0
createDate Timestamp 创建时间 4.8.0
lastOpDate Timestamp 最后一次修改时间 4.8.0
attachedClusterUuids List 已加载集群UUID 4.8.0
attachedVtepRefs List 详情参考attachedVtepRefs 4.8.0
attachedVxlanNetworkRefs List 详情参考attachedVxlanNetworkRef 4.8.0
attachedVniRanges List 详情参考attachedVniRanges 4.8.0
#attachedVtepRefs
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 4.8.0
hostUuid String 物理机UUID 4.8.0
vtepIp String 隧道端点IP地址 4.8.0
port Integer 端口号 4.8.0
type String 资源类型 4.8.0
createDate Timestamp 创建时间 4.8.0
lastOpDate Timestamp 最后一次修改时间 4.8.0
poolUuid String 资源池的UUID 4.8.0
#attachedVxlanNetworkRefs
名字 类型 描述 起始版本
vni Integer VNI号 4.8.0
poolUuid String 资源池UUID 4.8.0
uuid String 资源的UUID,唯一标示该资源 4.8.0
name String 资源名称 4.8.0
description String 资源的详细描述 4.8.0
startVni Integer 4.8.0
endVni Integer 4.8.0
createDate Timestamp 创建时间 4.8.0
lastOpDate Timestamp 最后一次修改时间 4.8.0
zoneUuid String 区域UUID 4.8.0
physicalInterface String 物理网卡 4.8.0
type String 资源类型 4.8.0
createDate Timestamp 创建时间 4.8.0
lastOpDate Timestamp 最后一次修改时间 4.8.0
attachedClusterUuids List 已加载集群UUID 4.8.0
#attachedVniRanges
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 4.8.0
name String 资源名称 4.8.0
description String 资源的详细描述 4.8.0
startVni Integer 起始VNI 4.8.0
endVni Integer 结束VNI 4.8.0
createDate Timestamp 创建时间 4.8.0
lastOpDate Timestamp 最后一次修改时间 4.8.0
l2NetworkUuid String 二层网络UUID 4.8.0

SDK示例

Java SDK
CreateL2HardwareVxlanNetworkPoolAction action = new CreateL2HardwareVxlanNetworkPoolAction();
action.sdnControllerUuid = "0b2231798a5c3971811ca4c9647776b8";
action.name = "Test-NetPool";
action.description = "Test";
action.zoneUuid = "0198cfa1482e31c2bc99512d1aa5b29b";
action.physicalInterface = "bond0";
action.vSwitchType = "LinuxBridge";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateL2HardwareVxlanNetworkPoolAction.Result res = action.call();
Python SDK
CreateL2HardwareVxlanNetworkPoolAction action = CreateL2HardwareVxlanNetworkPoolAction()
action.sdnControllerUuid = "0b2231798a5c3971811ca4c9647776b8"
action.name = "Test-NetPool"
action.description = "Test"
action.zoneUuid = "0198cfa1482e31c2bc99512d1aa5b29b"
action.physicalInterface = "bond0"
action.vSwitchType = "LinuxBridge"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateL2HardwareVxlanNetworkPoolAction.Result res = action.call()

获取虚拟交换机类型(GetVSwitchTypes)

API请求

URLs
GET zstack//v1/l2-networks/vSwitchTypes
Headers
OAuth: the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/l2-networks/vSwitchTypes
参数列表
名字 类型 位置 描述 可选值 起始版本
systemTags (可选) List query 系统标签 4.8.0
userTags (可选) List query 用户标签 4.8.0

API返回

返回示例
{
  "vSwitchTypes": [
    "LinuxBridge",
    "OVSDPDK"
  ]
}
名字 类型 描述 起始版本
code boolean 4.8.0
types List 4.8.0
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 4.8.0
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 4.8.0
description String 错误的概要描述 4.8.0
details String 错误的详细信息 4.8.0
elaboration String 保留字段,默认为null 4.8.0
opaque LinkedHashMap 保留字段,默认为null 4.8.0
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 4.8.0

SDK示例

Java SDK
GetVSwitchTypesAction action = new GetVSwitchTypesAction();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetVSwitchTypesAction.Result res = action.call();
Python SDK
GetVSwitchTypesAction action = GetVSwitchTypesAction()
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
GetVSwitchTypesAction.Result res = action.call()

创建tungsten fabric二层网络(CreateL2TfNetwork)

API请求

URLs
POST zstack/v1/l2-networks/tf
Headers
Authorization: OAuth the-session-uuid
Body
{
  "params": {
    "name": "Tf-L2-Network",
    "description": "Test",
    "zoneUuid": "10f059adb4c83f5ba9a296369d52ffbe",
    "vSwitchType": "LinuxBridge"
  },
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"name":"Tf-L2-Network","description":"Test","zoneUuid":"10f059adb4c83f5ba9a296369d52ffbe","vSwitchType":"LinuxBridge"}}' \
http://localhost:8080/zstack/v1/l2-networks/tf
参数列表
名字 类型 位置 描述 可选值 起始版本
ipPrefix (可选) String body(包含在params结构中) IP地址前缀 4.8.0
ipPrefixLength (可选) Integer body(包含在params结构中) IP地址前缀长度 4.8.0
name String body(包含在params结构中) 资源名称 4.8.0
description (可选) String body(包含在params结构中) 资源的详细描述 4.8.0
zoneUuid String body(包含在params结构中) 区域UUID 4.8.0
physicalInterface String body(包含在params结构中) 物理网卡 4.8.0
type (可选) String body(包含在params结构中) 二层网络类型 4.8.0
vSwitchType (可选) String body(包含在params结构中) 虚拟交换机类型
  • LinuxBridge
  • OvsDpdk
  • MacVlan
4.8.0
resourceUuid (可选) String body(包含在params结构中) 资源UUID 4.8.0
tagUuids (可选) List body(包含在params结构中) 标签UUID列表 4.8.0
systemTags (可选) List body 系统标签 4.8.0
userTags (可选) List body 用户标签 4.8.0

API返回

返回示例
{
  "inventory": {
    "uuid": "672906b1aeca3a68a24c1b07a4f8deb5",
    "name": "test",
    "zoneUuid": "b478828872db33a4807d90e9f16f39e4",
    "physicalInterface": "eth0"
  }
}
名字 类型 描述 起始版本
success boolean 4.8.0
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 4.8.0
inventory L2NetworkInventory 详情参考inventory 4.8.0
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 4.8.0
description String 错误的概要描述 4.8.0
details String 错误的详细信息 4.8.0
elaboration String 保留字段,默认为null 4.8.0
opaque LinkedHashMap 保留字段,默认为null 4.8.0
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 4.8.0
#inventroy
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 4.8.0
name String 资源名称 4.8.0
description String 资源的详细描述 4.8.0
zoneUuid String 区域UUID 4.8.0
physicalInterface String 物理网卡 4.8.0
type String 资源类型 4.8.0
createDate Timestamp 创建时间 4.8.0
lastOpDate Timestamp 最后一次修改时间 4.8.0
attachedClusterUuids List 已加载集群UUID 4.8.0

SDK示例

Java SDK
CreateL2TfNetworkAction action = new CreateL2TfNetworkAction();
action.name = "Tf-L2-Network";
action.description = "Test";
action.zoneUuid = "10f059adb4c83f5ba9a296369d52ffbe";
action.vSwitchType = "LinuxBridge";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateL2TfNetworkAction.Result res = action.call();
Python SDK
CreateL2TfNetworkAction action = CreateL2TfNetworkAction()
action.name = "Tf-L2-Network"
action.description = "Test"
action.zoneUuid = "10f059adb4c83f5ba9a296369d52ffbe"
action.vSwitchType = "LinuxBridge"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateL2TfNetworkAction.Result res = action.call()
开发手册 | 4.8.38 | ZStack Cloud · ZCF | ZStack 资源中心