Openstack - Cinder Migration to Different AZ

## What's this?

AZ 間の Cinder volume 移動

1. Cinder upload to Glance as a image
2. Create Cinder volume from the image between AZ

## Initial state

    # cinder list
    +--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
    |                  ID                  |   Status  | Display Name | Size | Volume Type | Bootable | Attached to |
    +--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
    | 3f0f1bd7-6914-46e9-acec-be364b965052 | available | admin_vol01  |  1   |     None    |  false   |             |
    +--------------------------------------+-----------+--------------+------+-------------+----------+-------------+

    # cinder show admin_vol01
    +--------------------------------+--------------------------------------+
    |            Property            |                Value                 |
    +--------------------------------+--------------------------------------+
    |          attachments           |                  []                  |
    |       availability_zone        |                 nova                 |
    |            bootable            |                false                 |
    |           created_at           |      2015-03-20T02:46:43.000000      |
    |      display_description       |                                      |
    |          display_name          |             admin_vol01              |
    |           encrypted            |                False                 |
    |               id               | 3f0f1bd7-6914-46e9-acec-be364b965052 |
    |            metadata            |                  {}                  |
    |     os-vol-host-attr:host      |                node-17               |
    | os-vol-mig-status-attr:migstat |                 None                 |
    | os-vol-mig-status-attr:name_id |                 None                 |
    |  os-vol-tenant-attr:tenant_id  |   a8085d1871f847bdb906ef4a28d1bd48   |
    |              size              |                  1                   |
    |          snapshot_id           |                 None                 |
    |          source_volid          |                 None                 |
    |             status             |              available               |
    |          volume_type           |                 None                 |
    +--------------------------------+--------------------------------------+


## Upload a Cinder volume to Glance as image

#### Cinder upload to image

    # cinder upload-to-image --disk-format qcow2 --container-format bare 3f0f1bd7-6914-46e9-acec-be364b965052 admin_vol01_img
    +---------------------+--------------------------------------+
    |       Property      |                Value                 |
    +---------------------+--------------------------------------+
    |   container_format  |                 bare                 |
    |     disk_format     |                qcow2                 |
    | display_description |                                      |
    |          id         | 3f0f1bd7-6914-46e9-acec-be364b965052 |
    |       image_id      | 7d38b665-64b7-406c-b5e6-09579936dbf2 |
    |      image_name     |           admin_vol01_img            |
    |         size        |                  1                   |
    |        status       |              uploading               |
    |      updated_at     |      2015-03-20T02:46:44.000000      |
    |     volume_type     |                 None                 |
    +---------------------+--------------------------------------+

#### Check Glance image

    # glance image-list
    +--------------------------------------+----------------------------------------+-------------+------------------+------------+--------+
    | ID                                   | Name                                   | Disk Format | Container Format | Size       | Status |
    +--------------------------------------+----------------------------------------+-------------+------------------+------------+--------+
    | 7d38b665-64b7-406c-b5e6-09579936dbf2 | admin_vol01_img                        | qcow2       | bare             | 197120     | active |
    +--------------------------------------+----------------------------------------+-------------+------------------+------------+--------+

## Create Cinder volume from the Glance image in different AZ

#### AZ

    # cinder availability-zone-list
    +-------+-----------+
    |  Name |   Status  |
    +-------+-----------+
    |  nova | available |
    | nova2 | available |
    +-------+-----------+

#### Cinder services

    # cinder service-list
    +------------------+---------+-------+---------+-------+----------------------------+
    |      Binary      | Host    |  Zone |  Status | State |         Updated_at         |
    +------------------+---------+-------+---------+-------+----------------------------+
    |  cinder-backup   | node-17 |  nova | enabled |   up  | 2015-03-20T06:06:07.000000 |
    |  cinder-backup   | node-18 |  nova | enabled |   up  | 2015-03-20T06:06:06.000000 |
    |  cinder-backup   | node-22 |  nova | enabled |   up  | 2015-03-20T06:06:06.000000 |
    | cinder-scheduler | node-17 |  nova | enabled |   up  | 2015-03-20T06:06:03.000000 |
    | cinder-scheduler | node-18 |  nova | enabled |   up  | 2015-03-20T06:06:06.000000 |
    | cinder-scheduler | node-22 | nova2 | enabled |   up  | 2015-03-20T06:06:01.000000 |
    |  cinder-volume   | node-17 |  nova | enabled |   up  | 2015-03-20T06:06:05.000000 |
    |  cinder-volume   | node-18 |  nova | enabled |   up  | 2015-03-20T06:06:10.000000 |
    |  cinder-volume   | node-22 | nova2 | enabled |   up  | 2015-03-20T06:06:10.000000 |
    +------------------+---------+-------+---------+-------+----------------------------+

#### Create Cinder volume from the Glance image in different AZ

    # cinder create --availability-zone=nova2 --image-id 7d38b665-64b7-406c-b5e6-09579936dbf2 --display-name "admin_vol11_from_img" 1
    +---------------------+--------------------------------------+
    |       Property      |                Value                 |
    +---------------------+--------------------------------------+
    |     attachments     |                  []                  |
    |  availability_zone  |                nova2                 |
    |       bootable      |                false                 |
    |      created_at     |      2015-03-20T06:07:51.997398      |
    | display_description |                 None                 |
    |     display_name    |         admin_vol11_from_img         |
    |      encrypted      |                False                 |
    |          id         | 3a71b20d-87f4-44ab-9a8e-46106541b08c |
    |       image_id      | 7d38b665-64b7-406c-b5e6-09579936dbf2 |
    |       metadata      |                  {}                  |
    |         size        |                  1                   |
    |     snapshot_id     |                 None                 |
    |     source_volid    |                 None                 |
    |        status       |               creating               |
    |     volume_type     |                 None                 |
    +---------------------+--------------------------------------+

#### Cinder list

    # cinder list
    +--------------------------------------+-----------+----------------------+------+-------------+----------+-------------+
    |                  ID                  |   Status  |     Display Name     | Size | Volume Type | Bootable | Attached to |
    +--------------------------------------+-----------+----------------------+------+-------------+----------+-------------+
    | 3a71b20d-87f4-44ab-9a8e-46106541b08c | available | admin_vol11_from_img |  1   |     None    |   true   |             |
    | 3f0f1bd7-6914-46e9-acec-be364b965052 | available |     admin_vol01      |  1   |     None    |  false   |             |
    +--------------------------------------+-----------+----------------------+------+-------------+----------+-------------+


## Environment

* Openstack : Juno
* Ceph : Firefly


## Reference

[Cinder Migration to Different Backend][link-01]
[Cinder Migration to Different AZ][link-02]
[Cinder Migration to Different Region][link-03]

[link-01]:http://qiita.com/idzzy/items/d4258be6bf73b0060dfb
[link-02]:http://qiita.com/idzzy/items/153c5668ba08c87c1d2b
[link-03]:http://qiita.com/idzzy/items/25dc605342738409a76b