3 # Copyright (c) 2016 Open Platform for NFV Project, Inc. and its contributors
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 # Small script for calculation of cores not suitable for deployment
18 # of VM's and adaptation of nova.conf accordingly
19 # nova.conf path should come as first param
20 # this should be executed when nova is enabled and already configured
22 source /etc/default/ovs-dpdk
24 OVS_CORE_MASK=$(echo $OVS_CORE_MASK | sed 's/^0x//')
25 OVS_PMD_CORE_MASK=$(echo $OVS_PMD_CORE_MASK | sed 's/^0x//')
26 BAD_CORES=$((`echo $((16#${OVS_CORE_MASK}))` | `echo $((16#${OVS_PMD_CORE_MASK}))`))
30 for cpu in $(seq 0 `expr $TOTAL_CORES - 1`);do
31 tmp=`echo 2^$cpu | bc`
32 if [ $(($tmp & $BAD_CORES)) -eq 0 ]; then
36 vcpu_pin_set=${vcpu_pin_set::-1}
38 crudini --set $1 DEFAULT vcpu_pin_set $vcpu_pin_set