Openstack - Cinder Migration to Different Region

## What's this?

Region 間の Cinder volume の移動

1. [Region1] Cinder upload to Glance
2. [Somewhere installed Openstack client tool] Download Glance image from Region1
3. [Somewhere installed Openstack client tool] Upload Glance image to Region2
4. [Region2] Create Cinder volume from the image

## [Region1] Initial State

    # cinder list
    +--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
    |                  ID                  |   Status  | Display Name | Size | Volume Type | Bootable | Attached to |
    +--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
    | 64b66381-0068-4d5a-99c3-c59da5792061 | available | admin_vol01  |  1   |     None    |  false   |             |
    +--------------------------------------+-----------+--------------+------+-------------+----------+-------------+

    # cinder show 64b66381-0068-4d5a-99c3-c59da5792061
    +--------------------------------+--------------------------------------+
    |            Property            |                Value                 |
    +--------------------------------+--------------------------------------+
    |          attachments           |                  []                  |
    |       availability_zone        |                 nova                 |
    |            bootable            |                false                 |
    |           created_at           |      2015-03-20T07:23:22.000000      |
    |      display_description       |                                      |
    |          display_name          |             admin_vol01              |
    |           encrypted            |                False                 |
    |               id               | 64b66381-0068-4d5a-99c3-c59da5792061 |
    |            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                 |
    +--------------------------------+--------------------------------------+


## [Region1] Upload Cinder volume to Glance as image

#### Cinder upload to image

    # cinder upload-to-image --disk-format qcow2 --container-format bare 64b66381-0068-4d5a-99c3-c59da5792061 admin_vol01_img
    +---------------------+--------------------------------------+
    |       Property      |                Value                 |
    +---------------------+--------------------------------------+
    |   container_format  |                 bare                 |
    |     disk_format     |                qcow2                 |
    | display_description |                                      |
    |          id         | 64b66381-0068-4d5a-99c3-c59da5792061 |
    |       image_id      | 9c33c6ef-a25b-47f0-bef7-3e5ed6df54c2 |
    |      image_name     |           admin_vol01_img            |
    |         size        |                  1                   |
    |        status       |              uploading               |
    |      updated_at     |      2015-03-20T07:23:22.000000      |
    |     volume_type     |                 None                 |
    +---------------------+--------------------------------------+

#### Check Glance image

    # glance image-list
    +--------------------------------------+----------------------------------------+-------------+------------------+------------+--------+
    | ID                                   | Name                                   | Disk Format | Container Format | Size       | Status |
    +--------------------------------------+----------------------------------------+-------------+------------------+------------+--------+
    | 9c33c6ef-a25b-47f0-bef7-3e5ed6df54c2 | admin_vol01_img                        | qcow2       | bare             | 197120     | active |
    +--------------------------------------+----------------------------------------+-------------+------------------+------------+--------+


## Download from Region1 to Somewhere server installed Openstack client tool

#### Env

    $ env | egrep "OS_REGION_NAME|OS_AUTH_URL|OS_USERNAME"
    OS_REGION_NAME=RegionOne
    OS_AUTH_URL=http://10.30.0.2:5000/v2.0/
    OS_USERNAME=admin

#### Glance download

    $ glance image-download --file admin_vol01_img_PoC1 admin_vol01_img

    $ ls -l admin_vol01_img_PoC1
    -rw-r--r-- 1 root root 197120 Mar 20 16:28 admin_vol01_img_PoC1


## Upload to Region2 from Somewhere server installed Openstack client tool

#### Env

    $ env | egrep "OS_REGION_NAME|OS_AUTH_URL|OS_USERNAME"
    OS_REGION_NAME=RegionTwo
    OS_AUTH_URL=http://10.32.37.45:5000/v2.0/
    OS_USERNAME=admin

#### Glance upload (= create from download file)

    $ glance image-create --name admin_vol01_img_PoC1 --disk-format qcow2 --container-format bare --is-public True --file admin_vol01_img_PoC1
    +------------------+--------------------------------------+
    | Property         | Value                                |
    +------------------+--------------------------------------+
    | checksum         | 5789e2a5cabb3007171a45a06e86936f     |
    | container_format | bare                                 |
    | created_at       | 2015-03-20T07:29:58                  |
    | deleted          | False                                |
    | deleted_at       | None                                 |
    | disk_format      | qcow2                                |
    | id               | c56612a0-3bc0-4419-b09b-7db0f9e9b53c |
    | is_public        | True                                 |
    | min_disk         | 0                                    |
    | min_ram          | 0                                    |
    | name             | admin_vol01_img_PoC1                 |
    | owner            | 103cfcfb3a094c3382441d21ccff32b3     |
    | protected        | False                                |
    | size             | 197120                               |
    | status           | active                               |
    | updated_at       | 2015-03-20T07:29:59                  |
    | virtual_size     | None                                 |
    +------------------+--------------------------------------+

#### Glance image list

    $ glance image-list
    +--------------------------------------+----------------------+-------------+------------------+------------+--------+
    | ID                                   | Name                 | Disk Format | Container Format | Size       | Status |
    +--------------------------------------+----------------------+-------------+------------------+------------+--------+
    | c56612a0-3bc0-4419-b09b-7db0f9e9b53c | admin_vol01_img_PoC1 | qcow2       | bare             | 197120     | active |
    +--------------------------------------+----------------------+-------------+------------------+------------+--------+

### [Region2] Create Cinder volume from the Glance image

#### Cinder create from the image uploaded from different Region

    $ cinder create --image-id c56612a0-3bc0-4419-b09b-7db0f9e9b53c --display-name "admin_vol11_from_PoC1" 1
    +---------------------+--------------------------------------+
    |       Property      |                Value                 |
    +---------------------+--------------------------------------+
    |     attachments     |                  []                  |
    |  availability_zone  |                 nova                 |
    |       bootable      |                false                 |
    |      created_at     |      2015-03-20T07:33:13.078943      |
    | display_description |                 None                 |
    |     display_name    |        admin_vol11_from_PoC1         |
    |      encrypted      |                False                 |
    |          id         | 5607c316-6c82-4462-999e-8f7f1bdef1cb |
    |       image_id      | c56612a0-3bc0-4419-b09b-7db0f9e9b53c |
    |       metadata      |                  {}                  |
    |         size        |                  1                   |
    |     snapshot_id     |                 None                 |
    |     source_volid    |                 None                 |
    |        status       |               creating               |
    |     volume_type     |                 None                 |
    +---------------------+--------------------------------------+

#### Cinder volume list

    # cinder list
    +--------------------------------------+-----------+-----------------------+------+-------------+----------+-------------+
    |                  ID                  |   Status  |      Display Name     | Size | Volume Type | Bootable | Attached to |
    +--------------------------------------+-----------+-----------------------+------+-------------+----------+-------------+
    | 5607c316-6c82-4462-999e-8f7f1bdef1cb | available | admin_vol11_from_PoC1 |  1   |     None    |   true   |             |
    +--------------------------------------+-----------+-----------------------+------+-------------+----------+-------------+


## 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