diff --git a/devstack/dom0_functions b/devstack/dom0_functions index fbcbfb0..11f6da7 100644 --- a/devstack/dom0_functions +++ b/devstack/dom0_functions @@ -9,3 +9,68 @@ function dom0_plugin_location { done return 1 } + +function get_default_sr { + xe pool-list params=default-SR minimal=true +} + +function get_local_sr_path { + pbd_device_config_path=`xe pbd-list sr-uuid=$(get_default_sr) params=device-config | grep " path: "` + if [ -n "$pbd_device_config_path" ]; then + pbd_uuid=`xe pbd-list sr-uuid=$(get_default_sr) minimal=true` + pbd_path=`xe pbd-param-get uuid=$pbd_uuid param-name=device-config param-key=path || echo ""` + else + pbd_path="/var/run/sr-mount/$(get_default_sr)" + fi + + if [ -d "$pbd_path" ]; then + echo $pbd_path + return 0 + else + return 1 + fi +} + +function create_directory_for_images { + if [ -d "/images" ]; then + echo "INFO: /images directory already exists, using that" >&2 + else + local local_path + local_path="$(get_local_sr_path)/os-images" + mkdir -p $local_path + ln -s $local_path /images + fi +} + +function create_directory_for_kernels { + if [ -d "/boot/guest" ]; then + echo "INFO: /boot/guest directory already exists, using that" >&2 + else + local local_path + local_path="$(get_local_sr_path)/os-guest-kernels" + mkdir -p $local_path + ln -s $local_path /boot/guest + fi +} + +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'/' -f 1 | cut -d'-' -f 1) + 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 +} diff --git a/devstack/plugin.sh b/devstack/plugin.sh index dd1841e..16bd74e 100755 --- a/devstack/plugin.sh +++ b/devstack/plugin.sh @@ -245,6 +245,29 @@ function cleanup_dom0_iptables { $_ERREXIT_XENSERVER } +# Prepare directories for kernels and images in Dom0 +function create_dom0_kernel_and_image_dir { + local ssh_dom0=$(get_dom0_ssh) + + { + echo "set -eux" + cat $OS_XENAPI_DIR/devstack/dom0_functions + echo "create_directory_for_images" + echo "create_directory_for_kernels" + } | $ssh_dom0 +} + +# Install conntrack-tools in Dom0 +function install_dom0_conntrack { + local ssh_dom0=$(get_dom0_ssh) + + { + echo "set -eux" + cat $OS_XENAPI_DIR/devstack/dom0_functions + echo "install_conntrack_tools" + } | $ssh_dom0 +} + if [[ "$MODE" == "stack" ]]; then case "$PHASE" in pre-install) @@ -254,6 +277,8 @@ if [[ "$MODE" == "stack" ]]; then # Called after the layer 1 and 2 projects source and their dependencies have been installed install_dom0_plugins config_dom0_iptables + install_dom0_conntrack + create_dom0_kernel_and_image_dir # set image variables DEFAULT_IMAGE_NAME="cirros-${CIRROS_VERSION}-${CIRROS_ARCH}-disk" DEFAULT_IMAGE_FILE_NAME="cirros-${CIRROS_VERSION}-${CIRROS_ARCH}-disk.vhd.tgz"