1 heat_template_version: pike
3 # NOTE: You don't need to pass the parameter explicitly from the
4 # parent template, it can be specified via the parameter_defaults
5 # in the resource_registry instead, if you want to override the default
6 # and/or share values with other templates in the tree.
11 ContrailVrouterPhysicalInterface:
13 description: vRouter physical interface
15 ContrailVlanParentInterface:
17 description: Parent interface of vlan interface
19 ContrailBondInterface:
21 description: Bond interface name
23 ContrailBondInterfaceMembers:
25 description: Bond interface members
29 description: Bond Mode
33 description: Bond Policy
37 description: Role Specific parameters
40 type: comma_delimited_list
46 This template installs the Contrail kernel module packages in order
47 to bring vhost0 interface up. Vhost0 interface must be up before
48 os-net-config takes over.
52 ContrailVrouterModuleDeployment:
53 type: OS::Heat::SoftwareDeployment
55 name: ContrailVrouterModuleDeployment
56 server: {get_param: server}
57 config: {get_resource: ContrailVrouterModuleConfig}
59 phy_int: {get_param: ContrailVrouterPhysicalInterface}
60 bond_int: {get_param: ContrailBondInterface}
61 bond_int_members: {get_param: ContrailBondInterfaceMembers}
62 vlan_parent: {get_param: ContrailVlanParentInterface}
63 contrail_repo: {get_param: ContrailRepo}
64 bond_mode: {get_param: ContrailBondMode}
65 bond_policy: {get_param: ContrailBondPolicy}
66 actions: ['CREATE'] # Only do this on CREATE
68 ContrailVrouterModuleConfig:
69 type: OS::Heat::SoftwareConfig
75 - name: bond_int_members
84 bond_int_members=$bond_int_members
86 bond_policy=$bond_policy
87 vlan_parent=$vlan_parent
88 contrail_repo=$contrail_repo
89 if [[ ${contrail_repo} ]]; then
90 yum install -y contrail-vrouter-utils
92 function pkt_setup () {
93 for f in /sys/class/net/$1/queues/rx-*
95 q="$(echo $f | cut -d '-' -f2)"
99 str=(`printf "%x" $mask`)
100 if [ $s -gt 0 ]; then
101 for ((i=0; i < $s; i++))
106 echo $str > $f/rps_cpus
110 function insert_vrouter() {
111 if [ -f /sys/class/net/pkt1/queues/rx-0/rps_cpus ]; then
114 if [ -f /sys/class/net/pkt2/queues/rx-0/rps_cpus ]; then
117 if [ -f /sys/class/net/pkt3/queues/rx-0/rps_cpus ]; then
120 DEV_MAC=$(cat /sys/class/net/${phy_int}/address)
121 vif --create vhost0 --mac $DEV_MAC
122 vif --add ${phy_int} --mac $DEV_MAC --vrf 0 --vhost-phys --type physical
123 vif --add vhost0 --mac $DEV_MAC --vrf 0 --type vhost --xconnect ${phy_int}
124 ip link set vhost0 up
127 if [[ ${bond_int} ]]; then
128 bond_int_member_list=$(echo ${bond_int_members} | tr "," "\n")
129 ip link add name ${bond_int} type bond
130 echo ${bond_mode} > /sys/class/net/${bond_int}/bonding/mode
131 echo ${bond_policy} > /sys/class/net/${bond_int}/bonding/xmit_hash_policy
132 for member in ${bond_int_member_list}; do
133 ip link set dev $member master ${bond_int}
136 if [[ ${vlan_parent} ]]; then
137 vlanId=`echo ${phy_int} | awk -F"vlan" '{print $2}'`
138 ip link add name ${phy_int} link ${vlan_parent} type vlan id ${vlanId}
140 if [[ ${contrail_repo} ]]; then
141 yumdownloader contrail-vrouter --destdir /tmp
143 rpm2cpio /tmp/contrail-vrouter*.rpm | cpio -idmv
144 cp `find /tmp/lib/modules -name vrouter.ko |tail -1` /tmp
145 insmod /tmp/vrouter.ko
150 if [[ `ifconfig ${phy_int} |grep "inet "` ]]; then
152 if [[ `ip route show |grep default|grep ${phy_int}` ]]; then
153 def_gw=`ip route show |grep default|grep ${phy_int}|awk '{print $3}'`
155 ip=`ifconfig ${phy_int} |grep "inet "|awk '{print $2}'`
156 mask=`ifconfig ${phy_int} |grep "inet "|awk '{print $4}'`
157 ip address delete $ip/$mask dev ${phy_int}
158 ip address add $ip/$mask dev vhost0
159 if [[ $def_gw ]]; then
160 ip route add default via $def_gw