diff --git a/files/apts/ryu b/files/apts/ryu new file mode 100644 index 0000000000..1e8f2d2ba9 --- /dev/null +++ b/files/apts/ryu @@ -0,0 +1,4 @@ +python-setuptools +python-gevent +python-gflags +python-sphinx diff --git a/files/rpms/ryu b/files/rpms/ryu new file mode 100644 index 0000000000..1e8f2d2ba9 --- /dev/null +++ b/files/rpms/ryu @@ -0,0 +1,4 @@ +python-setuptools +python-gevent +python-gflags +python-sphinx diff --git a/lib/nova b/lib/nova index 333695ea3e..dbfc294787 100644 --- a/lib/nova +++ b/lib/nova @@ -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 < /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 diff --git a/stack.sh b/stack.sh index 774c454c2d..3fc3204d63 100755 --- a/stack.sh +++ b/stack.sh @@ -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 < $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 <>${SWIFT_CONFIG_PROXY_SERVER} + if is_service_enabled swift3; then + cat <>${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 diff --git a/stackrc b/stackrc index 3002c46343..f9a41bd7b3 100644 --- a/stackrc +++ b/stackrc @@ -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. diff --git a/unstack.sh b/unstack.sh index 49f1e8bb84..42cb7aff0d 100755 --- a/unstack.sh +++ b/unstack.sh @@ -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