blob: a5e03acd51f0a75cc72e07ee2a4d477f4fe9819a [file] [log] [blame]
Isaku Yamahata0dd34df2012-12-28 13:15:31 +09001# common functions for ovs based plugin
2# -------------------------------------
3
4# Save trace setting
Dean Troyer8d55be32013-02-07 17:16:35 -06005MY_XTRACE=$(set +o | grep xtrace)
Isaku Yamahata0dd34df2012-12-28 13:15:31 +09006set +o xtrace
7
JordanP614202f2013-05-16 11:16:13 +02008OVS_BRIDGE=${OVS_BRIDGE:-br-int}
9PUBLIC_BRIDGE=${PUBLIC_BRIDGE:-br-ex}
10
Isaku Yamahata0dd34df2012-12-28 13:15:31 +090011function is_quantum_ovs_base_plugin() {
12 # Yes, we use OVS.
13 return 0
14}
15
16function _quantum_ovs_base_setup_bridge() {
17 local bridge=$1
Davanum Srinivas88a3bc12013-02-04 09:16:14 -050018 quantum-ovs-cleanup
Isaku Yamahata0dd34df2012-12-28 13:15:31 +090019 sudo ovs-vsctl --no-wait -- --may-exist add-br $bridge
20 sudo ovs-vsctl --no-wait br-set-external-id $bridge bridge-id $bridge
21}
22
JordanP614202f2013-05-16 11:16:13 +020023function quantum_ovs_base_cleanup() {
24 # remove all OVS ports that look like Quantum created ports
25 for port in $(sudo ovs-vsctl list port | grep -o -e tap[0-9a-f\-]* -e q[rg]-[0-9a-f\-]*); do
26 sudo ovs-vsctl del-port ${port}
27 done
28
29 # remove all OVS bridges created by Quantum
30 for bridge in $(sudo ovs-vsctl list-br | grep -o -e ${OVS_BRIDGE} -e ${PUBLIC_BRIDGE}); do
31 sudo ovs-vsctl del-br ${bridge}
32 done
33}
34
Isaku Yamahata0dd34df2012-12-28 13:15:31 +090035function _quantum_ovs_base_install_agent_packages() {
36 local kernel_version
37 # Install deps
38 # FIXME add to ``files/apts/quantum``, but don't install if not needed!
39 if is_ubuntu; then
40 kernel_version=`cat /proc/version | cut -d " " -f3`
41 install_package make fakeroot dkms openvswitch-switch openvswitch-datapath-dkms linux-headers-$kernel_version
Gary Kotton5452b182013-02-25 13:02:38 +000042 elif is_fedora; then
43 install_package openvswitch
44 # Ensure that the service is started
45 restart_service openvswitch
46 elif is_suse; then
Vincent Untz3f34d9a2013-03-12 17:57:36 +010047 ### FIXME: Find out if package can be pushed to Factory
48 echo "OpenVSwitch packages can be installed from Cloud:OpenStack:Master in OBS"
Isaku Yamahata0dd34df2012-12-28 13:15:31 +090049 restart_service openvswitch
50 fi
51}
52
53function _quantum_ovs_base_configure_debug_command() {
54 iniset $QUANTUM_TEST_CONFIG_FILE DEFAULT external_network_bridge $PUBLIC_BRIDGE
55}
56
Akihiro MOTOKI3452f8e2013-03-21 14:11:27 +090057function _quantum_ovs_base_configure_firewall_driver() {
58 if [[ "$Q_USE_SECGROUP" == "True" ]]; then
59 iniset /$Q_PLUGIN_CONF_FILE SECURITYGROUP firewall_driver quantum.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver
60 else
61 iniset /$Q_PLUGIN_CONF_FILE SECURITYGROUP firewall_driver quantum.agent.firewall.NoopFirewallDriver
62 fi
63}
64
Isaku Yamahata0dd34df2012-12-28 13:15:31 +090065function _quantum_ovs_base_configure_l3_agent() {
66 iniset $Q_L3_CONF_FILE DEFAULT external_network_bridge $PUBLIC_BRIDGE
67
Davanum Srinivas88a3bc12013-02-04 09:16:14 -050068 quantum-ovs-cleanup
Isaku Yamahata0dd34df2012-12-28 13:15:31 +090069 sudo ovs-vsctl --no-wait -- --may-exist add-br $PUBLIC_BRIDGE
70 # ensure no IP is configured on the public bridge
71 sudo ip addr flush dev $PUBLIC_BRIDGE
72}
73
Akihiro MOTOKI3452f8e2013-03-21 14:11:27 +090074function _quantum_ovs_base_configure_nova_vif_driver() {
75 # The hybrid VIF driver needs to be specified when Quantum Security Group
76 # is enabled (until vif_security attributes are supported in VIF extension)
77 if [[ "$Q_USE_SECGROUP" == "True" ]]; then
78 NOVA_VIF_DRIVER=${NOVA_VIF_DRIVER:-"nova.virt.libvirt.vif.LibvirtHybridOVSBridgeDriver"}
79 else
80 NOVA_VIF_DRIVER=${NOVA_VIF_DRIVER:-"nova.virt.libvirt.vif.LibvirtGenericVIFDriver"}
81 fi
82}
83
Isaku Yamahata0dd34df2012-12-28 13:15:31 +090084# Restore xtrace
Dean Troyer8d55be32013-02-07 17:16:35 -060085$MY_XTRACE