Improve linux_net.py patch
[ovsnfv.git] / fuel-plugin-ovsnfv / deployment_scripts / puppet / modules / ovsdpdk / files / linux_net.sh
1 #!/usr/bin/env bash
2
3 # This script is patching /usr/lib/python2.7/dist-packages/nova/network/linux_net.py
4 # More specifically it's adding '1' as recognized exit code
5 # it's WA and will work just when _setr_device_mtu will not change dramatically
6
7 # step1) get ROW for patching
8 FILE="/usr/lib/python2.7/dist-packages/nova/network/linux_net.py"
9
10 ROW=`grep -n "def _set_device_mtu(dev, mtu=None):" $FILE | cut -d ":" -f 1`
11
12 # step2) use sed for patching it
13
14 sed -i.bck "$((ROW+8))s/check_exit_code=\[0, 2, 254\]/check_exit_code=\[0, 1, 2, 254\]/" $FILE
15
16 diff $FILE $FILE.bck
17
18 if [ $? -eq 0 ]; then
19   echo "WARNING: linux_net.py not patched, please check if it's really needed"
20 else
21   echo "SUCCESS: linux_net.py patched"
22 fi