Install conntrack and create image/kernel dir in Dom0

We are moving files from devstack/tools/xen/ to os-xenapi repo,
but I found devstack/lib/nova_plugins/hypervisor-xenserver file
will use some functions in tools/xen/functions, e.g.
- create_directory_for_images
- create_directory_for_kernels
- install_conntrack_tools
Once we remove all files under tools/xen to os-xenapi, devstack
will fail to deploy nova-compute service as it cannot find files
in tools/xen anymore. Thus, I made this patch to let our devstack
plugin to trigger the above functions. So we can safely remove
the whole folder tools/xen and some functions in devstack repo

Change-Id: I712ee74ce945859ba5118e09b7d9436ca2686cb7
This commit is contained in:
Huan Xie 2017-05-26 23:47:33 -07:00
parent 644e5d49f3
commit e291f25596
2 changed files with 90 additions and 0 deletions

View File

@ -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
}

View File

@ -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"