Skip to content

Commit 602cf9b

Browse files
committed
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
1 parent eccaa80 commit 602cf9b

7 files changed

Lines changed: 116 additions & 19 deletions

File tree

files/apts/ryu

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
python-setuptools
2+
python-gevent
3+
python-gflags
4+
python-sphinx

files/rpms/ryu

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
python-setuptools
2+
python-gevent
3+
python-gflags
4+
python-sphinx

lib/nova

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ function configure_nova() {
213213
fi
214214
fi
215215

216-
if is_service_enabled quantum && [[ $Q_PLUGIN = "openvswitch" ]] && ! sudo grep -q '^cgroup_device_acl' $QEMU_CONF ; then
216+
if is_service_enabled quantum && is_quantum_ovs_base_plugin "$Q_PLUGIN" && ! sudo grep -q '^cgroup_device_acl' $QEMU_CONF ; then
217217
# Add /dev/net/tun to cgroup_device_acls, needed for type=ethernet interfaces
218218
cat <<EOF | sudo tee -a $QEMU_CONF
219219
cgroup_device_acl = [

lib/quantum

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,29 @@ function quantum_setup_ovs_bridge() {
3333
sudo ovs-vsctl --no-wait br-set-external-id $bridge bridge-id $bridge
3434
}
3535

36+
function quantum_setup_external_bridge() {
37+
local bridge=$1
38+
# Create it if it does not exist
39+
sudo ovs-vsctl --no-wait -- --may-exist add-br $bridge
40+
# remove internal ports
41+
for PORT in `sudo ovs-vsctl --no-wait list-ports $bridge`; do
42+
TYPE=$(sudo ovs-vsctl get interface $PORT type)
43+
if [[ "$TYPE" == "internal" ]]; then
44+
echo `sudo ip link delete $PORT` > /dev/null
45+
sudo ovs-vsctl --no-wait del-port $bridge $PORT
46+
fi
47+
done
48+
# ensure no IP is configured on the public bridge
49+
sudo ip addr flush dev $bridge
50+
}
51+
52+
function is_quantum_ovs_base_plugin() {
53+
local plguin=$1
54+
if [[ ",openvswitch,ryu," =~ ,${plugin}, ]]; then
55+
return 0
56+
fi
57+
return 1
58+
}
59+
3660
# Restore xtrace
3761
$XTRACE

stack.sh

Lines changed: 78 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,18 @@ Q_USE_ROOTWRAP=${Q_USE_ROOTWRAP=:-True}
342342
# Meta data IP
343343
Q_META_DATA_IP=${Q_META_DATA_IP:-$HOST_IP}
344344

345+
RYU_DIR=$DEST/ryu
346+
# Ryu API Host
347+
RYU_API_HOST=${RYU_API_HOST:-127.0.0.1}
348+
# Ryu API Port
349+
RYU_API_PORT=${RYU_API_PORT:-8080}
350+
# Ryu OFP Host
351+
RYU_OFP_HOST=${RYU_OFP_HOST:-127.0.0.1}
352+
# Ryu OFP Port
353+
RYU_OFP_PORT=${RYU_OFP_PORT:-6633}
354+
# Ryu Applications
355+
RYU_APPS=${RYU_APPS:-ryu.app.simple_isolation,ryu.app.rest}
356+
345357
# Name of the LVM volume group to use/create for iscsi volumes
346358
VOLUME_GROUP=${VOLUME_GROUP:-stack-volumes}
347359
VOLUME_NAME_PREFIX=${VOLUME_NAME_PREFIX:-volume-}
@@ -773,7 +785,7 @@ if is_service_enabled horizon; then
773785
fi
774786

775787
if is_service_enabled q-agt; then
776-
if [[ "$Q_PLUGIN" = "openvswitch" ]]; then
788+
if is_quantum_ovs_base_plugin "$Q_PLUGIN"; then
777789
# Install deps
778790
# FIXME add to files/apts/quantum, but don't install if not needed!
779791
if [[ "$os_PACKAGE" = "deb" ]]; then
@@ -875,7 +887,9 @@ fi
875887
if is_service_enabled tempest; then
876888
install_tempest
877889
fi
878-
890+
if is_service_enabled ryu || (is_service_enabled quantum && [[ "$Q_PLUGIN" = "ryu" ]]); then
891+
git_clone $RYU_REPO $RYU_DIR $RYU_BRANCH
892+
fi
879893

880894
# Initialization
881895
# ==============
@@ -924,6 +938,9 @@ fi
924938
if is_service_enabled tempest; then
925939
configure_tempest
926940
fi
941+
if is_service_enabled ryu || (is_service_enabled quantum && [[ "$Q_PLUGIN" = "ryu" ]]); then
942+
setup_develop $RYU_DIR
943+
fi
927944

928945
if [[ $TRACK_DEPENDS = True ]] ; then
929946
$DEST/.venv/bin/pip freeze > $DEST/requires-post-pip
@@ -1132,6 +1149,31 @@ if is_service_enabled g-reg; then
11321149
fi
11331150

11341151

1152+
# Ryu
1153+
# ---
1154+
# Ryu is not a part of OpenStack project. Please ignore following block if
1155+
# you are not interested in Ryu.
1156+
# launch ryu manager
1157+
if is_service_enabled ryu; then
1158+
RYU_CONF_DIR=/etc/ryu
1159+
if [[ ! -d $RYU_CONF_DIR ]]; then
1160+
sudo mkdir -p $RYU_CONF_DIR
1161+
fi
1162+
sudo chown `whoami` $RYU_CONF_DIR
1163+
RYU_CONF=$RYU_CONF_DIR/ryu.conf
1164+
sudo rm -rf $RYU_CONF
1165+
1166+
cat <<EOF > $RYU_CONF
1167+
--app_lists=$RYU_APPS
1168+
--wsapi_host=$RYU_API_HOST
1169+
--wsapi_port=$RYU_API_PORT
1170+
--ofp_listen_host=$RYU_OFP_HOST
1171+
--ofp_tcp_listen_port=$RYU_OFP_PORT
1172+
EOF
1173+
screen_it ryu "cd $RYU_DIR && $RYU_DIR/bin/ryu-manager --flagfile $RYU_CONF"
1174+
fi
1175+
1176+
11351177
# Quantum
11361178
# -------
11371179

@@ -1219,6 +1261,11 @@ if is_service_enabled quantum; then
12191261
Q_PLUGIN_CONF_FILENAME=linuxbridge_conf.ini
12201262
Q_DB_NAME="quantum_linux_bridge"
12211263
Q_PLUGIN_CLASS="quantum.plugins.linuxbridge.lb_quantum_plugin.LinuxBridgePluginV2"
1264+
elif [[ "$Q_PLUGIN" = "ryu" ]]; then
1265+
Q_PLUGIN_CONF_PATH=etc/quantum/plugins/ryu
1266+
Q_PLUGIN_CONF_FILENAME=ryu.ini
1267+
Q_DB_NAME="ovs_quantum"
1268+
Q_PLUGIN_CLASS="quantum.plugins.ryu.ryu_quantum_plugin.RyuQuantumPluginV2"
12221269
else
12231270
echo "Unknown Quantum plugin '$Q_PLUGIN'.. exiting"
12241271
exit 1
@@ -1314,6 +1361,9 @@ if is_service_enabled q-svc; then
13141361
if [[ "$LB_VLAN_RANGES" != "" ]]; then
13151362
iniset /$Q_PLUGIN_CONF_FILE VLANS network_vlan_ranges $LB_VLAN_RANGES
13161363
fi
1364+
elif [[ "$Q_PLUGIN" = "ryu" ]]; then
1365+
iniset /$Q_PLUGIN_CONF_FILE OVS openflow_controller $RYU_OFP_HOST:$RYU_OFP_PORT
1366+
iniset /$Q_PLUGIN_CONF_FILE OVS openflow_rest_api $RYU_API_HOST:$RYU_API_PORT
13171367
fi
13181368
fi
13191369

@@ -1363,6 +1413,14 @@ if is_service_enabled q-agt; then
13631413
iniset /$Q_PLUGIN_CONF_FILE LINUX_BRIDGE physical_interface_mappings $LB_INTERFACE_MAPPINGS
13641414
fi
13651415
AGENT_BINARY="$QUANTUM_DIR/bin/quantum-linuxbridge-agent"
1416+
elif [[ "$Q_PLUGIN" = "ryu" ]]; then
1417+
# Set up integration bridge
1418+
OVS_BRIDGE=${OVS_BRIDGE:-br-int}
1419+
quantum_setup_ovs_bridge $OVS_BRIDGE
1420+
if [ -n "$RYU_INTERNAL_INTERFACE" ]; then
1421+
sudo ovs-vsctl --no-wait -- --may-exist add-port $OVS_BRIDGE $RYU_INTERNAL_INTERFACE
1422+
fi
1423+
AGENT_BINARY="$QUANTUM_DIR/quantum/plugins/ryu/agent/ryu_quantum_agent.py"
13661424
fi
13671425
# Update config w/rootwrap
13681426
iniset /$Q_PLUGIN_CONF_FILE AGENT root_helper "$Q_RR_COMMAND"
@@ -1391,6 +1449,9 @@ if is_service_enabled q-dhcp; then
13911449
iniset $Q_DHCP_CONF_FILE DEFAULT interface_driver quantum.agent.linux.interface.OVSInterfaceDriver
13921450
elif [[ "$Q_PLUGIN" = "linuxbridge" ]]; then
13931451
iniset $Q_DHCP_CONF_FILE DEFAULT interface_driver quantum.agent.linux.interface.BridgeInterfaceDriver
1452+
elif [[ "$Q_PLUGIN" = "ryu" ]]; then
1453+
iniset $Q_DHCP_CONF_FILE DEFAULT interface_driver quantum.agent.linux.interface.RyuInterfaceDriver
1454+
iniset $Q_DHCP_CONF_FILE DEFAULT ryu_api_host $RYU_API_HOST:$RYU_API_PORT
13941455
fi
13951456
fi
13961457

@@ -1417,21 +1478,16 @@ if is_service_enabled q-l3; then
14171478
iniset $Q_L3_CONF_FILE DEFAULT interface_driver quantum.agent.linux.interface.OVSInterfaceDriver
14181479
iniset $Q_L3_CONF_FILE DEFAULT external_network_bridge $PUBLIC_BRIDGE
14191480
# Set up external bridge
1420-
# Create it if it does not exist
1421-
sudo ovs-vsctl --no-wait -- --may-exist add-br $PUBLIC_BRIDGE
1422-
# remove internal ports
1423-
for PORT in `sudo ovs-vsctl --no-wait list-ports $PUBLIC_BRIDGE`; do
1424-
TYPE=$(sudo ovs-vsctl get interface $PORT type)
1425-
if [[ "$TYPE" == "internal" ]]; then
1426-
echo `sudo ip link delete $PORT` > /dev/null
1427-
sudo ovs-vsctl --no-wait del-port $bridge $PORT
1428-
fi
1429-
done
1430-
# ensure no IP is configured on the public bridge
1431-
sudo ip addr flush dev $PUBLIC_BRIDGE
1481+
quantum_setup_external_bridge $PUBLIC_BRIDGE
14321482
elif [[ "$Q_PLUGIN" = "linuxbridge" ]]; then
14331483
iniset $Q_L3_CONF_FILE DEFAULT interface_driver quantum.agent.linux.interface.BridgeInterfaceDriver
14341484
iniset $Q_L3_CONF_FILE DEFAULT external_network_bridge ''
1485+
elif [[ "$Q_PLUGIN" = "ryu" ]]; then
1486+
iniset $Q_L3_CONF_FILE DEFAULT interface_driver quantum.agent.linux.interface.RyuInterfaceDriver
1487+
iniset $Q_L3_CONF_FILE DEFAULT external_network_bridge $PUBLIC_BRIDGE
1488+
iniset $Q_L3_CONF_FILE DEFAULT ryu_api_host $RYU_API_HOST:$RYU_API_PORT
1489+
# Set up external bridge
1490+
quantum_setup_external_bridge $PUBLIC_BRIDGE
14351491
fi
14361492
fi
14371493

@@ -1599,8 +1655,8 @@ if is_service_enabled swift; then
15991655
iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} filter:keystoneauth operator_roles
16001656
iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:keystoneauth operator_roles "Member, admin"
16011657

1602-
if is_service_enabled swift3;then
1603-
cat <<EOF>>${SWIFT_CONFIG_PROXY_SERVER}
1658+
if is_service_enabled swift3; then
1659+
cat <<EOF >>${SWIFT_CONFIG_PROXY_SERVER}
16041660
# NOTE(chmou): s3token middleware is not updated yet to use only
16051661
# username and password.
16061662
[filter:s3token]
@@ -1753,6 +1809,11 @@ if is_service_enabled quantum; then
17531809
NOVA_VIF_DRIVER="nova.virt.libvirt.vif.LibvirtHybridOVSBridgeDriver"
17541810
elif [[ "$Q_PLUGIN" = "linuxbridge" ]]; then
17551811
NOVA_VIF_DRIVER="nova.virt.libvirt.vif.QuantumLinuxBridgeVIFDriver"
1812+
elif [[ "$Q_PLUGIN" = "ryu" ]]; then
1813+
NOVA_VIF_DRIVER="quantum.plugins.ryu.nova.vif.LibvirtOpenVswitchOFPRyuDriver"
1814+
add_nova_opt "libvirt_ovs_integration_bridge=$OVS_BRIDGE"
1815+
add_nova_opt "linuxnet_ovs_ryu_api_host=$RYU_API_HOST:$RYU_API_PORT"
1816+
add_nova_opt "libvirt_ovs_ryu_api_host=$RYU_API_HOST:$RYU_API_PORT"
17561817
fi
17571818
add_nova_opt "libvirt_vif_driver=$NOVA_VIF_DRIVER"
17581819
add_nova_opt "linuxnet_interface_driver=$LINUXNET_VIF_DRIVER"
@@ -1899,7 +1960,7 @@ if is_service_enabled q-svc; then
18991960
EXT_NET_ID=$(quantum net-create ext_net -- --router:external=True | grep ' id ' | get_field 2)
19001961
EXT_GW_IP=$(quantum subnet-create --ip_version 4 $EXT_NET_ID $FLOATING_RANGE -- --enable_dhcp=False | grep 'gateway_ip' | get_field 2)
19011962
quantum router-gateway-set $ROUTER_ID $EXT_NET_ID
1902-
if [[ "$Q_PLUGIN" = "openvswitch" ]] && [[ "$Q_USE_NAMESPACE" = "True" ]]; then
1963+
if is_quantum_ovs_base_plugin "$Q_PLUGIN" && [[ "$Q_USE_NAMESPACE" = "True" ]]; then
19031964
CIDR_LEN=${FLOATING_RANGE#*/}
19041965
sudo ip addr add $EXT_GW_IP/$CIDR_LEN dev $PUBLIC_BRIDGE
19051966
sudo ip link set $PUBLIC_BRIDGE up

stackrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ TEMPEST_BRANCH=master
101101
HEAT_REPO=${GIT_BASE}/heat-api/heat.git
102102
HEAT_BRANCH=master
103103

104+
# ryu service
105+
RYU_REPO=https://github.com/osrg/ryu.git
106+
RYU_BRANCH=master
107+
104108
# Nova hypervisor configuration. We default to libvirt with **kvm** but will
105109
# drop back to **qemu** if we are unable to load the kvm module. ``stack.sh`` can
106110
# also install an **LXC** or **OpenVZ** based system.

unstack.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,5 +111,5 @@ fi
111111
# Quantum dhcp agent runs dnsmasq
112112
if is_service_enabled q-dhcp; then
113113
pid=$(ps aux | awk '/[d]nsmasq.+interface=tap/ { print $2 }')
114-
[ ! -z $pid ] && sudo kill -9 $pid
114+
[ ! -z "$pid" ] && sudo kill -9 $pid
115115
fi

0 commit comments

Comments
 (0)