Add support for the Quantum Ryu plugin.

This patch allows using the Quantum Ryu plugin.
Ryu plugin lets Quantum link Open vSwitch and Ryu OpenFlow controller[1].

Ryu OpenFlow controller is not Openstack component, but I added some
processing that is related with Ryu to stack.sh for the convenience of
the person who intend to try the plugin.

Instructions for using Ryu plugin:
1. Enable services: "q-svc", "q-agt", "q-dhcp", "q-l3", "quantum", "ryu"
2. Set Q_PLUGIN to "ryu"
3. Set an internal network interface name to connect br-int on plural
   hosts to RYU_INTERNAL_INTERFACE (optional)

Example localrc:
  disable_service n-net
  enable_service q-svc q-agt q-dhcp q-l3 quantum ryu
  Q_PLUGIN=ryu
  RYU_INTERNAL_INTERFACE=eth1

[1] http://osrg.github.com/ryu/

Change-Id: Ic1da132fa421f1c70c10a319ee3239831b0f956f
This commit is contained in:
Yoshihiro Kaneko 2012-07-23 06:27:36 +00:00
parent eccaa80ba8
commit 602cf9bd68
7 changed files with 116 additions and 19 deletions

4
files/apts/ryu Normal file
View File

@ -0,0 +1,4 @@
python-setuptools
python-gevent
python-gflags
python-sphinx

4
files/rpms/ryu Normal file
View File

@ -0,0 +1,4 @@
python-setuptools
python-gevent
python-gflags
python-sphinx

View File

