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

View File

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

View File

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