@@ -28,7 +28,7 @@ declare OCID_OR_IP
2828
2929# former implementation of oci-network-config was mixing options and sub-commands.
3030# oci-network-config-main.py now expect proper command line like '<sub-command> <options>'
31- # translate the command line accordingly (as expected by new implemetation )
31+ # translate the command line accordingly (as expected by new implementation )
3232# if first token does not start by '-' we consider that command line is following the new format
3333
3434if [ " ${1: 0: 1} " != ' -' ]
5454 COMMAND=" show --compat-output"
5555 else
5656 # display information after operation. Used to be an option
57- # change thiso to call ourself again with the show command
57+ # change this to call ourself again with the show command
5858 post_operation_show=1
5959 fi
6060 shift
6161 ;;
62- -a|--auto|-c|--configure) COMMAND=" configure" ; shift ;;
63- -d|--deconfigure) COMMAND=" unconfigure" ; shift ;;
64- --create-vnic) COMMAND=" attach-vnic" ; shift ;;
65- --detach-vnic) COMMAND=" detach-vnic" ; OCID_OR_IP=$2 ; shift 2 ;;
66- --add-private-ip) COMMAND=" add-secondary-addr" ; shift ;;
67- --del-private-ip) COMMAND=" remove-secondary-addr" ; cmd_line=" ${cmd_line} --ip-address=$2 " ; shift 2 ;;
62+ -a|--auto|-c|--configure) COMMAND=" configure" ; post_operation_show=1 ; shift ;;
63+ -d|--deconfigure) COMMAND=" unconfigure" ; post_operation_show=1 ; shift ;;
64+ --create-vnic) COMMAND=" attach-vnic" ; post_operation_show=1 ; shift ;;
65+ --detach-vnic) COMMAND=" detach-vnic" ; OCID_OR_IP=$2 ; post_operation_show=1 ; shift 2 ;;
66+ --add-private-ip) COMMAND=" add-secondary-addr" ; post_operation_show=1 ; shift ;;
67+ --del-private-ip) COMMAND=" remove-secondary-addr" ; cmd_line=" ${cmd_line} --ip-address=$2 " ; post_operation_show=1 ; shift 2 ;;
6868 -X|--exclude) if [ -z ${COMMAND} ]
6969 then
7070 COMMAND=" show --compat-output" ;
132132 if [ ${OCID_OR_IP: 0: 6} == ' ocid1.' ]
133133 then
134134 cmd_line=" ${cmd_line} --ocid=${OCID_OR_IP} "
135- else
135+ else
136136 cmd_line=" ${cmd_line} --ip-address=${OCID_OR_IP} "
137137 fi
138138fi
@@ -153,25 +153,41 @@ then
153153 then
154154 cmd_line=" $cmd_line --ip-address=${PRIVATE_IP} "
155155 fi
156- else
157- # if we have found --private-ip and --vnic we gonna add an ip to a vnic
158- if [ -n " ${VNIC_OCID} " ] && [ -n " ${PRIVATE_IP} " ]
156+ # else
157+ # obsolete comment # if we have found --private-ip and --vnic we gonne add an ip to a vnic
158+ # if [ -n "${VNIC_OCID}" ] && [ -n "${PRIVATE_IP}" ]
159+ # then
160+ # force command to be
161+ # COMMAND="add-secondary-addr"
162+ # cmd_line="$cmd_line --ip-address=${PRIVATE_IP} --ocid=${VNIC_OCID}"
163+ # fi
164+ elif [ " ${COMMAND} " == " add-secondary-addr" ]
165+ then
166+ # --vnic is an option for --add-private-ip only, the requirement for --private-ip is not necessary
167+ # and the --vnic option should only be required if there is more than 1 vnic.
168+ # if --vnic option specified, translate to --ocid optione
169+ if [ -n " ${VNIC_OCID} " ]
159170 then
160- # force command to be
161- COMMAND=" add-secondary-addr"
162- cmd_line=" $cmd_line --ip-address=${PRIVATE_IP} --ocid=${VNIC_OCID} "
171+ cmd_line=" $cmd_line --ocid=${VNIC_OCID} "
163172 fi
173+ if [ -n " ${PRIVATE_IP} " ]
174+ then
175+ cmd_line=" $cmd_line --ip-address=${PRIVATE_IP} "
176+ fi
177+ # else
178+ # echo "_GT_ ${COMMAND} handled elsewhere"
164179fi
165- if [ ${EXCLUDED_ITEMS[${COMMAND}]+_} ] && [ -n ${EXCLUDED_ITEMS[${COMMAND}]} ]
180+
181+ if [ ${EXCLUDED_ITEMS[${COMMAND}]+_} ] && [ -n " ${EXCLUDED_ITEMS[${COMMAND}]} " ]
166182then
167- for i in " ${EXCLUDED_ITEMS[${COMMAND}]} "
183+ for i in ${EXCLUDED_ITEMS[${COMMAND}]}
168184 do
169185 cmd_line=" ${cmd_line} --exclude ${i} "
170186 done
171187fi
172- if [ ${INCLUDED_ITEMS[${COMMAND}]+_} ] && [ -n ${INCLUDED_ITEMS[${COMMAND}]} ]
188+ if [ ${INCLUDED_ITEMS[${COMMAND}]+_} ] && [ -n " ${INCLUDED_ITEMS[${COMMAND}]} " ]
173189then
174- for i in " ${INCLUDED_ITEMS[${COMMAND}]} "
190+ for i in ${INCLUDED_ITEMS[${COMMAND}]}
175191 do
176192 cmd_line=" ${cmd_line} --include ${i} "
177193 done
180196if [ $post_operation_show -eq 1 ]
181197then
182198 ${_PY3} ${s_dir} /oci-network-config-main.py $COMMAND ${cmd_line}
183- # print things as we used to do : incolude systme interface as table , vnic as list etc..
199+ # print things as we used to do : include system interface as table , vnic as list etc..
184200 if [ $? -eq 0 ]
185201 then
186202 exec ${_PY3} ${s_dir} /oci-network-config-main.py show --compat-output
0 commit comments