1616"""Volume v1 Backup action implementations"""
1717
1818import copy
19+ import logging
1920
2021from osc_lib .command import command
2122from osc_lib import utils
2425from openstackclient .i18n import _
2526
2627
27- class CreateBackup (command .ShowOne ):
28- """Create new backup"""
28+ class CreateVolumeBackup (command .ShowOne ):
29+ """Create new volume backup"""
2930
3031 def get_parser (self , prog_name ):
31- parser = super (CreateBackup , self ).get_parser (prog_name )
32+ parser = super (CreateVolumeBackup , self ).get_parser (prog_name )
3233 parser .add_argument (
3334 'volume' ,
3435 metavar = '<volume>' ,
@@ -67,11 +68,28 @@ def take_action(self, parsed_args):
6768 return zip (* sorted (six .iteritems (backup ._info )))
6869
6970
70- class DeleteBackup (command .Command ):
71- """Delete backup(s)"""
71+ class CreateBackup (CreateVolumeBackup ):
72+ """Create new backup"""
73+
74+ # TODO(Huanxuan Ao): Remove this class and ``backup create`` command
75+ # two cycles after Newton.
76+
77+ # This notifies cliff to not display the help for this command
78+ deprecated = True
79+
80+ log = logging .getLogger ('deprecated' )
81+
82+ def take_action (self , parsed_args ):
83+ self .log .warning (_ ('This command has been deprecated. '
84+ 'Please use "volume backup create" instead.' ))
85+ return super (CreateBackup , self ).take_action (parsed_args )
86+
87+
88+ class DeleteVolumeBackup (command .Command ):
89+ """Delete volume backup(s)"""
7290
7391 def get_parser (self , prog_name ):
74- parser = super (DeleteBackup , self ).get_parser (prog_name )
92+ parser = super (DeleteVolumeBackup , self ).get_parser (prog_name )
7593 parser .add_argument (
7694 'backups' ,
7795 metavar = '<backup>' ,
@@ -88,11 +106,28 @@ def take_action(self, parsed_args):
88106 volume_client .backups .delete (backup_id )
89107
90108
91- class ListBackup (command .Lister ):
92- """List backups"""
109+ class DeleteBackup (DeleteVolumeBackup ):
110+ """Delete backup(s)"""
111+
112+ # TODO(Huanxuan Ao): Remove this class and ``backup delete`` command
113+ # two cycles after Newton.
114+
115+ # This notifies cliff to not display the help for this command
116+ deprecated = True
117+
118+ log = logging .getLogger ('deprecated' )
119+
120+ def take_action (self , parsed_args ):
121+ self .log .warning (_ ('This command has been deprecated. '
122+ 'Please use "volume backup delete" instead.' ))
123+ return super (DeleteBackup , self ).take_action (parsed_args )
124+
125+
126+ class ListVolumeBackup (command .Lister ):
127+ """List volume backups"""
93128
94129 def get_parser (self , prog_name ):
95- parser = super (ListBackup , self ).get_parser (prog_name )
130+ parser = super (ListVolumeBackup , self ).get_parser (prog_name )
96131 parser .add_argument (
97132 '--long' ,
98133 action = 'store_true' ,
@@ -142,11 +177,28 @@ def _format_volume_id(volume_id):
142177 ) for s in data ))
143178
144179
145- class RestoreBackup (command .Command ):
146- """Restore backup"""
180+ class ListBackup (ListVolumeBackup ):
181+ """List backups"""
182+
183+ # TODO(Huanxuan Ao): Remove this class and ``backup list`` command
184+ # two cycles after Newton.
185+
186+ # This notifies cliff to not display the help for this command
187+ deprecated = True
188+
189+ log = logging .getLogger ('deprecated' )
190+
191+ def take_action (self , parsed_args ):
192+ self .log .warning (_ ('This command has been deprecated. '
193+ 'Please use "volume backup list" instead.' ))
194+ return super (ListBackup , self ).take_action (parsed_args )
195+
196+
197+ class RestoreVolumeBackup (command .Command ):
198+ """Restore volume backup"""
147199
148200 def get_parser (self , prog_name ):
149- parser = super (RestoreBackup , self ).get_parser (prog_name )
201+ parser = super (RestoreVolumeBackup , self ).get_parser (prog_name )
150202 parser .add_argument (
151203 'backup' ,
152204 metavar = '<backup>' ,
@@ -169,11 +221,28 @@ def take_action(self, parsed_args):
169221 destination_volume .id )
170222
171223
172- class ShowBackup (command .ShowOne ):
173- """Display backup details"""
224+ class RestoreBackup (RestoreVolumeBackup ):
225+ """Restore backup"""
226+
227+ # TODO(Huanxuan Ao): Remove this class and ``backup restore`` command
228+ # two cycles after Newton.
229+
230+ # This notifies cliff to not display the help for this command
231+ deprecated = True
232+
233+ log = logging .getLogger ('deprecated' )
234+
235+ def take_action (self , parsed_args ):
236+ self .log .warning (_ ('This command has been deprecated. '
237+ 'Please use "volume backup restore" instead.' ))
238+ return super (RestoreBackup , self ).take_action (parsed_args )
239+
240+
241+ class ShowVolumeBackup (command .ShowOne ):
242+ """Display volume backup details"""
174243
175244 def get_parser (self , prog_name ):
176- parser = super (ShowBackup , self ).get_parser (prog_name )
245+ parser = super (ShowVolumeBackup , self ).get_parser (prog_name )
177246 parser .add_argument (
178247 'backup' ,
179248 metavar = '<backup>' ,
@@ -187,3 +256,20 @@ def take_action(self, parsed_args):
187256 parsed_args .backup )
188257 backup ._info .pop ('links' )
189258 return zip (* sorted (six .iteritems (backup ._info )))
259+
260+
261+ class ShowBackup (ShowVolumeBackup ):
262+ """Display backup details"""
263+
264+ # TODO(Huanxuan Ao): Remove this class and ``backup show`` command
265+ # two cycles after Newton.
266+
267+ # This notifies cliff to not display the help for this command
268+ deprecated = True
269+
270+ log = logging .getLogger ('deprecated' )
271+
272+ def take_action (self , parsed_args ):
273+ self .log .warning (_ ('This command has been deprecated. '
274+ 'Please use "volume backup show" instead.' ))
275+ return super (ShowBackup , self ).take_action (parsed_args )
0 commit comments