@ -213,7 +213,7 @@ function configure_nova() {
fi
fi
if is_service_enabled quantum && [[ $Q_PLUGIN = "openvswitch" ]] && ! sudo grep -q '^cgroup_device_acl' $QEMU_CONF ; then
if is_service_enabled quantum && is_quantum_ovs_base_plugin "$Q_PLUGIN" && ! sudo grep -q '^cgroup_device_acl' $QEMU_CONF ; then
# Add /dev/net/tun to cgroup_device_acls, needed for type=ethernet interfaces
cat <<EOF | sudo tee -a $QEMU_CONF
cgroup_device_acl = [

View File

@ -33,5 +33,29 @@ function quantum_setup_ovs_bridge() {
sudo ovs-vsctl --no-wait br-set-external-id $bridge bridge-id $bridge
}
function quantum_setup_external_bridge() {
local bridge=$1
# Create it if it does not exist
sudo ovs-vsctl --no-wait -- --may-exist add-br $bridge
# remove internal ports
for PORT in `sudo ovs-vsctl --no-wait list-ports $bridge`; do
TYPE=$(sudo ovs-vsctl get interface $PORT type)
if [[ "$TYPE" == "internal" ]]; then
echo `sudo ip link delete $PORT` > /dev/null
sudo ovs-vsctl --no-wait del-port $bridge $PORT
fi
done
# ensure no IP is configured on the public bridge
sudo ip addr flush dev $bridge
}
function is_quantum_ovs_base_plugin() {
local plguin=$1
if [[ ",openvswitch,ryu," =~ ,${plugin}, ]]; then
return 0
fi
return 1
}
# Restore xtrace
$XTRACE

View File

@ -342,6 +342,18 @@ Q_USE_ROOTWRAP=${Q_USE_ROOTWRAP=:-True}
# Meta data IP
Q_META_DATA_IP=${Q_META_DATA_IP:-$HOST_IP}
RYU_DIR=$DEST/ryu
# Ryu API Host
RYU_API_HOST=${RYU_API_HOST:-127.0.0.1}
# Ryu API Port
RYU_API_PORT=${RYU_API_PORT:-8080}
# Ryu OFP Host
RYU_OFP_HOST=${RYU_OFP_HOST:-127.0.0.1}
# Ryu OFP Port
RYU_OFP_PORT=${RYU_OFP_PORT:-6633}
# Ryu Applications
RYU_APPS=${RYU_APPS:-ryu.app.simple_isolation,ryu.app.rest}
# Name of the LVM volume group to use/create for iscsi volumes
VOLUME_GROUP=${VOLUME_GROUP:-stack-volumes}
VOLUME_NAME_PREFIX=${VOLUME_NAME_PREFIX:-volume-}
@ -773,7 +785,7 @@ if is_service_enabled horizon; then
fi
if is_service_enabled q-agt; then
if [[ "$Q_PLUGIN" = "openvswitch" ]]; then
if is_quantum_ovs_base_plugin "$Q_PLUGIN"; then
# Install deps
# FIXME add to files/apts/quantum, but don't install if not needed!
if [[ "$os_PACKAGE" = "deb" ]]; then
@ -875,7 +887,9 @@ fi
if is_service_enabled tempest; then
install_tempest
fi
if is_service_enabled ryu || (is_service_enabled quantum && [[ "$Q_PLUGIN" = "ryu" ]]); then
git_clone $RYU_REPO $RYU_DIR $RYU_BRANCH
fi
# Initialization
# ==============
@ -924,6 +938,9 @@ fi
if is_service_enabled tempest; then
configure_tempest
fi
if is_service_enabled ryu || (is_service_enabled quantum && [[ "$Q_PLUGIN" = "ryu" ]]); then
setup_develop $RYU_DIR
fi
if [[ $TRACK_DEPENDS = True ]] ; then
$DEST/.venv/bin/pip freeze > $DEST/requires-post-pip
@ -1132,6 +1149,31 @@ if is_service_enabled g-reg; then
fi
# Ryu
# ---
# Ryu is not a part of OpenStack project. Please ignore following block if
# you are not interested in Ryu.
# launch ryu manager
if is_service_enabled ryu; then
RYU_CONF_DIR=/etc/ryu
if [[ ! -d $RYU_CONF_DIR ]]; then
sudo mkdir -p $RYU_CONF_DIR
fi
sudo chown `whoami` $RYU_CONF_DIR
RYU_CONF=$RYU_CONF_DIR/ryu.conf
sudo rm -rf $RYU_CONF
cat <<EOF > $RYU_CONF
--app_lists=$RYU_APPS
--wsapi_host=$RYU_API_HOST
--wsapi_port=$RYU_API_PORT
--ofp_listen_host=$RYU_OFP_HOST
--ofp_tcp_listen_port=$RYU_OFP_PORT
EOF
screen_it ryu "cd $RYU_DIR && $RYU_DIR/bin/ryu-manager --flagfile $RYU_CONF"
fi
# Quantum
# -------
@ -1219,6 +1261,11 @@ if is_service_enabled quantum; then
Q_PLUGIN_CONF_FILENAME=linuxbridge_conf.ini
Q_DB_NAME="quantum_linux_bridge"
Q_PLUGIN_CLASS="quantum.plugins.linuxbridge.lb_quantum_plugin.LinuxBridgePluginV2"
elif [[ "$Q_PLUGIN" = "ryu" ]]; then
Q_PLUGIN_CONF_PATH=etc/quantum/plugins/ryu
Q_PLUGIN_CONF_FILENAME=ryu.ini
Q_DB_NAME="ovs_quantum"
Q_PLUGIN_CLASS="quantum.plugins.ryu.ryu_quantum_plugin.RyuQuantumPluginV2"
else
echo "Unknown Quantum plugin '$Q_PLUGIN'.. exiting"
exit 1
@ -1314,6 +1361,9 @@ if is_service_enabled q-svc; then
if [[ "$LB_VLAN_RANGES" != "" ]]; then
iniset /$Q_PLUGIN_CONF_FILE VLANS network_vlan_ranges $LB_VLAN_RANGES
fi
elif [[ "$Q_PLUGIN" = "ryu" ]]; then
iniset /$Q_PLUGIN_CONF_FILE OVS openflow_controller $RYU_OFP_HOST:$RYU_OFP_PORT
iniset /$Q_PLUGIN_CONF_FILE OVS openflow_rest_api $RYU_API_HOST:$RYU_API_PORT
fi
fi
@ -1363,6 +1413,14 @@ if is_service_enabled q-agt; then
iniset /$Q_PLUGIN_CONF_FILE LINUX_BRIDGE physical_interface_mappings $LB_INTERFACE_MAPPINGS
fi
AGENT_BINARY="$QUANTUM_DIR/bin/quantum-linuxbridge-agent"
elif [[ "$Q_PLUGIN" = "ryu" ]]; then
# Set up integration bridge
OVS_BRIDGE=${OVS_BRIDGE:-br-int}
quantum_setup_ovs_bridge $OVS_BRIDGE
if [ -n "$RYU_INTERNAL_INTERFACE" ]; then
sudo ovs-vsctl --no-wait -- --may-exist add-port $OVS_BRIDGE $RYU_INTERNAL_INTERFACE
fi
AGENT_BINARY="$QUANTUM_DIR/quantum/plugins/ryu/agent/ryu_quantum_agent.py"
fi
# Update config w/rootwrap
iniset /$Q_PLUGIN_CONF_FILE AGENT root_helper "$Q_RR_COMMAND"
@ -1391,6 +1449,9 @@ if is_service_enabled q-dhcp; then
iniset $Q_DHCP_CONF_FILE DEFAULT interface_driver quantum.agent.linux.interface.OVSInterfaceDriver
elif [[ "$Q_PLUGIN" = "linuxbridge" ]]; then
iniset $Q_DHCP_CONF_FILE DEFAULT interface_driver quantum.agent.linux.interface.BridgeInterfaceDriver
elif [[ "$Q_PLUGIN" = "ryu" ]]; then
iniset $Q_DHCP_CONF_FILE DEFAULT interface_driver quantum.agent.linux.interface.RyuInterfaceDriver
iniset $Q_DHCP_CONF_FILE DEFAULT ryu_api_host $RYU_API_HOST:$RYU_API_PORT
fi
fi
@ -1417,21 +1478,16 @@ if is_service_enabled q-l3; then
iniset $Q_L3_CONF_FILE DEFAULT interface_driver quantum.agent.linux.interface.OVSInterfaceDriver
iniset $Q_L3_CONF_FILE DEFAULT external_network_bridge $PUBLIC_BRIDGE
# Set up external bridge
# Create it if it does not exist
sudo ovs-vsctl --no-wait -- --may-exist add-br $PUBLIC_BRIDGE
# remove internal ports
for PORT in `sudo ovs-vsctl --no-wait list-ports $PUBLIC_BRIDGE`; do
TYPE=$(sudo ovs-vsctl get interface $PORT type)
if [[ "$TYPE" == "internal" ]]; then
echo `sudo ip link delete $PORT` > /dev/null
sudo ovs-vsctl --no-wait del-port $bridge $PORT
fi
done
# ensure no IP is configured on the public bridge
sudo ip addr flush dev $PUBLIC_BRIDGE
quantum_setup_external_bridge $PUBLIC_BRIDGE
elif [[ "$Q_PLUGIN" = "linuxbridge" ]]; then
iniset $Q_L3_CONF_FILE DEFAULT interface_driver quantum.agent.linux.interface.BridgeInterfaceDriver
iniset $Q_L3_CONF_FILE DEFAULT external_network_bridge ''
elif [[ "$Q_PLUGIN" = "ryu" ]]; then
iniset $Q_L3_CONF_FILE DEFAULT interface_driver quantum.agent.linux.interface.RyuInterfaceDriver
iniset $Q_L3_CONF_FILE DEFAULT external_network_bridge $PUBLIC_BRIDGE
iniset $Q_L3_CONF_FILE DEFAULT ryu_api_host $RYU_API_HOST:$RYU_API_PORT
# Set up external bridge
quantum_setup_external_bridge $PUBLIC_BRIDGE
fi
fi
@ -1599,8 +1655,8 @@ if is_service_enabled swift; then
iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} filter:keystoneauth operator_roles
iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:keystoneauth operator_roles "Member, admin"
if is_service_enabled swift3;then
cat <<EOF>>${SWIFT_CONFIG_PROXY_SERVER}
if is_service_enabled swift3; then
cat <<EOF >>${SWIFT_CONFIG_PROXY_SERVER}
# NOTE(chmou): s3token middleware is not updated yet to use only
# username and password.
[filter:s3token]
@ -1753,6 +1809,11 @@ if is_service_enabled quantum; then
NOVA_VIF_DRIVER="nova.virt.libvirt.vif.LibvirtHybridOVSBridgeDriver"
elif [[ "$Q_PLUGIN" = "linuxbridge" ]]; then
NOVA_VIF_DRIVER="nova.virt.libvirt.vif.QuantumLinuxBridgeVIFDriver"
elif [[ "$Q_PLUGIN" = "ryu" ]]; then
NOVA_VIF_DRIVER="quantum.plugins.ryu.nova.vif.LibvirtOpenVswitchOFPRyuDriver"
add_nova_opt "libvirt_ovs_integration_bridge=$OVS_BRIDGE"
add_nova_opt "linuxnet_ovs_ryu_api_host=$RYU_API_HOST:$RYU_API_PORT"
add_nova_opt "libvirt_ovs_ryu_api_host=$RYU_API_HOST:$RYU_API_PORT"
fi
add_nova_opt "libvirt_vif_driver=$NOVA_VIF_DRIVER"
add_nova_opt "linuxnet_interface_driver=$LINUXNET_VIF_DRIVER"
@ -1899,7 +1960,7 @@ if is_service_enabled q-svc; then
EXT_NET_ID=$(quantum net-create ext_net -- --router:external=True | grep ' id ' | get_field 2)
EXT_GW_IP=$(quantum subnet-create --ip_version 4 $EXT_NET_ID $FLOATING_RANGE -- --enable_dhcp=False | grep 'gateway_ip' | get_field 2)
quantum router-gateway-set $ROUTER_ID $EXT_NET_ID
if [[ "$Q_PLUGIN" = "openvswitch" ]] && [[ "$Q_USE_NAMESPACE" = "True" ]]; then
if is_quantum_ovs_base_plugin "$Q_PLUGIN" && [[ "$Q_USE_NAMESPACE" = "True" ]]; then
CIDR_LEN=${FLOATING_RANGE#*/}
sudo ip addr add $EXT_GW_IP/$CIDR_LEN dev $PUBLIC_BRIDGE
sudo ip link set $PUBLIC_BRIDGE up

View File

@ -101,6 +101,10 @@ TEMPEST_BRANCH=master
HEAT_REPO=${GIT_BASE}/heat-api/heat.git
HEAT_BRANCH=master
# ryu service
RYU_REPO=https://github.com/osrg/ryu.git
RYU_BRANCH=master
# Nova hypervisor configuration. We default to libvirt with **kvm** but will
# drop back to **qemu** if we are unable to load the kvm module. ``stack.sh`` can
# also install an **LXC** or **OpenVZ** based system.

View File

@ -111,5 +111,5 @@ fi
# Quantum dhcp agent runs dnsmasq
if is_service_enabled q-dhcp; then
pid=$(ps aux | awk '/[d]nsmasq.+interface=tap/ { print $2 }')
[ ! -z $pid ] && sudo kill -9 $pid
[ ! -z "$pid" ] && sudo kill -9 $pid
fi