Browse code

Merge "Add support for configuring OVS to work with OpenDaylight"

Jenkins authored on 2014/03/08 03:53:58
Showing 5 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,67 @@
0
+# opendaylight.sh - DevStack extras script
1
+
2
+# Need this first to get the is_***_enabled for ODL
3
+source $TOP_DIR/lib/opendaylight
4
+
5
+if is_service_enabled odl-server; then
6
+    if [[ "$1" == "source" ]]; then
7
+        # no-op
8
+        :
9
+    elif [[ "$1" == "stack" && "$2" == "install" ]]; then
10
+        install_opendaylight
11
+        configure_opendaylight
12
+        init_opendaylight
13
+    elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
14
+        # This has to start before Neutron
15
+        start_opendaylight
16
+    elif [[ "$1" == "stack" && "$2" == "post-extra" ]]; then
17
+        # no-op
18
+        :
19
+    fi
20
+
21
+    if [[ "$1" == "unstack" ]]; then
22
+        stop_opendaylight
23
+        cleanup_opendaylight
24
+    fi
25
+
26
+    if [[ "$1" == "clean" ]]; then
27
+        # no-op
28
+        :
29
+    fi
30
+fi
31
+
32
+if is_service_enabled odl-compute; then
33
+    if [[ "$1" == "source" ]]; then
34
+        # no-op
35
+        :
36
+    elif [[ "$1" == "stack" && "$2" == "install" ]]; then
37
+        install_opendaylight-compute
38
+    elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
39
+        create_nova_conf_neutron
40
+    elif [[ "$1" == "stack" && "$2" == "extra" ]]; then
41
+        echo_summary "Initializing OpenDaylight"
42
+        ODL_LOCAL_IP=${ODL_LOCAL_IP:-$HOST_IP}
43
+        ODL_MGR_PORT=${ODL_MGR_PORT:-6640}
44
+        read ovstbl <<< $(sudo ovs-vsctl get Open_vSwitch . _uuid)
45
+        sudo ovs-vsctl set-manager tcp:$ODL_MGR_IP:$ODL_MGR_PORT
46
+        sudo ovs-vsctl set Open_vSwitch $ovstbl other_config={"local_ip"="$ODL_LOCAL_IP"}
47
+    elif [[ "$1" == "stack" && "$2" == "post-extra" ]]; then
48
+        # no-op
49
+        :
50
+    fi
51
+
52
+    if [[ "$1" == "unstack" ]]; then
53
+        sudo ovs-vsctl del-manager
54
+        BRIDGES=$(sudo ovs-vsctl list-br)
55
+        for bridge in $BRIDGES ; do
56
+            sudo ovs-vsctl del-controller $bridge
57
+        done
58
+
59
+        stop_opendaylight-compute
60
+    fi
61
+
62
+    if [[ "$1" == "clean" ]]; then
63
+        # no-op
64
+        :
65
+    fi
66
+fi
0 67
new file mode 100644
... ...
@@ -0,0 +1,2 @@
0
+openvswitch-datapath-dkms # NOPRIME
1
+openvswitch-switch # NOPRIME
0 2
new file mode 100644
... ...
@@ -0,0 +1,4 @@
0
+openvswitch # NOPRIME
1
+openvswitch-controller # NOPRIME
2
+openvswitch-switch # NOPRIME
3
+
0 4
new file mode 100644
... ...
@@ -0,0 +1 @@
0
+openvswitch # NOPRIME
0 1
new file mode 100644
... ...
@@ -0,0 +1,167 @@
0
+# lib/opendaylight
1
+# Functions to control the configuration and operation of the opendaylight service
2
+
3
+# Dependencies:
4
+#
5
+# - ``functions`` file
6
+# # ``DEST`` must be defined
7
+# # ``STACK_USER`` must be defined
8
+
9
+# ``stack.sh`` calls the entry points in this order:
10
+#
11
+# - is_opendaylight_enabled
12
+# - is_opendaylight-compute_enabled
13
+# - install_opendaylight
14
+# - install_opendaylight-compute
15
+# - configure_opendaylight
16
+# - init_opendaylight
17
+# - start_opendaylight
18
+# - stop_opendaylight-compute
19
+# - stop_opendaylight
20
+# - cleanup_opendaylight
21
+
22
+# Save trace setting
23
+XTRACE=$(set +o | grep xtrace)
24
+set +o xtrace
25
+
26
+
27
+# For OVS_BRIDGE and PUBLIC_BRIDGE
28
+source $TOP_DIR/lib/neutron_plugins/ovs_base
29
+
30
+# Defaults
31
+# --------
32
+
33
+# The IP address of ODL. Set this in local.conf.
34
+# ODL_MGR_IP=
35
+ODL_MGR_IP=${ODL_MGR_IP:-$SERVICE_HOST}
36
+
37
+# <define global variables here that belong to this project>
38
+ODL_DIR=$DEST/opendaylight
39
+
40
+# The OpenDaylight Package, currently using 'Hydrogen' release
41
+ODL_PKG=${ODL_PKG:-distributions-virtualization-0.1.1-osgipackage.zip}
42
+
43
+# The OpenDaylight URL
44
+ODL_URL=${ODL_URL:-https://nexus.opendaylight.org/content/repositories/opendaylight.release/org/opendaylight/integration/distributions-virtualization/0.1.1}
45
+
46
+# Default arguments for OpenDaylight. This is typically used to set
47
+# Java memory options.
48
+#   ODL_ARGS=Xmx1024m -XX:MaxPermSize=512m
49
+ODL_ARGS=${ODL_ARGS:-"-XX:MaxPermSize=384m"}
50
+
51
+# How long to pause after ODL starts to let it complete booting
52
+ODL_BOOT_WAIT=${ODL_BOOT_WAIT:-60}
53
+
54
+# Set up default directories
55
+
56
+
57
+# Entry Points
58
+# ------------
59
+
60
+# Test if OpenDaylight is enabled
61
+# is_opendaylight_enabled
62
+function is_opendaylight_enabled {
63
+    [[ ,${ENABLED_SERVICES} =~ ,"odl-" ]] && return 0
64
+    return 1
65
+}
66
+
67
+# cleanup_opendaylight() - Remove residual data files, anything left over from previous
68
+# runs that a clean run would need to clean up
69
+function cleanup_opendaylight {
70
+    :
71
+}
72
+
73
+# configure_opendaylight() - Set config files, create data dirs, etc
74
+function configure_opendaylight {
75
+    # Remove simple forwarder
76
+    rm -f $ODL_DIR/opendaylight/plugins/org.opendaylight.controller.samples.simpleforwarding*
77
+
78
+    # Configure OpenFlow 1.3
79
+    echo "ovsdb.of.version=1.3" >> $ODL_DIR/opendaylight/configuration/config.ini
80
+}
81
+
82
+# init_opendaylight() - Initialize databases, etc.
83
+function init_opendaylight {
84
+    # clean up from previous (possibly aborted) runs
85
+    # create required data files
86
+    :
87
+}
88
+
89
+# install_opendaylight() - Collect source and prepare
90
+function install_opendaylight {
91
+    local _pwd=$(pwd)
92
+
93
+    if is_ubuntu; then
94
+        install_package maven openjdk-7-jre openjdk-7-jdk
95
+    else
96
+        yum_install maven java-1.7.0-openjdk
97
+    fi
98
+
99
+    # Download OpenDaylight
100
+    mkdir -p $ODL_DIR
101
+    cd $ODL_DIR
102
+    wget -N $ODL_URL/$ODL_PKG
103
+    unzip -u $ODL_PKG
104
+}
105
+
106
+# install_opendaylight-compute - Make sure OVS is install
107
+function install_opendaylight-compute {
108
+    local kernel_version
109
+    # Install deps
110
+    # FIXME add to ``files/apts/neutron``, but don't install if not needed!
111
+    if is_ubuntu; then
112
+        kernel_version=`cat /proc/version | cut -d " " -f3`
113
+        install_package make fakeroot dkms openvswitch-switch openvswitch-datapath-dkms linux-headers-$kernel_version
114
+    elif is_fedora; then
115
+        install_package openvswitch
116
+        # Ensure that the service is started
117
+        restart_service openvswitch
118
+    elif is_suse; then
119
+        install_package openvswitch
120
+        restart_service openvswitch-switch
121
+        restart_service openvswitch-controller
122
+    fi
123
+}
124
+
125
+# start_opendaylight() - Start running processes, including screen
126
+function start_opendaylight {
127
+    if is_ubuntu; then
128
+        JHOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64
129
+    else
130
+        JHOME=/usr/lib/jvm/java-1.7.0-openjdk
131
+    fi
132
+
133
+    # The flags to ODL have the following meaning:
134
+    #   -of13: runs ODL using OpenFlow 1.3 protocol support.
135
+    #   -virt ovsdb: Runs ODL in "virtualization" mode with OVSDB support
136
+    screen_it odl-server "cd $ODL_DIR/opendaylight && JAVE_HOME=$JHOME ./run.sh $ODL_ARGS -of13 -virt ovsdb"
137
+
138
+    # Sleep a bit to let OpenDaylight finish starting up
139
+    sleep $ODL_BOOT_WAIT
140
+}
141
+
142
+# stop_opendaylight() - Stop running processes (non-screen)
143
+function stop_opendaylight {
144
+    screen_stop odl-server
145
+}
146
+
147
+# stop_opendaylight-compute() - Remove OVS bridges
148
+function stop_opendaylight-compute {
149
+    # remove all OVS ports that look like Neutron created ports
150
+    for port in $(sudo ovs-vsctl list port | grep -o -e tap[0-9a-f\-]* -e q[rg]-[0-9a-f\-]*); do
151
+        sudo ovs-vsctl del-port ${port}
152
+    done
153
+
154
+    # remove all OVS bridges created by Neutron
155
+    for bridge in $(sudo ovs-vsctl list-br | grep -o -e ${OVS_BRIDGE} -e ${PUBLIC_BRIDGE}); do
156
+        sudo ovs-vsctl del-br ${bridge}
157
+    done
158
+}
159
+
160
+# Restore xtrace
161
+$XTRACE
162
+
163
+# Tell emacs to use shell-script-mode
164
+## Local variables:
165
+## mode: shell-script
166
+## End: