clean up rest server and related demo scripts
diff --git a/scripts/all-linkup.sh b/scripts/all-linkup.sh
index 9067012..290a17d 100755
--- a/scripts/all-linkup.sh
+++ b/scripts/all-linkup.sh
@@ -3,11 +3,6 @@
controller=`hostname`
switches=`sudo ovs-vsctl list-br`
-function host2ip (){
- ip=`grep $1 /etc/hosts |grep -v "ip6"| awk '{print $1}'`
- echo $ip
-}
-
for s in $switches; do
ports=`sudo ovs-vsctl --pretty list-ports $s`
for p in $ports; do
diff --git a/scripts/ctrl-local.sh b/scripts/ctrl-local.sh
index 023a9db..1418a2c 100755
--- a/scripts/ctrl-local.sh
+++ b/scripts/ctrl-local.sh
@@ -1,9 +1,8 @@
#! /bin/bash
controller=`hostname`
-switches=`ifconfig -a | grep sw |grep -v eth | awk '{print $1}'`
-
+switches=`sudo ovs-vsctl list-br`
function host2ip (){
- ip=`grep $1 /etc/hosts |grep -v "ip6"| awk '{print $1}'`
+ ip=`getent hosts $1 | awk '{print $1}' | tail -n 1`
echo $ip
}
diff --git a/scripts/ctrl-none.sh b/scripts/ctrl-none.sh
index 74349e3..fb8d2a0 100755
--- a/scripts/ctrl-none.sh
+++ b/scripts/ctrl-none.sh
@@ -1,9 +1,8 @@
#! /bin/bash
controller=""
-switches=`ifconfig -a | grep sw |grep -v eth | awk '{print $1}'`
-
+switches=`sudo ovs-vsctl list-br`
function host2ip (){
- ip=`grep $1 /etc/hosts |grep -v "ip6"| awk '{print $1}'`
+ ip=`getent hosts $1 | awk '{print $1}' | tail -n 1`
echo $ip
}
diff --git a/scripts/ctrl-one.sh b/scripts/ctrl-one.sh
index 207d3f2..9fe8341 100755
--- a/scripts/ctrl-one.sh
+++ b/scripts/ctrl-one.sh
@@ -8,10 +8,9 @@
#controller=`hostname`
controller=$1
-switches=`ifconfig -a | grep sw |grep -v eth | awk '{print $1}'`
-
+switches=`sudo ovs-vsctl list-br`
function host2ip (){
- ip=`grep $1 /etc/hosts |grep -v "ip6"| awk '{print $1}'`
+ ip=`getent hosts $1 | awk '{print $1}' | tail -n 1`
echo $ip
}
diff --git a/scripts/link.sh b/scripts/link.sh
index dc202e7..57323ef 100755
--- a/scripts/link.sh
+++ b/scripts/link.sh
@@ -1,7 +1,7 @@
#! /bin/bash
controller=`hostname`
-switches=`ifconfig -a | grep sw |grep -v eth | awk '{print $1}'`
+switches=`sudo ovs-vsctl list-br`
function host2ip (){
ip=`grep $1 /etc/hosts |grep -v "ip6"| awk '{print $1}'`
@@ -12,14 +12,16 @@
if [ $# != 3 ];then
echo "usage: $0 <dpid> <port> <up|down>"
+ echo " example: $0 00:00:00:00:ba:5e:ba:11 1 up"
+ exit
fi
-src_dpid="dpid:"`echo $1 | sed s'/://g'`
+src_dpid=`echo $1 | sed s'/://g'`
src_port=$2
cmd=$3
for s in $switches; do
- dpid=`sudo ovs-ofctl show $s |grep dpid | awk '{print $4}'`
+ dpid=`sudo ovs-ofctl show $s |grep dpid | awk '{if(match($0,/dpid:[0-9|a-d]*/)){ print substr($0,RSTART+5,RLENGTH)}}'`
if [ "x$dpid" == "x$src_dpid" ]; then
# intf=`sudo ovs-ofctl show $s |grep addr | awk -v p=$src_port 'BEGIN {pat="^ "p"\("}
diff --git a/scripts/showdpid.sh b/scripts/showdpid.sh
index 1dff291..14b6345 100755
--- a/scripts/showdpid.sh
+++ b/scripts/showdpid.sh
@@ -2,17 +2,6 @@
controller=""
#switches=`ifconfig -a | grep sw |grep -v eth | awk '{print $1}'`
switches=`sudo ovs-vsctl list-br`
-
-function host2ip (){
- ip=`grep $1 /etc/hosts |grep -v "ip6"| awk '{print $1}'`
- echo $ip
-}
-
-url=""
-for c in $controller; do
- url="$url tcp:`host2ip $c`:6633"
-done
-echo $url
for s in $switches; do
echo -n "$s : "
sudo ovs-ofctl show $s |grep dpid
diff --git a/scripts/showflow.sh b/scripts/showflow.sh
index 15824d7..63b82b7 100755
--- a/scripts/showflow.sh
+++ b/scripts/showflow.sh
@@ -2,11 +2,6 @@
controller=""
switches=`sudo ovs-vsctl list-br`
-function host2ip (){
- ip=`grep $1 /etc/hosts |grep -v "ip6"| awk '{print $1}'`
- echo $ip
-}
-
dpids=()
for s in $switches; do
i=`sudo ovs-ofctl show $s |grep dpid | awk -F ":" '{print $4}'`