Browse code

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

Huan Xie authored on 2016/08/08 16:23:36
Showing 2 changed files
... ...
@@ -87,6 +87,7 @@ CRONTAB
87 87
         cat $TOP_DIR/tools/xen/functions
88 88
         echo "create_directory_for_images"
89 89
         echo "create_directory_for_kernels"
90
+        echo "install_conntrack_tools"
90 91
     } | $ssh_dom0
91 92
 
92 93
 }
... ...
@@ -305,3 +305,25 @@ function get_domid {
305 305
 
306 306
     xe vm-list name-label="$vm_name_label" params=dom-id minimal=true
307 307
 }
308
+
309
+function install_conntrack_tools {
310
+    local xs_host
311
+    local xs_ver_major
312
+    local centos_ver
313
+    local conntrack_conf
314
+    xs_host=$(xe host-list --minimal)
315
+    xs_ver_major=$(xe host-param-get uuid=$xs_host param-name=software-version param-key=product_version_text_short | cut -d'.' -f 1)
316
+    if [ $xs_ver_major -gt 6 ]; then
317
+        # Only support conntrack-tools in Dom0 with XS7.0 and above
318
+        if [ ! -f /usr/sbin/conntrackd ]; then
319
+            sed -i s/#baseurl=/baseurl=/g /etc/yum.repos.d/CentOS-Base.repo
320
+            centos_ver=$(yum version nogroups |grep Installed | cut -d' ' -f 2 | cut -d'.' -f1-2 | tr '-' '.')
321
+            yum install -y --enablerepo=base --releasever=$centos_ver conntrack-tools
322
+            # Backup conntrackd.conf after install conntrack-tools, use the one with statistic mode
323
+            mv /etc/conntrackd/conntrackd.conf /etc/conntrackd/conntrackd.conf.back
324
+            conntrack_conf=$(find /usr/share/doc -name conntrackd.conf |grep stats)
325
+            cp $conntrack_conf /etc/conntrackd/conntrackd.conf
326
+        fi
327
+        service conntrackd restart
328
+    fi
329
+}