Browse Source

Clean up code

Implement: Fuel install OVS with NSH/DPDK

Change-Id: I3fe071eb23f3f425e183725440c5a041f8b8cfae
Closes-Bug:#1507877
Signed-off-by: lingyu1 <ling.y.yu@intel.com>
tags/10.0-eol
lingyu1 3 years ago
parent
commit
8e950c32dc

+ 1
- 21
deployment_scripts/puppet/manifests/ovs-install-compute.pp View File

@@ -3,27 +3,7 @@ if $operatingsystem == 'Ubuntu' {
3 3
         if $fuel_settings['fuel-plugin-ovs']['use_dpdk'] {
4 4
                 $NICS = $fuel_settings['fuel-plugin-ovs']['dpdk-bind-nic']
5 5
                 exec { "install dpdk":
6
-                        command => "wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/dpdk-install.sh; bash ./dpdk-install.sh",
7
-                        path   => "/usr/bin:/usr/sbin:/bin:/sbin",
8
-                } ->
9
-                exec {'dpdk-init':
10
-                command => "wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/dpdk.init -O /etc/init.d/dpdk;chmod +x /etc/init.d/dpdk",
11
-                path   => "/usr/bin:/usr/sbin:/bin:/sbin",
12
-                } ->
13
-                exec {'dpdk-conf':
14
-                command => "wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/dpdk.conf -O /etc/default/dpdk.conf",
15
-                path   => "/usr/bin:/usr/sbin:/bin:/sbin",
16
-                } ->
17
-                exec {'adapt_conf_file':
18
-                command => "sed 's/DPDK_NIC_MAPPINGS=.*/DPDK_NIC_MAPPINGS=${NICS}/' -i /etc/default/dpdk.conf",
19
-                path   => "/usr/bin:/usr/sbin:/bin:/sbin",
20
-                } ->
21
-                exec {'dpdk start':
22
-                command => "bash /etc/init.d/dpdk start",
23
-                path   => "/usr/bin:/usr/sbin:/bin:/sbin",
24
-                } ->
25
-                exec { "install ovs with dpdk":
26
-                        command => "wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/ovs-dpdk-install.sh; bash ./ovs-dpdk-install.sh",
6
+                        command => "wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/dpdk-install.sh; bash ./dpdk-install.sh $NICS",
27 7
                         path   => "/usr/bin:/usr/sbin:/bin:/sbin",
28 8
                 }
29 9
         } else {

+ 1
- 21
deployment_scripts/puppet/manifests/ovs-install-controller.pp View File

@@ -3,27 +3,7 @@ if $operatingsystem == 'Ubuntu' {
3 3
         if $fuel_settings['fuel-plugin-ovs']['use_dpdk'] {
4 4
                 $NICS = $fuel_settings['fuel-plugin-ovs']['dpdk-bind-nic']
5 5
                 exec { "install dpdk":
6
-                        command => "wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/dpdk-install.sh; bash ./dpdk-install.sh",
7
-                        path   => "/usr/bin:/usr/sbin:/bin:/sbin",
8
-                } ->
9
-                exec {'dpdk-init':
10
-                command => "wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/dpdk.init -O /etc/init.d/dpdk;chmod +x /etc/init.d/dpdk",
11
-                path   => "/usr/bin:/usr/sbin:/bin:/sbin",
12
-                } ->
13
-                exec {'dpdk-conf':
14
-                command => "wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/dpdk.conf -O /etc/default/dpdk.conf",
15
-                path   => "/usr/bin:/usr/sbin:/bin:/sbin",
16
-                } ->
17
-                exec {'adapt_conf_file':
18
-                command => "sed 's/DPDK_NIC_MAPPINGS=.*/DPDK_NIC_MAPPINGS=${NICS}/' -i /etc/default/dpdk.conf",
19
-                path   => "/usr/bin:/usr/sbin:/bin:/sbin",
20
-                } ->
21
-                exec {'dpdk start':
22
-                command => "bash /etc/init.d/dpdk start",
23
-                path   => "/usr/bin:/usr/sbin:/bin:/sbin",
24
-                } ->
25
-                exec { "install ovs with dpdk":
26
-                        command => "wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/ovs-dpdk-install.sh; bash ./ovs-dpdk-install.sh",
6
+                        command => "wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/dpdk-install.sh; bash ./dpdk-install.sh $NICS",
27 7
                         path   => "/usr/bin:/usr/sbin:/bin:/sbin",
28 8
                 }
29 9
         } else {

+ 1
- 21
deployment_scripts/puppet/manifests/ovs-install-primary-controller.pp View File

@@ -3,27 +3,7 @@ if $operatingsystem == 'Ubuntu' {
3 3
         if $fuel_settings['fuel-plugin-ovs']['use_dpdk'] {
4 4
                 $NICS = $fuel_settings['fuel-plugin-ovs']['dpdk-bind-nic']
5 5
                 exec { "install dpdk":
6
-                        command => "wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/dpdk-install.sh; bash ./dpdk-install.sh",
7
-                        path   => "/usr/bin:/usr/sbin:/bin:/sbin",
8
-                } ->
9
-                exec {'dpdk-init':
10
-                command => "wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/dpdk.init -O /etc/init.d/dpdk;chmod +x /etc/init.d/dpdk",
11
-                path   => "/usr/bin:/usr/sbin:/bin:/sbin",
12
-                } ->
13
-                exec {'dpdk-conf':
14
-                command => "wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/dpdk.conf -O /etc/default/dpdk.conf",
15
-                path   => "/usr/bin:/usr/sbin:/bin:/sbin",
16
-                } ->
17
-                exec {'adapt_conf_file':
18
-                command => "sed 's/DPDK_NIC_MAPPINGS=.*/DPDK_NIC_MAPPINGS=${NICS}/' -i /etc/default/dpdk.conf",
19
-                path   => "/usr/bin:/usr/sbin:/bin:/sbin",
20
-                } ->
21
-                exec {'dpdk start':
22
-                command => "bash /etc/init.d/dpdk start",
23
-                path   => "/usr/bin:/usr/sbin:/bin:/sbin",
24
-                } ->
25
-                exec { "install ovs with dpdk":
26
-                        command => "wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/ovs-dpdk-install.sh; bash ./ovs-dpdk-install.sh",
6
+                        command => "wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/dpdk-install.sh; bash ./dpdk-install.sh $NICS",
27 7
                         path   => "/usr/bin:/usr/sbin:/bin:/sbin",
28 8
                 }
29 9
         } else {

+ 15
- 2
repositories/ubuntu/dpdk/dpdk-install.sh View File

@@ -1,10 +1,23 @@
1 1
 #!/bin/bash
2
-set -eux
3 2
 
3
+NICS=$1
4 4
 INSTALL_HOME=/usr/share/dpdk/
5 5
 sudo rm -rf $INSTALL_HOME ; mkdir -p $INSTALL_HOME
6 6
 cd $INSTALL_HOME
7 7
 wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/dpdk-2.1.0.tar.gz;
8 8
 tar -xvzf dpdk-2.1.0.tar.gz
9 9
 cd $INSTALL_HOME/dpdk-2.1.0; make install T=x86_64-native-linuxapp-gcc
10
-
10
+wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/dpdk.init -O /etc/init.d/dpdk
11
+chmod +x /etc/init.d/dpdk
12
+wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/dpdk.conf -O /etc/default/dpdk.conf
13
+sed "s/DPDK_NIC_MAPPINGS=.*/DPDK_NIC_MAPPINGS=${NICS}/" -i /etc/default/dpdk.conf
14
+sudo service dpdk start
15
+INSTALL_HOME=/usr/share/ovs-dpdk/
16
+sudo rm -rf $INSTALL_HOME ; mkdir -p $INSTALL_HOME
17
+cd $INSTALL_HOME
18
+wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/openvswitch-datapath-dkms_2.4.90-1_all.deb
19
+sudo dpkg -i openvswitch-datapath-dkms_2.4.90-1_all.deb
20
+wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/openvswitch-common_2.4.90-1_amd64.deb
21
+sudo dpkg -i openvswitch-common_2.4.90-1_amd64.deb
22
+wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/openvswitch-switch_2.4.90-1_amd64.deb
23
+sudo dpkg -i openvswitch-switch_2.4.90-1_amd64.deb

+ 59
- 3
repositories/ubuntu/dpdk/dpdk.init View File

@@ -14,7 +14,6 @@
14 14
 # See the License for the specific language governing permissions and
15 15
 # limitations under the License.
16 16
 #
17
-set -eux
18 17
 echo "sourcing config"
19 18
 source /etc/default/dpdk.conf
20 19
 
@@ -22,6 +21,53 @@ RTE_SDK=${RTE_SDK:-/usr/share/dpdk/dpdk-2.1.0}
22 21
 RTE_TARGET=${RTE_TARGET:-x86_64-native-linuxapp-gcc}
23 22
 DPDK_DIR=$RTE_SDK
24 23
 
24
+
25
+remove_igb_uio_module(){
26
+    sudo rmmod igb_uio
27
+}
28
+
29
+unbind_nics(){
30
+    NICS=`RTE_SDK=${DPDK_DIR} RTE_TARGET=build ${DPDK_DIR}/tools/dpdk_nic_bind.py --status | grep drv=igb_uio | head -1`
31
+    while [ "${NICS}" != "" ]
32
+    do
33
+        BUSID=`echo "${NICS}" | awk '{ print $1 }'`
34
+        NANTIC=`echo "${NICS}" | grep "82574L"`
35
+        FVL=`echo "${NICS}" | grep "X710"`
36
+        RRC=`echo "${NICS}" | grep "82576"`
37
+        EM=`echo "${NICS}" | grep "82540EM"`
38
+        if [ "${NANTIC}" != "" ] ;then
39
+            DRIVER=e1000e
40
+        elif [ "${FVL}" != "" ] ;then
41
+            DRIVER=i40e
42
+        elif [ "${RRC}" != "" ] ;then
43
+            DRIVER=igb
44
+        elif [ "${EM}" != "" ] ;then
45
+            DRIVER=e1000
46
+        else
47
+            DRIVER=ixgbe
48
+        fi
49
+        sudo RTE_SDK=${DPDK_DIR} RTE_TARGET=build ${DPDK_DIR}/tools/dpdk_nic_bind.py -b ${DRIVER} ${BUSID}
50
+        NICS=`RTE_SDK=${DPDK_DIR} RTE_TARGET=build ${DPDK_DIR}/tools/dpdk_nic_bind.py --status | grep drv=igb_uio | head -1`
51
+    done
52
+}
53
+
54
+free_hugepages() {
55
+    HUGEPAGE_SIZE=$(grep Hugepagesize /proc/meminfo | awk '{ print $2 }')
56
+
57
+    if [ -d $DPDK_HUGEPAGE_MOUNT ]; then
58
+       sudo rm -rf ${DPDK_HUGEPAGE_MOUNT}/rtemap*
59
+    fi
60
+
61
+    sudo umount ${DPDK_HUGEPAGE_MOUNT}
62
+
63
+    # de-allocate hugepages
64
+    if [ $DPDK_ALLOCATE_HUGEPAGES == 'True' ]; then
65
+       for d in /sys/devices/system/node/node? ; do
66
+          echo 0 | sudo tee $d/hugepages/hugepages-${HUGEPAGE_SIZE}kB/nr_hugepages
67
+       done
68
+    fi
69
+}
70
+
25 71
 load_igb_uio_module(){
26 72
     if [ ! -f $RTE_SDK/$RTE_TARGET/kmod/igb_uio.ko ];then
27 73
         echo "## ERROR: Target does not have the DPDK UIO Kernel Module."
@@ -77,13 +123,23 @@ cmd_start(){
77 123
     load_igb_uio_module
78 124
     bind_nics
79 125
 }
80
-
126
+cmd_stop(){
127
+    #if physical nics bindings are defined, bind nics with linux driver
128
+    echo "rebinding nics to linux_driver"
129
+    unbind_nics
130
+    remove_igb_uio_module
131
+    echo "unmounting hugepages"
132
+    free_hugepages
133
+}
81 134
 case "$1" in
82 135
     start)
83 136
         cmd_start
84 137
         ;;
138
+    stop)
139
+        cmd_stop
140
+    ;;
85 141
     *)
86
-        echo "Usage: $0 {start}" >&2
142
+        echo "Usage: $0 {start|stop}" >&2
87 143
         exit 1
88 144
         ;;
89 145
 esac

+ 0
- 12
repositories/ubuntu/dpdk/ovs-dpdk-install.sh View File

@@ -1,12 +0,0 @@
1
-#!/bin/bash
2
-set -eux
3
-
4
-INSTALL_HOME=/usr/share/ovs-dpdk/
5
-sudo rm -rf $INSTALL_HOME ; mkdir -p $INSTALL_HOME
6
-cd $INSTALL_HOME
7
-wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/openvswitch-datapath-dkms_2.4.90-1_all.deb
8
-sudo dpkg -i openvswitch-datapath-dkms_2.4.90-1_all.deb
9
-wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/openvswitch-common_2.4.90-1_amd64.deb
10
-sudo dpkg -i openvswitch-common_2.4.90-1_amd64.deb
11
-wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/openvswitch-switch_2.4.90-1_amd64.deb
12
-sudo dpkg -i openvswitch-switch_2.4.90-1_amd64.deb

Loading…
Cancel
Save