3.9. 实例:创建 NFS ISO 存储
NFS ISO 存储域就是附加到数据中心上的、一个挂载的 NFS 共享,它为 DVD/CD-ROM ISO 和虚拟软盘(VFD)镜像提供存储空间。创建新的存储域需要一个
POST 请求(包括了存储域的表述)发送到存储域集合的 URL。
在 Red Hat Enterprise Virtualization 3.6 以及更高的版本中,可以在存储域中默认启用“删除后清除数据”选项。您需要在
POST 请求中指定 <wipe_after_delete>。这个选项可以在域被创建后进行修改,但这不会改变那些已存在磁盘的“删除后清除数据”的设置。
例 3.9. 创建一个 NFS ISO 存储域
请求:
POST /api/storagedomains HTTP/1.1
Accept: application/xml
Content-type: application/xml
<storage_domain>
<name>iso1</name>
<type>iso</type>
<storage>
<type>nfs</type>
<address>192.168.0.10</address>
<path>/iso1</path>
</storage>
<host>
<name>hypervisor</name>
</host>
</storage_domain>
cURL 命令:
# curl -X POST -H "Accept: application/xml" -H "Content-Type: application/xml" \
-u [USER:PASS] --cacert [CERT] \
-d "<storage_domain><name>iso1</name><type>iso</type> \
<storage><type>nfs</type><address>192.168.0.10</address> \
<path>/iso1</path></storage> \
<host><name>hypervisor</name></host></storage_domain>" \
https://[RHEVM Host]:443/api/storagedomains
API 创建了一个 NFS iso 存储域(名为
iso1,带有一个 192.168.0.10:/iso1 导出路径),并可以通过 hypervisor 主机访问存储域。API 同时返回新建存储域资源的以下表述。
结果:
HTTP/1.1 200 OK
Accept: application/xml
<storage_domain id="00f0d9ce-da15-4b9e-9e3e-3c898fa8b6da"
href="/api/storagedomains/00f0d9ce-da15-4b9e-9e3e-3c898fa8b6da">
<name>iso1</name>
<link rel="permissions"
href="/api/storagedomains/00f0d9ce-da15-4b9e-9e3e-3c898fa8b6da/
permissions"/>
<link rel="files"
href="/api/storagedomains/00f0d9ce-da15-4b9e-9e3e-3c898fa8b6da/files"/>
<type>iso</type>
<host id="" href="">
<master>false</master>
<storage>
<type>nfs</type>
<address>192.168.0.10</address>
<path>/iso1</path>
</storage>
<available>82678120448</available>
<used>18253611008</used>
<committed>0</committed>
<storage_format>v1</storage_format>
<host id="0656f432-923a-11e0-ad20-5254004ac988"
href="/api/hosts/0656f432-923a-11e0-ad20-5254004ac988">
</storage_domain>