diff options
| author | Huanxuan Ao <huanxuan.ao@easystack.cn> | 2016-08-09 10:12:04 +0800 |
|---|---|---|
| committer | Huanxuan Ao <huanxuan.ao@easystack.cn> | 2016-08-11 09:32:10 +0800 |
| commit | 39c5eb9e3fe89bf177e513e447f22b62f5e4785c (patch) | |
| tree | 46dae19c7d0728186443876767bf3b9bbc84b500 /openstackclient/volume | |
| parent | 80fd9b2bd442ec6fdc81885bcb8b8e6adc7336d7 (diff) | |
| download | python-openstackclient-39c5eb9e3fe89bf177e513e447f22b62f5e4785c.tar.gz | |
Rename backup commands in volume v1 and v2
Backup commands are used only in volume service now,
but "backup" is too generic, users may not know the
commands are used for volume from the commands name.
By seeing the command name, users can only see the
"backup" but do not know which object the backup
commands work for. It may confuse users. I think
rename "backup" to "volume backup" can depict resource
relation and will be helpful for users to know the
commands clearly.
So add new commands ``volume backup create/delete/
list/show/restore`` to replace the old commands
``backup create/delete/list/show/restore``. And also
deprecate old commands.
Change-Id: I4f844d9bc48573eb4d17288ce6b8a90cea00d16a
Implements: bp backup-snapshot-renamed-for-volume-resource
Co-Authored-By: Sheel Rana <ranasheel2000@gmail.com>
Diffstat (limited to 'openstackclient/volume')
| -rw-r--r-- | openstackclient/volume/v1/backup.py | 116 | ||||
| -rw-r--r-- | openstackclient/volume/v2/backup.py | 115 |
2 files changed, 201 insertions, 30 deletions
diff --git a/openstackclient/volume/v1/backup.py b/openstackclient/volume/v1/backup.py index 5f34a2c5..539ed369 100644 --- a/openstackclient/volume/v1/backup.py +++ b/openstackclient/volume/v1/backup.py @@ -16,6 +16,7 @@ """Volume v1 Backup action implementations""" import copy +import logging from osc_lib.command import command from osc_lib import utils @@ -24,11 +25,11 @@ import six from openstackclient.i18n import _ -class CreateBackup(command.ShowOne): - """Create new backup""" +class CreateVolumeBackup(command.ShowOne): + """Create new volume backup""" 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( 'volume', metavar='<volume>', @@ -67,11 +68,28 @@ class CreateBackup(command.ShowOne): return zip(*sorted(six.iteritems(backup._info))) -class DeleteBackup(command.Command): - """Delete backup(s)""" +class CreateBackup(CreateVolumeBackup): + """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): - parser = super(DeleteBackup, self).get_parser(prog_name) + parser = super(DeleteVolumeBackup, self).get_parser(prog_name) parser.add_argument( 'backups', metavar='<backup>', @@ -88,11 +106,28 @@ class DeleteBackup(command.Command): volume_client.backups.delete(backup_id) -class ListBackup(command.Lister): - """List backups""" +class DeleteBackup(DeleteVolumeBackup): + """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): - parser = super(ListBackup, self).get_parser(prog_name) + parser = super(ListVolumeBackup, self).get_parser(prog_name) parser.add_argument( '--long', action='store_true', @@ -142,11 +177,28 @@ class ListBackup(command.Lister): ) for s in data)) -class RestoreBackup(command.Command): - """Restore backup""" +class ListBackup(ListVolumeBackup): + """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): - parser = super(RestoreBackup, self).get_parser(prog_name) + parser = super(RestoreVolumeBackup, self).get_parser(prog_name) parser.add_argument( 'backup', metavar='<backup>', @@ -169,11 +221,28 @@ class RestoreBackup(command.Command): destination_volume.id) -class ShowBackup(command.ShowOne): - """Display backup details""" +class RestoreBackup(RestoreVolumeBackup): + """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): - parser = super(ShowBackup, self).get_parser(prog_name) + parser = super(ShowVolumeBackup, self).get_parser(prog_name) parser.add_argument( 'backup', metavar='<backup>', @@ -187,3 +256,20 @@ class ShowBackup(command.ShowOne): parsed_args.backup) backup._info.pop('links') 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) diff --git a/openstackclient/volume/v2/backup.py b/openstackclient/volume/v2/backup.py index 3d27c121..07c1c94f 100644 --- a/openstackclient/volume/v2/backup.py +++ b/openstackclient/volume/v2/backup.py @@ -28,11 +28,11 @@ from openstackclient.i18n import _ LOG = logging.getLogger(__name__) -class CreateBackup(command.ShowOne): - """Create new backup""" +class CreateVolumeBackup(command.ShowOne): + """Create new volume backup""" 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( "volume", metavar="<volume>", @@ -93,11 +93,28 @@ class CreateBackup(command.ShowOne): return zip(*sorted(six.iteritems(backup._info))) -class DeleteBackup(command.Command): - """Delete backup(s)""" +class CreateBackup(CreateVolumeBackup): + """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): - parser = super(DeleteBackup, self).get_parser(prog_name) + parser = super(DeleteVolumeBackup, self).get_parser(prog_name) parser.add_argument( "backups", metavar="<backup>", @@ -134,11 +151,28 @@ class DeleteBackup(command.Command): raise exceptions.CommandError(msg) -class ListBackup(command.Lister): - """List backups""" +class DeleteBackup(DeleteVolumeBackup): + """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): - parser = super(ListBackup, self).get_parser(prog_name) + parser = super(ListVolumeBackup, self).get_parser(prog_name) parser.add_argument( "--long", action="store_true", @@ -188,11 +222,28 @@ class ListBackup(command.Lister): ) for s in data)) -class RestoreBackup(command.ShowOne): - """Restore backup""" +class ListBackup(ListVolumeBackup): + """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): - parser = super(RestoreBackup, self).get_parser(prog_name) + parser = super(RestoreVolumeBackup, self).get_parser(prog_name) parser.add_argument( "backup", metavar="<backup>", @@ -213,11 +264,28 @@ class RestoreBackup(command.ShowOne): return volume_client.restores.restore(backup.id, destination_volume.id) -class ShowBackup(command.ShowOne): - """Display backup details""" +class RestoreBackup(RestoreVolumeBackup): + """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): - parser = super(ShowBackup, self).get_parser(prog_name) + parser = super(ShowVolumeBackup, self).get_parser(prog_name) parser.add_argument( "backup", metavar="<backup>", @@ -231,3 +299,20 @@ class ShowBackup(command.ShowOne): parsed_args.backup) backup._info.pop("links", None) 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) |
