Skip to content

Commit 5df3627

Browse files
author
guido tijskens
committed
fix spaces in subnet names
1 parent 5af590f commit 5df3627

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

bin/oci-network-config

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ then
4444
fi
4545

4646

47-
48-
PARSED_ARGUMENTS=$(getopt -a --quiet -o hsacde:n:rX:I:q --long help,show,create-vnic,nic-index:,detach-vnic:,add-private-ip,del-private-ip:,private-ip:,subnet:,vnic-name:,assign-public-ip,vnic:,auto,configure,deconfigure,ns,sshd,exclude:,include:,quiet -- "$@")
47+
PARSED_ARGUMENTS=$(getopt -a --quiet -o hsacde:n:rX:I:q --long help,show,create-vnic,nic-index:,ipv4,ipv6,detach-vnic:,add-private-ip,del-private-ip:,private-ip:,subnet:,vnic-name:,assign-public-ip,vnic:,auto,configure,deconfigure,ns,sshd,exclude:,include:,quiet -- "$@")
4948
eval set -- "$PARSED_ARGUMENTS"
5049
while :
5150
do
@@ -94,6 +93,8 @@ do
9493
--subnet) cmd_line="${cmd_line} --subnet=$2" ; shift 2 ;;
9594
--nic-index) cmd_line="${cmd_line} --nic-index=$2" ; shift 2 ;;
9695
--private-ip) PRIVATE_IP=$2 ; shift 2 ;;
96+
--ipv4) echo ""; echo "--ipv4 ia an invalid option in compatible mode"; echo ""; COMMAND="usage"; post_operation_show=0; break ;;
97+
--ipv6) echo ""; echo "--ipv6 ia an invalid option in compatible mode"; echo ""; COMMAND="usage"; post_operation_show=0; break ;;
9798
--help)
9899
if [ -z ${COMMAND} ]
99100
then
@@ -110,6 +111,7 @@ do
110111

111112
esac
112113
done
114+
113115
shift $((OPTIND-1))
114116
read -r -a LEFT_OVERS <<<"$@"
115117
# special case for -e option. former syntax was '-e IP VNIC'. This cannot be handle

lib/oci_utils/impl/oci_network_config_main.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@
3838
VNIC_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+
4148
def 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

Comments
 (0)