Modify scripts for creating and removing physical topology in openflow-renderer. 93/31893/1
authortianran zhou <zhoutianran@huawei.com>
Sat, 26 Dec 2015 07:44:15 +0000 (15:44 +0800)
committertianran zhou <zhoutianran@huawei.com>
Sat, 26 Dec 2015 07:46:09 +0000 (15:46 +0800)
Change-Id: Ifc473824ac2b78352f197e05cb782832f9367b73
Signed-off-by: tianran zhou <zhoutianran@huawei.com>
nemo-renderers/openflow-renderer/src/test/resources/network-down-bod.sh
nemo-renderers/openflow-renderer/src/test/resources/network-down-servicechain.sh
nemo-renderers/openflow-renderer/src/test/resources/network-up-bod.sh
nemo-renderers/openflow-renderer/src/test/resources/network-up-servicechain.sh

index 23b64a112ef08719ec0303a748fd237bfe4e1660..5aa232f29d3c882bb1c851f1f31dd14bdd639d27 100644 (file)
@@ -1,5 +1,7 @@
 #!/bin/bash
 
+echo "Shutting down OpenFlow soft switches......"
+
 pkill -9 ofdatapath
 pkill -9  ofprotocol
 
@@ -9,26 +11,43 @@ pkill -9 fail-ofprotocol
 pkill -9 ext-ofdatapath
 pkill -9 ext-ofprotocol
 
+echo "Removing links......"
+
 ip link del sw1-eth1
 ip link del sw1-eth2
 ip link del sw1-eth3
 ip link del sw2-eth1
+ip link del sw2-eth2
 ip link del sw2-eth3
-ip link del sw3-eth1
-ip link del sw3-eth2
+#ip link del sw3-eth1
+#ip link del sw3-eth2
 ip link del sw3-eth3
-ip link del sw4-eth1
+ip link del sw3-eth4
+#ip link del sw4-eth1
+ip link del sw4-eth2
+
+echo "Removing hosts......"
 
-ip link del server1-eth0
+#ip link del server1-eth0
 ip netns delete server1
-ip link del vm1-eth0
+#ip link del vm1-eth0
 ip netns delete vm1
-ip link del vm2-eth0
+#ip link del vm2-eth0
 ip netns delete vm2
+#ip link del server2-eth0
+ip netns delete server2
+#ip link del enter-eth0
+ip netns delete enter
+#ip link del inet-eth0
+ip netns delete inet
+
+echo "Removing temporary and log files......"
 
 rm /tmp/sw*
