Isaku Yamahata | 0dd34df | 2012-12-28 13:15:31 +0900 | [diff] [blame] | 1 | # Quantum Open vSwtich 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 | source $TOP_DIR/lib/quantum_plugins/ovs_base |
| 9 | |
| 10 | function quantum_plugin_create_nova_conf() { |
| 11 | NOVA_VIF_DRIVER=${NOVA_VIF_DRIVER:-"nova.virt.libvirt.vif.LibvirtHybridOVSBridgeDriver"} |
| 12 | if [ "$VIRT_DRIVER" = 'xenserver' ]; then |
| 13 | iniset $NOVA_CONF DEFAULT xenapi_vif_driver nova.virt.xenapi.vif.XenAPIOpenVswitchDriver |
| 14 | iniset $NOVA_CONF DEFAULT xenapi_ovs_integration_bridge $FLAT_NETWORK_BRIDGE |
| 15 | fi |
| 16 | } |
| 17 | |
| 18 | function quantum_plugin_install_agent_packages() { |
| 19 | _quantum_ovs_base_install_agent_packages |
| 20 | } |
| 21 | |
| 22 | function quantum_plugin_configure_common() { |
| 23 | Q_PLUGIN_CONF_PATH=etc/quantum/plugins/openvswitch |
| 24 | Q_PLUGIN_CONF_FILENAME=ovs_quantum_plugin.ini |
| 25 | Q_DB_NAME="ovs_quantum" |
| 26 | Q_PLUGIN_CLASS="quantum.plugins.openvswitch.ovs_quantum_plugin.OVSQuantumPluginV2" |
| 27 | } |
| 28 | |
| 29 | function quantum_plugin_configure_debug_command() { |
| 30 | _quantum_ovs_base_configure_debug_command |
| 31 | } |
| 32 | |
| 33 | function quantum_plugin_configure_dhcp_agent() { |
Dan Wendlandt | adcb18f | 2013-02-22 07:27:26 -0800 | [diff] [blame] | 34 | iniset $Q_DHCP_CONF_FILE DEFAULT dhcp_agent_manager quantum.agent.dhcp_agent.DhcpAgentWithStateReport |
Isaku Yamahata | 0dd34df | 2012-12-28 13:15:31 +0900 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | function quantum_plugin_configure_l3_agent() { |
| 38 | _quantum_ovs_base_configure_l3_agent |
| 39 | } |
| 40 | |
| 41 | function quantum_plugin_configure_plugin_agent() { |
| 42 | # Setup integration bridge |
| 43 | OVS_BRIDGE=${OVS_BRIDGE:-br-int} |
| 44 | _quantum_ovs_base_setup_bridge $OVS_BRIDGE |
| 45 | |
| 46 | # Setup agent for tunneling |
| 47 | if [[ "$OVS_ENABLE_TUNNELING" = "True" ]]; then |
| 48 | # Verify tunnels are supported |
| 49 | # REVISIT - also check kernel module support for GRE and patch ports |
| 50 | OVS_VERSION=`ovs-vsctl --version | head -n 1 | awk '{print $4;}'` |
| 51 | if [ $OVS_VERSION \< "1.4" ] && ! is_service_enabled q-svc ; then |
Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame^] | 52 | die $LINENO "You are running OVS version $OVS_VERSION. OVS 1.4+ is required for tunneling between multiple hosts." |
Isaku Yamahata | 0dd34df | 2012-12-28 13:15:31 +0900 | [diff] [blame] | 53 | fi |
| 54 | iniset /$Q_PLUGIN_CONF_FILE OVS enable_tunneling True |
| 55 | iniset /$Q_PLUGIN_CONF_FILE OVS local_ip $HOST_IP |
| 56 | fi |
| 57 | |
| 58 | # Setup physical network bridge mappings. Override |
| 59 | # ``OVS_VLAN_RANGES`` and ``OVS_BRIDGE_MAPPINGS`` in ``localrc`` for more |
| 60 | # complex physical network configurations. |
| 61 | if [[ "$OVS_BRIDGE_MAPPINGS" = "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]] && [[ "$OVS_PHYSICAL_BRIDGE" != "" ]]; then |
| 62 | OVS_BRIDGE_MAPPINGS=$PHYSICAL_NETWORK:$OVS_PHYSICAL_BRIDGE |
| 63 | |
| 64 | # Configure bridge manually with physical interface as port for multi-node |
| 65 | sudo ovs-vsctl --no-wait -- --may-exist add-br $OVS_PHYSICAL_BRIDGE |
| 66 | fi |
| 67 | if [[ "$OVS_BRIDGE_MAPPINGS" != "" ]]; then |
| 68 | iniset /$Q_PLUGIN_CONF_FILE OVS bridge_mappings $OVS_BRIDGE_MAPPINGS |
| 69 | fi |
| 70 | AGENT_BINARY="$QUANTUM_DIR/bin/quantum-openvswitch-agent" |
| 71 | |
| 72 | if [ "$VIRT_DRIVER" = 'xenserver' ]; then |
| 73 | # Nova will always be installed along with quantum for a domU |
| 74 | # devstack install, so it should be safe to rely on nova.conf |
| 75 | # for xenapi configuration. |
Maru Newby | a1a61c8 | 2013-02-13 19:20:03 +0000 | [diff] [blame] | 76 | Q_RR_DOM0_COMMAND="$QUANTUM_DIR/bin/quantum-rootwrap-xen-dom0 $NOVA_CONF" |
Isaku Yamahata | 0dd34df | 2012-12-28 13:15:31 +0900 | [diff] [blame] | 77 | # Under XS/XCP, the ovs agent needs to target the dom0 |
| 78 | # integration bridge. This is enabled by using a root wrapper |
| 79 | # that executes commands on dom0 via a XenAPI plugin. |
| 80 | iniset /$Q_PLUGIN_CONF_FILE AGENT root_helper "$Q_RR_DOM0_COMMAND" |
| 81 | |
| 82 | # FLAT_NETWORK_BRIDGE is the dom0 integration bridge. To |
| 83 | # ensure the bridge lacks direct connectivity, set |
| 84 | # VM_VLAN=-1;VM_DEV=invalid in localrc |
| 85 | iniset /$Q_PLUGIN_CONF_FILE OVS integration_bridge $FLAT_NETWORK_BRIDGE |
| 86 | |
| 87 | # The ovs agent needs to ensure that the ports associated with |
| 88 | # a given network share the same local vlan tag. On |
| 89 | # single-node XS/XCP, this requires monitoring both the dom0 |
| 90 | # bridge, where VM's are attached, and the domU bridge, where |
| 91 | # dhcp servers are attached. |
| 92 | if is_service_enabled q-dhcp; then |
| 93 | iniset /$Q_PLUGIN_CONF_FILE OVS domu_integration_bridge $OVS_BRIDGE |
| 94 | # DomU will use the regular rootwrap |
| 95 | iniset /$Q_PLUGIN_CONF_FILE AGENT domu_root_helper "$Q_RR_COMMAND" |
| 96 | # Plug the vm interface into the domU integration bridge. |
| 97 | sudo ip addr flush dev $GUEST_INTERFACE_DEFAULT |
| 98 | sudo ip link set $OVS_BRIDGE up |
| 99 | # Assign the VM IP only if it has been set explicitly |
| 100 | if [[ "$VM_IP" != "" ]]; then |
| 101 | sudo ip addr add $VM_IP dev $OVS_BRIDGE |
| 102 | fi |
| 103 | sudo ovs-vsctl add-port $OVS_BRIDGE $GUEST_INTERFACE_DEFAULT |
| 104 | fi |
| 105 | fi |
| 106 | } |
| 107 | |
| 108 | function quantum_plugin_configure_service() { |
| 109 | if [[ "$ENABLE_TENANT_TUNNELS" = "True" ]]; then |
| 110 | iniset /$Q_PLUGIN_CONF_FILE OVS tenant_network_type gre |
| 111 | iniset /$Q_PLUGIN_CONF_FILE OVS tunnel_id_ranges $TENANT_TUNNEL_RANGES |
| 112 | elif [[ "$ENABLE_TENANT_VLANS" = "True" ]]; then |
| 113 | iniset /$Q_PLUGIN_CONF_FILE OVS tenant_network_type vlan |
| 114 | else |
| 115 | echo "WARNING - The openvswitch plugin is using local tenant networks, with no connectivity between hosts." |
| 116 | fi |
| 117 | |
| 118 | # Override ``OVS_VLAN_RANGES`` and ``OVS_BRIDGE_MAPPINGS`` in ``localrc`` |
| 119 | # for more complex physical network configurations. |
| 120 | if [[ "$OVS_VLAN_RANGES" = "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]]; then |
| 121 | OVS_VLAN_RANGES=$PHYSICAL_NETWORK |
| 122 | if [[ "$TENANT_VLAN_RANGE" != "" ]]; then |
| 123 | OVS_VLAN_RANGES=$OVS_VLAN_RANGES:$TENANT_VLAN_RANGE |
| 124 | fi |
| 125 | fi |
| 126 | if [[ "$OVS_VLAN_RANGES" != "" ]]; then |
| 127 | iniset /$Q_PLUGIN_CONF_FILE OVS network_vlan_ranges $OVS_VLAN_RANGES |
| 128 | fi |
| 129 | |
| 130 | # Enable tunnel networks if selected |
| 131 | if [[ $OVS_ENABLE_TUNNELING = "True" ]]; then |
| 132 | iniset /$Q_PLUGIN_CONF_FILE OVS enable_tunneling True |
| 133 | fi |
| 134 | } |
| 135 | |
| 136 | function quantum_plugin_setup_interface_driver() { |
| 137 | local conf_file=$1 |
| 138 | iniset $conf_file DEFAULT interface_driver quantum.agent.linux.interface.OVSInterfaceDriver |
| 139 | } |
| 140 | |
| 141 | # Restore xtrace |
Dean Troyer | 8d55be3 | 2013-02-07 17:16:35 -0600 | [diff] [blame] | 142 | $MY_XTRACE |