From 26edd7b071f84e2fd2a9953086209e02b0c27ef3 Mon Sep 17 00:00:00 2001 From: Huan Xie Date: Mon, 8 Aug 2016 07:23:36 +0000 Subject: [PATCH] Install conntrack in XenServer Dom0 Neutron openvswitch agent running in compute node will control the actual connection of the VMs in Dom0 via conntrack-tools, but Dom0 doesn't install conntrack-tools RPM by default. This patch is to add such support with XenServer 7.0 and above. Change-Id: Iec56db761015d4b7baa5a5f54314f4ff3fa67e02 --- lib/nova_plugins/hypervisor-xenserver | 1 + tools/xen/functions | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/lib/nova_plugins/hypervisor-xenserver b/lib/nova_plugins/hypervisor-xenserver index e75226ae64..e5d25da3a3 100644 --- a/lib/nova_plugins/hypervisor-xenserver +++ b/lib/nova_plugins/hypervisor-xenserver @@ -87,6 +87,7 @@ CRONTAB cat $TOP_DIR/tools/xen/functions echo "create_directory_for_images" echo "create_directory_for_kernels" + echo "install_conntrack_tools" } | $ssh_dom0 } diff --git a/tools/xen/functions b/tools/xen/functions index cf145686b5..e1864eb4bb 100644 --- a/tools/xen/functions +++ b/tools/xen/functions @@ -305,3 +305,25 @@ function get_domid { xe vm-list name-label="$vm_name_label" params=dom-id minimal=true } + +function install_conntrack_tools { + local xs_host + local xs_ver_major + local centos_ver + local conntrack_conf + xs_host=$(xe host-list --minimal) + xs_ver_major=$(xe host-param-get uuid=$xs_host param-name=software-version param-key=product_version_text_short | cut -d'.' -f 1) + if [ $xs_ver_major -gt 6 ]; then + # Only support conntrack-tools in Dom0 with XS7.0 and above + if [ ! -f /usr/sbin/conntrackd ]; then + sed -i s/#baseurl=/baseurl=/g /etc/yum.repos.d/CentOS-Base.repo + centos_ver=$(yum version nogroups |grep Installed | cut -d' ' -f 2 | cut -d'.' -f1-2 | tr '-' '.') + yum install -y --enablerepo=base --releasever=$centos_ver conntrack-tools + # Backup conntrackd.conf after install conntrack-tools, use the one with statistic mode + mv /etc/conntrackd/conntrackd.conf /etc/conntrackd/conntrackd.conf.back + conntrack_conf=$(find /usr/share/doc -name conntrackd.conf |grep stats) + cp $conntrack_conf /etc/conntrackd/conntrackd.conf + fi + service conntrackd restart + fi +}