3.2. 实例:列出数据中心集合

Red Hat Enterprise Virtualization Manager 在安装时创建一个 Default 数据中心。这个实例使用 Default 数据中心作为虚拟环境的基础。
以下请求会获得数据中心集合的表述。

例 3.2. 列出数据中心集合

请求

GET /api/datacenters HTTP/1.1
Accept: application/xml

cURL 命令:

# curl -X GET -H "Accept: application/xml" -u [USER:PASS] \
    --cacert [CERT] \
    https://[RHEVM Host]:443/api/datacenters

结果:

HTTP/1.1 200 OK
Content-Type: application/xml

<data_centers>
    <data_center href="/api/datacenters/00000002-0002-0002-0002-0000000003ab" id="00000002-0002-0002-0002-0000000003ab">
        <name>Default</name>
        <description>The default Data Center</description>
        <link rel="storagedomains"/>
          href="/api/datacenters/00000002-0002-0002-0002-0000000003ab/storagedomains"
        <link rel="clusters"/>
          href="/api/datacenters/00000002-0002-0002-0002-0000000003ab/clusters" 
        <link rel="networks"/>
          href="/api/datacenters/00000002-0002-0002-0002-0000000003ab/networks" 
        <link rel="permissions"/>
          href="/api/datacenters/00000002-0002-0002-0002-0000000003ab/permissions" 
        <link rel="quotas"/>
          href="/api/datacenters/00000002-0002-0002-0002-0000000003ab/quotas" 
        <link rel="iscsibonds"/>
          href="/api/datacenters/00000002-0002-0002-0002-0000000003ab/iscsibonds" 
        <link rel="qoss"/>
          href="/api/datacenters/00000002-0002-0002-0002-0000000003ab/qoss" 
        <local>false</local>
        <storage_format>v3</storage_format>
        <version major="3" minor="5"/>
        <supported_versions>
            <version major="3" minor="5"/>
        </supported_versions>
        <status>
            <state>up</state>
        </status>
    </data_center>
</data_centers>

请记录 Default 数据中心的 id 值。访问虚拟环境中和这个数据中心相关的其它资源时需要指定这个值。
数据中心同时还包括了一个到 storagedomains 子集合的连接。数据中心使用这个子集合从 storagedomains 主集合中附加存储域。