a4663ff357840e1e55d84bf36b972c7dfe812ffa
[apex.git] / build / ovs-dpdk-preconfig.yaml
1 heat_template_version: 2014-10-16
2
3 description: >
4   Example extra config for post-deployment
5
6 parameters:
7   server:
8     type: string
9   OvsDpdkCoreList:
10     description: >
11       List of logical cores for OVS DPDK
12     type: string
13     default: ""
14   OvsDpdkSocketMemory:
15     description: Memory allocated for each socket
16     default: ""
17     type: string
18   PmdCoreList:
19     description: >
20       A list or range of physical CPU cores to be pinned to PMD
21       The given args will be appended to the tuned cpu-partitioning profile.
22       Ex. HostCpusList: '4-12' will tune cores from 4-12
23     type: string
24     default: ""
25
26 resources:
27   OvsDpdkSetup:
28     type: OS::Heat::StructuredDeployment
29     properties:
30       server:  {get_param: server}
31       config: {get_resource: OvsDpdkConfig}
32
33   OvsDpdkConfig:
34     type: OS::Heat::SoftwareConfig
35     properties:
36       group: script
37       config:
38         str_replace:
39           template: |
40             #!/bin/bash
41             set -x
42             get_mask()
43             {
44               local list=$1
45               local mask=0
46               declare -a bm
47               max_idx=0
48               for core in $(echo $list | sed 's/,/ /g')
49               do
50                   index=$(($core/32))
51                   bm[$index]=0
52                   if [ $max_idx -lt $index ]; then
53                      max_idx=$index
54                   fi
55               done
56               for ((i=$max_idx;i>=0;i--));
57               do
58                   bm[$i]=0
59               done
60               for core in $(echo $list | sed 's/,/ /g')
61               do
62                   index=$(($core/32))
63                   temp=$((1<<$core))
64                   bm[$index]=$((${bm[$index]} | $temp))
65               done
66               printf -v mask "%x" "${bm[$max_idx]}"
67               for ((i=$max_idx-1;i>=0;i--));
68               do
69                   printf -v hex "%08x" "${bm[$i]}"
70                   mask+=$hex
71               done
72               printf "%s" "$mask"
73             }
74             pmd_cpu_mask=$( get_mask $PMD_CORES )
75             dpdk_lcore_mask=$( get_mask $DPDK_CORES )
76             yum remove -y vpp-devel
77             yum install -y /root/dpdk_rpms/*
78             systemctl restart openvswitch
79             sleep 5
80             sed  -i "s/#user\s*=.*/user = \"root\"/" /etc/libvirt/qemu.conf
81             sed  -i "s/#group\s*=.*/group = \"root\"/" /etc/libvirt/qemu.conf
82             ovs-vsctl --no-wait set Open_vSwitch . other_config:dpdk-init=true
83             if [ -n "$SOCKET_MEMORY" ]; then
84               ovs-vsctl --no-wait set Open_vSwitch . other_config:dpdk-socket-mem=$SOCKET_MEMORY
85             fi
86             if [[ -n "$pmd_cpu_mask" && -n "$PMD_CORES" ]]; then
87               ovs-vsctl --no-wait set Open_vSwitch . other_config:pmd-cpu-mask=$pmd_cpu_mask
88             fi
89             if [ -n "$dpdk_lcore_mask" && -n "$DPDK_CORES" ]]; then
90               ovs-vsctl --no-wait set Open_vSwitch . other_config:dpdk-lcore-mask=$dpdk_lcore_mask
91             fi
92             systemctl restart openvswitch
93
94           params:
95             $DPDK_CORES: {get_param: OvsDpdkCoreList}
96             $PMD_CORES: {get_param: PmdCoreList}
97             $SOCKET_MEMORY: {get_param: OvsDpdkSocketMemory}
98 outputs:
99   deploy_stdout:
100     description: Output of the extra dpdk ovs  deployment
101     value: {get_attr: [OvsDpdkSetup, deploy_stdout]}