1 heat_template_version: pike
6 default: http://192.168.24.1/contrail
7 VrouterPhysicalInterface:
9 description: vRouter physical interface
13 Prepares vhost0 interface to be used by os-net-config
17 type: OS::Heat::MultipartMime
20 - config: {get_resource: vrouter_module_config}
22 vrouter_module_config:
23 type: OS::Heat::SoftwareConfig
29 sed -i '/\[main\]/a \ \ \ \ \parser = future' /etc/puppet/puppet.conf
30 cat <<EOF > /etc/yum.repos.d/contrail.repo
33 baseurl=$contrail_repo
38 if [[ `hostname |awk -F"-" '{print $2}'` == "novacompute" || `hostname |awk -F"-" '{print $2}'` == "contrailtsn" ]]; then
39 yum install -y contrail-vrouter-utils
40 function pkt_setup () {
41 for f in /sys/class/net/$1/queues/rx-*
43 q="$(echo $f | cut -d '-' -f2)"
47 str=(`printf "%x" $mask`)
49 for ((i=0; i < $s; i++))
54 echo $str > $f/rps_cpus
58 function insert_vrouter() {
59 insmod /tmp/vrouter.ko
60 if [ -f /sys/class/net/pkt1/queues/rx-0/rps_cpus ]; then
63 if [ -f /sys/class/net/pkt2/queues/rx-0/rps_cpus ]; then
66 if [ -f /sys/class/net/pkt3/queues/rx-0/rps_cpus ]; then
69 DEV_MAC=$(cat /sys/class/net/$phy_int/address)
70 vif --create vhost0 --mac $DEV_MAC
71 vif --add $phy_int --mac $DEV_MAC --vrf 0 --vhost-phys --type physical
72 vif --add vhost0 --mac $DEV_MAC --vrf 0 --type vhost --xconnect $phy_int
76 yumdownloader contrail-vrouter --destdir /tmp
78 rpm2cpio /tmp/contrail-vrouter*.rpm | cpio -idmv
79 cp `find /tmp/lib/modules -name vrouter.ko |tail -1` /tmp
81 if [[ `ifconfig $dev |grep "inet "` ]]; then
83 if [[ `ip route show |grep default|grep $dev` ]]; then
84 def_gw=`ip route show |grep default|grep $dev|awk '{print $3}'`
86 ip=`ifconfig $dev |grep "inet "|awk '{print $2}'`
87 mask=`ifconfig $dev |grep "inet "|awk '{print $4}'`
88 ip address delete $ip/$mask dev $dev
89 ip address add $ip/$mask dev vhost0
90 if [[ $def_gw ]]; then
91 ip route add default via $def_gw
96 $phy_int: {get_param: VrouterPhysicalInterface}
97 $contrail_repo: {get_param: ContrailRepo}
100 # This means get_resource from the parent template will get the userdata, see:
101 # http://docs.openstack.org/developer/heat/template_guide/composition.html#making-your-template-resource-more-transparent
102 # Note this is new-for-kilo, an alternative is returning a value then using
103 # get_attr in the parent template instead.
105 value: {get_resource: userdata}