3.8. 例: NFS データストレージの作成

NFS データストレージドメインは、エクスポートされた NFS 共有です。データセンターにアタッチされ、仮想化ゲストのイメージを格納するストレージを提供します。新規ストレージドメインを作成するには、POST 要求にストレージドメインの表現を記載し、ストレージドメインコレクションの URL に送信する必要があります。
Red Hat Enterprise Virtualization 3.6 以降では、ストレージドメインの削除後にワイプのオプションをデフォルトで有効にすることができます。この設定は、POST 要求で <wipe_after_delete> を指定します。このオプションは、ドメインの作成後に編集することが可能ですが、その場合にはすでに存在していたディスクの「削除後にワイプ」プロパティーは変更されません。

例3.8 NFS データストレージドメインの作成

要求:

POST /api/storagedomains HTTP/1.1
Accept: application/xml
Content-type: application/xml

<storage_domain>
  <name>data1</name>
  <type>data</type>
  <storage>
    <type>nfs</type>
    <address>192.168.0.10</address>
    <path>/data1</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>data1</name><type>data</type> \
    <storage><type>nfs</type><address>192.168.0.10</address> \
    <path>/data1</path></storage> \ 
    <host><name>hypervisor</name></host></storage_domain>" \
    https://[RHEVM Host]:443/api/storagedomains

API は、192.168.0.10:/data1 のエクスポートパスで data1 という名前の NFS データストレージドメインを作成し、hypervisor ホスト経由のストレージドメインへのアクセスを設定します。また、API は新たに作成したストレージドメインリソースの表現を以下のように返します。
結果:

HTTP/1.1 200 OK
Accept: application/xml

<storage_domain id="9ca7cb40-9a2a-4513-acef-dc254af57aac"
  href="/api/storagedomains/9ca7cb40-9a2a-4513-acef-dc254af57aac">
    <name>data1</name>
    <link rel="permissions"
      href="/api/storagedomains/9ca7cb40-9a2a-4513-acef-dc254af57aac/
      permissions"/>
    <link rel="files"
      href="/api/storagedomains/9ca7cb40-9a2a-4513-acef-dc254af57aac/files"/>
    <type>data</type>
    <master>false</master>
    <storage>
        <type>nfs</type>
        <address>192.168.0.10</address>
        <path>/data1</path>
    </storage>
    <available>175019917312</available>
    <used>27917287424</used>
    <committed>10737418240</committed>
    <storage_format>v1</storage_format>
    <host id="0656f432-923a-11e0-ad20-5254004ac988"
      href="/api/hosts/0656f432-923a-11e0-ad20-5254004ac988">
</storage_domain>