Optionally configure libvirt for live migraiton.

This commit is contained in:
Adam Gandelman 2012-12-17 15:27:41 -08:00
parent 743a484c56
commit fcfae963db
6 changed files with 44 additions and 11 deletions

View File

@ -37,7 +37,17 @@ options:
virt-type:
default: kvm
type: string
description: "Virtualization flavor. Supported: kvm, xen, uml, lxc. qemu"
description: Virtualization flavor (kvm, xen, uml, lxc, qemu)
enable-live-migration:
default: False
type: boolean
description: Configure libvirt for live migration.
migration-auth-type:
default: sasl
type: string
description: |
TCP authentication scheme for libvirt live migration. Available options
include sasl or none.
# needed if using flatmanager
bridge-interface:
default: br100

View File

@ -12,7 +12,7 @@ nova_set_or_update() {
local nova_conf=${NOVA_CONF:-/etc/nova/nova.conf}
local api_conf=${API_CONF:-/etc/nova/api-paste.ini}
local libvirtd_conf=${LIBVIRTD_CONF:-/etc/libvirt/libvirtd.conf}
[[ -z $key ]] && juju-log "$CHARM set_or_update: value $value missing key" && exit 1
[[ -z $value ]] && juju-log "$CHARM set_or_update: key $key missing value" && exit 1
[[ -z "$conf_file" ]] && conf_file=$nova_conf
@ -22,7 +22,7 @@ nova_set_or_update() {
pattern="--$key="
out=$pattern
;;
"$api_conf") match="^$key = "
"$api_conf"|"$libvirtd_conf") match="^$key = "
pattern="$match"
out="$key = "
;;

View File

@ -15,6 +15,7 @@ nova_set_or_update() {
local quantum_conf=${QUANTUM_CONF:-/etc/quantum/quantum.conf}
local quantum_api_conf=${QUANTUM_API_CONF:-/etc/quantum/api-paste.ini}
local quantum_plugin_conf=${QUANTUM_PLUGIN_CONF:-/etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini}
local libvirtd_conf={$LIBVIRTD_CONF:-/etc/libvirt/libvirtd.conf}
[[ -z $key ]] && juju-log "$CHARM: set_or_update: value $value missing key" && exit 1
[[ -z $value ]] && juju-log "$CHARM: set_or_update: key $key missing value" && exit 1
@ -27,11 +28,8 @@ nova_set_or_update() {
pattern="$key="
out=$pattern
;;
"$api_conf") match="^$key = "
pattern="$match"
out="$key = "
;;
"$quantum_conf"|"$quantum_api_conf"|"$quantum_plugin_conf")
"$api_conf"|"$quantum_conf"|"$quantum_api_conf"|"$quantum_plugin_conf"| \
"$libvirtd_conf")
match="^$key = "
pattern="$match"
out="$key = "

View File

@ -7,6 +7,7 @@ CONF_DIR="/etc/nova"
NOVA_CONF=$(config-get nova-config)
API_CONF="/etc/nova/api-paste.ini"
QUANTUM_CONF="/etc/quantum/quantum.conf"
LIBVIRTD_CONF="/etc/libvirt/libvirtd.conf"
if [ -f /etc/nova/nm.conf ]; then
NET_MANAGER=$(cat /etc/nova/nm.conf)
@ -175,5 +176,29 @@ cgroup_device_acl = [
"/dev/rtc", "/dev/hpet", "/dev/net/tun",
]
EOF
service libvirt-bin reload
local enable_migration=$(config-get enable-live-migration)
if [[ "$enable_migration" == "True" ]] ||
[[ "$enable_migration" == "true" ]] ; then
# set appropriate option in /etc/default/libvirt-bin to allow
# listening on tcp
local cur_opts=$(grep "^libvirtd_opts" /etc/default/libvirt-bin |
cut -d= -f2 | sed -e 's/\"//g')
local new_opts=""
if [[ -z "$cur_opts" ]] ; then
new_opts="-d -l"
echo "libvirtd_opts=\"-d -l\"" >>/etc/default/libvirt-bin
elif ! echo "$cur_opts" | grep -q "\-l" ; then
new_opts="$cur_opts -l"
sed -i "s|\(libvirtd_opts=\).*|\1\"$new_opts\"|" /etc/default/libvirt-bin
fi
set_or_update "listen_tcp" 1 $LIBVIRTD_CONF
if [[ "$(config-get migration-auth-type)" == "none" ]] ; then
set_or_update "listen_tls" 0 $LIBVIRTD_CONF
set_or_update "auth_tcp" "\"none\"" $LIBVIRTD_CONF
fi
fi
service libvirt-bin restart
}

View File

@ -34,7 +34,7 @@ function config_changed() {
juju-log "$CHARM: Upgrading OpenStack release: $cur -> $available."
do_openstack_upgrade "$install_src" $PACKAGES
fi
configure_libvirt
set_config_flags
service_ctl all restart
}

View File

@ -1 +1 @@
80
86