Files
devstack/tools/xen/functions
Mate Lakat 8644676846 xenapi - use management network to reach OS VM
Devstack used the HOST_IP_IFACE to reach the OpenStack VM through ssh.
This patch changes this behavior, so that the IP address of the
interface connected to the management network will be used.

Related to blueprint xenapi-devstack-cleanup

Change-Id: I7f34d973870792d60a33ea512901d9b0d422150b
2013-05-12 18:41:40 +01:00

96 lines
2.2 KiB
Bash

#!/bin/bash
function xapi_plugin_location {
for PLUGIN_DIR in "/etc/xapi.d/plugins/" "/usr/lib/xcp/plugins/"; do
if [ -d $PLUGIN_DIR ]; then
echo $PLUGIN_DIR
return 0
fi
done
return 1
}
function zip_snapshot_location {
echo $1 | sed "s:\.git$::;s:$:/zipball/$2:g"
}
function create_directory_for_kernels {
if [ -d "/boot/guest" ]; then
echo "INFO: /boot/guest directory already exists, using that" >&2
else
local LOCALPATH="$(get_local_sr_path)/os-guest-kernels"
mkdir -p $LOCALPATH
ln -s $LOCALPATH /boot/guest
fi
}
function extract_remote_zipball {
local ZIPBALL_URL=$1
local LOCAL_ZIPBALL=$(mktemp)
local EXTRACTED_FILES=$(mktemp -d)
(
wget -nv $ZIPBALL_URL -O $LOCAL_ZIPBALL --no-check-certificate
unzip -q -o $LOCAL_ZIPBALL -d $EXTRACTED_FILES
rm -f $LOCAL_ZIPBALL
) >&2
echo "$EXTRACTED_FILES"
}
function find_xapi_plugins_dir {
find $1 -path '*/xapi.d/plugins' -type d -print
}
function install_xapi_plugins_from_zipball {
local XAPI_PLUGIN_DIR
local EXTRACTED_FILES
local EXTRACTED_PLUGINS_DIR
XAPI_PLUGIN_DIR=$(xapi_plugin_location)
EXTRACTED_FILES=$(extract_remote_zipball $1)
EXTRACTED_PLUGINS_DIR=$(find_xapi_plugins_dir $EXTRACTED_FILES)
cp -pr $EXTRACTED_PLUGINS_DIR/* $XAPI_PLUGIN_DIR
rm -rf $EXTRACTED_FILES
chmod a+x ${XAPI_PLUGIN_DIR}*
}
function get_local_sr {
xe sr-list name-label="Local storage" --minimal
}
function get_local_sr_path {
echo "/var/run/sr-mount/$(get_local_sr)"
}
function find_ip_by_name() {
local guest_name="$1"
local interface="$2"
local period=10
local max_tries=10
local i=0
while true; do
if [ $i -ge $max_tries ]; then
echo "Timeout: ip address for interface $interface of $guest_name"
exit 11
fi
ipaddress=$(xe vm-list --minimal \
name-label=$guest_name \
params=networks | sed -ne "s,^.*${interface}/ip: \([0-9.]*\).*\$,\1,p")
if [ -z "$ipaddress" ]; then
sleep $period
((i++))
else
echo $ipaddress
break
fi
done
}