4.6. 创建 NFS 数据存储
NFS 数据存储域是连接到数据中心的 NFS 共享,为虚拟 guest 映像提供存储。创建新存储域需要 POST 请求,其中包含存储域表示法,并发送到存储域集合的 URL。
在存储域上,您可以默认启用 wipe 后删除选项。要配置此功能,请在 POST 请求中指定 wipe_after_delete。可以在创建域后编辑此选项,但是这样做不会在删除已存在的磁盘属性后更改擦除。
请求应类似如下:
POST /ovirt-engine/api/storagedomains HTTP/1.1
Accept: application/xml
Content-type: application/xml
请求正文应类似如下:
<storage_domain>
<name>mydata</name>
<type>data</type>
<description>My data</description>
<storage>
<type>nfs</type>
<address>mynfs.example.com</address>
<path>/exports/mydata</path>
</storage>
<host>
<name>myhost</name>
</host>
</storage_domain>
同一个请求,使用 curl 命令:
# curl \
--cacert '/etc/pki/ovirt-engine/ca.pem' \
--user 'admin@internal:mypassword' \
--request POST \
--header 'Version: 4' \
--header 'Content-Type: application/xml' \
--header 'Accept: application/xml' \
--data '
<storage_domain>
<name>mydata</name>
<description>My data</description>
<type>data</type>
<storage>
<type>nfs</type>
<address>mynfs.example.com</address>
<path>/exports/mydata</path>
</storage>
<host>
<name>myhost</name>
</host>
</storage_domain>
' \
https://myengine.example.com/ovirt-engine/api/storagedomains
服务器使用主机 myhost 创建名为 my data 的 NFS 数据存储域,其导出路径为 mynfs.example.com:/exports/mydata。该 API 还返回以下表示新创建的存储域资源(类型为 StorageDomain):
<storage_domain href="/ovirt-engine/api/storagedomains/005" id="005">
<name>mydata</name>
<description>My data</description>
<available>42949672960</available>
<committed>0</committed>
<master>false</master>
<status>unattached</status>
<storage>
<address>mynfs.example.com</address>
<path>/exports/mydata</path>
<type>nfs</type>
</storage>
<storage_format>v3</storage_format>
<type>data</type>
<used>9663676416</used>
</storage_domain>