3838VNIC_PREFIX = ['ocid1.vnic.oc' ]
3939
4040
41+ class NameWithSpaces (argparse .Action ):
42+ """ Handle argparse arguments containing spaces.
43+ """
44+ def __call__ (self , parser , namespace , values , option_string = None ):
45+ setattr (namespace , self .dest , " " .join (values ))
46+
47+
4148def def_show_parser (s_parser ):
4249 """
4350 Define the show subparser.
@@ -117,7 +124,8 @@ def def_show_vnics_parser(s_parser):
117124 help = 'Show information of VNIC matching ocid.' )
118125 show_vnics_parser .add_argument ('--name' ,
119126 type = str ,
120- action = 'store' ,
127+ action = NameWithSpaces ,
128+ nargs = '+' ,
121129 metavar = 'VNIC_NAME' ,
122130 help = 'Show information of VNIC matching name.' )
123131 show_vnics_parser .add_argument ('--ip-address' ,
@@ -185,7 +193,8 @@ def def_show_vcn_parser(s_parser):
185193 help = 'Show information of VCN matching ocid.' )
186194 show_vcn_parser .add_argument ('--name' ,
187195 type = str ,
188- action = 'store' ,
196+ action = NameWithSpaces ,
197+ nargs = '+' ,
189198 metavar = 'VCN_NAME' ,
190199 help = 'Show information of VCN matching name.' )
191200 show_vcn_parser .add_argument ('--no-truncate' ,
@@ -224,8 +233,9 @@ def def_show_subnet_parser(s_parser):
224233 help = 'Show information of subnet matching ocid.' )
225234 show_subnet_parser .add_argument ('--name' ,
226235 type = str ,
227- action = 'store' ,
228- metavar = 'VCN_NAME' ,
236+ action = NameWithSpaces ,
237+ nargs = '+' ,
238+ metavar = 'SUBNET_NAME' ,
229239 help = 'Show information of subnet matching name.' )
230240 show_subnet_parser .add_argument ('--no-truncate' ,
231241 action = 'store_true' ,
@@ -339,12 +349,6 @@ def def_attach_vnic_parser(s_parser):
339349 metavar = 'IP_ADDR' ,
340350 type = ip_address_validator ,
341351 help = "Private IP to be assigned to the new VNIC." )
342- # attach_vnic_parser.add_argument('--ipv',
343- # action='store',
344- # type=int,
345- # choices=[4, 6],
346- # default=4,
347- # help='Add an ipv4 or ipv6 address.')
348352 ipv = attach_vnic_parser .add_mutually_exclusive_group ()
349353 ipv .add_argument ('-ipv4' , '--ipv4' ,
350354 action = 'store_true' ,
@@ -367,7 +371,8 @@ def def_attach_vnic_parser(s_parser):
367371 # type=subnet_ocid_validator,
368372 help = 'Connect the new VNIC to the subnet with the given OCID.' )
369373 attach_vnic_parser .add_argument ('-n' , '--name' ,
370- action = 'store' ,
374+ action = NameWithSpaces ,
375+ nargs = '+' ,
371376 metavar = 'NAME' ,
372377 help = 'Use NAME as the display name of the new VNIC.' )
373378 attach_vnic_parser .add_argument ('--assign-public-ip' ,
0 commit comments