blob: 2ada0dbf5a647d752630e8e90fbe1a2835458245 [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
8function is_quantum_ovs_base_plugin() {
9 # Yes, we use OVS.
10 return 0
11}
12
13function _quantum_ovs_base_setup_bridge() {
14 local bridge=$1
Davanum Srinivas88a3bc12013-02-04 09:16:14 -050015 quantum-ovs-cleanup
Isaku Yamahata0dd34df2012-12-28 13:15:31 +090016 sudo ovs-vsctl --no-wait -- --may-exist add-br $bridge
17 sudo ovs-vsctl --no-wait br-set-external-id $bridge bridge-id $bridge
18}
19
20function _quantum_ovs_base_install_agent_packages() {
21 local kernel_version
22 # Install deps
23 # FIXME add to ``files/apts/quantum``, but don't install if not needed!
24 if is_ubuntu; then
25 kernel_version=`cat /proc/version | cut -d " " -f3`
26 install_package make fakeroot dkms openvswitch-switch openvswitch-datapath-dkms linux-headers-$kernel_version
Gary Kotton5452b182013-02-25 13:02:38 +000027 elif is_fedora; then
28 install_package openvswitch
29 # Ensure that the service is started
30 restart_service openvswitch
31 elif is_suse; then
Vincent Untz3f34d9a2013-03-12 17:57:36 +010032 ### FIXME: Find out if package can be pushed to Factory
33 echo "OpenVSwitch packages can be installed from Cloud:OpenStack:Master in OBS"
Isaku Yamahata0dd34df2012-12-28 13:15:31 +090034 restart_service openvswitch
35 fi
36}
37
38function _quantum_ovs_base_configure_debug_command() {
39 iniset $QUANTUM_TEST_CONFIG_FILE DEFAULT external_network_bridge $PUBLIC_BRIDGE
40}
41
Akihiro MOTOKI3452f8e2013-03-21 14:11:27 +090042function _quantum_ovs_base_configure_firewall_driver() {
43 if [[ "$Q_USE_SECGROUP" == "True" ]]; then
44 iniset /$Q_PLUGIN_CONF_FILE SECURITYGROUP firewall_driver quantum.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver
45 else
46 iniset /$Q_PLUGIN_CONF_FILE SECURITYGROUP firewall_driver quantum.agent.firewall.NoopFirewallDriver
47 fi
48}
49
Isaku Yamahata0dd34df2012-12-28 13:15:31 +090050function _quantum_ovs_base_configure_l3_agent() {
51 iniset $Q_L3_CONF_FILE DEFAULT external_network_bridge $PUBLIC_BRIDGE
52
Davanum Srinivas88a3bc12013-02-04 09:16:14 -050053 quantum-ovs-cleanup
Isaku Yamahata0dd34df2012-12-28 13:15:31 +090054 sudo ovs-vsctl --no-wait -- --may-exist add-br $PUBLIC_BRIDGE
55 # ensure no IP is configured on the public bridge
56 sudo ip addr flush dev $PUBLIC_BRIDGE
57}
58
Akihiro MOTOKI3452f8e2013-03-21 14:11:27 +090059function _quantum_ovs_base_configure_nova_vif_driver() {
60 # The hybrid VIF driver needs to be specified when Quantum Security Group
61 # is enabled (until vif_security attributes are supported in VIF extension)
62 if [[ "$Q_USE_SECGROUP" == "True" ]]; then
63 NOVA_VIF_DRIVER=${NOVA_VIF_DRIVER:-"nova.virt.libvirt.vif.LibvirtHybridOVSBridgeDriver"}
64 else
65 NOVA_VIF_DRIVER=${NOVA_VIF_DRIVER:-"nova.virt.libvirt.vif.LibvirtGenericVIFDriver"}
66 fi
67}
68
Isaku Yamahata0dd34df2012-12-28 13:15:31 +090069# Restore xtrace
Dean Troyer8d55be32013-02-07 17:16:35 -060070$MY_XTRACE