karbor/doc/source/usage.rst
caowei ece1371099 Update usage.rst
* add swift_bank_plugin in openstack-infra.conf.
* fix output instruction of karbor protectable-list.

Change-Id: I3f5f4ced081f31366ba772febf6ec8fbc7672dc7
2016-11-09 22:04:30 +08:00

175 lines
34 KiB
ReStructuredText

=============
Usage Example
=============
Resources in OpenStack (server, volume, image, network, etc) can be protected by Karbor.
This example will show protecting volume.
#. Before starting the karbor-protection service, the admin needs to configure a
Provider in /etc/karbor/providers.d/openstack-infra.conf. The Swift plugin is
the default bank plugin. The admin also needs to configure the basic Swift
client account configuration::
cat providers.d/openstack-infra.conf
[provider]
name = OS Infra Provider
description = This provider uses OpenStack's own services (swift, cinder) as storage
id = cf56bd3e-97a7-4078-b6d5-f36246333fd9
plugin=karbor-volume-protection-plugin
bank=karbor-swift-bank-plugin
[swift_client]
swift_auth_url=http://10.229.47.230:5000/v2.0/
swift_auth_version=2
swift_user=admin
swift_key=123456
swift_tenant_name=admin
[swift_bank_plugin]
lease_expire_window=120
lease_renew_window=100
lease_validity_window=100
#. To use cinder or karbor client, we should provide Keystone authentication
variables::
export OS_USERNAME=admin
export OS_PASSWORD=123456
export OS_TENANT_NAME=admin
export OS_AUTH_URL=http://10.229.47.230:35357/v2.0/
#. Show the provider information::
karbor provider-show cf56bd3e-97a7-4078-b6d5-f36246333fd9
+----------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Property | Value |
+----------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| description | This provider uses OpenStack's own services (swift, cinder) as storage |
| extended_info_schema | {u'options_schema': {u'OS::Cinder::Volume': {u'required': [u'backup_name', u'backup_mode', u'container', u'force'], u'type': u'object', u'properties': {u'force': {u'default': False, u'type': u'boolean', u'description': u'Whether to backup, even if the volumeis attached', u'title': u'Force'}, u'backup_name': {u'type': u'string', u'description': u'The name of the backup.', u'title': u'Backup Name'}, u'container': {u'type': u'string', u'description': u'The container which been chosen.', u'title': u'Container'}, u'description': {u'type': u'string', u'description': u'The description of the volume.', u'title': u'Description'}, u'backup_mode': {u'default': u'auto', u'enum': [u'full', u'incremental', u'auto'], u'type': u'string', u'description': u'The backup mode.', u'title': u'Backup Mode'}}, u'title': u'Cinder Protection Options'}}, u'saved_info_schema': {u'OS::Cinder::Volume': {u'required': [u'name', u'status', u'progress', u'fail_reason', u'size', u'volume_id'], u'type': u'object', u'properties': {u'status': {u'enum': [u'creating', u'available', u'deleting', u'error', u'restoring', u'error_restoring'], u'type': u'string', u'description': u'The backup status, such as available.', u'title': u'Status'}, u'fail_reason': {u'type': u'string', u'description': u'The reason for the failure status of the backup.', u'title': u'Fail Reason'}, u'name': {u'type': u'string', u'description': u'The name for this backup.', u'title': u'Name'}, u'volume_id': {u'type': u'string', u'description': u'The ID of the volume from which the backup was created.', u'title': u'Volume ID'}, u'progress': {u'constraint': {u'max': 1, u'min': 0}, u'type': u'number', u'description': u'The current operation progress for this backup.', u'title': u'Progress'}, u'is_incremental': {u'type': u'boolean', u'description': u'The type of the backup, True is incremental and False is full.', u'title': u'Is Incremental'}, u'size': {u'type': u'integer', u'description': u'The size of the backup, in GB.', u'title': u'Size'}}, u'title': u'Cinder Protection Saved Info'}}, u'restore_schema': {u'OS::Cinder::Volume': {u'type': u'object', u'properties': {u'restore_name': {u'default': None, u'type': u'string', u'description': u'The name of the restored volume.', u'title': u'Restore Name'}, u'restore_description': {u'default': None, u'type': u'string', u'description': u'The description of the restored volume.', u'title': u'Restore Name'}, u'volume_id': {u'type': u'string', u'description': u'The target volume ID to restore to.', u'title': u'Volume ID'}}, u'title': u'Cinder Protection Restore'}}} |
| id | cf56bd3e-97a7-4078-b6d5-f36246333fd9 |
| name | OS Infra Provider |
+----------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
#. Use cinder client to create volumes::
cinder create 1 --name volume1
cinder create 1 --name volume2
cinder list
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
| ID | Status | Name | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
| c468688b-dcb1-4bdf-b26b-62e989ac940e | available | volume1 | 1 | lvmdriver-1 | false | |
| d107b234-e16d-4e1e-800d-86523c693e5c | available | volume2 | 1 | lvmdriver-1 | false | |
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
#. List the protectable resources::
karbor protectable-list
+-----------------------+
| Protectable type |
+-----------------------+
| OS::Cinder::Volume |
| OS::Glance::Image |
| OS::Keystone::Project |
| OS::Nova::Server |
+-----------------------+
karbor protectable-list-instances OS::Cinder::Volume
+--------------------------------------+--------------------+---------------------+
| Id | Type | Dependent resources |
+--------------------------------------+--------------------+---------------------+
| c468688b-dcb1-4bdf-b26b-62e989ac940e | OS::Cinder::Volume | [] |
| d107b234-e16d-4e1e-800d-86523c693e5c | OS::Cinder::Volume | [] |
+--------------------------------------+--------------------+---------------------+
#. Create a protection plan with a provider and resources::
karbor plan-create 'OS volumes protection plan.' 'cf56bd3e-97a7-4078-b6d5-f36246333fd9' 'd107b234-e16d-4e1e-800d-86523c693e5c'='OS::Cinder::Volume'='volume2','c468688b-dcb1-4bdf-b26b-62e989ac940e'='OS::Cinder::Volume'='volume1'
+-------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Property | Value |
+-------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| id | b5969bb9-c571-4538-b827-3746d11aa7a2 |
| name | OS volumes protection plan. |
| parameters | {u'user': {u'value': u'password'}} |
| provider_id | cf56bd3e-97a7-4078-b6d5-f36246333fd9 |
| resources | [{u'type': u'OS::Cinder::Volume', u'id': u'd107b234-e16d-4e1e-800d-86523c693e5c', u'name': u'volume2'}, {u'type': u'OS::Cinder::Volume', u'id': u'c468688b-dcb1-4bdf-b26b-62e989ac940e', u'name': u'volume1'}] |
| status | suspended |
+-------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
#. Execute a protect operation manually with a plan::
karbor checkpoint-create cf56bd3e-97a7-4078-b6d5-f36246333fd9 b5969bb9-c571-4538-b827-3746d11aa7a2
+-----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Property | Value |
+-----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| id | 503e12db-a815-4101-b526-6b687ba60080 |
| project_id | 8ea0fc3673794f1492b875d349400181 |
| protection_plan | {u'id': u'b5969bb9-c571-4538-b827-3746d11aa7a2', u'resources': [{u'type': u'OS::Cinder::Volume', u'id': u'd107b234-e16d-4e1e-800d-86523c693e5c', u'name': u'volume2'}, {u'type': u'OS::Cinder::Volume', u'id': u'c468688b-dcb1-4bdf-b26b-62e989ac940e', u'name': u'volume1'}], u'name': u'OS volumes protection plan.'} |
| provider_id | cf56bd3e-97a7-4078-b6d5-f36246333fd9 |
| resource_graph | None |
| status | protecting |
+-----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
# check the protect result
cinder backup-list
+--------------------------------------+--------------------------------------+-----------+--------------+------+--------------+---------------+
| ID | Volume ID | Status | Name | Size | Object Count | Container |
+--------------------------------------+--------------------------------------+-----------+--------------+------+--------------+---------------+
| 58811e5a-d65f-4d1e-8e3d-2e7f1b688c32 | c468688b-dcb1-4bdf-b26b-62e989ac940e | available | test_protect | 1 | 22 | volumebackups |
| de4bbdab-315b-40f3-b89a-25a23c387e04 | d107b234-e16d-4e1e-800d-86523c693e5c | available | test_protect | 1 | 22 | volumebackups |
+--------------------------------------+--------------------------------------+-----------+--------------+------+--------------+---------------+
karbor checkpoint-show cf56bd3e-97a7-4078-b6d5-f36246333fd9 503e12db-a815-4101-b526-6b687ba60080
#. Execute a protect operation automatically with a scheduler::
karbor trigger-create 'My Trigger' 'time' "pattern"="0 20 * * 2":"format"="crontab"
karbor scheduledoperation-create 'Protect with My Trigger' 'protect' <trigger_id> "plan_id"="b5969bb9-c571-4538-b827-3746d11aa7a2":"provider_id"="cf56bd3e-97a7-4078-b6d5-f36246333fd9"
#. Execute a restore operation manually with a checkpoint id::
karbor --debug restore-create cf56bd3e-97a7-4078-b6d5-f36246333fd9 2c14b9d6-529b-4308-bb17-7334eb351fd7 'http://10.229.47.230:35357/v2.0/' --parameters 'username'='admin' 'password'='123456'
+----------------+-------------------------------------------------+
| Property | Value |
+----------------+-------------------------------------------------+
| checkpoint_id | 2c14b9d6-529b-4308-bb17-7334eb351fd7 |
| id | 34a3418d-444e-4271-922e-e2e2c3fe89ec |
| parameters | {u'username': u'admin', u'password': u'123456'} |
| project_id | 8ea0fc3673794f1492b875d349400181 |
| provider_id | cf56bd3e-97a7-4078-b6d5-f36246333fd9 |
| restore_target | http://10.229.47.230:35357/v2.0/ |
| status | success |
+----------------+-------------------------------------------------+
cinder list
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
| ID | Status | Name | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
| c468688b-dcb1-4bdf-b26b-62e989ac940e | available | volume1 | 1 | lvmdriver-1 | false | |
| d107b234-e16d-4e1e-800d-86523c693e5c | available | volume2 | 1 | lvmdriver-1 | false | |
| e03c8369-0177-4b2f-87ba-8139dc1c5eaf | available | test_restore | 1 | lvmdriver-1 | false | |
| f208dacd-5a83-4b40-a22e-371c138bd97d | available | test_restore | 1 | lvmdriver-1 | false | |
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
#. Execute a delete operation manually with a checkpoint id::
cinder backup-list
+--------------------------------------+--------------------------------------+-----------+--------------+------+--------------+---------------+
| ID | Volume ID | Status | Name | Size | Object Count | Container |
+--------------------------------------+--------------------------------------+-----------+--------------+------+--------------+---------------+
| 58811e5a-d65f-4d1e-8e3d-2e7f1b688c32 | c468688b-dcb1-4bdf-b26b-62e989ac940e | available | test_protect | 1 | 22 | volumebackups |
| de4bbdab-315b-40f3-b89a-25a23c387e04 | d107b234-e16d-4e1e-800d-86523c693e5c | available | test_protect | 1 | 22 | volumebackups |
+--------------------------------------+--------------------------------------+-----------+--------------+------+--------------+---------------+
karbor checkpoint-delete cf56bd3e-97a7-4078-b6d5-f36246333fd9 2c14b9d6-529b-4308-bb17-7334eb351fd7
cinder backup-list
+----+-----------+--------+------+------+--------------+-----------+
| ID | Volume ID | Status | Name | Size | Object Count | Container |
+----+-----------+--------+------+------+--------------+-----------+
+----+-----------+--------+------+------+--------------+-----------+