Skip to content

Commit 55669b9

Browse files
author
Jordan Pittier
committed
Add 'all-projects' option to 'volume backup list'
Similar to what 'volume list --all-projects' does, 'volume backup list --all-projects' list volume backups accross all projects. Change-Id: Id5dda9b5adc822c4ddfb2dda339946d3322858e2
1 parent e07b0e0 commit 55669b9

6 files changed

Lines changed: 36 additions & 3 deletions

File tree

doc/source/command-objects/volume-backup.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ List volume backups
9494
[--volume <volume>]
9595
[--marker <marker>]
9696
[--limit <limit>]
97+
[--all-projects]
9798
9899
.. _volume_backup_list-backup:
99100
.. option:: --long
@@ -125,6 +126,10 @@ List volume backups
125126

126127
*Volume version 2 only*
127128

129+
.. option:: --all-projects
130+
131+
Include all projects (admin only)
132+
128133
volume backup restore
129134
---------------------
130135

openstackclient/tests/unit/volume/v1/test_backup.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ def test_backup_list_without_options(self):
260260
("name", None),
261261
("status", None),
262262
("volume", None),
263+
('all_projects', False),
263264
]
264265

265266
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -269,8 +270,9 @@ def test_backup_list_without_options(self):
269270
"name": None,
270271
"status": None,
271272
"volume_id": None,
273+
"all_tenants": False,
272274
}
273-
self.volumes_mock.get.assert_not_called
275+
self.volumes_mock.get.assert_not_called()
274276
self.backups_mock.list.assert_called_with(
275277
search_opts=search_opts,
276278
)
@@ -283,12 +285,14 @@ def test_backup_list_with_options(self):
283285
"--name", self.backups[0].name,
284286
"--status", "error",
285287
"--volume", self.volume.id,
288+
"--all-projects"
286289
]
287290
verifylist = [
288291
("long", True),
289292
("name", self.backups[0].name),
290293
("status", "error"),
291294
("volume", self.volume.id),
295+
('all_projects', True),
292296
]
293297

294298
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -298,6 +302,7 @@ def test_backup_list_with_options(self):
298302
"name": self.backups[0].name,
299303
"status": "error",
300304
"volume_id": self.volume.id,
305+
"all_tenants": True,
301306
}
302307
self.volumes_mock.get.assert_called_once_with(self.volume.id)
303308
self.backups_mock.list.assert_called_with(

openstackclient/tests/unit/volume/v2/test_backup.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ def test_backup_list_without_options(self):
294294
("volume", None),
295295
("marker", None),
296296
("limit", None),
297+
('all_projects', False),
297298
]
298299

299300
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -303,9 +304,10 @@ def test_backup_list_without_options(self):
303304
"name": None,
304305
"status": None,
305306
"volume_id": None,
307+
'all_tenants': False,
306308
}
307-
self.volumes_mock.get.assert_not_called
308-
self.backups_mock.get.assert_not_called
309+
self.volumes_mock.get.assert_not_called()
310+
self.backups_mock.get.assert_not_called()
309311
self.backups_mock.list.assert_called_with(
310312
search_opts=search_opts,
311313
marker=None,
@@ -321,6 +323,7 @@ def test_backup_list_with_options(self):
321323
"--status", "error",
322324
"--volume", self.volume.id,
323325
"--marker", self.backups[0].id,
326+
"--all-projects",
324327
"--limit", "3",
325328
]
326329
verifylist = [
@@ -329,6 +332,7 @@ def test_backup_list_with_options(self):
329332
("status", "error"),
330333
("volume", self.volume.id),
331334
("marker", self.backups[0].id),
335+
('all_projects', True),
332336
("limit", 3),
333337
]
334338

@@ -339,6 +343,7 @@ def test_backup_list_with_options(self):
339343
"name": self.backups[0].name,
340344
"status": "error",
341345
"volume_id": self.volume.id,
346+
'all_tenants': True,
342347
}
343348
self.volumes_mock.get.assert_called_once_with(self.volume.id)
344349
self.backups_mock.get.assert_called_once_with(self.backups[0].id)

openstackclient/volume/v1/backup.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,12 @@ def get_parser(self, prog_name):
172172
help=_("Filters results by the volume which they "
173173
"backup (name or ID)")
174174
)
175+
parser.add_argument(
176+
'--all-projects',
177+
action='store_true',
178+
default=False,
179+
help=_('Include all projects (admin only)'),
180+
)
175181
return parser
176182

177183
def take_action(self, parsed_args):
@@ -215,6 +221,7 @@ def _format_volume_id(volume_id):
215221
'name': parsed_args.name,
216222
'status': parsed_args.status,
217223
'volume_id': filter_volume_id,
224+
'all_tenants': parsed_args.all_projects,
218225
}
219226
data = volume_client.backups.list(
220227
search_opts=search_opts,

openstackclient/volume/v2/backup.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,12 @@ def get_parser(self, prog_name):
212212
metavar='<limit>',
213213
help=_('Maximum number of backups to display'),
214214
)
215+
parser.add_argument(
216+
'--all-projects',
217+
action='store_true',
218+
default=False,
219+
help=_('Include all projects (admin only)'),
220+
)
215221
return parser
216222

217223
def take_action(self, parsed_args):
@@ -259,6 +265,7 @@ def _format_volume_id(volume_id):
259265
'name': parsed_args.name,
260266
'status': parsed_args.status,
261267
'volume_id': filter_volume_id,
268+
'all_tenants': parsed_args.all_projects,
262269
}
263270
data = volume_client.backups.list(
264271
search_opts=search_opts,
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
features:
3+
- The ``openstack volume backup list`` command now supports the
4+
``all-projects`` option to list volume backups accross all projects.

0 commit comments

Comments
 (0)