Refactoring so that network configuration comes from cloud-controller

This commit is contained in:
James Page 2012-12-05 11:46:15 +00:00
parent b6b4cff68b
commit 424c2a44cf
4 changed files with 80 additions and 68 deletions

View File

@ -38,18 +38,6 @@ 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
@ -72,14 +60,3 @@ 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
.
This configuration only has context when used with
network-manager Quantum.

View File

@ -8,31 +8,29 @@ 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"
if [ -f /etc/nova/nm.conf ]; then
NET_MANAGER=$(cat /etc/nova/nm.conf)
fi
case $NET_MANAGER in
"Quantum")
QUANTUM_PLUGIN=$(cat /etc/nova/quantum_plugin.conf)
case $QUANTUM_PLUGIN in
"ovs")
SERVICES="$SERVICES quantum-plugin-openvswitch-agent"
QUANTUM_PLUGIN_CONF="/etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini"
;;
"nvp")
QUANTUM_PLUGIN_CONF="/etc/quantum/plugins/nicira/nvp.ini"
;;
*)
juju-log "Unrecognised plugin for quantum: $QUANTUM_PLUGIN" && exit 1
;;
esac
;;
"FlatManager"|"FlatDHCPManager")
SERVICES="$SERVICES nova-api nova-network"
;;
esac
if [[ -e $CHARM_DIR/lib/nova/nova-common ]] ; then
. $CHARM_DIR/lib/nova/nova-common
@ -86,10 +84,20 @@ function configure_network_manager {
# needed by the nova-network bits
# to be expanded later to cover flatDhcp and VLAN
echo "$0: configuring $1 network manager"
local net_manager=$1
local quantum_plugin=$2
local network_bridge=$(config-get bridge-interface)
case $1 in
# Store the network manager and quantum plugin
# for use in later hook invocations
[[ -n $net_manager ]] && echo $net_manager > /etc/nova/nm.conf
[[ -n $quantum_plugin ]] && echo $quantum_plugin > /etc/nova/quantum_plugin.conf
case $net_manager in
"FlatManager"|"FlatDHCPManager")
apt-get -y install nova-api nova-network
SERVICES="$SERVICES nova-api nova-network"
;;
"FlatManager")
local bridge_ip=$(config-get bridge-ip)
local bridge_netmask=$(config-get bridge-netmask)
@ -120,18 +128,22 @@ 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"
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
case $quantum_plugin in
"ovs")
apt-get -y install openvswitch-datapath-dkms
apt-get -y install quantum-plugin-openvswitch-agent
local quantum_plugin_conf="/etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini"
set_or_update "core_plugin" "quantum.plugins.openvswitch.ovs_quantum_plugin.OVSQuantumPluginV2" "$QUANTUM_CONF"
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"
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"
SERVICES="$SERVICES quantum-plugin-openvswitch-agent"
;;
esac
set_or_update "bind_host" "$(unit-get private-address)" "$QUANTUM_CONF"
;;
*) echo "ERROR: Invalid network manager $1" && exit 1 ;;
esac

View File

@ -20,10 +20,7 @@ function install_hook {
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
configure_libvirt
}
function config_changed() {
@ -77,7 +74,7 @@ function amqp_changed {
set_or_update rabbit_password $rabbit_password
set_or_update rabbit_virtual_host $rabbit_vhost
if [ "$(config-get network-manager)" == "Quantum" ]; then
if [ "$NET_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"
@ -140,13 +137,39 @@ 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
if [ "$network_manager" == "Quantum" ]; then
configure_network_manager "$network_manager" "$(relation-get quantum_plugin)"
configure_quantum_bridge
# Quantum also needs access to the quantum database
# depending on add-relation order, this relation
# may already be present so ask it for credentials if so
r_ids="$(relation-ids shared-db)"
for id in $r_ids ; do
relation-set -r $id \
quantum_database=quantum \
quantum_username=quantum \
quantum_hostname=$(unit-get private-address)
done
# Rabbit MQ relation may also already be in place
# shared vhost with nova so just grab settings and
# configure
r_ids="$(relation-ids amqp)"
for id in $r_ids ; do
for unit in $(relation-list -r $id) ; do
local rabbit_host=$(relation-get -r $id private-address $unit)
local rabbit_password=$(relation-get -r $id password $unit)
if [[ -n $rabbit_host ]] && \
[[ -n $rabbit_password ]]; then
set_or_update rabbit_host "$rabbit_host" "$QUANTUM_CONF"
set_or_update rabbit_userid "$(config-get rabbit-user)" "$QUANTUM_CONF"
set_or_update rabbit_password "$rabbit_password" "$QUANTUM_CONF"
set_or_update rabbit_virtual_host "$(config-get rabbit-vhost)" "$QUANTUM_CONF"
fi
done
done
else
configure_network_manager "$network_manager"
fi
configure_network_manager "$network_manager"
fi
# nova-c-c informs us of what volume service has been deployed.

View File

@ -1 +1 @@
77
80