虚拟机相关接口

获取相互依赖的镜像和分布式端口组

GET/zstack/v1/images-l3networks/dependencies

ZSvirt中一个分布式端口组属于一个数据中心,而镜像所在的镜像仓库可以加载到一个或多个数据中心。镜像仓库本身跟集群也存在依赖关系,例如分布式镜像仓库只能跟分布式存储一起工作。由于这种依赖关系的存在,创建虚拟机的时候指定的分布式端口组和镜像可能并不能一起工作。用户可以通过该API获得镜像或分布式端口组的相互依赖。

当指定了l3NetworkUuids参数时,返回的是可以跟这些分布式端口组一起工作的镜像清单。

当指定了imageUuid参数时,返回的是可以跟该镜像一起工作的分布式端口组清单。

Headers

Authorization: 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/images-l3networks/dependencies?zoneUuid=97c8f8e07cf23b8789f910cdd7221dda&imageUuid=f3081ae6203d30c49ca7194d6d07f412&raiseException=true

参数列表

名字类型位置描述可选值起始版本
zoneUuidStringquery数据中心UUID。必须指定,以确定分布式端口组和镜像依赖关系。 0.6
l3NetworkUuids (可选)Listquery分布式端口组UUID列表 0.6
imageUuid (可选)Stringquery镜像UUID 0.6
raiseException (可选)booleanquery是否引发异常 4.6.11
systemTags (可选)Listquery系统标签 0.6
userTags (可选)Listquery用户标签 0.6

API返回

返回示例

{
  "inventories": [
    {
      "uuid": "961b708c480a3f5ba605defbee45eb36",
      "name": "private L3",
      "type": "L3BasicNetwork",
      "zoneUuid": "c0904ef326bf3cc1b69056d1bcf4282d",
      "l2NetworkUuid": "a6ea56d5a589322082a4b7df3e135aeb",
      "state": "Enabled",
      "createDate": "Nov 14, 2017 10:20:57 PM",
      "lastOpDate": "Nov 14, 2017 10:20:57 PM",
      "ipRanges": [
        {
          "uuid": "516e170a56283a5bb9fa20f262b17bd0",
          "l3NetworkUuid": "961b708c480a3f5ba605defbee45eb36",
          "name": "ip range",
          "startIp": "192.168.0.10",
          "endIp": "192.168.0.100",
          "netmask": "255.255.255.0",
          "gateway": "192.168.0.1",
          "createDate": "Nov 14, 2017 10:20:57 PM",
          "lastOpDate": "Nov 14, 2017 10:20:57 PM"
        }
      ],
      "networkServices": [
        {
          "l3NetworkUuid": "961b708c480a3f5ba605defbee45eb36",
          "networkServiceProviderUuid": "8b31ada3e7703ae38b43a2b6f9617f96",
          "networkServiceType": "DHCP"
        },
        {
          "l3NetworkUuid": "961b708c480a3f5ba605defbee45eb36",
          "networkServiceProviderUuid": "8b31ada3e7703ae38b43a2b6f9617f96",
          "networkServiceType": "DNS"
        },
        {
          "l3NetworkUuid": "961b708c480a3f5ba605defbee45eb36",
          "networkServiceProviderUuid": "8b31ada3e7703ae38b43a2b6f9617f96",
          "networkServiceType": "SNAT"
        }
      ]
    }
  ]
}
名字类型描述起始版本
successboolean 0.6
inventoriesList若输入参数是l3NetworkUuids,为镜像清单;若输入参数是imageUuid,为分布式端口组清单0.6
errorErrorCode错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error0.6

error

名字类型描述起始版本
codeString错误码号,错误的全局唯一标识,例如SYS.1000, HOST.10010.6
descriptionString错误的概要描述0.6
detailsString错误的详细信息0.6
elaborationString保留字段,默认为null0.6
opaqueLinkedHashMap保留字段,默认为null0.6
causeErrorCode根错误,引发当前错误的源错误,若无原错误,该字段为null0.6

SDK示例

Java SDK

GetInterdependentL3NetworksImagesAction action = new GetInterdependentL3NetworksImagesAction();
action.zoneUuid = "97c8f8e07cf23b8789f910cdd7221dda";
action.imageUuid = "f3081ae6203d30c49ca7194d6d07f412";
action.raiseException = true;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetInterdependentL3NetworksImagesAction.Result res = action.call();

Python SDK

GetInterdependentL3NetworksImagesAction action = GetInterdependentL3NetworksImagesAction()
action.zoneUuid = "97c8f8e07cf23b8789f910cdd7221dda"
action.imageUuid = "f3081ae6203d30c49ca7194d6d07f412"
action.raiseException = true
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
GetInterdependentL3NetworksImagesAction.Result res = action.call()