Support 'True' and 'False' input for system commands

add args choice 'True' and 'False' for https_enabled and sdn_enabled
in 'system modify' and for dynamic in 'system network-add' command
to support input 'True' and 'False'.

make https_enabled and sdn_enabled to lower case in sys-api controller

Closes-bug: 1812268

Change-Id: If6411852edfc970ee1d749e4d4ccb8d045767bbc
Signed-off-by: sunausti <sunausti@starlingx.com>
This commit is contained in:
sunausti 2019-01-21 01:04:02 +00:00 committed by Sun Austin
parent f03f914ecf
commit 2b2782efb6
3 changed files with 9 additions and 5 deletions

View File

@ -60,7 +60,7 @@ def do_show(cc, args):
help='The name of the system')
@utils.arg('-s', '--sdn_enabled',
metavar='<sdn_enabled>',
choices=['true', 'false'],
choices=['true', 'false', 'True', 'False'],
help='The SDN enabled or disabled flag')
@utils.arg('-t', '--timezone',
metavar='<timezone>',
@ -79,7 +79,7 @@ def do_show(cc, args):
help='The location of the system')
@utils.arg('-p', '--https_enabled',
metavar='<https_enabled>',
choices=['true', 'false'],
choices=['true', 'false', 'True', 'False'],
help='The HTTPS enabled or disabled flag')
@utils.arg('-v', '--vswitch_type',
metavar='<vswitch_type>',

View File

@ -47,7 +47,7 @@ def do_network_list(cc, args):
help="Type of network [REQUIRED]")
@utils.arg('dynamic',
metavar='<dynamic>',
choices=['true', 'false'],
choices=['true', 'false', 'True', 'False'],
help="dynamic [REQUIRED]")
@utils.arg('pool_uuid',
metavar='<pool_uuid>',
@ -57,6 +57,10 @@ def do_network_add(cc, args):
field_list = ['name', 'type', 'dynamic', 'pool_uuid']
# make sure dynamic is lower
if args.dynamic is not None:
args.dynamic = args.dynamic.lower()
# Prune input fields down to required/expected values
data = dict((k, v) for (k, v) in vars(args).items()
if k in field_list and not (v is None))

View File

@ -422,11 +422,11 @@ class SystemController(rest.RestController):
timezone))
if p['path'] == '/sdn_enabled':
sdn_enabled = p['value']
sdn_enabled = p['value'].lower()
patch.remove(p)
if p['path'] == '/https_enabled':
https_enabled = p['value']
https_enabled = p['value'].lower()
patch.remove(p)
if p['path'] == '/distributed_cloud_role':