Quantum support updates

This commit is contained in:
James Page 2012-12-03 11:18:59 +00:00
parent d038132286
commit 28d3473024
6 changed files with 164 additions and 17 deletions

View File

@ -38,6 +38,18 @@ options:
default: kvm
type: string
description: "Virtualization flavor. Supported: kvm, xen, uml, lxc. qemu"
network-manager:
default: FlatDHCPManager
type: string
description: |
Network manager for the cloud; supports the following options
.
FlatDHCPManager (nova-network) (default)
FlatManager (nova-network)
Quantum (Full SDN solution)
.
When using the Quantum option you will most likely want to use
the quantum charm to provide L3 routing and DHCP Services.
# needed if using flatmanager
bridge-interface:
default: br100
@ -60,4 +72,15 @@ options:
default: None
type: string
description: Comma separated list of key=value config flags to be set in nova.conf.
# needed if using Quantum
quantum-plugin:
default: ovs
type: string
description: |
Quantum plugin to use for network management; supports
.
ovs - OpenvSwitch Plugin
nvp - Nicira NVP Plugin
.
This configuration only has context when used with
network-manager Quantum.

View File

@ -8,9 +8,13 @@ nova_set_or_update() {
local key="$1"
local value="$2"
local conf_file="$3"
local section="${4:-DEFAULT}"
local nova_conf=${NOVA_CONF:-/etc/nova/nova.conf}
local api_conf=${API_CONF:-/etc/nova/api-paste.ini}
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}
[[ -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,19 +31,39 @@ nova_set_or_update() {
pattern="$match"
out="$key = "
;;
"$quantum_conf"|"$quantum_api_conf"|"$quantum_plugin_conf")
match="^$key = "
pattern="$match"
out="$key = "
;;
*) juju-log "$CHARM ERROR: set_or_update: Invalid conf_file ($conf_file)"
esac
cat $conf_file | grep "$match$value" >/dev/null &&
juju-log "$CHARM: $key=$value already in set in $conf_file" \
&& return 0
if cat $conf_file | grep "$match" >/dev/null ; then
juju-log "$CHARM: Updating $conf_file, $key=$value"
sed -i "s|\($pattern\).*|\1$value|" $conf_file
else
juju-log "$CHARM: Setting new option $key=$value in $conf_file"
echo "$out$value" >>$conf_file
fi
case $conf_file in
"$quantum_conf"|"$quantum_api_conf"|"$quantum_plugin_conf")
python -c "
import ConfigParser
config = ConfigParser.RawConfigParser()
config.read('$conf_file')
config.set('$section','$key','$value')
with open('$conf_file', 'wb') as configfile:
config.write(configfile)
"
;;
*)
if cat $conf_file | grep "$match" >/dev/null ; then
juju-log "$CHARM: Updating $conf_file, $key=$value"
sed -i "s|\($pattern\).*|\1$value|" $conf_file
else
juju-log "$CHARM: Setting new option $key=$value in $conf_file"
echo "$out$value" >>$conf_file
fi
;;
esac
}
# Upgrade Helpers

View File

@ -50,7 +50,19 @@ function configure_network_manager {
"FlatDHCPManager")
set_or_update "network_manager" "nova.network.manager.FlatDHCPManager"
;;
*) echo "ERROR: Invalid network manager $1" && exit 1 ;;
"Quantum")
set_or_update "network_api_class" "nova.network.quantumv2.api.API"
set_or_update "quantum_auth_strategy" "keystone"
set_or_update "core_plugin" "$QUANTUM_CORE_PLUGIN" "$QUANTUM_CONF"
set_or_update "bind_host" "$(unit-get private-address)" "$QUANTUM_CONF"
if [ "$QUANTUM_PLUGIN" == "ovs" ]; then
set_or_update "tenant_network_type" "gre" $QUANTUM_PLUGIN_CONF "OVS"
set_or_update "enable_tunneling" "True" $QUANTUM_PLUGIN_CONF "OVS"
set_or_update "tunnel_id_ranges" "1:1000" $QUANTUM_PLUGIN_CONF "OVS"
set_or_update "local_ip" "$(unit-get private-address)" $QUANTUM_PLUGIN_CONF "OVS"
fi
;;
*) juju-log "ERROR: Invalid network manager $1" && exit 1 ;;
esac
}

