614202fc40
Also removes OVS ports Fix Bug #1156837 Change-Id: Id4178c0a12a3ada76403a57a736a9c7a908d6a4a
86 lines
3.0 KiB
Plaintext
86 lines
3.0 KiB
Plaintext
# common functions for ovs based plugin
|
|
# -------------------------------------
|
|
|
|
# Save trace setting
|
|
MY_XTRACE=$(set +o | grep xtrace)
|
|
set +o xtrace
|
|
|
|
OVS_BRIDGE=${OVS_BRIDGE:-br-int}
|
|
PUBLIC_BRIDGE=${PUBLIC_BRIDGE:-br-ex}
|
|
|
|
function is_quantum_ovs_base_plugin() {
|
|
# Yes, we use OVS.
|
|
return 0
|
|
}
|
|
|
|
function _quantum_ovs_base_setup_bridge() {
|
|
local bridge=$1
|
|
quantum-ovs-cleanup
|
|
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_cleanup() {
|
|
# remove all OVS ports that look like Quantum created ports
|
|
for port in $(sudo ovs-vsctl list port | grep -o -e tap[0-9a-f\-]* -e q[rg]-[0-9a-f\-]*); do
|
|
sudo ovs-vsctl del-port ${port}
|
|
done
|
|
|
|
# remove all OVS bridges created by Quantum
|
|
for bridge in $(sudo ovs-vsctl list-br | grep -o -e ${OVS_BRIDGE} -e ${PUBLIC_BRIDGE}); do
|
|
sudo ovs-vsctl del-br ${bridge}
|
|
done
|
|
}
|
|
|
|
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
|
|
elif is_fedora; then
|
|
install_package openvswitch
|
|
# Ensure that the service is started
|
|
restart_service openvswitch
|
|
elif is_suse; then
|
|
### FIXME: Find out if package can be pushed to Factory
|
|
echo "OpenVSwitch packages can be installed from Cloud:OpenStack:Master in OBS"
|
|
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_firewall_driver() {
|
|
if [[ "$Q_USE_SECGROUP" == "True" ]]; then
|
|
iniset /$Q_PLUGIN_CONF_FILE SECURITYGROUP firewall_driver quantum.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver
|
|
else
|
|
iniset /$Q_PLUGIN_CONF_FILE SECURITYGROUP firewall_driver quantum.agent.firewall.NoopFirewallDriver
|
|
fi
|
|
}
|
|
|
|
function _quantum_ovs_base_configure_l3_agent() {
|
|
iniset $Q_L3_CONF_FILE DEFAULT external_network_bridge $PUBLIC_BRIDGE
|
|
|
|
quantum-ovs-cleanup
|
|
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
|
|
}
|
|
|
|
function _quantum_ovs_base_configure_nova_vif_driver() {
|
|
# The hybrid VIF driver needs to be specified when Quantum Security Group
|
|
# is enabled (until vif_security attributes are supported in VIF extension)
|
|
if [[ "$Q_USE_SECGROUP" == "True" ]]; then
|
|
NOVA_VIF_DRIVER=${NOVA_VIF_DRIVER:-"nova.virt.libvirt.vif.LibvirtHybridOVSBridgeDriver"}
|
|
else
|
|
NOVA_VIF_DRIVER=${NOVA_VIF_DRIVER:-"nova.virt.libvirt.vif.LibvirtGenericVIFDriver"}
|
|
fi
|
|
}
|
|
|
|
# Restore xtrace
|
|
$MY_XTRACE
|