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
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
|
import functools
|
||||||
import six
|
import six
|
||||||
import sys
|
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, '
|
DISK_FORMATS = ('Acceptable formats: ami, ari, aki, vhd, vmdk, raw, '
|
||||||
'qcow2, vdi, and iso.')
|
'qcow2, vdi, and iso.')
|
||||||
|
|
||||||
|
_bool_strict = functools.partial(strutils.bool_from_string, strict=True)
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('--name', metavar='<NAME>',
|
@utils.arg('--name', metavar='<NAME>',
|
||||||
help='Filter images to those that have this 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,
|
choices=glanceclient.v1.images.SORT_DIR_VALUES,
|
||||||
help='Sort image list in specified direction.')
|
help='Sort image list in specified direction.')
|
||||||
@utils.arg('--is-public',
|
@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 '
|
help=('Allows the user to select a listing of public or non '
|
||||||
'public images.'))
|
'public images.'))
|
||||||
@utils.arg('--owner', default=None, metavar='<TENANT_ID>',
|
@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'
|
' the Glance server should immediately copy the data and'
|
||||||
' store it in its configured image store.'))
|
' store it in its configured image store.'))
|
||||||
@utils.arg('--is-public',
|
@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.')
|
help='Make image accessible to the public.')
|
||||||
@utils.arg('--is-protected',
|
@utils.arg('--is-protected',
|
||||||
type=strutils.bool_from_string, metavar='{True,False}',
|
type=_bool_strict, metavar='{True,False}',
|
||||||
help='Prevent image from being deleted.')
|
help='Prevent image from being deleted.')
|
||||||
@utils.arg('--property', metavar="<key=value>", action='append', default=[],
|
@utils.arg('--property', metavar="<key=value>", action='append', default=[],
|
||||||
help=("Arbitrary property to associate with image. "
|
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'
|
' the Glance server should immediately copy the data and'
|
||||||
' store it in its configured image store.'))
|
' store it in its configured image store.'))
|
||||||
@utils.arg('--is-public',
|
@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.')
|
help='Make image accessible to the public.')
|
||||||
@utils.arg('--is-protected',
|
@utils.arg('--is-protected',
|
||||||
type=strutils.bool_from_string, metavar='{True,False}',
|
type=_bool_strict, metavar='{True,False}',
|
||||||
help='Prevent image from being deleted.')
|
help='Prevent image from being deleted.')
|
||||||
@utils.arg('--property', metavar="<key=value>", action='append', default=[],
|
@utils.arg('--property', metavar="<key=value>", action='append', default=[],
|
||||||
help=("Arbitrary property to associate with image. "
|
help=("Arbitrary property to associate with image. "
|
||||||
|
Reference in New Issue
Block a user