View File

@ -1,11 +1,38 @@
#!/bin/bash -e
CHARM="nova-compute"
PACKAGES="nova-compute nova-api nova-network python-keystone"
SERVICES="nova-compute nova-api nova-network"
PACKAGES="nova-compute python-keystone"
SERVICES="nova-compute"
CONF_DIR="/etc/nova"
NOVA_CONF=$(config-get nova-config)
API_CONF="/etc/nova/api-paste.ini"
QUANTUM_CONF="/etc/quantum/quantum.conf"
NET_MANAGER=$(config-get network-manager)
if [ "$NET_MANAGER" == "Quantum" ]; then
QUANTUM_PLUGIN=$(config-get quantum-plugin)
case $QUANTUM_PLUGIN in
"ovs")
PACKAGES="$PACKAGES quantum-plugin-openvswitch-agent"
EARLY_PACKAGES="openvswitch-datapath-dkms" # OVS needs DKMS for GRE tunnels
SERVICES="$SERVICES quantum-plugin-openvswitch-agent"
QUANTUM_CORE_PLUGIN="quantum.plugins.openvswitch.ovs_quantum_plugin.OVSQuantumPluginV2"
QUANTUM_PLUGIN_CONF="/etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini"
;;
"nvp")
# TODO: This needs to be changed - but leaving hook in for the time being
PACKAGES="$PACKAGES quantum-plugin-nicira"
QUANTUM_CORE_PLUGIN="quantum.plugins.nicira.nicira_nvp_plugin.QuantumPlugin.NvpPluginV2"
QUANTUM_PLUGIN_CONF="/etc/quantum/plugins/nicira/nvp.ini"
;;
*)
juju-log "Unrecognised plugin for quantum: $QUANTUM_PLUGIN" && exit 1
;;
esac
else
PACKAGES="$PACKAGES nova-api nova-network"
SERVICES="$SERVICES nova-api nova-network"
fi
if [[ -e $CHARM_DIR/lib/nova/nova-common ]] ; then
. $CHARM_DIR/lib/nova/nova-common
@ -90,10 +117,40 @@ function configure_network_manager {
set_or_update "quantum_admin_password" "$(relation-get service_password)"
set_or_update "quantum_admin_auth_url" \
"http://$(relation-get keystone_host):$(relation-get auth_port)/v2.0"
# TODO: pass plugin type over relations for dynamic configuration
set_or_update "libvirt_vif_driver" "nova.virt.libvirt.vif.LibvirtHybridOVSBridgeDriver"
set_or_update "libvirt_use_virtio_for_bridges" "True"
set_or_update "core_plugin" "$QUANTUM_CORE_PLUGIN" "$QUANTUM_CONF"
set_or_update "bind_host" "$(unit-get private-address)" "$QUANTUM_CONF"
case $QUANTUM_PLUGIN in
"ovs")
set_or_update "libvirt_vif_driver" "nova.virt.libvirt.vif.LibvirtHybridOVSBridgeDriver"
set_or_update "libvirt_use_virtio_for_bridges" "True"
set_or_update "tenant_network_type" "gre" $QUANTUM_PLUGIN_CONF "OVS"
set_or_update "enable_tunneling" "True" $QUANTUM_PLUGIN_CONF "OVS"
set_or_update "tunnel_id_ranges" "1:1000" $QUANTUM_PLUGIN_CONF "OVS"
set_or_update "local_ip" "$(unit-get private-address)" $QUANTUM_PLUGIN_CONF "OVS"
;;
esac
;;
*) echo "ERROR: Invalid network manager $1" && exit 1 ;;
esac
}
BR_INT="br-int"
function configure_quantum_bridge {
if ! ovs-vsctl show | grep -q "Bridge $BR_INT"; then
ovs-vsctl add-br $BR_INT
fi
}
function configure_libvirt {
cat > /etc/libvirt/qemu.conf << EOF
# File installed by Juju nova-compute charm
cgroup_device_acl = [
"/dev/null", "/dev/full", "/dev/zero",
"/dev/random", "/dev/urandom",
"/dev/ptmx", "/dev/kvm", "/dev/kqemu",
"/dev/rtc", "/dev/hpet", "/dev/net/tun",
]
EOF
service libvirt-bin reload
}

