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