fuel plugin: Initial version
[ovsnfv.git] / fuel-plugin-ovsnfv / deployment_scripts / puppet / modules / ovsdpdk / files / set_vcpu_pin.sh
1 #!/usr/bin/env  bash
2
3 # Small script for calculation of cores not suitable for deployment
4 # of VM's and adaptation of nova.conf accordingly
5 # nova.conf path should come as first param
6 # this should be executed when nova is enabled and already configured
7
8 source /etc/default/ovs-dpdk
9
10 OVS_CORE_MASK=$(echo $OVS_CORE_MASK | sed 's/^0x//')
11 OVS_PMD_CORE_MASK=$(echo $OVS_PMD_CORE_MASK | sed 's/^0x//')
12 BAD_CORES=$((`echo $((16#${OVS_CORE_MASK}))` | `echo $((16#${OVS_PMD_CORE_MASK}))`))
13 TOTAL_CORES=`nproc`
14 vcpu_pin_set=""
15
16 for cpu in $(seq 0 `expr $TOTAL_CORES - 1`);do
17     tmp=`echo 2^$cpu | bc`
18     if [ $(($tmp & $BAD_CORES)) -eq 0 ]; then
19         vcpu_pin_set+=$cpu","
20     fi
21 done
22 vcpu_pin_set=${vcpu_pin_set::-1}
23
24 crudini --set $1 DEFAULT vcpu_pin_set $vcpu_pin_set