View File

@ -14,9 +14,16 @@ function install_hook {
apt-get -y install python-software-properties || exit 1
configure_install_source $(config-get openstack-origin)
apt-get update || exit 1
if [ -n "$EARLY_PACKAGES" ]; then
apt-get -y install $EARLY_PACKAGES || exit 1
fi
apt-get -y install $compute_pkg $PACKAGES || exit 1
service_ctl all stop
set_or_update "auth_strategy" "keystone"
if [ "$NET_MANAGER" == "Quantum" ]; then
configure_quantum_bridge
configure_libvirt
fi
}
function config_changed() {
@ -69,6 +76,14 @@ function amqp_changed {
set_or_update rabbit_userid $rabbit_user
set_or_update rabbit_password $rabbit_password
set_or_update rabbit_virtual_host $rabbit_vhost
if [ "$(config-get network-manager)" == "Quantum" ]; then
set_or_update rabbit_host "$rabbit_host" "$QUANTUM_CONF"
set_or_update rabbit_userid "$rabbit_user" "$QUANTUM_CONF"
set_or_update rabbit_password "$rabbit_password" "$QUANTUM_CONF"
set_or_update rabbit_virtual_host "$rabbit_vhost" "$QUANTUM_CONF"
fi
service_ctl all restart
}
@ -80,12 +95,15 @@ function db_joined {
local hostname=$(unit-get private-address)
juju-log "$CHARM - db_joined: requesting database access to $nova_db for "\
"$db_user@$hostname"
relation-set database=$nova_db username=$db_user hostname=$hostname
relation-set nova_database=$nova_db nova_username=$db_user nova_hostname=$hostname
if [ "$NET_MANAGER" == "Quantum" ]; then
relation-set quantum_database=quantum quantum_username=quantum quantum_hostname=$hostname
fi
}
function db_changed {
local db_host=`relation-get private-address`
local db_password=`relation-get password`
local db_password=`relation-get nova_password`
if [[ -z $db_host ]] || [[ -z $db_password ]] ; then
juju-log "$CHARM - db_changed: db_host||db_password set, will retry."
@ -97,6 +115,13 @@ function db_changed {
juju-log "$CHARM - db_changed: Configuring nova.conf for access to $nova_db"
set_or_update sql_connection "mysql://$db_user:$db_password@$db_host/$nova_db"
if [ "$NET_MANAGER" == "Quantum" ]; then
local quantum_db_password=`relation-get quantum_password`
set_or_update sql_connection "mysql://quantum:$quantum_db_password@$db_host/quantum?charset=utf8" \
$QUANTUM_PLUGIN_CONF "DATABASE"
fi
service_ctl all restart
}
@ -115,6 +140,12 @@ function compute_changed {
# needs to configure itself accordingly.
network_manager=`relation-get network_manager`
if [[ -n "$network_manager" ]] ; then
# Check locally configured network manager matches that provided
# from cloud controller - otherwise stuff will break.
if [ "$network_manager" != "$NET_MANAGER" ] ; then
juju-log "Locally configured network manager does not match cloud controller"
exit 1
fi
configure_network_manager "$network_manager"
fi

View File

@ -1 +1 @@
74
77