Merge Quantum networking support from James Page.
This commit is contained in:
commit
743a484c56
@ -60,4 +60,3 @@ options:
|
|||||||
default: None
|
default: None
|
||||||
type: string
|
type: string
|
||||||
description: Comma separated list of key=value config flags to be set in nova.conf.
|
description: Comma separated list of key=value config flags to be set in nova.conf.
|
||||||
|
|
||||||
|
@ -8,9 +8,13 @@ nova_set_or_update() {
|
|||||||
local key="$1"
|
local key="$1"
|
||||||
local value="$2"
|
local value="$2"
|
||||||
local conf_file="$3"
|
local conf_file="$3"
|
||||||
|
local section="${4:-DEFAULT}"
|
||||||
|
|
||||||
local nova_conf=${NOVA_CONF:-/etc/nova/nova.conf}
|
local nova_conf=${NOVA_CONF:-/etc/nova/nova.conf}
|
||||||
local api_conf=${API_CONF:-/etc/nova/api-paste.ini}
|
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 $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 $value ]] && juju-log "$CHARM: set_or_update: key $key missing value" && exit 1
|
||||||
@ -27,12 +31,30 @@ nova_set_or_update() {
|
|||||||
pattern="$match"
|
pattern="$match"
|
||||||
out="$key = "
|
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)"
|
*) juju-log "$CHARM ERROR: set_or_update: Invalid conf_file ($conf_file)"
|
||||||
esac
|
esac
|
||||||
|
|
||||||
cat $conf_file | grep "$match$value" >/dev/null &&
|
cat $conf_file | grep "$match$value" >/dev/null &&
|
||||||
juju-log "$CHARM: $key=$value already in set in $conf_file" \
|
juju-log "$CHARM: $key=$value already in set in $conf_file" \
|
||||||
&& return 0
|
&& return 0
|
||||||
|
|
||||||
|
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
|
if cat $conf_file | grep "$match" >/dev/null ; then
|
||||||
juju-log "$CHARM: Updating $conf_file, $key=$value"
|
juju-log "$CHARM: Updating $conf_file, $key=$value"
|
||||||
sed -i "s|\($pattern\).*|\1$value|" $conf_file
|
sed -i "s|\($pattern\).*|\1$value|" $conf_file
|
||||||
@ -40,6 +62,8 @@ nova_set_or_update() {
|
|||||||
juju-log "$CHARM: Setting new option $key=$value in $conf_file"
|
juju-log "$CHARM: Setting new option $key=$value in $conf_file"
|
||||||
echo "$out$value" >>$conf_file
|
echo "$out$value" >>$conf_file
|
||||||
fi
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
# Upgrade Helpers
|
# Upgrade Helpers
|
||||||
|
@ -50,7 +50,22 @@ function configure_network_manager {
|
|||||||
"FlatDHCPManager")
|
"FlatDHCPManager")
|
||||||
set_or_update "network_manager" "nova.network.manager.FlatDHCPManager"
|
set_or_update "network_manager" "nova.network.manager.FlatDHCPManager"
|
||||||
;;
|
;;
|
||||||
*) echo "ERROR: Invalid network manager $1" && exit 1 ;;
|
"Quantum")
|
||||||
|
local local_ip=$(get_ip `unit-get private-address`)
|
||||||
|
[[ -n $local_ip ]] || juju-log "Unable to resolve local IP address" \
|
||||||
|
&& exit 1
|
||||||
|
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" "0.0.0.0" "$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" "$local_ip" $QUANTUM_PLUGIN_CONF "OVS"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*) juju-log "ERROR: Invalid network manager $1" && exit 1 ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,3 +178,25 @@ get_os_version_codename() {
|
|||||||
"grizzly") echo "2012.3" ;;
|
"grizzly") echo "2012.3" ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_ip() {
|
||||||
|
dpkg -l | grep -q python-dnspython || {
|
||||||
|
apt-get -y install python-dnspython 2>&1 > /dev/null
|
||||||
|
}
|
||||||
|
hostname=$1
|
||||||
|
python -c "
|
||||||
|
import dns.resolver
|
||||||
|
import socket
|
||||||
|
try:
|
||||||
|
# Test to see if already an IPv4 address
|
||||||
|
socket.inet_aton('$hostname')
|
||||||
|
print '$hostname'
|
||||||
|
except socket.error:
|
||||||
|
try:
|
||||||
|
answers = dns.resolver.query('$hostname', 'A')
|
||||||
|
if answers:
|
||||||
|
print answers[0].address
|
||||||
|
except dns.resolver.NXDOMAIN:
|
||||||
|
pass
|
||||||
|
"
|
||||||
|
}
|
||||||
|
@ -1,11 +1,36 @@
|
|||||||
#!/bin/bash -e
|
#!/bin/bash -e
|
||||||
|
|
||||||
CHARM="nova-compute"
|
CHARM="nova-compute"
|
||||||
PACKAGES="nova-compute nova-api nova-network python-keystone"
|
PACKAGES="nova-compute python-keystone genisoimage"
|
||||||
SERVICES="nova-compute nova-api nova-network"
|
SERVICES="nova-compute"
|
||||||
CONF_DIR="/etc/nova"
|
CONF_DIR="/etc/nova"
|
||||||
NOVA_CONF=$(config-get nova-config)
|
NOVA_CONF=$(config-get nova-config)
|
||||||
API_CONF="/etc/nova/api-paste.ini"
|
API_CONF="/etc/nova/api-paste.ini"
|
||||||
|
QUANTUM_CONF="/etc/quantum/quantum.conf"
|
||||||
|
|
||||||
|
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
|
if [[ -e $CHARM_DIR/lib/nova/nova-common ]] ; then
|
||||||
. $CHARM_DIR/lib/nova/nova-common
|
. $CHARM_DIR/lib/nova/nova-common
|
||||||
@ -59,10 +84,27 @@ function configure_network_manager {
|
|||||||
# needed by the nova-network bits
|
# needed by the nova-network bits
|
||||||
# to be expanded later to cover flatDhcp and VLAN
|
# to be expanded later to cover flatDhcp and VLAN
|
||||||
echo "$0: configuring $1 network manager"
|
echo "$0: configuring $1 network manager"
|
||||||
|
local net_manager=$1
|
||||||
|
local quantum_plugin=$2
|
||||||
local network_bridge=$(config-get bridge-interface)
|
local network_bridge=$(config-get bridge-interface)
|
||||||
|
local private_address=$(get_ip `unit-get private-address`)
|
||||||
|
# Check to ensure we can actually resolve
|
||||||
|
# the local unit IP address
|
||||||
|
[[ -n $private_address ]] || {
|
||||||
|
juju-log "Unable to resolve local IP address"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
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")
|
"FlatManager")
|
||||||
local bridge_ip=$(config-get bridge-ip)
|
local bridge_ip=$(config-get bridge-ip)
|
||||||
local bridge_netmask=$(config-get bridge-netmask)
|
local bridge_netmask=$(config-get bridge-netmask)
|
||||||
@ -81,6 +123,57 @@ function configure_network_manager {
|
|||||||
# address of API server to forward requests
|
# address of API server to forward requests
|
||||||
set_or_update ec2_dmz_host $ec2_host
|
set_or_update ec2_dmz_host $ec2_host
|
||||||
;;
|
;;
|
||||||
|
"Quantum")
|
||||||
|
local keystone_host=$(relation-get keystone_host)
|
||||||
|
[[ -z $keystone_host ]] && juju-log "nova-compute: Missing keystone host" \
|
||||||
|
&& exit 0
|
||||||
|
set_or_update "network_api_class" "nova.network.quantumv2.api.API"
|
||||||
|
set_or_update "quantum_auth_strategy" "keystone"
|
||||||
|
set_or_update "quantum_url" "http://$(relation-get quantum_host):9696"
|
||||||
|
set_or_update "quantum_admin_tenant_name" "$(relation-get service_tenant)"
|
||||||
|
set_or_update "quantum_admin_username" "$(relation-get service_username)"
|
||||||
|
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 "force_config_drive" "True"
|
||||||
|
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" "$private_address" $quantum_plugin_conf "OVS"
|
||||||
|
SERVICES="$SERVICES quantum-plugin-openvswitch-agent"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
set_or_update "bind_host" "0.0.0.0" "$QUANTUM_CONF"
|
||||||
|
;;
|
||||||
*) echo "ERROR: Invalid network manager $1" && exit 1 ;;
|
*) echo "ERROR: Invalid network manager $1" && exit 1 ;;
|
||||||
esac
|
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
|
||||||
|
}
|
||||||
|
@ -17,6 +17,7 @@ function install_hook {
|
|||||||
apt-get -y install $compute_pkg $PACKAGES || exit 1
|
apt-get -y install $compute_pkg $PACKAGES || exit 1
|
||||||
service_ctl all stop
|
service_ctl all stop
|
||||||
set_or_update "auth_strategy" "keystone"
|
set_or_update "auth_strategy" "keystone"
|
||||||
|
configure_libvirt
|
||||||
}
|
}
|
||||||
|
|
||||||
function config_changed() {
|
function config_changed() {
|
||||||
@ -69,6 +70,14 @@ function amqp_changed {
|
|||||||
set_or_update rabbit_userid $rabbit_user
|
set_or_update rabbit_userid $rabbit_user
|
||||||
set_or_update rabbit_password $rabbit_password
|
set_or_update rabbit_password $rabbit_password
|
||||||
set_or_update rabbit_virtual_host $rabbit_vhost
|
set_or_update rabbit_virtual_host $rabbit_vhost
|
||||||
|
|
||||||
|
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"
|
||||||
|
set_or_update rabbit_virtual_host "$rabbit_vhost" "$QUANTUM_CONF"
|
||||||
|
fi
|
||||||
|
|
||||||
service_ctl all restart
|
service_ctl all restart
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,12 +89,15 @@ function db_joined {
|
|||||||
local hostname=$(unit-get private-address)
|
local hostname=$(unit-get private-address)
|
||||||
juju-log "$CHARM - db_joined: requesting database access to $nova_db for "\
|
juju-log "$CHARM - db_joined: requesting database access to $nova_db for "\
|
||||||
"$db_user@$hostname"
|
"$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 {
|
function db_changed {
|
||||||
local db_host=`relation-get private-address`
|
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
|
if [[ -z $db_host ]] || [[ -z $db_password ]] ; then
|
||||||
juju-log "$CHARM - db_changed: db_host||db_password set, will retry."
|
juju-log "$CHARM - db_changed: db_host||db_password set, will retry."
|
||||||
@ -97,6 +109,13 @@ function db_changed {
|
|||||||
juju-log "$CHARM - db_changed: Configuring nova.conf for access to $nova_db"
|
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"
|
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
|
service_ctl all restart
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,8 +134,40 @@ function compute_changed {
|
|||||||
# needs to configure itself accordingly.
|
# needs to configure itself accordingly.
|
||||||
network_manager=`relation-get network_manager`
|
network_manager=`relation-get network_manager`
|
||||||
if [[ -n "$network_manager" ]] ; then
|
if [[ -n "$network_manager" ]] ; then
|
||||||
|
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"
|
configure_network_manager "$network_manager"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# nova-c-c informs us of what volume service has been deployed.
|
# nova-c-c informs us of what volume service has been deployed.
|
||||||
volume_service=`relation-get volume_service`
|
volume_service=`relation-get volume_service`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user