diff options
author | Cindy Pallares <cindy.pallaresq@gmail.com> | 2014-12-19 11:53:50 -0500 |
---|---|---|
committer | Cindy Pallares <cindy.pallaresq@gmail.com> | 2015-01-06 11:36:01 -0500 |
commit | 6eaaad532ad42d46a4d5ccb6e96e6508bee5ebef (patch) | |
tree | 8d86c4898cb329e5574b2b75bc95ce9fc5072e4d /glanceclient/v1 | |
parent | 0cdc947bf998c7f00a23c11bf1be4bc5929b7803 (diff) | |
download | python-glanceclient-6eaaad532ad42d46a4d5ccb6e96e6508bee5ebef.tar.gz |
Make non-boolean check strict
Currently when we enter any non-boolean strings in the client, it
accepts it and defaults the value to false. It should check if the
strings are boolean values and respond with an error if they're not.
Closes-Bug: #1394236
Change-Id: Ie498ee1b93524d91a43343f73140446c2cc9ab92
Diffstat (limited to 'glanceclient/v1')
-rw-r--r-- | glanceclient/v1/shell.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/glanceclient/v1/shell.py b/glanceclient/v1/shell.py index d4d117e..5d5452e 100644 --- a/glanceclient/v1/shell.py +++ b/glanceclient/v1/shell.py @@ -16,6 +16,7 @@ from __future__ import print_function import copy +import functools import six import sys @@ -29,6 +30,8 @@ CONTAINER_FORMATS = 'Acceptable formats: ami, ari, aki, bare, and ovf.' DISK_FORMATS = ('Acceptable formats: ami, ari, aki, vhd, vmdk, raw, ' 'qcow2, vdi, and iso.') +_bool_strict = functools.partial(strutils.bool_from_string, strict=True) + @utils.arg('--name', metavar='<NAME>', help='Filter images to those that have this name.') @@ -58,7 +61,7 @@ DISK_FORMATS = ('Acceptable formats: ami, ari, aki, vhd, vmdk, raw, ' choices=glanceclient.v1.images.SORT_DIR_VALUES, help='Sort image list in specified direction.') @utils.arg('--is-public', - type=strutils.bool_from_string, metavar='{True,False}', + type=_bool_strict, metavar='{True,False}', help=('Allows the user to select a listing of public or non ' 'public images.')) @utils.arg('--owner', default=None, metavar='<TENANT_ID>', @@ -188,10 +191,10 @@ def do_image_download(gc, args): ' the Glance server should immediately copy the data and' ' store it in its configured image store.')) @utils.arg('--is-public', - type=strutils.bool_from_string, metavar='{True,False}', + type=_bool_strict, metavar='{True,False}', help='Make image accessible to the public.') @utils.arg('--is-protected', - type=strutils.bool_from_string, metavar='{True,False}', + type=_bool_strict, metavar='{True,False}', help='Prevent image from being deleted.') @utils.arg('--property', metavar="<key=value>", action='append', default=[], help=("Arbitrary property to associate with image. " @@ -265,10 +268,10 @@ def do_image_create(gc, args): ' the Glance server should immediately copy the data and' ' store it in its configured image store.')) @utils.arg('--is-public', - type=strutils.bool_from_string, metavar='{True,False}', + type=_bool_strict, metavar='{True,False}', help='Make image accessible to the public.') @utils.arg('--is-protected', - type=strutils.bool_from_string, metavar='{True,False}', + type=_bool_strict, metavar='{True,False}', help='Prevent image from being deleted.') @utils.arg('--property', metavar="<key=value>", action='append', default=[], help=("Arbitrary property to associate with image. " |