summaryrefslogtreecommitdiff
path: root/cinderclient/shell_utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'cinderclient/shell_utils.py')
-rw-r--r--cinderclient/shell_utils.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/cinderclient/shell_utils.py b/cinderclient/shell_utils.py
index e386558..949f7f7 100644
--- a/cinderclient/shell_utils.py
+++ b/cinderclient/shell_utils.py
@@ -143,6 +143,26 @@ def translate_availability_zone_keys(collection):
translate_keys(collection, convert)
+def extract_filters(args):
+ filters = {}
+ for f in args:
+ if '=' in f:
+ (key, value) = f.split('=', 1)
+ if value.startswith('{') and value.endswith('}'):
+ value = _build_internal_dict(value[1:-1])
+ filters[key] = value
+
+ return filters
+
+
+def _build_internal_dict(content):
+ result = {}
+ for pair in content.split(','):
+ k, v = pair.split(':', 1)
+ result.update({k.strip(): v.strip()})
+ return result
+
+
def extract_metadata(args, type='user_metadata'):
metadata = {}
if type == 'image_metadata':
@@ -169,6 +189,11 @@ def print_group_type_list(gtypes):
utils.print_list(gtypes, ['ID', 'Name', 'Description'])
+def print_resource_filter_list(filters):
+ formatter = {'Filters': lambda resource: ', '.join(resource.filters)}
+ utils.print_list(filters, ['Resource', 'Filters'], formatters=formatter)
+
+
def quota_show(quotas):
quotas_info_dict = utils.unicode_key_value_to_string(quotas._info)
quota_dict = {}