@@ -558,7 +558,7 @@ def load_arguments(self, _):
558558 # azure container storage
559559 c .argument (
560560 "enable_azure_container_storage" ,
561- arg_type = _get_enable_azure_container_storage_type ( ),
561+ arg_type = _get_container_storage_enum_type ( storage_pool_types ),
562562 help = "enable azure container storage. Can be used as a flag (defaults to True) or with a storage pool type value: (azureDisk, ephemeralDisk, elasticSan)" ,
563563 )
564564 c .argument (
@@ -764,12 +764,12 @@ def load_arguments(self, _):
764764 # azure container storage
765765 c .argument (
766766 "enable_azure_container_storage" ,
767- arg_type = _get_enable_azure_container_storage_type ( ),
767+ arg_type = _get_container_storage_enum_type ( storage_pool_types ),
768768 help = "enable azure container storage. Can be used as a flag (defaults to True) or with a storage pool type value: (azureDisk, ephemeralDisk, elasticSan)" ,
769769 )
770770 c .argument (
771771 "disable_azure_container_storage" ,
772- arg_type = _get_disable_azure_container_storage_type ( ),
772+ arg_type = _get_container_storage_enum_type ( disable_storage_pool_types ),
773773 help = "disable azure container storage or any one of the storage pool types. Can be used as a flag (defaults to True) or with a storagepool type value: azureDisk, ephemeralDisk, elasticSan, all (to disable all storage pools)." ,
774774 )
775775 c .argument (
@@ -1284,7 +1284,7 @@ def _get_default_install_location(exe_name):
12841284 return install_location
12851285
12861286
1287- def _get_enable_azure_container_storage_type ( ):
1287+ def _get_container_storage_enum_type ( choices ):
12881288 """Custom argument type that accepts both None and enum values"""
12891289 import argparse
12901290 from azure .cli .core .azclierror import InvalidArgumentValueError
@@ -1296,51 +1296,21 @@ def __call__(self, parser, namespace, values, option_string=None):
12961296 setattr (namespace , self .dest , True )
12971297 return
12981298
1299- if isinstance (values , str ):
1300- # Handle enum values (case insensitive)
1301- for storage_type in storage_pool_types :
1302- if values .lower () == storage_type .lower ():
1303- setattr (namespace , self .dest , storage_type )
1304- return
1305-
1306- # Invalid value
1307- valid_values = storage_pool_types
1308- raise InvalidArgumentValueError (
1309- f"Invalid value '{ values } '. Valid values are: { ', ' .join (valid_values )} "
1310- )
1311-
1312- return CLIArgumentType (
1313- nargs = '?' , # Optional argument
1314- action = AzureContainerStorageAction ,
1315- )
1316-
1317-
1318- def _get_disable_azure_container_storage_type ():
1319- """Custom argument type that accepts both None and enum values"""
1320- import argparse
1321- from azure .cli .core .azclierror import InvalidArgumentValueError
1322-
1323- class AzureContainerStorageAction (argparse .Action ):
1324- def __call__ (self , parser , namespace , values , option_string = None ):
1325- if values is None :
1326- # When used as a flag without value, set as True
1327- setattr (namespace , self .dest , True )
1299+ # Allow multiple enum values in a case insensitive manner
1300+ normalized_value_arr = values if isinstance (values , list ) else str (values ).split (',' )
1301+ normalized_value_arr = [str (v ).lower ().strip () for v in normalized_value_arr ]
1302+ valid_value_arr = [v for v in choices if v .lower () in normalized_value_arr ]
1303+ if len (valid_value_arr ) == len (normalized_value_arr ):
1304+ normalized_values = valid_value_arr [0 ] if len (valid_value_arr ) == 1 else valid_value_arr
1305+ setattr (namespace , self .dest , normalized_values )
13281306 return
13291307
1330- if isinstance (values , str ):
1331- # Handle enum values (case insensitive)
1332- for storage_type in disable_storage_pool_types :
1333- if values .lower () == storage_type .lower ():
1334- setattr (namespace , self .dest , storage_type )
1335- return
1336-
13371308 # Invalid value
1338- valid_values = disable_storage_pool_types
13391309 raise InvalidArgumentValueError (
1340- f"Invalid value '{ values } '. Valid values are: { ', ' .join (valid_values )} "
1310+ f"Invalid value '{ values } '. Valid values are: { ', ' .join (choices )} "
13411311 )
13421312
13431313 return CLIArgumentType (
1344- nargs = '? ' , # Optional argument
1314+ nargs = '* ' , # Allow multiple values
13451315 action = AzureContainerStorageAction ,
13461316 )
0 commit comments