Red Hat Training

A Red Hat training course is available for Red Hat Gluster Storage

10.4. Managing Bricks

This section describes the brick operations of the Red Hat Storage Console API such as adding and removing them from a volume.
22632%2C+Console+Developer+Guide-322-09-2014+17%3A11%3A35Report a bug

10.4.1. Listing of Bricks

A listing of bricks in a volume is obtained by issuing a GET request on the volume URI.
GET /api/clusters/99408929-82cf-4dc7-a532-9d998063fa95/glustervolumes/83101900-2f12-4855-838e-36b8a9e04554/bricks HTTP/1.1
Accept: application/xml
The API returns the following representation:
HTTP/1.1 200 OK
Accept: application/xml

<bricks>
    <brick href="/api/clusters/99408929-82cf-4dc7-a532-9d998063fa95/glustervolumes/83101900-2f12-4855-838e-36b8a9e04554/bricks/29311ecf-d8db-4912-902b-b31dba8803d2" id="29311ecf-d8db-4912-902b-b31dba8803d2">
        <actions>
            <link href="/api/clusters/99408929-82cf-4dc7-a532-9d998063fa95/glustervolumes/83101900-2f12-4855-838e-36b8a9e04554/bricks/29311ecf-d8db-4912-902b-b31dba8803d2/replace" rel="replace"/>
        </actions>
        <gluster_volume href="/api/clusters/99408929-82cf-4dc7-a532-9d998063fa95/glustervolumes/83101900-2f12-4855-838e-36b8a9e04554" id="83101900-2f12-4855-838e-36b8a9e04554"/>
        <server_id>fcb46b88-f32e-11e1-918a-0050568c4349</server_id>
        <brick_dir>/tmp/data-brick1</brick_dir>
        <state>UP</state>
    </brick>
    <brick href="/api/clusters/99408929-82cf-4dc7-a532-9d998063fa95/glustervolumes/83101900-2f12-4855-838e-36b8a9e04554/bricks/33f04f44-c78c-4c76-a23c-fe9d750c2fd3" id="33f04f44-c78c-4c76-a23c-fe9d750c2fd3">
        <actions>
            <link href="/api/clusters/99408929-82cf-4dc7-a532-9d998063fa95/glustervolumes/83101900-2f12-4855-838e-36b8a9e04554/bricks/33f04f44-c78c-4c76-a23c-fe9d750c2fd3/replace" rel="replace"/>
        </actions>
        <gluster_volume href="/api/clusters/99408929-82cf-4dc7-a532-9d998063fa95/glustervolumes/83101900-2f12-4855-838e-36b8a9e04554" id="83101900-2f12-4855-838e-36b8a9e04554"/>
        <server_id>de173e6a-fb05-11e1-a2fc-0050568c4349</server_id>
        <brick_dir>/tmp/data-brick2</brick_dir>
        <state>UP</state>
    </brick>
</bricks>
22632%2C+Console+Developer+Guide-322-09-2014+17%3A11%3A35Report a bug

10.4.2. Adding a Brick

The API adds a new brick to a volume in your cluster with a POST request to its URI.
POST /api/clusters/99408929-82cf-4dc7-a532-9d998063fa95/glustervolumes/83101900-2f12-4855-838e-36b8a9e04554/bricks HTTP/1.1
Accept: application/xml
Content-type: application/xml

<bricks>
  <brick>
<server_id>fcb46b88-f32e-11e1-918a-0050568c4349</server_id>
    <brick_dir>/export/data/brick3</brick_dir>
  </brick>
</bricks>
cURL command:
curl -X POST -H "Accept: application/xml" -H "Content-Type: application/xml" -u [USER:PASS] https://[RHSC HOST]/api/clusters/99408929-82cf-4dc7-a532-9d998063fa95/glustervolumes/83101900-2f12-4855-838e-36b8a9e04554/bricks -d "<bricks><brick><server_id>fcb46b88-f32e-11e1-918a-0050568c4349</server_id><brick_dir>/export/data/brick3</brick_dir></brick></bricks>"
The API returns the following representation:
HTTP/1.1 201 Created
Content-Type: application/xml

<bricks>
    <brick href="/api/clusters/99408929-82cf-4dc7-a532-9d998063fa95/glustervolumes/83101900-2f12-4855-838e-36b8a9e04554/bricks/a2a496fc-9df0-446f-b632-da808d65d501" id="a2a496fc-9df0-446f-b632-da808d65d501">
        <actions>
            <link href="/api/clusters/99408929-82cf-4dc7-a532-9d998063fa95/glustervolumes/83101900-2f12-4855-838e-36b8a9e04554/bricks/a2a496fc-9df0-446f-b632-da808d65d501/replace" rel="replace"/>
        </actions>
        <gluster_volume href="/api/clusters/99408929-82cf-4dc7-a532-9d998063fa95/glustervolumes/83101900-2f12-4855-838e-36b8a9e04554" id="83101900-2f12-4855-838e-36b8a9e04554"/>
        <server_id>fcb46b88-f32e-11e1-918a-0050568c4349</server_id>
        <brick_dir>/export/data/brick3</brick_dir>
        <state>UP</state>
    </brick>
</bricks>
22632%2C+Console+Developer+Guide-322-09-2014+17%3A11%3A35Report a bug

10.4.3. Removing a Brick

The API removes a brick(s) from a volume with a DELETE request sent to its URI. Before removing a brick, data must be migrated to ensure there is no data loss with a POST request sent to its URI.
POST /api/clusters/44571c63-a110-4fba-9a8c-7b30446ba8bf/glustervolumes/380474af-360b-48fa-a210-9c08b913ffa3/bricks/migrate -d "<action><bricks><brick><name>host:brick_dir</name></brick></bricks></action>"
cURL command:
curl -X POST -H "Accept: application/xml" -H "Content-Type: application/xml" [USER:PASS] https://[RHSC HOST]/api/clusters/44571c63-a110-4fba-9a8c-7b30446ba8bf/glustervolumes/380474af-360b-48fa-a210-9c08b913ffa3/bricks/migrate -d "<action><bricks><brick><name>host:brick_dir</name></brick></bricks></action>"
The API returns the following representation:
<action>
    <bricks>
        <brick>
            <name>host:brick_dir</name>
        </brick>
    </bricks>
    <job href="/api/jobs/5d070f64-2f9b-44d7-8c44-64829355422d" id="5d070f64-2f9b-44d7-8c44-64829355422d"/>
    <status>
        <state>complete</state>
    </status>
</action>
The status of remove brick (with data migration) is monitored using the job ID and its corresponding step ID by looking at the remove brick step.
/api/jobs/<job_id>/steps
/api/jobs/<job_id>/steps/<step_id> --for step type remove brick
/api/jobs/<job_id>/steps/<step_id>/statistics -- for detail information of remove brick
Now, you can delete the migrated bricks by issuing a DELETE request for a brick(s).
DELETE /api/clusters/99408929-82cf-4dc7-a532-9d998063fa95/glustervolumes/83101900-2f12-4855-838e-36b8a9e04554/bricks
cURL command:
curl -X DELETE -u [USER:PASS] https://[RHSC HOST]/api/clusters/99408929-82cf-4dc7-a532-9d998063fa95/glustervolumes/83101900-2f12-4855-838e-36b8a9e04554/bricks -d "<bricks><brick><name>host:brick_dir</brick></bricks>"
22632%2C+Console+Developer+Guide-322-09-2014+17%3A11%3A35Report a bug