OSDN Git Service

Improvement of net-llist command
authorniwa-hideyuki <niwa.hideyuki@jp.fujitsu.com>
Sun, 8 Feb 2015 02:51:36 +0000 (11:51 +0900)
committerniwa-hideyuki <niwa.hideyuki@jp.fujitsu.com>
Sun, 8 Feb 2015 02:51:36 +0000 (11:51 +0900)
lxcf/lib/lxcf-net-list

index 5db6c89..2f7c648 100755 (executable)
@@ -28,17 +28,16 @@ fi
 
 usage()
 {
-       echo "usage: net-list [ -b ] [ -v ]"
+       echo "usage: net-list [ -b ] "
 }
 
 # check options
 FLG_B=0 
 FLG_V=0 
 
-while getopts bv OPT ; do
+while getopts b OPT ; do
   case $OPT in
   b) FLG_B=1 ;;
-  v) FLG_V=1 ;;
   esac
 done
 shift $((OPTIND - 1))
@@ -50,7 +49,7 @@ list_br()
 
 list_veth()
 {
-       VETH_H=`ip a show | egrep -e "^[1-9]" -e inet | \
+       VETH_H=`ip a show | egrep -e "^[1-9]"  | \
          awk '{if (($1 == "inet") || ($1 == "inet6")){printf "\t%s",$2}else{printf "\n%s\t",$2}}END{printf "\n"}' | \
          egrep ^vh | sed 's/://g'`
        if [ x"$VETH_H" == x"" ]; then
@@ -77,7 +76,7 @@ list_veth()
 
                ip netns exec ${LXCNAME} ip a show | egrep -e "^[1-9]" -e inet | \
                  awk '{if (($1 == "inet") || ($1 == "inet6")){printf "\t%s",$2}else{printf "\n%s\t",$2}}END{printf "\n"}' | \
-                 egrep ^vg
+                 egrep ^vg | sed 's/^vg//g'
 
                rm -f /var/run/netns/${LXCNAME}
        done
@@ -95,23 +94,13 @@ if [ $FLG_B -eq 1 ]; then
                exit 0
        fi
 fi
-if [ $FLG_V -eq 1 ]; then
-       if [ $# -ne 0 ]; then
-               usage
-               exit -1
-       else
-               list_veth
-               exit 0
-       fi
-fi
 
 if [ $# -ne 0 ]; then
        usage
        exit -1
 fi
 
-ip a show | egrep -e "^[1-9]" -e inet | \
-  awk '{if (($1 == "inet") || ($1 == "inet6")){printf "\t%s",$2}else{printf "\n%s\t",$2}}END{printf "\n"}'
+list_veth
 
 
 exit 0