Openstack - Cinder Migration to Different Backend

## What's this?

Cinder volume を別の Storage backend へ移動

## Initial state

##### Cinder Services

    # cinder service-list
    +------------------+---------+-------+---------+-------+----------------------------+
    |      Binary      | Host    |  Zone |  Status | State |         Updated_at         |
    +------------------+---------+-------+---------+-------+----------------------------+
    |  cinder-backup   | node-17 |  nova | enabled |   up  | 2015-03-09T06:58:19.000000 |
    |  cinder-backup   | node-18 |  nova | enabled |   up  | 2015-03-09T06:58:28.000000 |
    |  cinder-backup   | node-22 |  nova | enabled |   up  | 2015-03-09T06:58:28.000000 |
    | cinder-scheduler | node-17 |  nova | enabled |   up  | 2015-03-09T06:58:25.000000 |
    | cinder-scheduler | node-18 |  nova | enabled |   up  | 2015-03-09T06:58:28.000000 |
    | cinder-scheduler | node-22 | nova2 | enabled |   up  | 2015-03-09T06:58:23.000000 |
    |  cinder-volume   | node-17 |  nova | enabled |   up  | 2015-03-09T06:58:26.000000 |
    |  cinder-volume   | node-18 |  nova | enabled |   up  | 2015-03-09T06:58:21.000000 |
    |  cinder-volume   | node-22 | nova2 | enabled |   up  | 2015-03-09T06:58:21.000000 |
    +------------------+---------+-------+---------+-------+----------------------------+

##### AZ

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

##### Host

    # cinder-manage host list
    host          zone
    node-17       nova
    node-18       nova
    node-22       nova2

##### Cinder Volume

    # cinder list
    +--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
    |                  ID                  |   Status  | Display Name | Size | Volume Type | Bootable | Attached to |
    +--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
    | 3ffaaea5-24a0-414b-a6c2-7c28a888795b | available | admin_vol01  |  1   |     None    |  false   |             |
    +--------------------------------------+-----------+--------------+------+-------------+----------+-------------+

    # cinder show 3ffaaea5-24a0-414b-a6c2-7c28a888795b
    +--------------------------------+--------------------------------------+
    |            Property            |                Value                 |
    +--------------------------------+--------------------------------------+
    |          attachments           |                  []                  |
    |       availability_zone        |                 nova                 |
    |            bootable            |                false                 |
    |           created_at           |      2015-03-09T06:41:33.000000      |
    |      display_description       |                                      |
    |          display_name          |             admin_vol01              |
    |           encrypted            |                False                 |
    |               id               | 3ffaaea5-24a0-414b-a6c2-7c28a888795b |
    |            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                 |
    +--------------------------------+--------------------------------------+


## Migrate cinder volume to different backend

##### Migrate volume(admin_vol01) from backend(node-17) to backend(node-18)

    # cinder migrate 3ffaaea5-24a0-414b-a6c2-7c28a888795b node-18

##### Created new Cinder volume(93f650fd-c4b3-420a-8409-d333c12e4d9c) as same name.

    # cinder list
    +--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
    |                  ID                  |   Status  | Display Name | Size | Volume Type | Bootable | Attached to |
    +--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
    | 3ffaaea5-24a0-414b-a6c2-7c28a888795b | available | admin_vol01  |  1   |     None    |  false   |             |
    | 93f650fd-c4b3-420a-8409-d333c12e4d9c | available | admin_vol01  |  1   |     None    |  false   |             |
    +--------------------------------------+-----------+--------------+------+-------------+----------+-------------+

##### New Cinder volume(93f650fd-c4b3-420a-8409-d333c12e4d9c) is on backend(node-18)

    # cinder show 93f650fd-c4b3-420a-8409-d333c12e4d9c
    +--------------------------------+---------------------------------------------+
    |            Property            |                    Value                    |
    +--------------------------------+---------------------------------------------+
    |          attachments           |                      []                     |
    |       availability_zone        |                     nova                    |
    |            bootable            |                    false                    |
    |           created_at           |          2015-03-09T06:41:33.000000         |
    |      display_description       |                                             |
    |          display_name          |                 admin_vol01                 |
    |           encrypted            |                    False                    |
    |               id               |     93f650fd-c4b3-420a-8409-d333c12e4d9c    |
    |            metadata            |                      {}                     |
    |     os-vol-host-attr:host      |            node-18                          |
    | os-vol-mig-status-attr:migstat | target:3ffaaea5-24a0-414b-a6c2-7c28a888795b |
    | 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                    |
    +--------------------------------+---------------------------------------------+

##### Cinder rename

    # cinder rename 93f650fd-c4b3-420a-8409-d333c12e4d9c admin_vol11

    # cinder list
    +--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
    |                  ID                  |   Status  | Display Name | Size | Volume Type | Bootable | Attached to |
    +--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
    | 3ffaaea5-24a0-414b-a6c2-7c28a888795b | available | admin_vol01  |  1   |     None    |  false   |             |
    | 93f650fd-c4b3-420a-8409-d333c12e4d9c | available | admin_vol11  |  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