9.4. Sub-Collections
9.4.1. Storage Domains Sub-Collection
9.4.1.1. Storage Domains Sub-Collection
Each data center contains a sub-collection for attached storages domain. An API user interacts with this sub-collection using the standard REST methods.
An attached storage domain has a similar representation to a top-level storage domain, with the exception that it has a data center specific
status and set of actions. States for the status element are listed in storage_domain_states under capabilities.
Important
The API as documented in this section is experimental and subject to change. It is not covered by the backwards compatibility statement.
9.4.1.2. Attaching and Detaching a Storage Domain
A data center is only ready for use when at least one storage domain is attached, which an API user
POSTs to the data center's storage domains sub-collection.
When attaching a storage domain, its
id or name must be supplied. An example of attaching a storage domain to a data center:
Example 9.5. Attach a storage domain to a data center
POST /api/datacenters/d70d5e2d-b8ad-494a-a4d2-c7a5631073c4/storagedomains HTTP/1.1
Accept: application/xml
Content-type: application/xml
<storage_domain id="fabe0451-701f-4235-8f7e-e20e458819ed"/>
HTTP/1.1 201 Created
Location: /datacenters/d70d5e2d-b8ad-494a-a4d2-c7a5631073c4/storagedomains/fabe0451-701f-4235-8f7e-e20e458819ed
Content-Type: application/xml
<storage_domain id="fabe0451-701f-4235-8f7e-e20e458819ed"
href="/api/datacenters/d70d5e2d-b8ad-494a-a4d2-c7a5631073c4/storagedomains/
fabe0451-701f-4235-8f7e-e20e458819ed">
<name>images0</name>
<type>data</type>
<status>
<state>inactive</state>
</status>
<master>true</master>
<storage>
<type>nfs</type>
<address>172.31.0.6</address>
<path>/exports/RHEVX/images/0</path>
</storage>
<data_center id="d70d5e2d-b8ad-494a-a4d2-c7a5631073c4"
href="/api/datacenters/d70d5e2d-b8ad-494a-a4d2-c7a5631073c4"/>
<actions>
<link rel="activate"
href="/api/datacenters/d70d5e2d-b8ad-494a-a4d2-c7a5631073c4/
storagedomains/fabe0451-701f-4235-8f7e-e20e458819ed/activate"/>
<link rel="deactivate"
href="/api/datacenters/d70d5e2d-b8ad-494a-a4d2-c7a5631073c4/
storagedomains/fabe0451-701f-4235-8f7e-e20e458819ed/deactivate"/>
</actions>
</storage_domain>
Detach a storage domain from a data center with a
DELETE request. Include an optional async element for this request to be asynchronous.
Example 9.6. Detach a storage domain from a data center
DELETE /api/datacenters/d70d5e2d-b8ad-494a-a4d2-c7a5631073c4/storagedomains/fabe0451-701f-4235-8f7e-e20e458819ed HTTP/1.1 Accept: application/xml Content-type: application/xml <action> <async>true</async> </action>
9.4.1.3. Actions
9.4.1.3.1. Activate Storage Domain Action
An attached storage domain requires activation on a data center before use. The activate action does not take any action specific parameters.
Example 9.7. Action to active a storage domain on a datacenter
POST /api/datacenters/d70d5e2d-b8ad-494a-a4d2-c7a5631073c4/storagedomains/fabe0451-701f-4235-8f7e-e20e458819ed/activate HTTP/1.1 Accept: application/xml Content-type: application/xml <action/>
9.4.1.3.2. Deactivate Storage Domain Action
An attached storage domain is deactivated on a data center before removal. The deactivate action does not take any action specific parameters.
Example 9.8. Action to deactivate a storage domain on a datacenter
POST /api/datacenters/d70d5e2d-b8ad-494a-a4d2-c7a5631073c4/storagedomains/fabe0451-701f-4235-8f7e-e20e458819ed/deactivate HTTP/1.1 Accept: application/xml Content-type: application/xml <action/>