~wuwenbin2/onosfw/openvswitch-onos

« back to all changes in this revision

Viewing changes to files/onos_pre.sh

  • Committer: wuwenbin2
  • Date: 2016-01-30 09:31:12 UTC
  • Revision ID: git-v1:3c7d911b6f3cfb783e1936e31eac1ef3633ad16c
add onos_pre.sh

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
ifconfig | grep onos_port
 
3
 
 
4
if [ $? -eq 1 ];then
 
5
  
 
6
  external_port="eth1";
 
7
  
 
8
  if [[ -z "$1" ]]; then
 
9
    return 1
 
10
  else
 
11
    external_port=$1
 
12
  fi
 
13
  
 
14
  ifconfig | grep br-ex
 
15
 
 
16
  if [ $? -eq 1 ];then
 
17
    echo "create br-ex with ${external_port} in computer node"
 
18
    sudo ovs-vsctl add-br br-ex
 
19
    sudo ovs-vsctl add-port br-ex ${external_port}
 
20
  fi
 
21
 
 
22
  echo "ready to create onos_port"
 
23
  sudo ip link add onos_port1 type veth peer name onos_port2
 
24
  sudo ifconfig onos_port1 up
 
25
  sudo ifconfig onos_port2 up
 
26
 
 
27
  external_mac=$(ifconfig ${external_port} | \
 
28
                 grep -Eo "[0-9a-f\]+:[0-9a-f\]+:[0-9a-f\]+:[0-9a-f\]+:[0-9a-f\]+:[0-9a-f\]+")
 
29
 
 
30
  sudo ifconfig onos_port2 hw ether ${external_mac}
 
31
  sudo ovs-vsctl add-port br-ex onos_port1
 
32
else
 
33
  echo "onos_port already exist"
 
34
 
 
35
fi