Merge "Rename backup commands in volume v1 and v2"

This commit is contained in:
Jenkins 2016-08-11 04:36:52 +00:00 committed by Gerrit Code Review
commit c9cf6c4eb2
7 changed files with 363 additions and 35 deletions

View File

@ -8,6 +8,7 @@ backup create
------------- -------------
Create new backup Create new backup
(Deprecated, please use ``volume backup create`` instead)
.. program:: backup create .. program:: backup create
.. code:: bash .. code:: bash
@ -60,6 +61,7 @@ backup delete
------------- -------------
Delete backup(s) Delete backup(s)
(Deprecated, please use ``volume backup delete`` instead)
.. program:: backup delete .. program:: backup delete
.. code:: bash .. code:: bash
@ -83,6 +85,7 @@ backup list
----------- -----------
List backups List backups
(Deprecated, please use ``volume backup list`` instead)
.. program:: backup list .. program:: backup list
.. code:: bash .. code:: bash
@ -98,6 +101,7 @@ backup restore
-------------- --------------
Restore backup Restore backup
(Deprecated, please use ``volume backup restore`` instead)
.. program:: backup restore .. program:: backup restore
.. code:: bash .. code:: bash
@ -119,6 +123,7 @@ backup show
----------- -----------
Display backup details Display backup details
(Deprecated, please use ``volume backup show`` instead)
.. program:: backup show .. program:: backup show
.. code:: bash .. code:: bash

View File

@ -0,0 +1,132 @@
=============
volume backup
=============
Block Storage v1, v2
volume backup create
--------------------
Create new volume backup
.. program:: volume backup create
.. code:: bash
os volume backup create
[--container <container>]
[--name <name>]
[--description <description>]
[--snapshot <snapshot>]
[--force]
[--incremental]
<volume>
.. option:: --container <container>
Optional backup container name
.. option:: --name <name>
Name of the backup
.. option:: --description <description>
Description of the backup
.. option:: --snapshot <snapshot>
Snapshot to backup (name or ID)
*Volume version 2 only*
.. option:: --force
Allow to back up an in-use volume
*Volume version 2 only*
.. option:: --incremental
Perform an incremental backup
*Volume version 2 only*
.. _volume_backup_create-backup:
.. describe:: <volume>
Volume to backup (name or ID)
volume backup delete
--------------------
Delete volume backup(s)
.. program:: volume backup delete
.. code:: bash
os volume backup delete
[--force]
<backup> [<backup> ...]
.. option:: --force
Allow delete in state other than error or available
*Volume version 2 only*
.. _volume_backup_delete-backup:
.. describe:: <backup>
Backup(s) to delete (name or ID)
volume backup list
------------------
List volume backups
.. program:: volume backup list
.. code:: bash
os volume backup list
.. _volume_backup_list-backup:
.. option:: --long
List additional fields in output
volume backup restore
---------------------
Restore volume backup
.. program:: volume backup restore
.. code:: bash
os volume backup restore
<backup>
<volume>
.. _volume_backup_restore-backup:
.. describe:: <backup>
Backup to restore (name or ID)
.. describe:: <volume>
Volume to restore to (name or ID)
volume backup show
------------------
Display volume backup details
.. program:: volume backup show
.. code:: bash
os volume backup show
<backup>
.. _volume_backup_show-backup:
.. describe:: <backup>
Backup to display (name or ID)

View File

