summaryrefslogtreecommitdiff
path: root/openstackclient/volume/v2
diff options
context:
space:
mode:
authorjiahui.qiang <jiahui.qiang@easystack.cn>2016-11-22 17:27:34 +0800
committerjiahui.qiang <jiahui.qiang@easystack.cn>2016-11-26 23:13:50 +0800
commit6ca4dc3533d009866f82515c34cb3881f993c750 (patch)
tree385f7e38a0523da415e3bbccfb86e0290fbc6fe7 /openstackclient/volume/v2
parente05c8d7bb04f477797e46e5728e93a35c104809a (diff)
downloadpython-openstackclient-6ca4dc3533d009866f82515c34cb3881f993c750.tar.gz
Add options to "volume snapshot list" command
Add "--name", "--status" and "--volume" options to "volume snapshot list" command for filtering results. Change-Id: I72db1abce7701f31598deec34801a4d1f5713870 Closes-Bug:#1645252
Diffstat (limited to 'openstackclient/volume/v2')
-rw-r--r--openstackclient/volume/v2/volume_snapshot.py34
1 files changed, 32 insertions, 2 deletions
diff --git a/openstackclient/volume/v2/volume_snapshot.py b/openstackclient/volume/v2/volume_snapshot.py
index 43f30326..86af6d8c 100644
--- a/openstackclient/volume/v2/volume_snapshot.py
+++ b/openstackclient/volume/v2/volume_snapshot.py
@@ -151,9 +151,31 @@ class ListVolumeSnapshot(command.Lister):
metavar='<limit>',
help=_('Maximum number of snapshots to display'),
)
+ parser.add_argument(
+ '--name',
+ metavar='<name>',
+ default=None,
+ help=_('Filters results by a name.')
+ )
+ parser.add_argument(
+ '--status',
+ metavar='<status>',
+ choices=['available', 'error', 'creating', 'deleting',
+ 'error-deleting'],
+ help=_("Filters results by a status. "
+ "('available', 'error', 'creating', 'deleting'"
+ " or 'error-deleting')")
+ )
+ parser.add_argument(
+ '--volume',
+ metavar='<volume>',
+ default=None,
+ help=_('Filters results by a volume (name or ID).')
+ )
return parser
def take_action(self, parsed_args):
+ volume_client = self.app.client_manager.volume
def _format_volume_id(volume_id):
"""Return a volume name if available
@@ -180,17 +202,25 @@ class ListVolumeSnapshot(command.Lister):
# Cache the volume list
volume_cache = {}
try:
- for s in self.app.client_manager.volume.volumes.list():
+ for s in volume_client.volumes.list():
volume_cache[s.id] = s
except Exception:
# Just forget it if there's any trouble
pass
+ volume_id = None
+ if parsed_args.volume:
+ volume_id = utils.find_resource(
+ volume_client.volumes, parsed_args.volume).id
+
search_opts = {
'all_tenants': parsed_args.all_projects,
+ 'name': parsed_args.name,
+ 'status': parsed_args.status,
+ 'volume_id': volume_id,
}
- data = self.app.client_manager.volume.volume_snapshots.list(
+ data = volume_client.volume_snapshots.list(
search_opts=search_opts,
marker=parsed_args.marker,
limit=parsed_args.limit,