• R/O
  • HTTP
  • SSH
  • HTTPS

Fulcon: コミット

Fulconのソース管理


コミットメタ情報

リビジョンc92d3e2e9c994e0adf12f2c40a652a89b46c3b21 (tree)
日時2016-04-08 17:25:26
作者NIWA Hideyuki <niwa.niwa@nift...>
コミッターNIWA Hideyuki

ログメッセージ

Ovs driver and correction of relation

変更サマリ

差分

--- a/README.md
+++ b/README.md
@@ -19,7 +19,7 @@ Fulcon / Slot-OS Platform 0.4 Copyright (C) 2015-2016 NIWA Hideyuki
1919 - Automatic update-function of two or more slots
2020 - High-speed backup function
2121
22-Fulcon can handle CentOS 7, Ubuntu 15.04, Fedora 23
22+Fulcon can handle CentOS 7, Ubuntu 15.04, 15.10, Fedora 23
2323
2424 ### Install package
2525
--- a/src/Makefile
+++ b/src/Makefile
@@ -24,6 +24,7 @@ install-subcmd :
2424 mkdir -p $(DESTDIR)$(libdir)/fulcon/sbin
2525 install -m 755 cmd/fulcond $(DESTDIR)$(libdir)/fulcon/sbin/fulcond
2626 install -m 755 subcmd/default-image $(DESTDIR)$(libdir)/fulcon/sbin/default-image
27+ install -m 755 subcmd/bridge-name $(DESTDIR)$(libdir)/fulcon/sbin/bridge-name
2728 install -m 755 subcmd/driver-name $(DESTDIR)$(libdir)/fulcon/sbin/driver-name
2829 install -m 755 subcmd/list $(DESTDIR)$(libdir)/fulcon/sbin/list
2930 install -m 755 subcmd/sysgen $(DESTDIR)$(libdir)/fulcon/sbin/sysgen
@@ -53,6 +54,7 @@ install-subcmd :
5354 install -m 755 subcmd/add-user $(DESTDIR)$(libdir)/fulcon/sbin/add-user
5455 install -m 755 subcmd/del-user $(DESTDIR)$(libdir)/fulcon/sbin/del-user
5556 install -m 755 subcmd/set-passwd $(DESTDIR)$(libdir)/fulcon/sbin/set-passwd
57+ install -m 755 subcmd/set-bridge $(DESTDIR)$(libdir)/fulcon/sbin/set-bridge
5658 install -m 755 subcmd/set-driver $(DESTDIR)$(libdir)/fulcon/sbin/set-driver
5759 install -m 755 subcmd/image-catalog $(DESTDIR)$(libdir)/fulcon/sbin/image-catalog
5860 install -m 755 subcmd/ls-image $(DESTDIR)$(libdir)/fulcon/sbin/ls-image
@@ -161,6 +163,28 @@ install-driver-docker : install-dockerfile
161163 install -m 755 driver/docker/fulcon-ip $(DESTDIR)$(libdir)/fulcon/driver/docker/fulcon-ip
162164 install -m 755 driver/docker/fulcon-status $(DESTDIR)$(libdir)/fulcon/driver/docker/fulcon-status
163165 install -m 755 driver/docker/find-id $(DESTDIR)$(libdir)/fulcon/driver/docker/find-id
166+ mkdir -p $(DESTDIR)$(libdir)/fulcon/driver/LinuxBridge
167+ install -m 755 driver/LinuxBridge/br-addbr $(DESTDIR)$(libdir)/fulcon/driver/LinuxBridge/br-addbr
168+ install -m 755 driver/LinuxBridge/br-delbr $(DESTDIR)$(libdir)/fulcon/driver/LinuxBridge/br-delbr
169+ install -m 755 driver/LinuxBridge/br-addif $(DESTDIR)$(libdir)/fulcon/driver/LinuxBridge/br-addif
170+ install -m 755 driver/LinuxBridge/br-delif $(DESTDIR)$(libdir)/fulcon/driver/LinuxBridge/br-delif
171+ install -m 755 driver/LinuxBridge/br-show $(DESTDIR)$(libdir)/fulcon/driver/LinuxBridge/br-show
172+ install -m 755 driver/LinuxBridge/br-br-list $(DESTDIR)$(libdir)/fulcon/driver/LinuxBridge/br-br-list
173+ install -m 755 driver/LinuxBridge/br-brif-list $(DESTDIR)$(libdir)/fulcon/driver/LinuxBridge/br-brif-list
174+ install -m 755 driver/LinuxBridge/br-check $(DESTDIR)$(libdir)/fulcon/driver/LinuxBridge/br-check
175+ install -m 755 driver/LinuxBridge/br-emptylist $(DESTDIR)$(libdir)/fulcon/driver/LinuxBridge/br-emptylist
176+ install -m 755 driver/LinuxBridge/br-if-list $(DESTDIR)$(libdir)/fulcon/driver/LinuxBridge/br-if-list
177+ mkdir -p $(DESTDIR)$(libdir)/fulcon/driver/OpenvSwitch
178+ install -m 755 driver/OpenvSwitch/br-addbr $(DESTDIR)$(libdir)/fulcon/driver/OpenvSwitch/br-addbr
179+ install -m 755 driver/OpenvSwitch/br-delbr $(DESTDIR)$(libdir)/fulcon/driver/OpenvSwitch/br-delbr
180+ install -m 755 driver/OpenvSwitch/br-addif $(DESTDIR)$(libdir)/fulcon/driver/OpenvSwitch/br-addif
181+ install -m 755 driver/OpenvSwitch/br-delif $(DESTDIR)$(libdir)/fulcon/driver/OpenvSwitch/br-delif
182+ install -m 755 driver/OpenvSwitch/br-show $(DESTDIR)$(libdir)/fulcon/driver/OpenvSwitch/br-show
183+ install -m 755 driver/OpenvSwitch/br-br-list $(DESTDIR)$(libdir)/fulcon/driver/OpenvSwitch/br-br-list
184+ install -m 755 driver/OpenvSwitch/br-brif-list $(DESTDIR)$(libdir)/fulcon/driver/OpenvSwitch/br-brif-list
185+ install -m 755 driver/OpenvSwitch/br-check $(DESTDIR)$(libdir)/fulcon/driver/OpenvSwitch/br-check
186+ install -m 755 driver/OpenvSwitch/br-emptylist $(DESTDIR)$(libdir)/fulcon/driver/OpenvSwitch/br-emptylist
187+ install -m 755 driver/OpenvSwitch/br-if-list $(DESTDIR)$(libdir)/fulcon/driver/OpenvSwitch/br-if-list
164188
165189 install-dockerfile :
166190 mkdir -p $(DESTDIR)/$(localstatedir)/lib/fulcon/driver/dockerfile
@@ -185,6 +209,7 @@ install-doc :
185209 install -m 644 doc/slot-os.help.txt $(DESTDIR)$(libdir)/slot-os/doc/help.txt
186210 mkdir -p $(DESTDIR)$(localstatedir)/lib/fulcon
187211 install -m 644 doc/default-driver $(DESTDIR)$(localstatedir)/lib/fulcon/default-driver
212+ install -m 644 doc/default-bridge $(DESTDIR)$(localstatedir)/lib/fulcon/default-bridge
188213
189214
190215 uninstall :
--- a/src/README
+++ b/src/README
@@ -19,7 +19,7 @@ Fulcon / Slot-OS Platform 0.4 Copyright (C) 2015-2016 NIWA Hideyuki
1919 - Automatic update-function of two or more slots
2020 - High-speed backup function
2121
22-Fulcon can handle CentOS 7, Ubuntu 15.04, Fedora 23
22+Fulcon can handle CentOS 7, Ubuntu 15.04, 15.10, Fedora 23
2323
2424 ### Install package
2525
--- a/src/cmd/fulcon
+++ b/src/cmd/fulcon
@@ -12,7 +12,14 @@ fi
1212 export PATH=/usr/lib/fulcon/sbin:$PATH
1313 export FULCONDIR=/var/lib/fulcon
1414
15-mkdir -p /var/lib/fulcon
15+mkdir -p $FULCONDIR/br
16+if [ ! -f $FULCONDIR/default-driver ]; then
17+ echo "docker" > $FULCONDIR/default-driver
18+fi
19+if [ ! -f $FULCONDIR/default-bridge ]; then
20+ echo "LinuxBridge" > $FULCONDIR/default-bridge
21+fi
22+
1623
1724 FLG_H=0
1825
--- /dev/null
+++ b/src/doc/default-bridge
@@ -0,0 +1 @@
1+LinuxBridge
--- /dev/null
+++ b/src/driver/LinuxBridge/br-br-list
@@ -0,0 +1,5 @@
1+#!/bin/bash
2+
3+# Copyright (C) 2016 NIWA Hideyuki
4+
5+brctl show | awk '{if((NF==3)||(NF==4))print $1}' | egrep "^fulcon"
--- /dev/null
+++ b/src/driver/LinuxBridge/br-brif-list
@@ -0,0 +1,10 @@
1+#!/bin/bash
2+
3+# Copyright (C) 2016 NIWA Hideyuki
4+
5+brctl show | awk 'BEGIN{f=0} \
6+ NR>1{ \
7+ if(NF==4){if(f!=0){printf "\n"}f=1;printf "%s %s ",$1,$4} \
8+ else if(NF==3){if(f!=0){printf "\n"}f=1;printf "%s\n",$1} \
9+ else {printf "%s ",$1}
10+ }' | egrep "^fulcon"
--- /dev/null
+++ b/src/driver/LinuxBridge/br-check
@@ -0,0 +1,7 @@
1+#!/bin/bash
2+
3+# Copyright (C) 2016 NIWA Hideyuki
4+
5+brctl show | egrep ^fulcon | \
6+ awk 'BEGIN{r=0}{if($1=="'$1'")r=1}END{exit(r)}'
7+
--- /dev/null
+++ b/src/driver/LinuxBridge/br-emptylist
@@ -0,0 +1,5 @@
1+#!/bin/bash
2+
3+# Copyright (C) 2016 NIWA Hideyuki
4+
5+brctl show | egrep ^fulcon | awk '(NF==3){print $1}'
--- /dev/null
+++ b/src/driver/LinuxBridge/br-if-list
@@ -0,0 +1,5 @@
1+#!/bin/bash
2+
3+# Copyright (C) 2016 NIWA Hideyuki
4+
5+br-brif-list | awk '{if($1=="'$1'"){for(i=2;i<=NF;i++){printf "%s ",$i}}}END{printf "\n"}'
--- /dev/null
+++ b/src/driver/OpenvSwitch/br-addbr
@@ -0,0 +1,11 @@
1+#!/bin/bash
2+
3+# Copyright (C) 2016 NIWA Hideyuki
4+
5+LXCBR=$1
6+ovs-vsctl show | egrep -w $LXCBR >& /dev/null
7+if [ $? -ne 0 ]; then
8+ ovs-vsctl add-br $LXCBR
9+ ip link set $LXCBR up
10+fi
11+
--- /dev/null
+++ b/src/driver/OpenvSwitch/br-addif
@@ -0,0 +1,6 @@
1+#!/bin/bash
2+
3+# Copyright (C) 2016 NIWA Hideyuki
4+
5+ovs-vsctl add-port $*
6+
--- /dev/null
+++ b/src/driver/OpenvSwitch/br-br-list
@@ -0,0 +1,7 @@
1+#!/bin/bash
2+
3+# Copyright (C) 2016 NIWA Hideyuki
4+
5+ovs-vsctl show | egrep -w Bridge | awk '{print $2}' | sed -e 's/"//g' | sort -n
6+
7+
--- /dev/null
+++ b/src/driver/OpenvSwitch/br-brif-list
@@ -0,0 +1,18 @@
1+#!/bin/bash
2+
3+# Copyright (C) 2016 NIWA Hideyuki
4+
5+print_list()
6+{
7+ ovs-vsctl show | sed -e 's/"//g' | \
8+ awk 'BEGIN{f=0} \
9+ { \
10+ if($1=="Bridge"){if(f==0){f=1}else{printf "\n"}printf "%s ",$2;br=$2} \
11+ else if($1=="Port"&& $2!=br){printf "%s ",$2} \
12+ }'
13+ echo
14+}
15+
16+print_list | sort -n
17+
18+
--- /dev/null
+++ b/src/driver/OpenvSwitch/br-check
@@ -0,0 +1,8 @@
1+#!/bin/bash
2+
3+# Copyright (C) 2016 NIWA Hideyuki
4+
5+ovs-vsctl show | sed -e 's/"//g' | \
6+awk 'BEGIN{r=0}$1=="Bridge"{if($2=="'$1'")r=1}END{exit(r)}'
7+
8+
--- /dev/null
+++ b/src/driver/OpenvSwitch/br-delbr
@@ -0,0 +1,5 @@
1+#!/bin/bash
2+
3+# Copyright (C) 2016 NIWA Hideyuki
4+
5+ovs-vsctl del-br $*
--- /dev/null
+++ b/src/driver/OpenvSwitch/br-delif
@@ -0,0 +1,5 @@
1+#!/bin/bash
2+
3+# Copyright (C) 2016 NIWA Hideyuki
4+
5+ovs-vsctl del-port $*
--- /dev/null
+++ b/src/driver/OpenvSwitch/br-emptylist
@@ -0,0 +1,12 @@
1+#!/bin/bash
2+
3+# Copyright (C) 2016 NIWA Hideyuki
4+
5+ovs-vsctl show | sed -e 's/"//g' | awk '{ \
6+ if($1=="Bridge"){printf "\n%s ",$2;br=$2} \
7+ else if($1=="Port"&& $2!=br){printf "%s ",$2} \
8+ }' | awk '(NF==1){print $1}' | sort -n
9+
10+
11+
12+
--- /dev/null
+++ b/src/driver/OpenvSwitch/br-if-list
@@ -0,0 +1,6 @@
1+#!/bin/bash
2+
3+# Copyright (C) 2016 NIWA Hideyuki
4+
5+br-brif-list | awk '$1=="'$1'"{print $0}' | cut -d ' ' -f 2-
6+
--- /dev/null
+++ b/src/driver/OpenvSwitch/br-show
@@ -0,0 +1,48 @@
1+#!/bin/bash
2+
3+# Copyright (C) 2016 NIWA Hideyuki
4+
5+print_data()
6+{
7+ echo "bridge name X X interfaces"
8+ ovs-vsctl show | egrep -v ovs_version | sed -e 's/\"//g' | \
9+ awk '{ \
10+ if($1=="Bridge"){if(f==1){printf "%s\t\tX\t\tX\n",br};br=$2;f=0} \
11+ else if($1=="Port" && $2!=br){ \
12+ if(f==0){printf "%s\t\tX\t\tX\t%s\n",br,$2; f=1} \
13+ else {printf "\t\t\t\t\t%s\n",$2} \
14+ }
15+ }'
16+}
17+
18+print_data1()
19+{
20+ LXCBR=$1
21+ BRIDGETEXT="Bridge \"$LXCBR\""
22+ ovs-vsctl show | egrep "$BRIDGETEXT" # >& /dev/null
23+ if [ $? -eq 1 ]; then
24+ echo "No such device"
25+ exit -1
26+ fi
27+
28+ echo "bridge name X X interfaces"
29+ ovs-vsctl show | egrep -v ovs_version | sed -e 's/\"//g' | \
30+ awk 'BEGIN{f=0} \
31+ { \
32+ if($1=="Bridge"&& $2=="'$LXCBR'"){printf "%s\t\t",$2;br=$2;f=0} \
33+ else if($1=="Port" && $2!=br){ \
34+ if(f==0){printf "%s\t\tX\t\tX\t%s\n",br,$2; f=1} \
35+ else {printf "\t\t\t\t\t%s\n",$2} \
36+ } \
37+ }'
38+ echo
39+}
40+
41+ print_data1 $1
42+exit
43+if [ $# -eq 1 -a x"$1" != x"br-show" ]; then
44+ LXCBR=$1
45+ print_data1 $LXCBR
46+else
47+ print_data
48+fi
--- a/src/driver/docker/fulcon-list-all
+++ b/src/driver/docker/fulcon-list-all
@@ -2,7 +2,7 @@
22
33 # Copyright (C) 2016 NIWA Hideyuki
44
5-exec docker ps --no-trunc -a | awk 'NR>1{printf "%s %s\n",$NF,$2}'
5+exec docker ps --no-trunc -a | egrep fulcon | awk '{printf "%s %s\n",$NF,$2}'
66
77
88
--- a/src/lib/lib-erase
+++ b/src/lib/lib-erase
@@ -28,12 +28,6 @@ else
2828 exit -1
2929 fi
3030
31-fulcon-list-all | awk 'BEGIN{r=1}{if($1=="'$NAME'")r=0}END{exit(r)}'
32-if [ $? -ne 0 ]; then
33- echo "error: can't find" $NAME
34- exit -1
35-fi
36-
3731 fulcon-stop $NAME >& /dev/null
3832 fulcon-erase $NAME >& /dev/null
3933 echo "erased" $NAME
--- a/src/lib/lib-list
+++ b/src/lib/lib-list
@@ -18,8 +18,8 @@ ALLCONT=`fulcon-list-all | awk '{printf "%s ",$1}'`
1818 list1()
1919 {
2020 NAME=$1
21- mkdir -p $FULCONDIR/slot/$NAME/net
22- mkdir -p $FULCONDIR/container/$NAME/net
21+ # mkdir -p $FULCONDIR/slot/$NAME/net
22+ # mkdir -p $FULCONDIR/container/$NAME/net
2323 if [ -f /var/lib/fulcon/container/$NAME/imagename ]; then
2424 IMAGE=`cat /var/lib/fulcon/container/$NAME/imagename`
2525 IPADDR=""
--- a/src/lib/lib-stop
+++ b/src/lib/lib-stop
@@ -2,6 +2,10 @@
22
33 # Copyright (C) 2015-2016 NIWA Hideyuki
44
5+FULCONDRIVER=`fulcon driver-name`
6+BRIDGEDRIVER=`fulcon bridge-name`
7+PATH=/usr/lib/fulcon/driver/$BRIDGEDRIVER:/usr/lib/fulcon/driver/$FULCONDRIVER:/usr/lib/fulcon/lib:$PATH
8+
59 usage()
610 {
711 echo "usage: lib-stop [ -f ] NAME"
@@ -36,12 +40,12 @@ fi
3640
3741 fulcon-stop $NAME >& /dev/null
3842
39-for i in `brctl show | egrep fulcon | awk '{print $1}' `
43+for i in `br-show | egrep fulcon | awk '{print $1}' `
4044 do
41- N=`brctl show $i | awk '($1=="'$i'"){print NF}'`
45+ N=`br-show $i | awk '($1=="'$i'"){print NF}'`
4246 if [ $N -eq 3 ]; then
4347 ip link set $i down
44- brctl delbr $i
48+ br-delbr $i
4549 fi
4650 done
4751
--- a/src/lib/lib-sysgen
+++ b/src/lib/lib-sysgen
@@ -32,6 +32,8 @@ if [ $? -eq 0 ]; then
3232 fi
3333
3434 fulcon-sysgen $NAME $IMAGE
35+mkdir -p $LIBDIR/container/$NAME/net
36+mkdir -p $LIBDIR/container/$NAME/resource
3537
3638 exit 0
3739
--- a/src/subcmd/br-add
+++ b/src/subcmd/br-add
@@ -3,7 +3,9 @@
33 # Copyright (C) 2015-2016 NIWA Hideyuki
44
55 FULCONDRIVER=`fulcon driver-name`
6-PATH=/usr/lib/fulcon/driver/$FULCONDRIVER:/usr/lib/fulcon/lib:$PATH
6+BRIDGEDRIVER=`fulcon bridge-name`
7+PATH=/usr/lib/fulcon/driver/$BRIDGEDRIVER:/usr/lib/fulcon/driver/$FULCONDRIVER:/usr/lib/fulcon/lib:$PATH
8+
79
810 usage()
911 {
@@ -61,9 +63,9 @@ if [ x"$NETDEV" != x"" ]; then
6163 fi
6264
6365 # check a exist bridge
64-brctl show | grep fulcon${BRNO} >& /dev/null
66+br-check
6567 if [ $? -eq 1 ]; then
66- brctl addbr fulcon$BRNO
68+ br-addbr fulcon$BRNO
6769 ip link set fulcon$BRNO up
6870 echo "generated new BRIDGE : fulcon"$BRNO
6971 else
@@ -73,7 +75,7 @@ fi
7375 # set ip address for bridge, add interface to net_device
7476 ip addr add $IPMASK dev fulcon$BRNO
7577 if [ x"$NETDEV" != x"" ]; then
76- brctl addif fulcon$BRNO $NETDEV
78+ br-addif fulcon$BRNO $NETDEV
7779
7880 # set promisc mode to net_device
7981 ip addr del $IPMASK dev $NETDEV
--- a/src/subcmd/br-del
+++ b/src/subcmd/br-del
@@ -3,7 +3,8 @@
33 # Copyright (C) 2015-2016 NIWA Hideyuki
44
55 FULCONDRIVER=`fulcon driver-name`
6-PATH=/usr/lib/fulcon/driver/$FULCONDRIVER:/usr/lib/fulcon/lib:$PATH
6+BRIDGEDRIVER=`fulcon bridge-name`
7+PATH=/usr/lib/fulcon/driver/$BRIDGEDRIVER:/usr/lib/fulcon/driver/$FULCONDRIVER:/usr/lib/fulcon/lib:$PATH
78
89 usage()
910 {
@@ -27,13 +28,16 @@ if [ $? -ne 0 ]; then
2728 fi
2829
2930 # delete all interface
30-for i in `brctl show $BRNO | awk 'NR>1{print $NF}'`
31-do
32- brctl delif $BRNO $i
33-done
31+BRIFLIST=`br-if-list $BRNO`
32+if [ x"$BRIFLIST" != x"" ]; then
33+ for i in $BRIFLIST
34+ do
35+ br-delif $BRNO $i
36+ done
37+fi
3438
3539 # delete bridge
3640 ip link set $BRNO down
37-brctl delbr $BRNO
41+br-delbr $BRNO
3842
3943
--- a/src/subcmd/br-info
+++ b/src/subcmd/br-info
@@ -1,5 +1,8 @@
11 #!/bin/bash
22
3+FULCONDRIVER=`fulcon driver-name`
4+BRIDGEDRIVER=`fulcon bridge-name`
5+PATH=/usr/lib/fulcon/driver/$BRIDGEDRIVER:/usr/lib/fulcon/driver/$FULCONDRIVER:/usr/lib/fulcon/lib:$PATH
36
47 # Copyright (C) 2015 NIWA Hideyuki
58
@@ -18,18 +21,6 @@ if [ $# -eq 1 -a x"$1" != x"br-info" ]; then
1821 exit -1
1922 fi
2023
21-for i in `brctl show | egrep fulcon | awk '{print $1}' `
22-do
23- N=`brctl show $i | awk '($1=="'$i'"){print NF}'`
24- if [ $N -eq 4 ]; then
25- ip a show $i
26- echo
27- brctl show $i
28- echo
29- else
30- ip link set $i down
31- brctl delbr $i
32- fi
33-done
24+br-brif-list
3425
3526 exit 0
--- /dev/null
+++ b/src/subcmd/bridge-name
@@ -0,0 +1,20 @@
1+#!/bin/bash
2+
3+# Copyright (C) 2015 NIWA Hideyuki
4+
5+FULCONDIR=/var/lib/fulcon
6+
7+umask 022
8+
9+usage()
10+{
11+ echo "usage: bridge-name"
12+}
13+
14+if [ $# -ne 1 -o x"$1" != x"bridge-name" ]; then
15+ usage
16+ exit -1
17+fi
18+
19+head -n 1 $FULCONDIR/default-bridge
20+
--- a/src/subcmd/net-add
+++ b/src/subcmd/net-add
@@ -1,11 +1,12 @@
1-#!/bin/bash
1+#!/bin/bash
22
33 # Copyright (C) 2015-2016 NIWA Hideyuki
44
55 FULCONDIR=/var/lib/fulcon
66
77 FULCONDRIVER=`fulcon driver-name`
8-PATH=/usr/lib/fulcon/driver/$FULCONDRIVER:/usr/lib/fulcon/lib:$PATH
8+BRIDGEDRIVER=`fulcon bridge-name`
9+PATH=/usr/lib/fulcon/driver/$BRIDGEDRIVER:/usr/lib/fulcon/driver/$FULCONDRIVER:/usr/lib/fulcon/lib:$PATH
910
1011 umask 022
1112
@@ -64,28 +65,36 @@ if [ x"`ip a show $NETDEV | egrep "inet " | awk '{print $2}'`" == x"" ]; then
6465 fi
6566
6667 # check unnecessary bridges
67-for i in `brctl show | egrep fulcon | awk '(NF==3){print $1}'`
68-do
69- ip link set $i down
70- brctl delbr $i
71-done
68+EMPTYBRLIST=`br-emptylist`
69+if [ x"$EMPTYBRLIST" != x"" ]; then
70+ for i in $EMPTYBRLIST
71+ do
72+ ip link set $i down
73+ br-delbr $i
74+ done
75+fi
7276
7377 RBR=0
7478 BRNO=0
7579 BNO=0
76-for i in `brctl show | egrep fulcon | awk '{print $1}'`
77-do
78- BIP=`ip a show $i | awk '$1=="inet"{print $2}'`
79- BIP=`net-ipv4 -g $BIP`
80- BNO=`echo $i | sed -e "s/fulcon//"`
81- if [ x"$BIP" == x"$LXCBRIP" ]; then
82- RBR=1
83- break
84- fi
85- if [ $BNO -gt $BRNO ]; then
86- BRNO=$BNO
87- fi
88-done
80+
81+BRLIST=`br-br-list`
82+if [ x"$BRLIST" != x"" ]; then
83+ for i in $BRLIST
84+ do
85+ BIP=`ip a show $i | awk '$1=="inet"{print $2}'`
86+ BIP=`net-ipv4 -g $BIP`
87+ BNO=`echo $i | sed -e "s/fulcon//"`
88+ if [ x"$BIP" == x"$LXCBRIP" ]; then
89+ RBR=1
90+ break
91+ fi
92+ if [ $BNO -gt $BRNO ]; then
93+ BRNO=$BNO
94+ fi
95+ done
96+fi
97+
8998 if [ $RBR -eq 0 ]; then
9099 LXCBR=`expr $BRNO + 1`
91100 else
@@ -139,15 +148,15 @@ setup_network()
139148
140149 ip link set ${LXCNAME}_${NUM} up
141150
142- brctl show $LXCBR |& egrep 'No such device' >& /dev/null
151+ br-check $LXCBR
143152 if [ $? -eq 0 ]; then
144- brctl addbr $LXCBR
153+ br-addbr $LXCBR
145154 ip link set $LXCBR up
146155 BR_BRCAST=`net-ipv4 -b ${LXCBRIP}/${LXCMASK}`
147156 ip addr add ${LXCBRIP}/${LXCMASK} broadcast $BR_BRCAST dev $LXCBR
148157 ip link set $LXCBR promisc on
149158 fi
150- brctl addif $LXCBR ${LXCNAME}_${NUM} >& /dev/null
159+ br-addif $LXCBR ${LXCNAME}_${NUM} >& /dev/null
151160
152161 # setting up of IP address
153162 LXCFBROADCAST=`net-ipv4 -b "${LXCIP}/${LXCMASK}"`
@@ -197,9 +206,9 @@ setup_network()
197206 ip addr add 0.0.0.0 dev $NETDEV >& /dev/null
198207 ip link set $NETDEV promisc on
199208
200- brctl show $LXCBR | egrep -w $NETDEV >& /dev/null
209+ br-if-list $LXCBR | egrep -w $NETDEV >& /dev/null
201210 if [ $? -ne 0 ]; then
202- brctl addif $LXCBR $NETDEV
211+ br-addif $LXCBR $NETDEV
203212 fi
204213 fi
205214
--- a/src/subcmd/net-del
+++ b/src/subcmd/net-del
@@ -3,7 +3,8 @@
33 # Copyright (C) 2015-2016 NIWA Hideyuki
44
55 FULCONDRIVER=`fulcon driver-name`
6-PATH=/usr/lib/fulcon/driver/$FULCONDRIVER:/usr/lib/fulcon/lib:$PATH
6+BRIDGEDRIVER=`fulcon bridge-name`
7+PATH=/usr/lib/fulcon/driver/$BRIDGEDRIVER:/usr/lib/fulcon/driver/$FULCONDRIVER:/usr/lib/fulcon/lib:$PATH
78
89 FULCONDIR=/var/lib/fulcon
910
@@ -29,21 +30,24 @@ NUM=$2
2930
3031 network_delete()
3132 {
32- ip link delete ${LXCNAME}_${NUM} type veth
33+ ip link delete ${LXCNAME}_${NUM} type veth >& /dev/null
3334 echo "deleted" ${LXCNAME}_${NUM}
3435
3536 # delete a IP address for container
3637 rm -f $FULCONDIR/container/${LXCNAME}/net/${LXCNAME}_${NUM}
3738
3839 # check bridges
39- for i in `brctl show | egrep fulcon | awk '(NF==3){print $1}'`
40- do
41- ip link set $i down
42- brctl delbr $i
43- done
40+ EMPTYLIST=`br-emptylist`
41+ if [ x"$EMPTYLIST" != x"" ]; then
42+ for i in $EMPTYLIST
43+ do
44+ ip link set $i down
45+ br-delbr $i
46+ done
47+ fi
4448 }
4549
46-brctl show |& egrep ${LXCNAME}_${NUM} >& /dev/null
50+br-check ${LXCNAME}_${NUM}
4751 if [ $? -eq 0 ]; then
4852 network_delete
4953 fi
--- a/src/subcmd/net-info
+++ b/src/subcmd/net-info
@@ -3,7 +3,8 @@
33 # Copyright (C) 2015 NIWA Hideyuki
44
55 FULCONDRIVER=`fulcon driver-name`
6-PATH=/usr/lib/fulcon/driver/$FULCONDRIVER:/usr/lib/fulcon/lib:$PATH
6+BRIDGEDRIVER=`fulcon bridge-name`
7+PATH=/usr/lib/fulcon/driver/$BRIDGEDRIVER:/usr/lib/fulcon/driver/$FULCONDRIVER:/usr/lib/fulcon/lib:$PATH
78 FULCONDIR=/var/lib/fulcon
89
910 usage()
--- a/src/subcmd/net-nic-add
+++ b/src/subcmd/net-nic-add
@@ -3,7 +3,8 @@
33 # Copyright (C) 2016 NIWA Hideyuki
44
55 FULCONDRIVER=`fulcon driver-name`
6-PATH=/usr/lib/fulcon/driver/$FULCONDRIVER:/usr/lib/fulcon/lib:$PATH
6+BRIDGEDRIVER=`fulcon bridge-name`
7+PATH=/usr/lib/fulcon/driver/$BRIDGEDRIVER:/usr/lib/fulcon/driver/$FULCONDRIVER:/usr/lib/fulcon/lib:$PATH
78 FULCONDIR=/var/lib/fulcon
89
910 usage()
@@ -32,7 +33,7 @@ if [ $? -ne 0 ]; then
3233 exit -1
3334 fi
3435
35-if [ x"`brctl show | egrep $NETDEV | awk '{print $NF}'`" == x"$NETDEV" ]; then
36+if [ `br-brif-list | egrep -w $NETDEV >& /dev/null` ]; then
3637 echo "error: $NETDEV has already been allocated in the bridge. "
3738 exit -1
3839 fi
@@ -58,7 +59,7 @@ BRNO="-1"
5859 IPMASK=`ip a show $NETDEV | egrep "inet " | awk '{print $2}'`
5960 IPG=`net-ipv4 -g $IPMASK`
6061 #
61-for i in `brctl show | egrep fulcon | awk '{print $1}'`
62+for i in `br-br-list`
6263 do
6364 BIP=`ip a show $i | egrep "inet " | awk '{print $2}'`
6465 BIPG=`net-ipv4 -g $BIP`
@@ -79,7 +80,7 @@ if [ $BRNO -eq -1 ]; then
7980 fi
8081 BRNO=`expr $BRNO + 1`
8182 done
82- brctl addbr fulcon$BRNO
83+ br-addbr fulcon$BRNO
8384 ip link set fulcon$BRNO up
8485 echo "generated new BRIDGE : fulcon"$BRNO
8586 fi
@@ -96,7 +97,7 @@ done
9697
9798 # set ip address for bridge, add interface to net_device
9899 ip addr add $IPMASK dev fulcon$BRNO
99-brctl addif fulcon$BRNO $NETDEV
100+br-addif fulcon$BRNO $NETDEV
100101
101102 # set BR MAC
102103 #MAC=`ip addr show fulcon$BRNO | egrep link/ether | awk '{print $2}' | awk -F : '{printf "52:54:00:%2s:%2s:%2s",$4,$5,$6}'`
--- a/src/subcmd/net-nic-del
+++ b/src/subcmd/net-nic-del
@@ -3,7 +3,8 @@
33 # Copyright (C) 2016 NIWA Hideyuki
44
55 FULCONDRIVER=`fulcon driver-name`
6-PATH=/usr/lib/fulcon/driver/$FULCONDRIVER:/usr/lib/fulcon/lib:$PATH
6+BRIDGEDRIVER=`fulcon bridge-name`
7+PATH=/usr/lib/fulcon/driver/$BRIDGEDRIVER:/usr/lib/fulcon/driver/$FULCONDRIVER:/usr/lib/fulcon/lib:$PATH
78 FULCONDIR=/var/lib/fulcon
89
910 usage()
@@ -23,9 +24,9 @@ fi
2324 NETDEV=$1
2425
2526 FLG=0
26-for i in `brctl show | egrep fulcon | awk '{print $1}'`
27+for i in `br-br-list`
2728 do
28- if [ x"`brctl show $i | egrep $NETDEV`" != x"" ]; then
29+ if [ x"`br-if-list $i | egrep -w $NETDEV`" != x"" ]; then
2930 # reset MAC
3031 #MAC=`ip addr show $i | egrep link/ether | awk '{print $2}'`
3132 #ip link set $NETDEV address $MAC
@@ -35,13 +36,16 @@ do
3536 #ip addr add $IP dev $NETDEV
3637
3738 # delete nic
38- brctl delif $i $NETDEV >& /dev/null
39+ br-delif $i $NETDEV >& /dev/null
3940
40- brctl show | egrep $i | awk '{exit(NF)}'
41- if [ $? -lt 4 ]; then
42- # delete br
43- ip link set $i down
44- brctl delbr $i
41+ EMPTYLIST=`br-emptylist`
42+ if [ x"$EMPTYLIST" != x"" ]; then
43+ for j in $EMPTYLIST
44+ do
45+ # delete br
46+ ip link set $j down
47+ br-delbr $j
48+ done
4549 fi
4650
4751 FLG=1
--- /dev/null
+++ b/src/subcmd/set-bridge
@@ -0,0 +1,12 @@
1+#!/bin/sh
2+
3+DRIVERNAME=$1
4+
5+if [ x"$DRIVERNAME" != x"LinuxBridge" -a x"$DRIVERNAME" != x"OpenvSwitch" ]; then
6+ echo "error: unsupported bridge driver:" $DIRVERNAME
7+ exit -1
8+fi
9+
10+echo $DRIVERNAME > /var/lib/fulcon/default-bridge
11+echo "default bridge driver :" $DRIVERNAME
12+
--- a/src/subcmd/sysgen
+++ b/src/subcmd/sysgen
@@ -4,7 +4,6 @@
44
55 FULCONDRIVER=`fulcon driver-name`
66 PATH=/usr/lib/fulcon/driver/$FULCONDRIVER:/usr/lib/fulcon/lib:$PATH
7-
87 RCODE=0
98
109 usage()
旧リポジトリブラウザで表示