-rm /tmp/*.log
+#rm /tmp/*.log
 rm /tmp/vconn-unix.*
 rm /tmp/vlogs.*
 
+echo "Shutting down network done."
+
 exit 0
\ No newline at end of file
index 2ec5dd4b82a16055f73434e9f9bb4665297326e7..9fe1dd8ca562188882104a753300ec09e53a73b1 100644 (file)
@@ -1,5 +1,7 @@
 #!/bin/bash
 
+echo "Shutting down OpenFlow soft switches......"
+
 pkill -9 ofdatapath
 pkill -9  ofprotocol
 
@@ -9,23 +11,43 @@ pkill -9 fail-ofprotocol
 pkill -9 ext-ofdatapath
 pkill -9 ext-ofprotocol
 
+echo "Removing links......"
+
+ip link del sw1-eth1
 ip link del sw1-eth2
 ip link del sw1-eth3
 ip link del sw2-eth1
+ip link del sw2-eth2
 ip link del sw2-eth3
-ip link del sw3-eth1
-ip link del sw3-eth2
+#ip link del sw3-eth1
+#ip link del sw3-eth2
 ip link del sw3-eth3
-ip link del sw4-eth1
+ip link del sw3-eth4
+#ip link del sw4-eth1
+ip link del sw4-eth2
+
+echo "Removing hosts......"
 
-ip link del fw2-eth0
+#ip link del fw1-eth0
+ip netns delete fw1
+#ip link del fw2-eth0
 ip netns delete fw2
-ip link del cache1-eth0
+#ip link del cache1-eth0
 ip netns delete cache1
+#ip link del cache2-eth0
+ip netns delete cache2
+#ip link del head-eth0
+ip netns delete head
+#ip link del branch-eth0
+ip netns delete branch
+
+echo "Removing temporary and log files......"
 
 rm /tmp/sw*
-rm /tmp/*.log
+#rm /tmp/*.log
 rm /tmp/vconn-unix.*
 rm /tmp/vlogs.*
 
+echo "Shutting down network done."
+
 exit 0
\ No newline at end of file
index 21a1e81d431d50fcaae22af76a876658d9d91180..c08b950cb410c343e35e28fbbdda920b5f5c29cb 100644 (file)
@@ -1,5 +1,7 @@
 #!/bin/bash
 
+echo "Creating links......"
+
 ########## sw1 ##########
 ip link add name sw1-eth1 type veth peer name server1-eth0
 ip link add name sw1-eth2 type veth peer name vm1-eth0
@@ -7,15 +9,20 @@ ip link add name sw1-eth3 type veth peer name sw3-eth1
 
 ########## sw2 ##########
 ip link add name sw2-eth1 type veth peer name vm2-eth0
+ip link add name sw2-eth2 type veth peer name server2-eth0
 ip link add name sw2-eth3 type veth peer name sw3-eth2
 
 ########## sw3 ##########
 #ip link add name sw3-eth1 type veth peer name sw1-eth3
 #ip link add name sw3-eth2 type veth peer name sw2-eth3
 ip link add name sw3-eth3 type veth peer name sw4-eth1
+ip link add name sw3-eth4 type veth peer name inet-eth0
 
 ########## sw4 ##########
 #ip link add name sw4-eth1 type veth peer name sw3-eth3
+ip link add name sw4-eth2 type veth peer name enter-eth0
+
+echo "Creating hosts......"
 
 ########## server1 ##########
 ip netns add server1
@@ -29,22 +36,88 @@ ip link set vm1-eth0 netns vm1
 ip netns add vm2
 ip link set vm2-eth0 netns vm2
 
+########## server2 ##########
+ip netns add server2
+ip link set server2-eth0 netns server2
+
+########## enterprise ##########
+ip netns add enter
+ip link set enter-eth0 netns enter
+
+########## internet ##########
+ip netns add inet
+ip link set inet-eth0 netns inet
+
+echo "Starting OpenFlow soft switches......"
+
 ########## sw1 ##########
 ofdatapath -i sw1-eth1,sw1-eth2,sw1-eth3 punix:/tmp/sw1 -d 000000000001 1> /tmp/sw1-ofd.log 2> /tmp/sw1-ofd.log &
 ofprotocol unix:/tmp/sw1 tcp:127.0.0.1:6633 --fail=closed --listen=ptcp:6661 1> /tmp/sw1-ofp.log 2> /tmp/sw1-ofp.log &
 
 ########## sw2 ##########
-ofdatapath -i sw2-eth1,eth1,sw2-eth3 punix:/tmp/sw2 -d 000000000002 1> /tmp/sw2-ofd.log 2> /tmp/sw2-ofd.log &
+ofdatapath -i sw2-eth1,sw2-eth2,sw2-eth3 punix:/tmp/sw2 -d 000000000002 1> /tmp/sw2-ofd.log 2> /tmp/sw2-ofd.log &
 ofprotocol unix:/tmp/sw2 tcp:127.0.0.1:6633 --fail=closed --listen=ptcp:6662 1> /tmp/sw2-ofp.log 2> /tmp/sw2-ofp.log &
 
 ########## sw3 ##########
-ofdatapath -i sw3-eth1,sw3-eth2,sw3-eth3,eth2 punix:/tmp/sw3 -d 000000000003 1> /tmp/sw3-ofd.log 2> /tmp/sw3-ofd.log &
+ofdatapath -i sw3-eth1,sw3-eth2,sw3-eth3,sw3-eth4 punix:/tmp/sw3 -d 000000000003 1> /tmp/sw3-ofd.log 2> /tmp/sw3-ofd.log &
 ofprotocol unix:/tmp/sw3 tcp:127.0.0.1:6633 --fail=closed --listen=ptcp:6663 1> /tmp/sw3-ofp.log 2> /tmp/sw3-ofp.log &
 
 ########## sw4 ##########
-ofdatapath -i sw4-eth1,eth3 punix:/tmp/sw4 -d 000000000004 1> /tmp/sw4-ofd.log 2> /tmp/sw4-ofd.log &
+ofdatapath -i sw4-eth1,sw4-eth2 punix:/tmp/sw4 -d 000000000004 1> /tmp/sw4-ofd.log 2> /tmp/sw4-ofd.log &
 ofprotocol unix:/tmp/sw4 tcp:127.0.0.1:6633 --fail=closed --listen=ptcp:6664 1> /tmp/sw4-ofp.log 2> /tmp/sw4-ofp.log &
 
+echo "Configuring OpenFlow soft switches......"
+
+ifconfig sw3-eth4 down
+ifconfig sw3-eth4 hw ether 00:00:00:00:03:04
+ifconfig sw3-eth4 up
+
+ifconfig sw4-eth2 down
+ifconfig sw4-eth2 hw ether 00:00:00:00:04:02
+ifconfig sw4-eth2 up
+
+echo "Configuring hosts......"
+
+ip netns exec server1 ifconfig server1-eth0 down
+ip netns exec server1 ifconfig server1-eth0 hw ether 00:00:00:00:00:01
+ip netns exec server1 ifconfig server1-eth0 192.168.11.2/24
+ip netns exec server1 ifconfig server1-eth0 up
+ip netns exec server1 route add default gw 192.168.11.1
+
+ip netns exec vm1 ifconfig vm1-eth0 down
+ip netns exec vm1 ifconfig vm1-eth0 hw ether 00:00:00:00:00:02
+ip netns exec vm1 ifconfig vm1-eth0 192.168.12.2/24
+ip netns exec vm1 ifconfig vm1-eth0 up
+ip netns exec vm1 route add default gw 192.168.12.1
+
+ip netns exec vm2 ifconfig vm2-eth0 down
+ip netns exec vm2 ifconfig vm2-eth0 hw ether 00:00:00:00:00:03
+ip netns exec vm2 ifconfig vm2-eth0 192.168.12.3/24
+ip netns exec vm2 ifconfig vm2-eth0 up
+ip netns exec vm2 route add default gw 192.168.12.1
+
+ip netns exec server2 ifconfig server2-eth0 down
+ip netns exec server2 ifconfig server2-eth0 hw ether 00:00:00:00:00:04
+ip netns exec server2 ifconfig server2-eth0 192.168.12.4/24
+ip netns exec server2 ifconfig server2-eth0 up
+ip netns exec server2 route add default gw 192.168.12.1
+
+ip netns exec enter ifconfig enter-eth0 down
+ip netns exec enter ifconfig enter-eth0 hw ether 00:00:00:00:00:05
+ip netns exec enter ifconfig enter-eth0 192.168.13.2/24
+ip netns exec enter ifconfig enter-eth0 up
+ip netns exec enter route add default gw 192.168.13.1
+ip netns exec enter arp -s 192.168.13.1 00:00:00:00:04:02
+
+ip netns exec inet ifconfig inet-eth0 down
+ip netns exec inet ifconfig inet-eth0 hw ether 00:00:00:00:00:06
+ip netns exec inet ifconfig inet-eth0 172.168.1.2/24
+ip netns exec inet ifconfig inet-eth0 up
+ip netns exec inet route add default gw 172.168.1.1
+ip netns exec inet arp -s 172.168.1.1 00:00:00:00:03:04
+
+echo "Configuring flow entries for topology discovery......"
+
 sleep 5
 
 ########## lldp ##########
@@ -53,66 +126,6 @@ dpctl unix:/tmp/sw2 flow-mod cmd=add,table=0,idle=0,hard=0,prio=65535 eth_type=0
 dpctl unix:/tmp/sw3 flow-mod cmd=add,table=0,idle=0,hard=0,prio=65535 eth_type=0x88cc apply:output=ctrl:0xff
 dpctl unix:/tmp/sw4 flow-mod cmd=add,table=0,idle=0,hard=0,prio=65535 eth_type=0x88cc apply:output=ctrl:0xff
 
-########## arp ##########
-dpctl unix:/tmp/sw1 flow-mod cmd=add,table=0,idle=0,hard=0,prio=65535 eth_type=0x0806 apply:output=ctrl:0xff
-dpctl unix:/tmp/sw2 flow-mod cmd=add,table=0,idle=0,hard=0,prio=65535 eth_type=0x0806 apply:output=ctrl:0xff
-dpctl unix:/tmp/sw3 flow-mod cmd=add,table=0,idle=0,hard=0,prio=65535 eth_type=0x0806 apply:output=ctrl:0xff
-dpctl unix:/tmp/sw4 flow-mod cmd=add,table=0,idle=0,hard=0,prio=65535 eth_type=0x0806 apply:output=ctrl:0xff
-
-exit 0
-
-
-
-ip netns exec server1 bash
-ifconfig server1-eth0 down
-ifconfig server1-eth0 hw ether 00:00:00:00:00:03
-ifconfig server1-eth0 192.168.11.2/24
-ifconfig server1-eth0 up
-ifconfig server1-eth0
-route add default gw 192.168.11.1
-route -n
-exit
-
-ip netns exec vm1 bash
-ifconfig vm1-eth0 down
-ifconfig vm1-eth0 hw ether 00:00:00:00:00:01
-ifconfig vm1-eth0 192.168.12.2/24
-ifconfig vm1-eth0 up
-ifconfig vm1-eth0
-route add default gw 192.168.12.1
-route -n
-exit
-
-ip netns exec vm2 bash
-ifconfig vm2-eth0 down
-ifconfig vm2-eth0 hw ether 00:00:00:00:00:02
-ifconfig vm2-eth0 192.168.12.3/24
-ifconfig vm2-eth0 up
-ifconfig vm2-eth0
-route add default gw 192.168.12.1
-route -n
-exit
-
-
-
-ip netns exec server1 bash
-ping -c 3 192.168.12.4
-ping -c 3 192.168.13.2
-ping -c 3 172.168.1.2
-exit
-
-ip netns exec vm1 bash
-ping -c 3 192.168.12.3
-ping -c 3 192.168.12.4
-ping -c 3 192.168.11.2
-ping -c 3 192.168.13.2
-ping -c 3 172.168.1.2
-exit
-
-ip netns exec vm2 bash
-ping -c 3 192.168.12.2
-ping -c 3 192.168.12.4
-ping -c 3 192.168.11.2
-ping -c 3 192.168.13.2
-ping -c 3 172.168.1.2
-exit
+echo "Creating network done."
+
+exit 0
\ No newline at end of file
index 60bb5e08b202ffdd501a638f42086733bd8d74b2..4e52dae4725e0839373977826a17868bb36838cb 100644 (file)
@@ -1,20 +1,32 @@
 #!/bin/bash
 
+echo "Creating links......"
+
 ########## sw1 ##########
+ip link add name sw1-eth1 type veth peer name fw1-eth0
 ip link add name sw1-eth2 type veth peer name fw2-eth0
 ip link add name sw1-eth3 type veth peer name sw3-eth1
 
 ########## sw2 ##########
 ip link add name sw2-eth1 type veth peer name cache1-eth0
+ip link add name sw2-eth2 type veth peer name cache2-eth0
 ip link add name sw2-eth3 type veth peer name sw3-eth2
 
 ########## sw3 ##########
 #ip link add name sw3-eth1 type veth peer name sw1-eth3
 #ip link add name sw3-eth2 type veth peer name sw2-eth3
 ip link add name sw3-eth3 type veth peer name sw4-eth1
+ip link add name sw3-eth4 type veth peer name branch-eth0
 
 ########## sw4 ##########
 #ip link add name sw4-eth1 type veth peer name sw3-eth3
+ip link add name sw4-eth2 type veth peer name head-eth0
+
+echo "Creating hosts......"
+
+########## fw1 ##########
+ip netns add fw1
+ip link set fw1-eth0 netns fw1
 
 ########## fw2 ##########
 ip netns add fw2
@@ -24,22 +36,88 @@ ip link set fw2-eth0 netns fw2
 ip netns add cache1
 ip link set cache1-eth0 netns cache1
 
+########## cache2 ##########
+ip netns add cache2
+ip link set cache2-eth0 netns cache2
+
+########## headquarter ##########
+ip netns add head
+ip link set head-eth0 netns head
+
+########## branch ##########
+ip netns add branch
+ip link set branch-eth0 netns branch
+
+echo "Starting OpenFlow soft switches......"
+
 ########## sw1 ##########
-ofdatapath -i eth0,sw1-eth2,sw1-eth3 punix:/tmp/sw1 -d 000000000001 1> /tmp/sw1-ofd.log 2> /tmp/sw1-ofd.log &
+ofdatapath -i sw1-eth1,sw1-eth2,sw1-eth3 punix:/tmp/sw1 -d 000000000001 1> /tmp/sw1-ofd.log 2> /tmp/sw1-ofd.log &
 ofprotocol unix:/tmp/sw1 tcp:127.0.0.1:6633 --fail=closed --listen=ptcp:6661 1> /tmp/sw1-ofp.log 2> /tmp/sw1-ofp.log &
 
 ########## sw2 ##########
-ofdatapath -i sw2-eth1,eth1,sw2-eth3 punix:/tmp/sw2 -d 000000000002 1> /tmp/sw2-ofd.log 2> /tmp/sw2-ofd.log &
+ofdatapath -i sw2-eth1,sw2-eth2,sw2-eth3 punix:/tmp/sw2 -d 000000000002 1> /tmp/sw2-ofd.log 2> /tmp/sw2-ofd.log &
 ofprotocol unix:/tmp/sw2 tcp:127.0.0.1:6633 --fail=closed --listen=ptcp:6662 1> /tmp/sw2-ofp.log 2> /tmp/sw2-ofp.log &
 
 ########## sw3 ##########
-ofdatapath -i sw3-eth1,sw3-eth2,sw3-eth3,eth2 punix:/tmp/sw3 -d 000000000003 1> /tmp/sw3-ofd.log 2> /tmp/sw3-ofd.log &
+ofdatapath -i sw3-eth1,sw3-eth2,sw3-eth3,sw3-eth4 punix:/tmp/sw3 -d 000000000003 1> /tmp/sw3-ofd.log 2> /tmp/sw3-ofd.log &
 ofprotocol unix:/tmp/sw3 tcp:127.0.0.1:6633 --fail=closed --listen=ptcp:6663 1> /tmp/sw3-ofp.log 2> /tmp/sw3-ofp.log &
 
 ########## sw4 ##########
-ofdatapath -i sw4-eth1,eth3 punix:/tmp/sw4 -d 000000000004 1> /tmp/sw4-ofd.log 2> /tmp/sw4-ofd.log &
+ofdatapath -i sw4-eth1,sw4-eth2 punix:/tmp/sw4 -d 000000000004 1> /tmp/sw4-ofd.log 2> /tmp/sw4-ofd.log &
 ofprotocol unix:/tmp/sw4 tcp:127.0.0.1:6633 --fail=closed --listen=ptcp:6664 1> /tmp/sw4-ofp.log 2> /tmp/sw4-ofp.log &
 
+echo "Configuring OpenFlow soft switches......"
+
+ifconfig sw1-eth1 down
+ifconfig sw1-eth1 hw ether 00:00:00:00:01:01
+ifconfig sw1-eth1 up
+
+ifconfig sw2-eth2 down
+ifconfig sw2-eth2 hw ether 00:00:00:00:02:02
+ifconfig sw2-eth2 up
+
+ifconfig sw3-eth4 down
+ifconfig sw3-eth4 hw ether 00:00:00:00:03:04
+ifconfig sw3-eth4 up
+
+ifconfig sw4-eth2 down
+ifconfig sw4-eth2 hw ether 00:00:00:00:04:02
+ifconfig sw4-eth2 up
+
+echo "Configuring hosts......"
+
+ip netns exec fw1 ifconfig fw1-eth0 down
+ip netns exec fw1 ifconfig fw1-eth0 hw ether 00:00:00:00:00:01
+ip netns exec fw1 ifconfig fw1-eth0 192.168.13.2/24
+ip netns exec fw1 ifconfig fw1-eth0 up
+ip netns exec fw1 route add default gw 192.168.13.1
+ip netns exec fw1 arp -s 192.168.13.1 00:00:00:00:01:01
+ip netns exec fw1 echo 1 > /proc/sys/net/ipv4/ip_forward
+
+ip netns exec cache2 ifconfig cache2-eth0 down
+ip netns exec cache2 ifconfig cache2-eth0 hw ether 00:00:00:00:00:02
+ip netns exec cache2 ifconfig cache2-eth0 192.168.14.2/24
+ip netns exec cache2 ifconfig cache2-eth0 up
+ip netns exec cache2 route add default gw 192.168.14.1
+ip netns exec cache2 arp -s 192.168.14.1 00:00:00:00:02:02
+ip netns exec cache2 echo 1 > /proc/sys/net/ipv4/ip_forward
+
+ip netns exec head ifconfig head-eth0 down
+ip netns exec head ifconfig head-eth0 hw ether 00:00:00:00:00:03
+ip netns exec head ifconfig head-eth0 192.168.11.2/24
+ip netns exec head ifconfig head-eth0 up
+ip netns exec head route add default gw 192.168.11.1
+ip netns exec head arp -s 192.168.11.1 00:00:00:00:04:02
+
+ip netns exec branch ifconfig branch-eth0 down
+ip netns exec branch ifconfig branch-eth0 hw ether 00:00:00:00:00:04
+ip netns exec branch ifconfig branch-eth0 192.168.12.2/24
+ip netns exec branch ifconfig branch-eth0 up
+ip netns exec branch route add default gw 192.168.12.1
+ip netns exec branch arp -s 192.168.12.1 00:00:00:00:03:04
+
+echo "Configuring flow entries for topology discovery......"
+
 sleep 5
 
 ########## lldp ##########
@@ -48,31 +126,14 @@ dpctl unix:/tmp/sw2 flow-mod cmd=add,table=0,idle=0,hard=0,prio=65535 eth_type=0
 dpctl unix:/tmp/sw3 flow-mod cmd=add,table=0,idle=0,hard=0,prio=65535 eth_type=0x88cc apply:output=ctrl:0xff
 dpctl unix:/tmp/sw4 flow-mod cmd=add,table=0,idle=0,hard=0,prio=65535 eth_type=0x88cc apply:output=ctrl:0xff
 
-exit 0
-
-
-
-ip netns exec fw2 bash
-ifconfig fw2-eth0 down
-ifconfig fw2-eth0 hw ether 00:00:00:00:00:01
-ifconfig fw2-eth0 up
-ifconfig fw2-eth0
-exit
-
-ip netns exec cache1 bash
-ifconfig cache1-eth0 down
-ifconfig cache1-eth0 hw ether 00:00:00:00:00:02
-ifconfig cache1-eth0 up
-ifconfig cache1-eth0
-exit
+echo "Creating network done."
 
+exit 0
 
 
-echo 1 > /proc/sys/net/ipv4/ip_forward
-cat /proc/sys/net/ipv4/ip_forward
 
-iptables -A FORWARD -i eth0 -j DROP
-iptables -vxnL FORWARD
+ip netns exec fw1 iptables -A FORWARD -i fw1-eth0 -j DROP
+ip netns exec fw1 iptables -vxnL FORWARD
 
-iptables -D FORWARD -i eth0 -j DROP
-iptables -vxnL FORWARD
+ip netns exec fw1 iptables -D FORWARD -i fw1-eth0 -j DROP
+ip netns exec fw1 iptables -vxnL FORWARD