Skip to content

Commit c9cf6c4

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Rename backup commands in volume v1 and v2"
2 parents 5b724fc + 39c5eb9 commit c9cf6c4

7 files changed

Lines changed: 363 additions & 35 deletions

File tree

doc/source/command-objects/backup.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ backup create
88
-------------
99

1010
Create new backup
11+
(Deprecated, please use ``volume backup create`` instead)
1112

1213
.. program:: backup create
1314
.. code:: bash
@@ -60,6 +61,7 @@ backup delete
6061
-------------
6162

6263
Delete backup(s)
64+
(Deprecated, please use ``volume backup delete`` instead)
6365

6466
.. program:: backup delete
6567
.. code:: bash
@@ -83,6 +85,7 @@ backup list
8385
-----------
8486

8587
List backups
88+
(Deprecated, please use ``volume backup list`` instead)
8689

8790
.. program:: backup list
8891
.. code:: bash
@@ -98,6 +101,7 @@ backup restore
98101
--------------
99102

100103
Restore backup
104+
(Deprecated, please use ``volume backup restore`` instead)
101105

102106
.. program:: backup restore
103107
.. code:: bash
@@ -119,6 +123,7 @@ backup show
119123
-----------
120124

121125
Display backup details
126+
(Deprecated, please use ``volume backup show`` instead)
122127

123128
.. program:: backup show
124129
.. code:: bash
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
=============
2+
volume backup
3+
=============
4+
5+
Block Storage v1, v2
6+
7+
volume backup create
8+
--------------------
9+
10+
Create new volume backup
11+
12+
.. program:: volume backup create
13+
.. code:: bash
14+
15+
os volume backup create
16+
[--container <container>]
17+
[--name <name>]
18+
[--description <description>]
19+
[--snapshot <snapshot>]
20+
[--force]
21+
[--incremental]
22+
<volume>
23+
24+
.. option:: --container <container>
25+
26+
Optional backup container name
27+
28+
.. option:: --name <name>
29+
30+
Name of the backup
31+
32+
.. option:: --description <description>
33+
34+
Description of the backup
35+
36+
.. option:: --snapshot <snapshot>
37+
38+
Snapshot to backup (name or ID)
39+
40+
*Volume version 2 only*
41+
42+
.. option:: --force
43+
44+
Allow to back up an in-use volume
45+
46+
*Volume version 2 only*
47+
48+
.. option:: --incremental
49+
50+
Perform an incremental backup
51+
52+
*Volume version 2 only*
53+
54+
.. _volume_backup_create-backup:
55+
.. describe:: <volume>
56+
57+
Volume to backup (name or ID)
58+
59+
volume backup delete
60+
--------------------
61+
62+
Delete volume backup(s)
63+
64+
.. program:: volume backup delete
65+
.. code:: bash
66+
67+
os volume backup delete
68+
[--force]
69+
<backup> [<backup> ...]
70+
71+
.. option:: --force
72+
73+
Allow delete in state other than error or available
74+
75+
*Volume version 2 only*
76+
77+
.. _volume_backup_delete-backup:
78+
.. describe:: <backup>
79+
80+
Backup(s) to delete (name or ID)
81+
82+
volume backup list
83+
------------------
84+
85+
List volume backups
86+
87+
.. program:: volume backup list
88+
.. code:: bash
89+
90+
os volume backup list
91+
92+
.. _volume_backup_list-backup:
93+
.. option:: --long
94+
95+
List additional fields in output
96+
97+
volume backup restore
98+
---------------------
99+
100+
Restore volume backup
101+
102+
.. program:: volume backup restore
103+
.. code:: bash
104+
105+
os volume backup restore
106+
<backup>
107+
<volume>
108+
109+
.. _volume_backup_restore-backup:
110+
.. describe:: <backup>
111+
112+
Backup to restore (name or ID)
113+
114+
.. describe:: <volume>
115+
116+
Volume to restore to (name or ID)
117+
118+
volume backup show
119+
------------------
120+
121+
Display volume backup details
122+
123+
.. program:: volume backup show
124+
.. code:: bash
125+
126+
os volume backup show
127+
<backup>
128+
129+
.. _volume_backup_show-backup:
130+
.. describe:: <backup>
131+
132+
Backup to display (name or ID)

openstackclient/tests/volume/v2/test_backup.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def setUp(self):
7777
self.backups_mock.create.return_value = self.new_backup
7878

7979
# Get the command object to test
80-
self.cmd = backup.CreateBackup(self.app, None)
80+
self.cmd = backup.CreateVolumeBackup(self.app, None)
8181

8282
def test_backup_create(self):
8383
arglist = [
@@ -154,7 +154,7 @@ def setUp(self):
154154
self.backups_mock.delete.return_value = None
155155

156156
# Get the command object to mock
157-
self.cmd = backup.DeleteBackup(self.app, None)
157+
self.cmd = backup.DeleteVolumeBackup(self.app, None)
158158

159159
def test_backup_delete(self):
160160
arglist = [
@@ -281,7 +281,7 @@ def setUp(self):
281281
self.volumes_mock.list.return_value = [self.volume]
282282
self.backups_mock.list.return_value = self.backups
283283
# Get the command to test
284-
self.cmd = backup.ListBackup(self.app, None)
284+
self.cmd = backup.ListVolumeBackup(self.app, None)
285285

286286
def test_backup_list_without_options(self):
287287
arglist = []
@@ -317,7 +317,7 @@ def setUp(self):
317317
self.volumes_mock.get.return_value = self.volume
318318
self.restores_mock.restore.return_value = None
319319
# Get the command object to mock
320-
self.cmd = backup.RestoreBackup(self.app, None)
320+
self.cmd = backup.RestoreVolumeBackup(self.app, None)
321321

322322
def test_backup_restore(self):
323323
arglist = [
@@ -370,7 +370,7 @@ def setUp(self):
370370

371371
self.backups_mock.get.return_value = self.backup
372372
# Get the command object to test
373-
self.cmd = backup.ShowBackup(self.app, None)
373+
self.cmd = backup.ShowVolumeBackup(self.app, None)
374374

375375
def test_backup_show(self):
376376
arglist = [

openstackclient/volume/v1/backup.py

Lines changed: 101 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"""Volume v1 Backup action implementations"""
1717

1818
import copy
19+
import logging
1920

2021
from osc_lib.command import command
2122
from osc_lib import utils
@@ -24,11 +25,11 @@
2425
from 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

Comments
 (0)