Chapter 8. Data Centers

The datacenters collection provides information about the data centers in a Red Hat Enterprise Virtualization environment. An API user accesses this information through the rel="datacenters" link obtained from the entry point URI (see Chapter 4, Entry Point).
The following table shows specific elements contained in a data center resource representation.

Note

The icons used in the properties column of this table are described in Table 7.1, “Element property icons”

Table 8.1. Data center elements

Element Type Description Properties
link rel="storagedomains" relationship A link to the sub-collection for storage domains attached to this data center.
link rel="permissions" relationship A link to the sub-collection for data center permissions. See Section 7.3.7, “ Permissions ”.
storage_type enumerated Describes the storage type in this datacenter. A list of enumerated values is available in capabilities. See Section 6.1.6, “Storage Types”.
storage_format enumerated Describes the storage format version for the data center. A list of enumerated values are available in capabilities. See Section 6.1.20, “Storage Formats”.
version major= minor= complex The compatibility level of the data center. See Chapter 5, Compatibility Level Versions.
supported_versions complex A list of possible version levels for the data center. See Chapter 5, Compatibility Level Versions.
status see below The data center status.

The status contains one of the following enumerative values: uninitialized, up, maintenance, not_operational, problematic and contend. These states are listed in data_center_states under capabilities (See Section 6.1.21, “Resource Status States”).

Example 8.1. An XML representation of a data center

<data_center id="01a45ff0-915a-11e0-8b87-5254004ac988"
  href="/api/datacenters/01a45ff0-915a-11e0-8b87-5254004ac988">
    <name>Default</name>
    <description>The default Data Center</description>
    <link rel="storagedomains"
      href="/api/datacenters/01a45ff0-915a-11e0-8b87-5254004ac988/
      storagedomains"/>
    <link rel="permissions"
      href="/api/datacenters/01a45ff0-915a-11e0-8b87-5254004ac988/permissions"/>
    <storage_type>nfs</storage_type>
    <storage_format>v1</storage_format>
    <version minor="0" major="3"/>
    <supported_versions>
        <version minor="0" major="3"/>
    </supported_versions>
    <status>
        <state>up</state>
    </status>
</data_center>

Creation of a new data center requires the name, storage_type and version elements. See Section 7.2.4, “ Creating a Resource in a Collection ” for more information.

Example 8.2. Creating a data center

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

<data_center>
    <name>NewDatacenter</name>
    <storage_type>nfs</storage_type>
    <version minor="0" major="3"/>
</data_center>

The name and description elements are updatable post-creation. See Section 7.3.2, “ Updating a Resource ” for more information.

Example 8.3. Updating a data center

PUT /api/datacenters/01a45ff0-915a-11e0-8b87-5254004ac988 HTTP/1.1
Accept: application/xml
Content-type: application/xml

<data_center>
    <name>UpdatedName</name>
    <description>An updated description for the data center</description>
</data_center>

Removal of a data center requires a DELETE request.

Example 8.4. Removing a data center

DELETE /api/datacenters/01a45ff0-915a-11e0-8b87-5254004ac988 HTTP/1.1

HTTP/1.1 204 No Content

8.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 as per Chapter 7, Common Features.
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 (See Section 6.1.21, “Resource Status States”)

Important

The API as documented in this section is experimental and subject to change. It is not covered by the backwards compatibility statement in Section 6, “Backwards Compatibility Statement”.

8.1.1. Attaching 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 8.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>

8.1.2. Actions

There are two possible actions for attached storage domains: activate and deactivate.

8.1.2.1.  Activate Action

An attached storage domain requires activation on a data center before use. The activate action does not take any action specific parameters.

Example 8.6. 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/>

8.1.2.2.  Deactivate Action

An attached storage domain is deactivated on a data center before removal. The deactivate action does not take any action specific parameters.

Example 8.7. 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/>