| Isaku Yamahata | 0dd34df | 2012-12-28 13:15:31 +0900 | [diff] [blame] | 1 | # common functions for ovs based plugin | 
|  | 2 | # ------------------------------------- | 
|  | 3 |  | 
|  | 4 | # Save trace setting | 
| Dean Troyer | 8d55be3 | 2013-02-07 17:16:35 -0600 | [diff] [blame] | 5 | MY_XTRACE=$(set +o | grep xtrace) | 
| Isaku Yamahata | 0dd34df | 2012-12-28 13:15:31 +0900 | [diff] [blame] | 6 | set +o xtrace | 
|  | 7 |  | 
|  | 8 | function is_quantum_ovs_base_plugin() { | 
|  | 9 | # Yes, we use OVS. | 
|  | 10 | return 0 | 
|  | 11 | } | 
|  | 12 |  | 
|  | 13 | function _quantum_ovs_base_setup_bridge() { | 
|  | 14 | local bridge=$1 | 
| Davanum Srinivas | 88a3bc1 | 2013-02-04 09:16:14 -0500 | [diff] [blame] | 15 | quantum-ovs-cleanup | 
| Isaku Yamahata | 0dd34df | 2012-12-28 13:15:31 +0900 | [diff] [blame] | 16 | 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 |  | 
|  | 20 | function _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 Kotton | 5452b18 | 2013-02-25 13:02:38 +0000 | [diff] [blame] | 27 | 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 Untz | 3f34d9a | 2013-03-12 17:57:36 +0100 | [diff] [blame] | 32 | ### FIXME: Find out if package can be pushed to Factory | 
|  | 33 | echo "OpenVSwitch packages can be installed from Cloud:OpenStack:Master in OBS" | 
| Isaku Yamahata | 0dd34df | 2012-12-28 13:15:31 +0900 | [diff] [blame] | 34 | restart_service openvswitch | 
|  | 35 | fi | 
|  | 36 | } | 
|  | 37 |  | 
|  | 38 | function _quantum_ovs_base_configure_debug_command() { | 
|  | 39 | iniset $QUANTUM_TEST_CONFIG_FILE DEFAULT external_network_bridge $PUBLIC_BRIDGE | 
|  | 40 | } | 
|  | 41 |  | 
| Akihiro MOTOKI | 3452f8e | 2013-03-21 14:11:27 +0900 | [diff] [blame] | 42 | function _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 Yamahata | 0dd34df | 2012-12-28 13:15:31 +0900 | [diff] [blame] | 50 | function _quantum_ovs_base_configure_l3_agent() { | 
|  | 51 | iniset $Q_L3_CONF_FILE DEFAULT external_network_bridge $PUBLIC_BRIDGE | 
|  | 52 |  | 
| Davanum Srinivas | 88a3bc1 | 2013-02-04 09:16:14 -0500 | [diff] [blame] | 53 | quantum-ovs-cleanup | 
| Isaku Yamahata | 0dd34df | 2012-12-28 13:15:31 +0900 | [diff] [blame] | 54 | 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 MOTOKI | 3452f8e | 2013-03-21 14:11:27 +0900 | [diff] [blame] | 59 | function _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 Yamahata | 0dd34df | 2012-12-28 13:15:31 +0900 | [diff] [blame] | 69 | # Restore xtrace | 
| Dean Troyer | 8d55be3 | 2013-02-07 17:16:35 -0600 | [diff] [blame] | 70 | $MY_XTRACE |