@ -77,7 +77,7 @@ class TestBackupCreate(TestBackup):
self.backups_mock.create.return_value = self.new_backup self.backups_mock.create.return_value = self.new_backup
# Get the command object to test # Get the command object to test
self.cmd = backup.CreateBackup(self.app, None) self.cmd = backup.CreateVolumeBackup(self.app, None)
def test_backup_create(self): def test_backup_create(self):
arglist = [ arglist = [
@ -154,7 +154,7 @@ class TestBackupDelete(TestBackup):
self.backups_mock.delete.return_value = None self.backups_mock.delete.return_value = None
# Get the command object to mock # Get the command object to mock
self.cmd = backup.DeleteBackup(self.app, None) self.cmd = backup.DeleteVolumeBackup(self.app, None)
def test_backup_delete(self): def test_backup_delete(self):
arglist = [ arglist = [
@ -281,7 +281,7 @@ class TestBackupList(TestBackup):
self.volumes_mock.list.return_value = [self.volume] self.volumes_mock.list.return_value = [self.volume]
self.backups_mock.list.return_value = self.backups self.backups_mock.list.return_value = self.backups
# Get the command to test # Get the command to test
self.cmd = backup.ListBackup(self.app, None) self.cmd = backup.ListVolumeBackup(self.app, None)
def test_backup_list_without_options(self): def test_backup_list_without_options(self):
arglist = [] arglist = []
@ -317,7 +317,7 @@ class TestBackupRestore(TestBackup):
self.volumes_mock.get.return_value = self.volume self.volumes_mock.get.return_value = self.volume
self.restores_mock.restore.return_value = None self.restores_mock.restore.return_value = None
# Get the command object to mock # Get the command object to mock
self.cmd = backup.RestoreBackup(self.app, None) self.cmd = backup.RestoreVolumeBackup(self.app, None)
def test_backup_restore(self): def test_backup_restore(self):
arglist = [ arglist = [
@ -370,7 +370,7 @@ class TestBackupShow(TestBackup):
self.backups_mock.get.return_value = self.backup self.backups_mock.get.return_value = self.backup
# Get the command object to test # Get the command object to test
self.cmd = backup.ShowBackup(self.app, None) self.cmd = backup.ShowVolumeBackup(self.app, None)
def test_backup_show(self): def test_backup_show(self):
arglist = [ arglist = [

View File

@ -16,6 +16,7 @@
"""Volume v1 Backup action implementations""" """Volume v1 Backup action implementations"""
import copy import copy
import logging
from osc_lib.command import command from osc_lib.command import command
from osc_lib import utils from osc_lib import utils
@ -24,11 +25,11 @@ import six
from openstackclient.i18n import _ from openstackclient.i18n import _
class CreateBackup(command.ShowOne): class CreateVolumeBackup(command.ShowOne):
"""Create new backup""" """Create new volume backup"""
def get_parser(self, prog_name): def get_parser(self, prog_name):
parser = super(CreateBackup, self).get_parser(prog_name) parser = super(CreateVolumeBackup, self).get_parser(prog_name)
parser.add_argument( parser.add_argument(
'volume', 'volume',
metavar='<volume>', metavar='<volume>',
@ -67,11 +68,28 @@ class CreateBackup(command.ShowOne):
return zip(*sorted(six.iteritems(backup._info))) return zip(*sorted(six.iteritems(backup._info)))
class DeleteBackup(command.Command): class CreateBackup(CreateVolumeBackup):
"""Delete backup(s)""" """Create new backup"""
# TODO(Huanxuan Ao): Remove this class and ``backup create`` command
# two cycles after Newton.
# This notifies cliff to not display the help for this command
deprecated = True
log = logging.getLogger('deprecated')
def take_action(self, parsed_args):
self.log.warning(_('This command has been deprecated. '
'Please use "volume backup create" instead.'))
return super(CreateBackup, self).take_action(parsed_args)
class DeleteVolumeBackup(command.Command):
"""Delete volume backup(s)"""
def get_parser(self, prog_name): def get_parser(self, prog_name):
parser = super(DeleteBackup, self).get_parser(prog_name) parser = super(DeleteVolumeBackup, self).get_parser(prog_name)
parser.add_argument( parser.add_argument(
'backups', 'backups',
metavar='<backup>', metavar='<backup>',
@ -88,11 +106,28 @@ class DeleteBackup(command.Command):
volume_client.backups.delete(backup_id) volume_client.backups.delete(backup_id)
class ListBackup(command.Lister): class DeleteBackup(DeleteVolumeBackup):
"""List backups""" """Delete backup(s)"""
# TODO(Huanxuan Ao): Remove this class and ``backup delete`` command
# two cycles after Newton.
# This notifies cliff to not display the help for this command
deprecated = True
log = logging.getLogger('deprecated')
def take_action(self, parsed_args):
self.log.warning(_('This command has been deprecated. '
'Please use "volume backup delete" instead.'))
return super(DeleteBackup, self).take_action(parsed_args)
class ListVolumeBackup(command.Lister):
"""List volume backups"""
def get_parser(self, prog_name): def get_parser(self, prog_name):
parser = super(ListBackup, self).get_parser(prog_name) parser = super(ListVolumeBackup, self).get_parser(prog_name)
parser.add_argument( parser.add_argument(
'--long', '--long',
action='store_true', action='store_true',
@ -142,11 +177,28 @@ class ListBackup(command.Lister):
) for s in data)) ) for s in data))
class RestoreBackup(command.Command): class ListBackup(ListVolumeBackup):
"""Restore backup""" """List backups"""
# TODO(Huanxuan Ao): Remove this class and ``backup list`` command
# two cycles after Newton.
# This notifies cliff to not display the help for this command
deprecated = True
log = logging.getLogger('deprecated')
def take_action(self, parsed_args):
self.log.warning(_('This command has been deprecated. '
'Please use "volume backup list" instead.'))
return super(ListBackup, self).take_action(parsed_args)
class RestoreVolumeBackup(command.Command):
"""Restore volume backup"""
def get_parser(self, prog_name): def get_parser(self, prog_name):
parser = super(RestoreBackup, self).get_parser(prog_name) parser = super(RestoreVolumeBackup, self).get_parser(prog_name)
parser.add_argument( parser.add_argument(
'backup', 'backup',
metavar='<backup>', metavar='<backup>',
@ -169,11 +221,28 @@ class RestoreBackup(command.Command):
destination_volume.id) destination_volume.id)
class ShowBackup(command.ShowOne): class RestoreBackup(RestoreVolumeBackup):
"""Display backup details""" """Restore backup"""
# TODO(Huanxuan Ao): Remove this class and ``backup restore`` command
# two cycles after Newton.
# This notifies cliff to not display the help for this command
deprecated = True
log = logging.getLogger('deprecated')
def take_action(self, parsed_args):
self.log.warning(_('This command has been deprecated. '
'Please use "volume backup restore" instead.'))
return super(RestoreBackup, self).take_action(parsed_args)
class ShowVolumeBackup(command.ShowOne):
"""Display volume backup details"""
def get_parser(self, prog_name): def get_parser(self, prog_name):
parser = super(ShowBackup, self).get_parser(prog_name) parser = super(ShowVolumeBackup, self).get_parser(prog_name)
parser.add_argument( parser.add_argument(
'backup', 'backup',
metavar='<backup>', metavar='<backup>',
@ -187,3 +256,20 @@ class ShowBackup(command.ShowOne):
parsed_args.backup) parsed_args.backup)
backup._info.pop('links') backup._info.pop('links')
return zip(*sorted(six.iteritems(backup._info))) return zip(*sorted(six.iteritems(backup._info)))
class ShowBackup(ShowVolumeBackup):
"""Display backup details"""
# TODO(Huanxuan Ao): Remove this class and ``backup show`` command
# two cycles after Newton.
# This notifies cliff to not display the help for this command
deprecated = True
log = logging.getLogger('deprecated')
def take_action(self, parsed_args):
self.log.warning(_('This command has been deprecated. '
'Please use "volume backup show" instead.'))
return super(ShowBackup, self).take_action(parsed_args)

View File

@ -28,11 +28,11 @@ from openstackclient.i18n import _
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
class CreateBackup(command.ShowOne): class CreateVolumeBackup(command.ShowOne):
"""Create new backup""" """Create new volume backup"""
def get_parser(self, prog_name): def get_parser(self, prog_name):
parser = super(CreateBackup, self).get_parser(prog_name) parser = super(CreateVolumeBackup, self).get_parser(prog_name)
parser.add_argument( parser.add_argument(
"volume", "volume",
metavar="<volume>", metavar="<volume>",
@ -93,11 +93,28 @@ class CreateBackup(command.ShowOne):
return zip(*sorted(six.iteritems(backup._info))) return zip(*sorted(six.iteritems(backup._info)))
class DeleteBackup(command.Command): class CreateBackup(CreateVolumeBackup):
"""Delete backup(s)""" """Create new backup"""
# TODO(Huanxuan Ao): Remove this class and ``backup create`` command
# two cycles after Newton.
# This notifies cliff to not display the help for this command
deprecated = True
log = logging.getLogger('deprecated')
def take_action(self, parsed_args):
self.log.warning(_('This command has been deprecated. '
'Please use "volume backup create" instead.'))
return super(CreateBackup, self).take_action(parsed_args)
class DeleteVolumeBackup(command.Command):
"""Delete volume backup(s)"""
def get_parser(self, prog_name): def get_parser(self, prog_name):
parser = super(DeleteBackup, self).get_parser(prog_name) parser = super(DeleteVolumeBackup, self).get_parser(prog_name)
parser.add_argument( parser.add_argument(
"backups", "backups",
metavar="<backup>", metavar="<backup>",
@ -134,11 +151,28 @@ class DeleteBackup(command.Command):
raise exceptions.CommandError(msg) raise exceptions.CommandError(msg)
class ListBackup(command.Lister): class DeleteBackup(DeleteVolumeBackup):
"""List backups""" """Delete backup(s)"""
# TODO(Huanxuan Ao): Remove this class and ``backup delete`` command
# two cycles after Newton.
# This notifies cliff to not display the help for this command
deprecated = True
log = logging.getLogger('deprecated')
def take_action(self, parsed_args):
self.log.warning(_('This command has been deprecated. '
'Please use "volume backup delete" instead.'))
return super(DeleteBackup, self).take_action(parsed_args)
class ListVolumeBackup(command.Lister):
"""List volume backups"""
def get_parser(self, prog_name): def get_parser(self, prog_name):
parser = super(ListBackup, self).get_parser(prog_name) parser = super(ListVolumeBackup, self).get_parser(prog_name)
parser.add_argument( parser.add_argument(
"--long", "--long",
action="store_true", action="store_true",
@ -188,11 +222,28 @@ class ListBackup(command.Lister):
) for s in data)) ) for s in data))
class RestoreBackup(command.ShowOne): class ListBackup(ListVolumeBackup):
"""Restore backup""" """List backups"""
# TODO(Huanxuan Ao): Remove this class and ``backup list`` command
# two cycles after Newton.
# This notifies cliff to not display the help for this command
deprecated = True
log = logging.getLogger('deprecated')
def take_action(self, parsed_args):
self.log.warning(_('This command has been deprecated. '
'Please use "volume backup list" instead.'))
return super(ListBackup, self).take_action(parsed_args)
class RestoreVolumeBackup(command.ShowOne):
"""Restore volume backup"""
def get_parser(self, prog_name): def get_parser(self, prog_name):
parser = super(RestoreBackup, self).get_parser(prog_name) parser = super(RestoreVolumeBackup, self).get_parser(prog_name)
parser.add_argument( parser.add_argument(
"backup", "backup",
metavar="<backup>", metavar="<backup>",
@ -213,11 +264,28 @@ class RestoreBackup(command.ShowOne):
return volume_client.restores.restore(backup.id, destination_volume.id) return volume_client.restores.restore(backup.id, destination_volume.id)
class ShowBackup(command.ShowOne): class RestoreBackup(RestoreVolumeBackup):
"""Display backup details""" """Restore backup"""
# TODO(Huanxuan Ao): Remove this class and ``backup restore`` command
# two cycles after Newton.
# This notifies cliff to not display the help for this command
deprecated = True
log = logging.getLogger('deprecated')
def take_action(self, parsed_args):
self.log.warning(_('This command has been deprecated. '
'Please use "volume backup restore" instead.'))
return super(RestoreBackup, self).take_action(parsed_args)
class ShowVolumeBackup(command.ShowOne):
"""Display volume backup details"""
def get_parser(self, prog_name): def get_parser(self, prog_name):
parser = super(ShowBackup, self).get_parser(prog_name) parser = super(ShowVolumeBackup, self).get_parser(prog_name)
parser.add_argument( parser.add_argument(
"backup", "backup",
metavar="<backup>", metavar="<backup>",
@ -231,3 +299,20 @@ class ShowBackup(command.ShowOne):
parsed_args.backup) parsed_args.backup)
backup._info.pop("links", None) backup._info.pop("links", None)
return zip(*sorted(six.iteritems(backup._info))) return zip(*sorted(six.iteritems(backup._info)))
class ShowBackup(ShowVolumeBackup):
"""Display backup details"""
# TODO(Huanxuan Ao): Remove this class and ``backup show`` command
# two cycles after Newton.
# This notifies cliff to not display the help for this command
deprecated = True
log = logging.getLogger('deprecated')
def take_action(self, parsed_args):
self.log.warning(_('This command has been deprecated. '
'Please use "volume backup show" instead.'))
return super(ShowBackup, self).take_action(parsed_args)

View File

@ -0,0 +1,8 @@
---
features:
- Add new commands ``volume backup create/delete/list/show/restore``. It is
used to replace the old commands ``backup create/delete/list/show/restore``.
[Blueprint `backup-snapshot-renamed-for-volume-resource <https://blueprints.launchpad.net/python-openstackclient/+spec/backup-snapshot-renamed-for-volume-resource>`_]
deprecations:
- Deprecate commands ``backup create/delete/list/show/restore``.
[Blueprint `backup-snapshot-renamed-for-volume-resource <https://blueprints.launchpad.net/python-openstackclient/+spec/backup-snapshot-renamed-for-volume-resource>`_]

View File

@ -458,6 +458,12 @@ openstack.volume.v1 =
volume_show = openstackclient.volume.v1.volume:ShowVolume volume_show = openstackclient.volume.v1.volume:ShowVolume
volume_unset = openstackclient.volume.v1.volume:UnsetVolume volume_unset = openstackclient.volume.v1.volume:UnsetVolume
volume_backup_create = openstackclient.volume.v1.backup:CreateVolumeBackup
volume_backup_delete = openstackclient.volume.v1.backup:DeleteVolumeBackup
volume_backup_list = openstackclient.volume.v1.backup:ListVolumeBackup
volume_backup_restore = openstackclient.volume.v1.backup:RestoreVolumeBackup
volume_backup_show = openstackclient.volume.v1.backup:ShowVolumeBackup
volume_type_create = openstackclient.volume.v1.volume_type:CreateVolumeType volume_type_create = openstackclient.volume.v1.volume_type:CreateVolumeType
volume_type_delete = openstackclient.volume.v1.volume_type:DeleteVolumeType volume_type_delete = openstackclient.volume.v1.volume_type:DeleteVolumeType
volume_type_list = openstackclient.volume.v1.volume_type:ListVolumeType volume_type_list = openstackclient.volume.v1.volume_type:ListVolumeType
@ -499,6 +505,12 @@ openstack.volume.v2 =
volume_show = openstackclient.volume.v2.volume:ShowVolume volume_show = openstackclient.volume.v2.volume:ShowVolume
volume_unset = openstackclient.volume.v2.volume:UnsetVolume volume_unset = openstackclient.volume.v2.volume:UnsetVolume
volume_backup_create = openstackclient.volume.v2.backup:CreateVolumeBackup
volume_backup_delete = openstackclient.volume.v2.backup:DeleteVolumeBackup
volume_backup_list = openstackclient.volume.v2.backup:ListVolumeBackup
volume_backup_restore = openstackclient.volume.v2.backup:RestoreVolumeBackup
volume_backup_show = openstackclient.volume.v2.backup:ShowVolumeBackup
volume_type_create = openstackclient.volume.v2.volume_type:CreateVolumeType volume_type_create = openstackclient.volume.v2.volume_type:CreateVolumeType
volume_type_delete = openstackclient.volume.v2.volume_type:DeleteVolumeType volume_type_delete = openstackclient.volume.v2.volume_type:DeleteVolumeType
volume_type_list = openstackclient.volume.v2.volume_type:ListVolumeType volume_type_list = openstackclient.volume.v2.volume_type:ListVolumeType