lib/quantum: refactor quantum plugins and third party
As quantum plugin support is coming like floodlight, nvp and nec, it's worth while to refactor quantum plugin logic so that each plugin can be modified/enhanced intervening with other quantum plugin. And new plugin support can be added easily (hopefully) without modifying core logic. Change-Id: Ic5ab5b993272fdd3b4e779823323777a845ee681
This commit is contained in:
parent
e575b6f9ae
commit
0dd34df455
1
AUTHORS
1
AUTHORS
@ -19,6 +19,7 @@ Gabriel Hurley <gabriel@strikeawe.com>
|
||||
Gary Kotton <gkotton@redhat.com>
|
||||
Hengqing Hu <hudayou@hotmail.com>
|
||||
Hua ZHANG <zhuadl@cn.ibm.com>
|
||||
Isaku Yamahata <yamahata@private.email.ne.jp>
|
||||
Jake Dahn <admin@jakedahn.com>
|
||||
James E. Blair <james.blair@rackspace.com>
|
||||
Jason Cannavale <jason.cannavale@rackspace.com>
|
||||
|
2
lib/nova
2
lib/nova
@ -229,7 +229,7 @@ function configure_nova() {
|
||||
configure_baremetal_nova_dirs
|
||||
fi
|
||||
|
||||
if is_service_enabled quantum && is_quantum_ovs_base_plugin "$Q_PLUGIN" && ! sudo grep -q '^cgroup_device_acl' $QEMU_CONF ; then
|
||||
if is_service_enabled quantum && is_quantum_ovs_base_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 = [
|
||||
|
328
lib/quantum
328
lib/quantum
@ -171,6 +171,11 @@ if is_service_enabled quantum; then
|
||||
OVS_ENABLE_TUNNELING=${OVS_ENABLE_TUNNELING:-$ENABLE_TENANT_TUNNELS}
|
||||
fi
|
||||
|
||||
# Quantum plugin specific functions
|
||||
# ---------------------------------
|
||||
# Please refer to lib/quantum_plugins/README.md for details.
|
||||
source $TOP_DIR/lib/quantum_plugins/$Q_PLUGIN
|
||||
|
||||
# Entry Points
|
||||
# ------------
|
||||
|
||||
@ -210,22 +215,9 @@ function create_nova_conf_quantum() {
|
||||
iniset $NOVA_CONF DEFAULT quantum_admin_tenant_name "$SERVICE_TENANT_NAME"
|
||||
iniset $NOVA_CONF DEFAULT quantum_url "http://$Q_HOST:$Q_PORT"
|
||||
|
||||
if [[ "$Q_PLUGIN" = "openvswitch" ]]; then
|
||||
NOVA_VIF_DRIVER=${NOVA_VIF_DRIVER:-"nova.virt.libvirt.vif.LibvirtHybridOVSBridgeDriver"}
|
||||
if [ "$VIRT_DRIVER" = 'xenserver' ]; then
|
||||
add_nova_opt "xenapi_vif_driver=nova.virt.xenapi.vif.XenAPIOpenVswitchDriver"
|
||||
add_nova_opt "xenapi_ovs_integration_bridge=$FLAT_NETWORK_BRIDGE"
|
||||
fi
|
||||
elif [[ "$Q_PLUGIN" = "linuxbridge" ]]; then
|
||||
NOVA_VIF_DRIVER=${NOVA_VIF_DRIVER:-"nova.virt.libvirt.vif.QuantumLinuxBridgeVIFDriver"}
|
||||
elif [[ "$Q_PLUGIN" = "ryu" ]]; then
|
||||
NOVA_VIF_DRIVER=${NOVA_VIF_DRIVER:-"quantum.plugins.ryu.nova.vif.LibvirtOpenVswitchOFPRyuDriver"}
|
||||
iniset $NOVA_CONF DEFAULT libvirt_ovs_integration_bridge "$OVS_BRIDGE"
|
||||
iniset $NOVA_CONF DEFAULT linuxnet_ovs_ryu_api_host "$RYU_API_HOST:$RYU_API_PORT"
|
||||
iniset $NOVA_CONF DEFAULT libvirt_ovs_ryu_api_host "$RYU_API_HOST:$RYU_API_PORT"
|
||||
elif [[ "$Q_PLUGIN" = "bigswitch_floodlight" ]]; then
|
||||
NOVA_VIF_DRIVER=${NOVA_VIF_DRIVER:-"nova.virt.libvirt.vif.LibvirtHybridOVSBridgeDriver"}
|
||||
fi
|
||||
# set NOVA_VIF_DRIVER and optionally set options in nova_conf
|
||||
quantum_plugin_create_nova_conf
|
||||
|
||||
iniset $NOVA_CONF DEFAULT libvirt_vif_driver "$NOVA_VIF_DRIVER"
|
||||
iniset $NOVA_CONF DEFAULT linuxnet_interface_driver "$LINUXNET_VIF_DRIVER"
|
||||
if is_service_enabled q-meta; then
|
||||
@ -297,7 +289,7 @@ function create_quantum_initial_network() {
|
||||
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 is_quantum_ovs_base_plugin "$Q_PLUGIN" && [[ "$Q_USE_NAMESPACE" = "True" ]]; then
|
||||
if is_quantum_ovs_base_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
|
||||
@ -328,29 +320,8 @@ function install_quantumclient() {
|
||||
|
||||
# install_quantum_agent_packages() - Collect source and prepare
|
||||
function install_quantum_agent_packages() {
|
||||
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 is_ubuntu; then
|
||||
kernel_version=`cat /proc/version | cut -d " " -f3`
|
||||
install_package make fakeroot dkms openvswitch-switch openvswitch-datapath-dkms linux-headers-$kernel_version
|
||||
else
|
||||
### FIXME(dtroyer): Find RPMs for OpenVSwitch
|
||||
echo "OpenVSwitch packages need to be located"
|
||||
# Fedora does not started OVS by default
|
||||
restart_service openvswitch
|
||||
fi
|
||||
elif [[ "$Q_PLUGIN" = "linuxbridge" ]]; then
|
||||
install_package bridge-utils
|
||||
fi
|
||||
}
|
||||
|
||||
function is_quantum_ovs_base_plugin() {
|
||||
local plugin=$1
|
||||
if [[ ",openvswitch,ryu,bigswitch_floodlight," =~ ,${plugin}, ]]; then
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
# install packages that is specific to plugin agent
|
||||
quantum_plugin_install_agent_packages
|
||||
}
|
||||
|
||||
function setup_quantum() {
|
||||
@ -407,29 +378,9 @@ function _configure_quantum_common() {
|
||||
|
||||
cp $QUANTUM_DIR/etc/quantum.conf $QUANTUM_CONF
|
||||
|
||||
if [[ "$Q_PLUGIN" = "openvswitch" ]]; then
|
||||
Q_PLUGIN_CONF_PATH=etc/quantum/plugins/openvswitch
|
||||
Q_PLUGIN_CONF_FILENAME=ovs_quantum_plugin.ini
|
||||
Q_DB_NAME="ovs_quantum"
|
||||
Q_PLUGIN_CLASS="quantum.plugins.openvswitch.ovs_quantum_plugin.OVSQuantumPluginV2"
|
||||
elif [[ "$Q_PLUGIN" = "linuxbridge" ]]; then
|
||||
Q_PLUGIN_CONF_PATH=etc/quantum/plugins/linuxbridge
|
||||
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"
|
||||
elif [[ "$Q_PLUGIN" = "bigswitch_floodlight" ]]; then
|
||||
Q_PLUGIN_CONF_PATH=etc/quantum/plugins/bigswitch
|
||||
Q_PLUGIN_CONF_FILENAME=restproxy.ini
|
||||
Q_DB_NAME="restproxy_quantum"
|
||||
Q_PLUGIN_CLASS="quantum.plugins.bigswitch.plugin.QuantumRestProxyV2"
|
||||
BS_FL_CONTROLLERS_PORT=${BS_FL_CONTROLLERS_PORT:-localhost:80}
|
||||
BS_FL_CONTROLLER_TIMEOUT=${BS_FL_CONTROLLER_TIMEOUT:-10}
|
||||
fi
|
||||
# set plugin-specific variables
|
||||
# Q_PLUGIN_CONF_PATH, Q_PLUGIN_CONF_FILENAME, Q_DB_NAME, Q_PLUGIN_CLASS
|
||||
quantum_plugin_configure_common
|
||||
|
||||
if [[ $Q_PLUGIN_CONF_PATH == '' || $Q_PLUGIN_CONF_FILENAME == '' || $Q_PLUGIN_CLASS == '' ]]; then
|
||||
echo "Quantum plugin not set.. exiting"
|
||||
@ -463,15 +414,7 @@ function _configure_quantum_debug_command() {
|
||||
_quantum_setup_keystone $QUANTUM_TEST_CONFIG_FILE DEFAULT set_auth_url
|
||||
_quantum_setup_interface_driver $QUANTUM_TEST_CONFIG_FILE
|
||||
|
||||
if is_quantum_ovs_base_plugin "$Q_PLUGIN"; then
|
||||
iniset $QUANTUM_TEST_CONFIG_FILE DEFAULT external_network_bridge $PUBLIC_BRIDGE
|
||||
elif [[ "$Q_PLUGIN" = "linuxbridge" ]]; then
|
||||
iniset $QUANTUM_TEST_CONFIG_FILE DEFAULT external_network_bridge ''
|
||||
fi
|
||||
|
||||
if [[ "$Q_PLUGIN" = "ryu" ]]; then
|
||||
iniset $QUANTUM_TEST_CONFIG_FILE DEFAULT ryu_api_host $RYU_API_HOST:$RYU_API_PORT
|
||||
fi
|
||||
quantum_plugin_configure_debug_command
|
||||
}
|
||||
|
||||
function _configure_quantum_dhcp_agent() {
|
||||
@ -489,9 +432,7 @@ function _configure_quantum_dhcp_agent() {
|
||||
_quantum_setup_keystone $Q_DHCP_CONF_FILE DEFAULT set_auth_url
|
||||
_quantum_setup_interface_driver $Q_DHCP_CONF_FILE
|
||||
|
||||
if [[ "$Q_PLUGIN" = "ryu" ]]; then
|
||||
iniset $Q_DHCP_CONF_FILE DEFAULT ryu_api_host $RYU_API_HOST:$RYU_API_PORT
|
||||
fi
|
||||
quantum_plugin_configure_dhcp_agent
|
||||
}
|
||||
|
||||
function _configure_quantum_l3_agent() {
|
||||
@ -510,16 +451,7 @@ function _configure_quantum_l3_agent() {
|
||||
_quantum_setup_keystone $Q_L3_CONF_FILE DEFAULT set_auth_url
|
||||
_quantum_setup_interface_driver $Q_L3_CONF_FILE
|
||||
|
||||
if is_quantum_ovs_base_plugin "$Q_PLUGIN"; then
|
||||
iniset $Q_L3_CONF_FILE DEFAULT external_network_bridge $PUBLIC_BRIDGE
|
||||
_quantum_setup_external_bridge $PUBLIC_BRIDGE
|
||||
elif [[ "$Q_PLUGIN" = "linuxbridge" ]]; then
|
||||
iniset $Q_L3_CONF_FILE DEFAULT external_network_bridge ''
|
||||
fi
|
||||
|
||||
if [[ "$Q_PLUGIN" = "ryu" ]]; then
|
||||
iniset $Q_L3_CONF_FILE DEFAULT ryu_api_host $RYU_API_HOST:$RYU_API_PORT
|
||||
fi
|
||||
quantum_plugin_configure_l3_agent
|
||||
}
|
||||
|
||||
function _configure_quantum_metadata_agent() {
|
||||
@ -546,105 +478,7 @@ function _configure_quantum_plugin_agent() {
|
||||
iniset /$Q_PLUGIN_CONF_FILE AGENT root_helper "$Q_RR_COMMAND"
|
||||
|
||||
# Configure agent for plugin
|
||||
if [[ "$Q_PLUGIN" = "openvswitch" ]]; then
|
||||
_configure_quantum_plugin_agent_openvswitch
|
||||
elif [[ "$Q_PLUGIN" = "linuxbridge" ]]; then
|
||||
_configure_quantum_plugin_agent_linuxbridge
|
||||
elif [[ "$Q_PLUGIN" = "ryu" ]]; then
|
||||
_configure_quantum_plugin_agent_ryu
|
||||
fi
|
||||
}
|
||||
|
||||
function _configure_quantum_plugin_agent_linuxbridge() {
|
||||
# Setup physical network interface mappings. Override
|
||||
# ``LB_VLAN_RANGES`` and ``LB_INTERFACE_MAPPINGS`` in ``localrc`` for more
|
||||
# complex physical network configurations.
|
||||
if [[ "$LB_INTERFACE_MAPPINGS" = "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]] && [[ "$LB_PHYSICAL_INTERFACE" != "" ]]; then
|
||||
LB_INTERFACE_MAPPINGS=$PHYSICAL_NETWORK:$LB_PHYSICAL_INTERFACE
|
||||
fi
|
||||
if [[ "$LB_INTERFACE_MAPPINGS" != "" ]]; then
|
||||
iniset /$Q_PLUGIN_CONF_FILE LINUX_BRIDGE physical_interface_mappings $LB_INTERFACE_MAPPINGS
|
||||
fi
|
||||
AGENT_BINARY="$QUANTUM_DIR/bin/quantum-linuxbridge-agent"
|
||||
}
|
||||
|
||||
function _configure_quantum_plugin_agent_openvswitch() {
|
||||
# Setup integration bridge
|
||||
OVS_BRIDGE=${OVS_BRIDGE:-br-int}
|
||||
_quantum_setup_ovs_bridge $OVS_BRIDGE
|
||||
|
||||
# Setup agent for tunneling
|
||||
if [[ "$OVS_ENABLE_TUNNELING" = "True" ]]; then
|
||||
# Verify tunnels are supported
|
||||
# REVISIT - also check kernel module support for GRE and patch ports
|
||||
OVS_VERSION=`ovs-vsctl --version | head -n 1 | awk '{print $4;}'`
|
||||
if [ $OVS_VERSION \< "1.4" ] && ! is_service_enabled q-svc ; then
|
||||
echo "You are running OVS version $OVS_VERSION."
|
||||
echo "OVS 1.4+ is required for tunneling between multiple hosts."
|
||||
exit 1
|
||||
fi
|
||||
iniset /$Q_PLUGIN_CONF_FILE OVS enable_tunneling True
|
||||
iniset /$Q_PLUGIN_CONF_FILE OVS local_ip $HOST_IP
|
||||
fi
|
||||
|
||||
# Setup physical network bridge mappings. Override
|
||||
# ``OVS_VLAN_RANGES`` and ``OVS_BRIDGE_MAPPINGS`` in ``localrc`` for more
|
||||
# complex physical network configurations.
|
||||
if [[ "$OVS_BRIDGE_MAPPINGS" = "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]] && [[ "$OVS_PHYSICAL_BRIDGE" != "" ]]; then
|
||||
OVS_BRIDGE_MAPPINGS=$PHYSICAL_NETWORK:$OVS_PHYSICAL_BRIDGE
|
||||
|
||||
# Configure bridge manually with physical interface as port for multi-node
|
||||
sudo ovs-vsctl --no-wait -- --may-exist add-br $OVS_PHYSICAL_BRIDGE
|
||||
fi
|
||||
if [[ "$OVS_BRIDGE_MAPPINGS" != "" ]]; then
|
||||
iniset /$Q_PLUGIN_CONF_FILE OVS bridge_mappings $OVS_BRIDGE_MAPPINGS
|
||||
fi
|
||||
AGENT_BINARY="$QUANTUM_DIR/bin/quantum-openvswitch-agent"
|
||||
|
||||
if [ "$VIRT_DRIVER" = 'xenserver' ]; then
|
||||
# Nova will always be installed along with quantum for a domU
|
||||
# devstack install, so it should be safe to rely on nova.conf
|
||||
# for xenapi configuration.
|
||||
Q_RR_DOM0_COMMAND="$QUANTUM_DIR/bin/quantum-rootwrap-dom0 $NOVA_CONF"
|
||||
# Under XS/XCP, the ovs agent needs to target the dom0
|
||||
# integration bridge. This is enabled by using a root wrapper
|
||||
# that executes commands on dom0 via a XenAPI plugin.
|
||||
iniset /$Q_PLUGIN_CONF_FILE AGENT root_helper "$Q_RR_DOM0_COMMAND"
|
||||
|
||||
# FLAT_NETWORK_BRIDGE is the dom0 integration bridge. To
|
||||
# ensure the bridge lacks direct connectivity, set
|
||||
# VM_VLAN=-1;VM_DEV=invalid in localrc
|
||||
iniset /$Q_PLUGIN_CONF_FILE OVS integration_bridge $FLAT_NETWORK_BRIDGE
|
||||
|
||||
# The ovs agent needs to ensure that the ports associated with
|
||||
# a given network share the same local vlan tag. On
|
||||
# single-node XS/XCP, this requires monitoring both the dom0
|
||||
# bridge, where VM's are attached, and the domU bridge, where
|
||||
# dhcp servers are attached.
|
||||
if is_service_enabled q-dhcp; then
|
||||
iniset /$Q_PLUGIN_CONF_FILE OVS domu_integration_bridge $OVS_BRIDGE
|
||||
# DomU will use the regular rootwrap
|
||||
iniset /$Q_PLUGIN_CONF_FILE AGENT domu_root_helper "$Q_RR_COMMAND"
|
||||
# Plug the vm interface into the domU integration bridge.
|
||||
sudo ip addr flush dev $GUEST_INTERFACE_DEFAULT
|
||||
sudo ip link set $OVS_BRIDGE up
|
||||
# Assign the VM IP only if it has been set explicitly
|
||||
if [[ "$VM_IP" != "" ]]; then
|
||||
sudo ip addr add $VM_IP dev $OVS_BRIDGE
|
||||
fi
|
||||
sudo ovs-vsctl add-port $OVS_BRIDGE $GUEST_INTERFACE_DEFAULT
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function _configure_quantum_plugin_agent_ryu() {
|
||||
# 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"
|
||||
quantum_plugin_configure_plugin_agent
|
||||
}
|
||||
|
||||
# _configure_quantum_service() - Set config files for quantum service
|
||||
@ -674,57 +508,7 @@ function _configure_quantum_service() {
|
||||
_quantum_setup_keystone $Q_API_PASTE_FILE filter:authtoken
|
||||
|
||||
# Configure plugin
|
||||
if [[ "$Q_PLUGIN" = "openvswitch" ]]; then
|
||||
if [[ "$ENABLE_TENANT_TUNNELS" = "True" ]]; then
|
||||
iniset /$Q_PLUGIN_CONF_FILE OVS tenant_network_type gre
|
||||
iniset /$Q_PLUGIN_CONF_FILE OVS tunnel_id_ranges $TENANT_TUNNEL_RANGES
|
||||
elif [[ "$ENABLE_TENANT_VLANS" = "True" ]]; then
|
||||
iniset /$Q_PLUGIN_CONF_FILE OVS tenant_network_type vlan
|
||||
else
|
||||
echo "WARNING - The openvswitch plugin is using local tenant networks, with no connectivity between hosts."
|
||||
fi
|
||||
|
||||
# Override ``OVS_VLAN_RANGES`` and ``OVS_BRIDGE_MAPPINGS`` in ``localrc``
|
||||
# for more complex physical network configurations.
|
||||
if [[ "$OVS_VLAN_RANGES" = "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]]; then
|
||||
OVS_VLAN_RANGES=$PHYSICAL_NETWORK
|
||||
if [[ "$TENANT_VLAN_RANGE" != "" ]]; then
|
||||
OVS_VLAN_RANGES=$OVS_VLAN_RANGES:$TENANT_VLAN_RANGE
|
||||
fi
|
||||
fi
|
||||
if [[ "$OVS_VLAN_RANGES" != "" ]]; then
|
||||
iniset /$Q_PLUGIN_CONF_FILE OVS network_vlan_ranges $OVS_VLAN_RANGES
|
||||
fi
|
||||
|
||||
# Enable tunnel networks if selected
|
||||
if [[ $OVS_ENABLE_TUNNELING = "True" ]]; then
|
||||
iniset /$Q_PLUGIN_CONF_FILE OVS enable_tunneling True
|
||||
fi
|
||||
elif [[ "$Q_PLUGIN" = "linuxbridge" ]]; then
|
||||
if [[ "$ENABLE_TENANT_VLANS" = "True" ]]; then
|
||||
iniset /$Q_PLUGIN_CONF_FILE VLANS tenant_network_type vlan
|
||||
else
|
||||
echo "WARNING - The linuxbridge plugin is using local tenant networks, with no connectivity between hosts."
|
||||
fi
|
||||
|
||||
# Override ``LB_VLAN_RANGES`` and ``LB_INTERFACE_MAPPINGS`` in ``localrc``
|
||||
# for more complex physical network configurations.
|
||||
if [[ "$LB_VLAN_RANGES" = "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]]; then
|
||||
LB_VLAN_RANGES=$PHYSICAL_NETWORK
|
||||
if [[ "$TENANT_VLAN_RANGE" != "" ]]; then
|
||||
LB_VLAN_RANGES=$LB_VLAN_RANGES:$TENANT_VLAN_RANGE
|
||||
fi
|
||||
fi
|
||||
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
|
||||
elif [[ "$Q_PLUGIN" = "bigswitch_floodlight" ]]; then
|
||||
iniset /$Q_PLUGIN_CONF_FILE RESTPROXY servers $BS_FL_CONTROLLERS_PORT
|
||||
iniset /$Q_PLUGIN_CONF_FILE RESTPROXY servertimeout $BS_FL_CONTROLLER_TIMEOUT
|
||||
fi
|
||||
quantum_plugin_configure_service
|
||||
}
|
||||
|
||||
# Utility Functions
|
||||
@ -784,32 +568,8 @@ function _quantum_setup_keystone() {
|
||||
rm -f $QUANTUM_AUTH_CACHE_DIR/*
|
||||
}
|
||||
|
||||
function _quantum_setup_ovs_bridge() {
|
||||
local bridge=$1
|
||||
quantum-ovs-cleanup --ovs_integration_bridge $bridge
|
||||
sudo ovs-vsctl --no-wait -- --may-exist add-br $bridge
|
||||
sudo ovs-vsctl --no-wait br-set-external-id $bridge bridge-id $bridge
|
||||
}
|
||||
|
||||
function _quantum_setup_interface_driver() {
|
||||
local conf_file=$1
|
||||
if [[ "$Q_PLUGIN" == "openvswitch" ]]; then
|
||||
iniset $conf_file DEFAULT interface_driver quantum.agent.linux.interface.OVSInterfaceDriver
|
||||
elif [[ "$Q_PLUGIN" = "linuxbridge" ]]; then
|
||||
iniset $conf_file DEFAULT interface_driver quantum.agent.linux.interface.BridgeInterfaceDriver
|
||||
elif [[ "$Q_PLUGIN" = "ryu" ]]; then
|
||||
iniset $conf_file DEFAULT interface_driver quantum.agent.linux.interface.RyuInterfaceDriver
|
||||
elif [[ "$Q_PLUGIN" = "bigswitch_floodlight" ]]; then
|
||||
iniset $conf_file DEFAULT interface_driver quantum.agent.linux.interface.OVSInterfaceDriver
|
||||
fi
|
||||
}
|
||||
|
||||
function _quantum_setup_external_bridge() {
|
||||
local bridge=$1
|
||||
quantum-ovs-cleanup --external_network_bridge $bridge
|
||||
sudo ovs-vsctl --no-wait -- --may-exist add-br $bridge
|
||||
# ensure no IP is configured on the public bridge
|
||||
sudo ip addr flush dev $bridge
|
||||
quantum_plugin_setup_interface_driver $1
|
||||
}
|
||||
|
||||
# Functions for Quantum Exercises
|
||||
@ -886,55 +646,45 @@ function _ssh_check_quantum() {
|
||||
|
||||
# Quantum 3rd party programs
|
||||
#---------------------------
|
||||
# A comma-separated list of 3rd party programs
|
||||
QUANTUM_THIRD_PARTIES="ryu,bigswitch_floodlight"
|
||||
for third_party in ${QUANTUM_THIRD_PARTIES//,/ }; do
|
||||
source lib/$third_party
|
||||
# please refer to lib/quantum_thirdparty/README.md for details
|
||||
QUANTUM_THIRD_PARTIES=""
|
||||
for f in $TOP_DIR/lib/quantum_thirdparty/*; do
|
||||
third_party=$(basename $f)
|
||||
if is_service_enabled $third_party; then
|
||||
source $TOP_DIR/lib/quantum_thirdparty/$third_party
|
||||
QUANTUM_THIRD_PARTIES="$QUANTUM_THIRD_PARTIES,$third_party"
|
||||
fi
|
||||
done
|
||||
|
||||
function _quantum_third_party_do() {
|
||||
for third_party in ${QUANTUM_THIRD_PARTIES//,/ }; do
|
||||
${1}_${third_party}
|
||||
done
|
||||
}
|
||||
|
||||
# configure_quantum_third_party() - Set config files, create data dirs, etc
|
||||
function configure_quantum_third_party() {
|
||||
for third_party in ${QUANTUM_THIRD_PARTIES//,/ }; do
|
||||
if is_service_enabled $third_party; then
|
||||
configure_${third_party}
|
||||
fi
|
||||
done
|
||||
_quantum_third_party_do configure
|
||||
}
|
||||
|
||||
# init_quantum_third_party() - Initialize databases, etc.
|
||||
function init_quantum_third_party() {
|
||||
for third_party in ${QUANTUM_THIRD_PARTIES//,/ }; do
|
||||
if is_service_enabled $third_party; then
|
||||
init_${third_party}
|
||||
fi
|
||||
done
|
||||
_quantum_third_party_do init
|
||||
}
|
||||
|
||||
# install_quantum_third_party() - Collect source and prepare
|
||||
function install_quantum_third_party() {
|
||||
for third_party in ${QUANTUM_THIRD_PARTIES//,/ }; do
|
||||
if is_service_enabled $third_party; then
|
||||
install_${third_party}
|
||||
fi
|
||||
done
|
||||
_quantum_third_party_do install
|
||||
}
|
||||
|
||||
# start_quantum_third_party() - Start running processes, including screen
|
||||
function start_quantum_third_party() {
|
||||
for third_party in ${QUANTUM_THIRD_PARTIES//,/ }; do
|
||||
if is_service_enabled $third_party; then
|
||||
start_${third_party}
|
||||
fi
|
||||
done
|
||||
_quantum_third_party_do start
|
||||
}
|
||||
|
||||
# stop_quantum_third_party - Stop running processes (non-screen)
|
||||
function stop_quantum_third_party() {
|
||||
for third_party in ${QUANTUM_THIRD_PARTIES//,/ }; do
|
||||
if is_service_enabled $third_party; then
|
||||
stop_${third_party}
|
||||
fi
|
||||
done
|
||||
_quantum_third_party_do stop
|
||||
}
|
||||
|
||||
|
||||
|
34
lib/quantum_plugins/README.md
Normal file
34
lib/quantum_plugins/README.md
Normal file
@ -0,0 +1,34 @@
|
||||
Quantum plugin specific files
|
||||
=============================
|
||||
Quantum plugins require plugin specific behavior.
|
||||
The files under the directory, ``lib/quantum_plugins/``, will be used
|
||||
when their service is enabled.
|
||||
Each plugin has ``lib/quantum_plugins/$Q_PLUGIN`` and define the following
|
||||
functions.
|
||||
Plugin specific configuration variables should be in this file.
|
||||
|
||||
* filename: ``$Q_PLUGIN``
|
||||
* The corresponding file name MUST be the same to plugin name ``$Q_PLUGIN``.
|
||||
Plugin specific configuration variables should be in this file.
|
||||
|
||||
functions
|
||||
---------
|
||||
``lib/quantum`` calls the following functions when the ``$Q_PLUGIN`` is enabled
|
||||
|
||||
* ``quantum_plugin_create_nova_conf`` :
|
||||
set ``NOVA_VIF_DRIVER`` and optionally set options in nova_conf
|
||||
e.g.
|
||||
NOVA_VIF_DRIVER=${NOVA_VIF_DRIVER:-"nova.virt.libvirt.vif.LibvirtHybridOVSBridgeDriver"}
|
||||
* ``quantum_plugin_install_agent_packages`` :
|
||||
install packages that is specific to plugin agent
|
||||
e.g.
|
||||
install_package bridge-utils
|
||||
* ``quantum_plugin_configure_common`` :
|
||||
set plugin-specific variables, ``Q_PLUGIN_CONF_PATH``, ``Q_PLUGIN_CONF_FILENAME``,
|
||||
``Q_DB_NAME``, ``Q_PLUGIN_CLASS``
|
||||
* ``quantum_plugin_configure_debug_command``
|
||||
* ``quantum_plugin_configure_dhcp_agent``
|
||||
* ``quantum_plugin_configure_l3_agent``
|
||||
* ``quantum_plugin_configure_plugin_agent``
|
||||
* ``quantum_plugin_configure_service``
|
||||
* ``quantum_plugin_setup_interface_driver``
|
55
lib/quantum_plugins/bigswitch_floodlight
Normal file
55
lib/quantum_plugins/bigswitch_floodlight
Normal file
@ -0,0 +1,55 @@
|
||||
# Quantum Big Switch/FloodLight plugin
|
||||
# ------------------------------------
|
||||
|
||||
# Save trace setting
|
||||
XTRACE=$(set +o | grep xtrace)
|
||||
set +o xtrace
|
||||
|
||||
source $TOP_DIR/lib/quantum_plugins/ovs_base
|
||||
source $TOP_DIR/lib/quantum_thirdparty/bigswitch_floodlight # for third party service specific configuration values
|
||||
|
||||
function quantum_plugin_create_nova_conf() {
|
||||
NOVA_VIF_DRIVER=${NOVA_VIF_DRIVER:-"nova.virt.libvirt.vif.LibvirtHybridOVSBridgeDriver"}
|
||||
}
|
||||
|
||||
function quantum_plugin_install_agent_packages() {
|
||||
_quantum_ovs_base_install_agent_packages
|
||||
}
|
||||
|
||||
function quantum_plugin_configure_common() {
|
||||
Q_PLUGIN_CONF_PATH=etc/quantum/plugins/bigswitch
|
||||
Q_PLUGIN_CONF_FILENAME=restproxy.ini
|
||||
Q_DB_NAME="restproxy_quantum"
|
||||
Q_PLUGIN_CLASS="quantum.plugins.bigswitch.plugin.QuantumRestProxyV2"
|
||||
BS_FL_CONTROLLERS_PORT=${BS_FL_CONTROLLERS_PORT:-localhost:80}
|
||||
BS_FL_CONTROLLER_TIMEOUT=${BS_FL_CONTROLLER_TIMEOUT:-10}
|
||||
}
|
||||
|
||||
function quantum_plugin_configure_debug_command() {
|
||||
_quantum_ovs_base_configure_debug_command
|
||||
}
|
||||
|
||||
function quantum_plugin_configure_dhcp_agent() {
|
||||
:
|
||||
}
|
||||
|
||||
function quantum_plugin_configure_l3_agent() {
|
||||
_quantum_ovs_base_configure_l3_agent
|
||||
}
|
||||
|
||||
function quantum_plugin_configure_plugin_agent() {
|
||||
:
|
||||
}
|
||||
|
||||
function quantum_plugin_configure_service() {
|
||||
iniset /$Q_PLUGIN_CONF_FILE RESTPROXY servers $BS_FL_CONTROLLERS_PORT
|
||||
iniset /$Q_PLUGIN_CONF_FILE RESTPROXY servertimeout $BS_FL_CONTROLLER_TIMEOUT
|
||||
}
|
||||
|
||||
function quantum_plugin_setup_interface_driver() {
|
||||
local conf_file=$1
|
||||
iniset $conf_file DEFAULT interface_driver quantum.agent.linux.interface.OVSInterfaceDriver
|
||||
}
|
||||
|
||||
# Restore xtrace
|
||||
$XTRACE
|
79
lib/quantum_plugins/linuxbridge
Normal file
79
lib/quantum_plugins/linuxbridge
Normal file
@ -0,0 +1,79 @@
|
||||
# Quantum Linux Bridge plugin
|
||||
# ---------------------------
|
||||
|
||||
# Save trace setting
|
||||
XTRACE=$(set +o | grep xtrace)
|
||||
set +o xtrace
|
||||
|
||||
function is_quantum_ovs_base_plugin() {
|
||||
# linuxbridge doesn't use OVS
|
||||
return 1
|
||||
}
|
||||
|
||||
function quantum_plugin_create_nova_conf() {
|
||||
NOVA_VIF_DRIVER=${NOVA_VIF_DRIVER:-"nova.virt.libvirt.vif.QuantumLinuxBridgeVIFDriver"}
|
||||
}
|
||||
|
||||
function quantum_plugin_install_agent_packages() {
|
||||
install_package bridge-utils
|
||||
}
|
||||
|
||||
function quantum_plugin_configure_common() {
|
||||
Q_PLUGIN_CONF_PATH=etc/quantum/plugins/linuxbridge
|
||||
Q_PLUGIN_CONF_FILENAME=linuxbridge_conf.ini
|
||||
Q_DB_NAME="quantum_linux_bridge"
|
||||
Q_PLUGIN_CLASS="quantum.plugins.linuxbridge.lb_quantum_plugin.LinuxBridgePluginV2"
|
||||
}
|
||||
|
||||
function quantum_plugin_configure_debug_command() {
|
||||
iniset $QUANTUM_TEST_CONFIG_FILE DEFAULT external_network_bridge
|
||||
}
|
||||
|
||||
function quantum_plugin_configure_dhcp_agent() {
|
||||
:
|
||||
}
|
||||
|
||||
function quantum_plugin_configure_l3_agent() {
|
||||
iniset $Q_L3_CONF_FILE DEFAULT external_network_bridge
|
||||
}
|
||||
|
||||
function quantum_plugin_configure_plugin_agent() {
|
||||
# Setup physical network interface mappings. Override
|
||||
# ``LB_VLAN_RANGES`` and ``LB_INTERFACE_MAPPINGS`` in ``localrc`` for more
|
||||
# complex physical network configurations.
|
||||
if [[ "$LB_INTERFACE_MAPPINGS" = "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]] && [[ "$LB_PHYSICAL_INTERFACE" != "" ]]; then
|
||||
LB_INTERFACE_MAPPINGS=$PHYSICAL_NETWORK:$LB_PHYSICAL_INTERFACE
|
||||
fi
|
||||
if [[ "$LB_INTERFACE_MAPPINGS" != "" ]]; then
|
||||
iniset /$Q_PLUGIN_CONF_FILE LINUX_BRIDGE physical_interface_mappings $LB_INTERFACE_MAPPINGS
|
||||
fi
|
||||
AGENT_BINARY="$QUANTUM_DIR/bin/quantum-linuxbridge-agent"
|
||||
}
|
||||
|
||||
function quantum_plugin_configure_service() {
|
||||
if [[ "$ENABLE_TENANT_VLANS" = "True" ]]; then
|
||||
iniset /$Q_PLUGIN_CONF_FILE VLANS tenant_network_type vlan
|
||||
else
|
||||
echo "WARNING - The linuxbridge plugin is using local tenant networks, with no connectivity between hosts."
|
||||
fi
|
||||
|
||||
# Override ``LB_VLAN_RANGES`` and ``LB_INTERFACE_MAPPINGS`` in ``localrc``
|
||||
# for more complex physical network configurations.
|
||||
if [[ "$LB_VLAN_RANGES" = "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]]; then
|
||||
LB_VLAN_RANGES=$PHYSICAL_NETWORK
|
||||
if [[ "$TENANT_VLAN_RANGE" != "" ]]; then
|
||||
LB_VLAN_RANGES=$LB_VLAN_RANGES:$TENANT_VLAN_RANGE
|
||||
fi
|
||||
fi
|
||||
if [[ "$LB_VLAN_RANGES" != "" ]]; then
|
||||
iniset /$Q_PLUGIN_CONF_FILE VLANS network_vlan_ranges $LB_VLAN_RANGES
|
||||
fi
|
||||
}
|
||||
|
||||
function quantum_plugin_setup_interface_driver() {
|
||||
local conf_file=$1
|
||||
iniset $conf_file DEFAULT interface_driver quantum.agent.linux.interface.BridgeInterfaceDriver
|
||||
}
|
||||
|
||||
# Restore xtrace
|
||||
$XTRACE
|
144
lib/quantum_plugins/openvswitch
Normal file
144
lib/quantum_plugins/openvswitch
Normal file
@ -0,0 +1,144 @@
|
||||
# Quantum Open vSwtich plugin
|
||||
# ---------------------------
|
||||
|
||||
# Save trace setting
|
||||
XTRACE=$(set +o | grep xtrace)
|
||||
set +o xtrace
|
||||
|
||||
source $TOP_DIR/lib/quantum_plugins/ovs_base
|
||||
|
||||
function quantum_plugin_create_nova_conf() {
|
||||
NOVA_VIF_DRIVER=${NOVA_VIF_DRIVER:-"nova.virt.libvirt.vif.LibvirtHybridOVSBridgeDriver"}
|
||||
if [ "$VIRT_DRIVER" = 'xenserver' ]; then
|
||||
iniset $NOVA_CONF DEFAULT xenapi_vif_driver nova.virt.xenapi.vif.XenAPIOpenVswitchDriver
|
||||
iniset $NOVA_CONF DEFAULT xenapi_ovs_integration_bridge $FLAT_NETWORK_BRIDGE
|
||||
fi
|
||||
}
|
||||
|
||||
function quantum_plugin_install_agent_packages() {
|
||||
_quantum_ovs_base_install_agent_packages
|
||||
}
|
||||
|
||||
function quantum_plugin_configure_common() {
|
||||
Q_PLUGIN_CONF_PATH=etc/quantum/plugins/openvswitch
|
||||
Q_PLUGIN_CONF_FILENAME=ovs_quantum_plugin.ini
|
||||
Q_DB_NAME="ovs_quantum"
|
||||
Q_PLUGIN_CLASS="quantum.plugins.openvswitch.ovs_quantum_plugin.OVSQuantumPluginV2"
|
||||
}
|
||||
|
||||
function quantum_plugin_configure_debug_command() {
|
||||
_quantum_ovs_base_configure_debug_command
|
||||
}
|
||||
|
||||
function quantum_plugin_configure_dhcp_agent() {
|
||||
:
|
||||
}
|
||||
|
||||
function quantum_plugin_configure_l3_agent() {
|
||||
_quantum_ovs_base_configure_l3_agent
|
||||
}
|
||||
|
||||
function quantum_plugin_configure_plugin_agent() {
|
||||
# Setup integration bridge
|
||||
OVS_BRIDGE=${OVS_BRIDGE:-br-int}
|
||||
_quantum_ovs_base_setup_bridge $OVS_BRIDGE
|
||||
|
||||
# Setup agent for tunneling
|
||||
if [[ "$OVS_ENABLE_TUNNELING" = "True" ]]; then
|
||||
# Verify tunnels are supported
|
||||
# REVISIT - also check kernel module support for GRE and patch ports
|
||||
OVS_VERSION=`ovs-vsctl --version | head -n 1 | awk '{print $4;}'`
|
||||
if [ $OVS_VERSION \< "1.4" ] && ! is_service_enabled q-svc ; then
|
||||
echo "You are running OVS version $OVS_VERSION."
|
||||
echo "OVS 1.4+ is required for tunneling between multiple hosts."
|
||||
exit 1
|
||||
fi
|
||||
iniset /$Q_PLUGIN_CONF_FILE OVS enable_tunneling True
|
||||
iniset /$Q_PLUGIN_CONF_FILE OVS local_ip $HOST_IP
|
||||
fi
|
||||
|
||||
# Setup physical network bridge mappings. Override
|
||||
# ``OVS_VLAN_RANGES`` and ``OVS_BRIDGE_MAPPINGS`` in ``localrc`` for more
|
||||
# complex physical network configurations.
|
||||
if [[ "$OVS_BRIDGE_MAPPINGS" = "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]] && [[ "$OVS_PHYSICAL_BRIDGE" != "" ]]; then
|
||||
OVS_BRIDGE_MAPPINGS=$PHYSICAL_NETWORK:$OVS_PHYSICAL_BRIDGE
|
||||
|
||||
# Configure bridge manually with physical interface as port for multi-node
|
||||
sudo ovs-vsctl --no-wait -- --may-exist add-br $OVS_PHYSICAL_BRIDGE
|
||||
fi
|
||||
if [[ "$OVS_BRIDGE_MAPPINGS" != "" ]]; then
|
||||
iniset /$Q_PLUGIN_CONF_FILE OVS bridge_mappings $OVS_BRIDGE_MAPPINGS
|
||||
fi
|
||||
AGENT_BINARY="$QUANTUM_DIR/bin/quantum-openvswitch-agent"
|
||||
|
||||
if [ "$VIRT_DRIVER" = 'xenserver' ]; then
|
||||
# Nova will always be installed along with quantum for a domU
|
||||
# devstack install, so it should be safe to rely on nova.conf
|
||||
# for xenapi configuration.
|
||||
Q_RR_DOM0_COMMAND="$QUANTUM_DIR/bin/quantum-rootwrap-dom0 $NOVA_CONF"
|
||||
# Under XS/XCP, the ovs agent needs to target the dom0
|
||||
# integration bridge. This is enabled by using a root wrapper
|
||||
# that executes commands on dom0 via a XenAPI plugin.
|
||||
iniset /$Q_PLUGIN_CONF_FILE AGENT root_helper "$Q_RR_DOM0_COMMAND"
|
||||
|
||||
# FLAT_NETWORK_BRIDGE is the dom0 integration bridge. To
|
||||
# ensure the bridge lacks direct connectivity, set
|
||||
# VM_VLAN=-1;VM_DEV=invalid in localrc
|
||||
iniset /$Q_PLUGIN_CONF_FILE OVS integration_bridge $FLAT_NETWORK_BRIDGE
|
||||
|
||||
# The ovs agent needs to ensure that the ports associated with
|
||||
# a given network share the same local vlan tag. On
|
||||
# single-node XS/XCP, this requires monitoring both the dom0
|
||||
# bridge, where VM's are attached, and the domU bridge, where
|
||||
# dhcp servers are attached.
|
||||
if is_service_enabled q-dhcp; then
|
||||
iniset /$Q_PLUGIN_CONF_FILE OVS domu_integration_bridge $OVS_BRIDGE
|
||||
# DomU will use the regular rootwrap
|
||||
iniset /$Q_PLUGIN_CONF_FILE AGENT domu_root_helper "$Q_RR_COMMAND"
|
||||
# Plug the vm interface into the domU integration bridge.
|
||||
sudo ip addr flush dev $GUEST_INTERFACE_DEFAULT
|
||||
sudo ip link set $OVS_BRIDGE up
|
||||
# Assign the VM IP only if it has been set explicitly
|
||||
if [[ "$VM_IP" != "" ]]; then
|
||||
sudo ip addr add $VM_IP dev $OVS_BRIDGE
|
||||
fi
|
||||
sudo ovs-vsctl add-port $OVS_BRIDGE $GUEST_INTERFACE_DEFAULT
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function quantum_plugin_configure_service() {
|
||||
if [[ "$ENABLE_TENANT_TUNNELS" = "True" ]]; then
|
||||
iniset /$Q_PLUGIN_CONF_FILE OVS tenant_network_type gre
|
||||
iniset /$Q_PLUGIN_CONF_FILE OVS tunnel_id_ranges $TENANT_TUNNEL_RANGES
|
||||
elif [[ "$ENABLE_TENANT_VLANS" = "True" ]]; then
|
||||
iniset /$Q_PLUGIN_CONF_FILE OVS tenant_network_type vlan
|
||||
else
|
||||
echo "WARNING - The openvswitch plugin is using local tenant networks, with no connectivity between hosts."
|
||||
fi
|
||||
|
||||
# Override ``OVS_VLAN_RANGES`` and ``OVS_BRIDGE_MAPPINGS`` in ``localrc``
|
||||
# for more complex physical network configurations.
|
||||
if [[ "$OVS_VLAN_RANGES" = "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]]; then
|
||||
OVS_VLAN_RANGES=$PHYSICAL_NETWORK
|
||||
if [[ "$TENANT_VLAN_RANGE" != "" ]]; then
|
||||
OVS_VLAN_RANGES=$OVS_VLAN_RANGES:$TENANT_VLAN_RANGE
|
||||
fi
|
||||
fi
|
||||
if [[ "$OVS_VLAN_RANGES" != "" ]]; then
|
||||
iniset /$Q_PLUGIN_CONF_FILE OVS network_vlan_ranges $OVS_VLAN_RANGES
|
||||
fi
|
||||
|
||||
# Enable tunnel networks if selected
|
||||
if [[ $OVS_ENABLE_TUNNELING = "True" ]]; then
|
||||
iniset /$Q_PLUGIN_CONF_FILE OVS enable_tunneling True
|
||||
fi
|
||||
}
|
||||
|
||||
function quantum_plugin_setup_interface_driver() {
|
||||
local conf_file=$1
|
||||
iniset $conf_file DEFAULT interface_driver quantum.agent.linux.interface.OVSInterfaceDriver
|
||||
}
|
||||
|
||||
# Restore xtrace
|
||||
$XTRACE
|
49
lib/quantum_plugins/ovs_base
Normal file
49
lib/quantum_plugins/ovs_base
Normal file
@ -0,0 +1,49 @@
|
||||
# common functions for ovs based plugin
|
||||
# -------------------------------------
|
||||
|
||||
# Save trace setting
|
||||
XTRACE=$(set +o | grep xtrace)
|
||||
set +o xtrace
|
||||
|
||||
function is_quantum_ovs_base_plugin() {
|
||||
# Yes, we use OVS.
|
||||
return 0
|
||||
}
|
||||
|
||||
function _quantum_ovs_base_setup_bridge() {
|
||||
local bridge=$1
|
||||
quantum-ovs-cleanup --ovs_integration_bridge $bridge
|
||||
sudo ovs-vsctl --no-wait -- --may-exist add-br $bridge
|
||||
sudo ovs-vsctl --no-wait br-set-external-id $bridge bridge-id $bridge
|
||||
}
|
||||
|
||||
function _quantum_ovs_base_install_agent_packages() {
|
||||
local kernel_version
|
||||
# Install deps
|
||||
# FIXME add to ``files/apts/quantum``, but don't install if not needed!
|
||||
if is_ubuntu; then
|
||||
kernel_version=`cat /proc/version | cut -d " " -f3`
|
||||
install_package make fakeroot dkms openvswitch-switch openvswitch-datapath-dkms linux-headers-$kernel_version
|
||||
else
|
||||
### FIXME(dtroyer): Find RPMs for OpenVSwitch
|
||||
echo "OpenVSwitch packages need to be located"
|
||||
# Fedora does not started OVS by default
|
||||
restart_service openvswitch
|
||||
fi
|
||||
}
|
||||
|
||||
function _quantum_ovs_base_configure_debug_command() {
|
||||
iniset $QUANTUM_TEST_CONFIG_FILE DEFAULT external_network_bridge $PUBLIC_BRIDGE
|
||||
}
|
||||
|
||||
function _quantum_ovs_base_configure_l3_agent() {
|
||||
iniset $Q_L3_CONF_FILE DEFAULT external_network_bridge $PUBLIC_BRIDGE
|
||||
|
||||
quantum-ovs-cleanup --external_network_bridge $PUBLIC_BRIDGE
|
||||
sudo ovs-vsctl --no-wait -- --may-exist add-br $PUBLIC_BRIDGE
|
||||
# ensure no IP is configured on the public bridge
|
||||
sudo ip addr flush dev $PUBLIC_BRIDGE
|
||||
}
|
||||
|
||||
# Restore xtrace
|
||||
$XTRACE
|
63
lib/quantum_plugins/ryu
Normal file
63
lib/quantum_plugins/ryu
Normal file
@ -0,0 +1,63 @@
|
||||
# Quantum Ryu plugin
|
||||
# ------------------
|
||||
|
||||
# Save trace setting
|
||||
XTRACE=$(set +o | grep xtrace)
|
||||
set +o xtrace
|
||||
|
||||
source $TOP_DIR/lib/quantum_plugins/ovs_base
|
||||
source $TOP_DIR/lib/quantum_thirdparty/ryu # for configuration value
|
||||
|
||||
function quantum_plugin_create_nova_conf() {
|
||||
NOVA_VIF_DRIVER=${NOVA_VIF_DRIVER:-"nova.virt.libvirt.vif.LibvirtHybridOVSBridgeDriver"}
|
||||
iniset $NOVA_CONF DEFAULT libvirt_ovs_integration_bridge "$OVS_BRIDGE"
|
||||
}
|
||||
|
||||
function quantum_plugin_install_agent_packages() {
|
||||
_quantum_ovs_base_install_agent_packages
|
||||
}
|
||||
|
||||
function quantum_plugin_configure_common() {
|
||||
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"
|
||||
}
|
||||
|
||||
function quantum_plugin_configure_debug_command() {
|
||||
_quantum_ovs_base_configure_debug_command
|
||||
iniset $QUANTUM_TEST_CONFIG_FILE DEFAULT ryu_api_host $RYU_API_HOST:$RYU_API_PORT
|
||||
}
|
||||
|
||||
function quantum_plugin_configure_dhcp_agent() {
|
||||
iniset $Q_DHCP_CONF_FILE DEFAULT ryu_api_host $RYU_API_HOST:$RYU_API_PORT
|
||||
}
|
||||
|
||||
function quantum_plugin_configure_l3_agent() {
|
||||
iniset $Q_L3_CONF_FILE DEFAULT ryu_api_host $RYU_API_HOST:$RYU_API_PORT
|
||||
_quantum_ovs_base_configure_l3_agent
|
||||
}
|
||||
|
||||
function quantum_plugin_configure_plugin_agent() {
|
||||
# Set up integration bridge
|
||||
OVS_BRIDGE=${OVS_BRIDGE:-br-int}
|
||||
_quantum_ovs_base_setup_bridge $OVS_BRIDGE
|
||||
if [ -n "$RYU_INTERNAL_INTERFACE" ]; then
|
||||
sudo ovs-vsctl --no-wait -- --may-exist add-port $OVS_BRIDGE $RYU_INTERNAL_INTERFACE
|
||||
fi
|
||||
iniset /$Q_PLUGIN_CONF_FILE OVS integration_bridge $OVS_BRIDGE
|
||||
AGENT_BINARY="$QUANTUM_DIR/quantum/plugins/ryu/agent/ryu_quantum_agent.py"
|
||||
}
|
||||
|
||||
function quantum_plugin_configure_service() {
|
||||
iniset /$Q_PLUGIN_CONF_FILE OVS openflow_rest_api $RYU_API_HOST:$RYU_API_PORT
|
||||
}
|
||||
|
||||
function quantum_plugin_setup_interface_driver() {
|
||||
local conf_file=$1
|
||||
iniset $conf_file DEFAULT interface_driver quantum.agent.linux.interface.OVSInterfaceDriver
|
||||
iniset $conf_file DEFAULT ovs_use_veth True
|
||||
}
|
||||
|
||||
# Restore xtrace
|
||||
$XTRACE
|
36
lib/quantum_thirdparty/README.md
vendored
Normal file
36
lib/quantum_thirdparty/README.md
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
Quantum third party specific files
|
||||
==================================
|
||||
Some Quantum plugins require third party programs to function.
|
||||
The files under the directory, ``lib/quantum_thirdparty/``, will be used
|
||||
when their service are enabled.
|
||||
Third party program specific configuration variables should be in this file.
|
||||
|
||||
* filename: ``<third_party>``
|
||||
* The corresponding file name should be same to service name, ``<third_party>``.
|
||||
|
||||
functions
|
||||
---------
|
||||
``lib/quantum`` calls the following functions when the ``<third_party>`` is enabled
|
||||
|
||||
functions to be implemented
|
||||
* ``configure_<third_party>``:
|
||||
set config files, create data dirs, etc
|
||||
e.g.
|
||||
sudo python setup.py deploy
|
||||
iniset $XXXX_CONF...
|
||||
|
||||
* ``init_<third_party>``:
|
||||
initialize databases, etc
|
||||
|
||||
* ``install_<third_party>``:
|
||||
collect source and prepare
|
||||
e.g.
|
||||
git clone xxx
|
||||
|
||||
* ``start_<third_party>``:
|
||||
start running processes, including screen
|
||||
e.g.
|
||||
screen_it XXXX "cd $XXXXY_DIR && $XXXX_DIR/bin/XXXX-bin"
|
||||
|
||||
* ``stop_<third_party>``:
|
||||
stop running processes (non-screen)
|
30
lib/ryu → lib/quantum_thirdparty/ryu
vendored
30
lib/ryu → lib/quantum_thirdparty/ryu
vendored
@ -17,6 +17,21 @@ RYU_OFP_HOST=${RYU_OFP_HOST:-127.0.0.1}
|
||||
RYU_OFP_PORT=${RYU_OFP_PORT:-6633}
|
||||
# Ryu Applications
|
||||
RYU_APPS=${RYU_APPS:-ryu.app.simple_isolation,ryu.app.rest}
|
||||
# Ryu configuration
|
||||
RYU_CONF_CONTENTS=${RYU_CONF_CONTENTS:-"
|
||||
--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
|
||||
--quantum_url=http://$Q_HOST:$Q_PORT
|
||||
--quantum_admin_username=$Q_ADMIN_USERNAME
|
||||
--quantum_admin_password=$SERVICE_PASSWORD
|
||||
--quantum_admin_tenant_name=$SERVICE_TENANT_NAME
|
||||
--quantum_admin_auth_url=$KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_AUTH_PORT/v2.0
|
||||
--quantum_auth_strategy=$Q_AUTH_STRATEGY
|
||||
--quantum_controller_addr=tcp:$RYU_OFP_HOST:$RYU_OFP_PORT
|
||||
"}
|
||||
|
||||
function configure_ryu() {
|
||||
setup_develop $RYU_DIR
|
||||
@ -31,26 +46,13 @@ function init_ryu() {
|
||||
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
|
||||
echo "${RYU_CONF_CONTENTS}" > $RYU_CONF
|
||||
}
|
||||
|
||||
function install_ryu() {
|
||||
git_clone $RYU_REPO $RYU_DIR $RYU_BRANCH
|
||||
}
|
||||
|
||||
function is_ryu_required() {
|
||||
if is_service_enabled ryu || (is_service_enabled quantum && [[ "$Q_PLUGIN" = "ryu" ]]); then
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
function start_ryu() {
|
||||
screen_it ryu "cd $RYU_DIR && $RYU_DIR/bin/ryu-manager --flagfile $RYU_CONF"
|
||||
}
|
Loading…
Reference in New Issue
Block a user