3 # copyright (C) 2015 FUJITSU LIMITED All Rights Reserved
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; version 2
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 DISTRO=`/usr/lib64/lxcf/lxcf-distro`
24 if [ ${EUID:-${UID}} != 0 ]; then
25 echo "error: Because you are not root, you cannot execute this command. "
31 echo "usage: net-list [ -b ] [ -v ]"
38 while getopts bv OPT ; do
53 VETH_H=`ip a show | egrep -e "^[1-9]" -e inet | \
54 awk '{if (($1 == "inet") || ($1 == "inet6")){printf "\t%s",$2}else{printf "\n%s\t",$2}}END{printf "\n"}' | \
55 egrep ^vh | sed 's/://g'`
56 if [ x"$VETH_H" == x"" ]; then
59 H_SRV=`for i in $VETH_H ; do echo $i | sed 's/^vh//g' ; done`
63 brctl show |& egrep ${LXCNAME} >& /dev/null
65 echo "error: can't find" ${LXCNAME}
69 LXCPROC=`/usr/lib64/lxcf/lxcf-find-init ${LXCNAME}`
71 echo "error: can't find" ${LXCNAME}
75 mkdir -p /var/run/netns/
76 ln -s /proc/${LXCPROC}/ns/net /var/run/netns/${LXCNAME}
78 ip netns exec ${LXCNAME} ip a show | egrep -e "^[1-9]" -e inet | \
79 awk '{if (($1 == "inet") || ($1 == "inet6")){printf "\t%s",$2}else{printf "\n%s\t",$2}}END{printf "\n"}' | \
82 rm -f /var/run/netns/${LXCNAME}
89 if [ $FLG_B -eq 1 ]; then
98 if [ $FLG_V -eq 1 ]; then
108 if [ $# -ne 0 ]; then
113 ip a show | egrep -e "^[1-9]" -e inet | \
114 awk '{if (($1 == "inet") || ($1 == "inet6")){printf "\t%s",$2}else{printf "\n%s\t",$2}}END{printf "\n"}'