Updates docs for SR1 with final revision
[genesis.git] / fuel / build / f_example_control_bond / puppet / modules / opnfv / files / control-bond
1 ##############################################################################
2 # Copyright (c) 2015 Ericsson AB and others.
3 # stefan.k.berg@ericsson.com
4 # jonas.bjurel@ericsson.com
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10
11 #!/bin/sh
12 ### BEGIN INIT INFO
13 # Provides:          control-bond
14 # Required-Start:    $remote_fs $all
15 # Required-Stop:
16 # Default-Start:     2 3 4 5
17 # Default-Stop:     0 1 6
18 # Short-Description: Bonds eth0 and eth1 and changes bridge configuration.
19 ### END INIT INFO
20
21
22 PATH=/sbin:/usr/sbin:/bin:/usr/bin
23 VSCTL=/usr/bin/ovs-vsctl
24 APPCTL=/usr/bin/ovs-appctl
25
26
27 add_control_bond() {
28         logger "Starting addition of control-bond"
29         $VSCTL --may-exist br-fw-admin
30         $VSCTL --may-exist br-mgmt
31         $VSCTL add-bond br-fw-admin bond-control eth0 eth1
32
33         $VSCTL set port br-mgmt tag=66
34         $APPCTL bond/set-active-slave bond-control eth0
35
36         $VSCTL add-port br-fw-admin admin-to-mgmt
37         $VSCTL add-port br-mgmt mgmt-to-admin
38         $VSCTL set interface admin-to-mgmt type=patch
39         $VSCTL set interface mgmt-to-admin type=patch
40
41         $VSCTL set interface admin-to-mgmt options:peer=mgmt-to-admin
42         $VSCTL set interface mgmt-to-admin options:peer=admin-to-mgmt
43
44         $VSCTL set port admin-to-mgmt trunk=66
45         $VSCTL set port mgmt-to-admin trunk=66
46         logger "Finished addition of control-bond"
47 }
48
49 status_control_bond() {
50        if [ ! -f $VSCTL ]; then
51          return 1
52        else
53          $VSCTL show | grep -q "admin-to-mgmt"
54          return $?
55        fi
56 }
57
58 case "$1" in
59     start)
60         status_control_bond
61         if [ $? -eq 0 ]; then
62             exit 0
63         else
64             add_control_bond
65         fi
66         ;;
67     restart|reload|force-reload)
68         echo "Error: argument '$1' not supported" >&2
69         exit 3
70         ;;
71     status)
72         status_control_bond
73         if [ $? -eq 0 ]; then
74            echo "The control-bond is enabled"
75            exit 0
76         else
77            echo "The control-bond is disabled"
78            exit 1
79         fi
80
81         ;;
82     stop)
83         echo "Stop is not supported"
84         exit 0
85         ;;
86     *)
87         echo "Usage: $0 start|status" >&2
88         exit 3
89         ;;
90 esac