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() { |
Akihiro MOTOKI | 3452f8e | 2013-03-21 14:11:27 +0900 | [diff] [blame] | 11 | _quantum_ovs_base_configure_nova_vif_driver |
Isaku Yamahata | 0dd34df | 2012-12-28 13:15:31 +0900 | [diff] [blame] | 12 | if [ "$VIRT_DRIVER" = 'xenserver' ]; then |
| 13 | iniset $NOVA_CONF DEFAULT xenapi_vif_driver nova.virt.xenapi.vif.XenAPIOpenVswitchDriver |
Mate Lakat | f652e0f | 2013-05-21 18:12:48 +0100 | [diff] [blame] | 14 | iniset $NOVA_CONF DEFAULT xenapi_ovs_integration_bridge $XEN_INTEGRATION_BRIDGE |
| 15 | # Disable nova's firewall so that it does not conflict with quantum |
| 16 | iniset $NOVA_CONF DEFAULT firewall_driver nova.virt.firewall.NoopFirewallDriver |
Isaku Yamahata | 0dd34df | 2012-12-28 13:15:31 +0900 | [diff] [blame] | 17 | fi |
| 18 | } |
| 19 | |
| 20 | function quantum_plugin_install_agent_packages() { |
| 21 | _quantum_ovs_base_install_agent_packages |
| 22 | } |
| 23 | |
| 24 | function quantum_plugin_configure_common() { |
| 25 | Q_PLUGIN_CONF_PATH=etc/quantum/plugins/openvswitch |
| 26 | Q_PLUGIN_CONF_FILENAME=ovs_quantum_plugin.ini |
| 27 | Q_DB_NAME="ovs_quantum" |
| 28 | Q_PLUGIN_CLASS="quantum.plugins.openvswitch.ovs_quantum_plugin.OVSQuantumPluginV2" |
| 29 | } |
| 30 | |
| 31 | function quantum_plugin_configure_debug_command() { |
| 32 | _quantum_ovs_base_configure_debug_command |
| 33 | } |
| 34 | |
| 35 | function quantum_plugin_configure_dhcp_agent() { |
Dan Wendlandt | adcb18f | 2013-02-22 07:27:26 -0800 | [diff] [blame] | 36 | 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] | 37 | } |
| 38 | |
| 39 | function quantum_plugin_configure_l3_agent() { |
| 40 | _quantum_ovs_base_configure_l3_agent |
Akihiro MOTOKI | 09d6185 | 2013-03-03 01:24:45 +0900 | [diff] [blame] | 41 | iniset $Q_L3_CONF_FILE DEFAULT l3_agent_manager quantum.agent.l3_agent.L3NATAgentWithStateReport |
Isaku Yamahata | 0dd34df | 2012-12-28 13:15:31 +0900 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | function quantum_plugin_configure_plugin_agent() { |
| 45 | # Setup integration bridge |
Isaku Yamahata | 0dd34df | 2012-12-28 13:15:31 +0900 | [diff] [blame] | 46 | _quantum_ovs_base_setup_bridge $OVS_BRIDGE |
Akihiro MOTOKI | 3452f8e | 2013-03-21 14:11:27 +0900 | [diff] [blame] | 47 | _quantum_ovs_base_configure_firewall_driver |
Isaku Yamahata | 0dd34df | 2012-12-28 13:15:31 +0900 | [diff] [blame] | 48 | |
| 49 | # Setup agent for tunneling |
| 50 | if [[ "$OVS_ENABLE_TUNNELING" = "True" ]]; then |
| 51 | # Verify tunnels are supported |
| 52 | # REVISIT - also check kernel module support for GRE and patch ports |
| 53 | OVS_VERSION=`ovs-vsctl --version | head -n 1 | awk '{print $4;}'` |
| 54 | if [ $OVS_VERSION \< "1.4" ] && ! is_service_enabled q-svc ; then |
Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 55 | 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] | 56 | fi |
| 57 | iniset /$Q_PLUGIN_CONF_FILE OVS enable_tunneling True |
| 58 | iniset /$Q_PLUGIN_CONF_FILE OVS local_ip $HOST_IP |
| 59 | fi |
| 60 | |
| 61 | # Setup physical network bridge mappings. Override |
| 62 | # ``OVS_VLAN_RANGES`` and ``OVS_BRIDGE_MAPPINGS`` in ``localrc`` for more |
| 63 | # complex physical network configurations. |
| 64 | if [[ "$OVS_BRIDGE_MAPPINGS" = "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]] && [[ "$OVS_PHYSICAL_BRIDGE" != "" ]]; then |
| 65 | OVS_BRIDGE_MAPPINGS=$PHYSICAL_NETWORK:$OVS_PHYSICAL_BRIDGE |
| 66 | |
| 67 | # Configure bridge manually with physical interface as port for multi-node |
| 68 | sudo ovs-vsctl --no-wait -- --may-exist add-br $OVS_PHYSICAL_BRIDGE |
| 69 | fi |
| 70 | if [[ "$OVS_BRIDGE_MAPPINGS" != "" ]]; then |
| 71 | iniset /$Q_PLUGIN_CONF_FILE OVS bridge_mappings $OVS_BRIDGE_MAPPINGS |
| 72 | fi |
| 73 | AGENT_BINARY="$QUANTUM_DIR/bin/quantum-openvswitch-agent" |
| 74 | |
| 75 | if [ "$VIRT_DRIVER" = 'xenserver' ]; then |
Mate Lakat | f652e0f | 2013-05-21 18:12:48 +0100 | [diff] [blame] | 76 | # Make a copy of our config for domU |
| 77 | sudo cp /$Q_PLUGIN_CONF_FILE "/$Q_PLUGIN_CONF_FILE.domu" |
| 78 | |
| 79 | # Deal with Dom0's L2 Agent: |
Maru Newby | a8f7a62 | 2013-05-01 20:48:54 +0000 | [diff] [blame] | 80 | Q_RR_DOM0_COMMAND="$QUANTUM_DIR/bin/quantum-rootwrap-xen-dom0 $Q_RR_CONF_FILE" |
| 81 | |
| 82 | # For now, duplicate the xen configuration already found in nova.conf |
| 83 | iniset $Q_RR_CONF_FILE XENAPI xenapi_connection_url "$XENAPI_CONNECTION_URL" |
| 84 | iniset $Q_RR_CONF_FILE XENAPI xenapi_connection_username "$XENAPI_USER" |
| 85 | iniset $Q_RR_CONF_FILE XENAPI xenapi_connection_password "$XENAPI_PASSWORD" |
| 86 | |
Isaku Yamahata | 0dd34df | 2012-12-28 13:15:31 +0900 | [diff] [blame] | 87 | # Under XS/XCP, the ovs agent needs to target the dom0 |
| 88 | # integration bridge. This is enabled by using a root wrapper |
| 89 | # that executes commands on dom0 via a XenAPI plugin. |
| 90 | iniset /$Q_PLUGIN_CONF_FILE AGENT root_helper "$Q_RR_DOM0_COMMAND" |
| 91 | |
Mate Lakat | f652e0f | 2013-05-21 18:12:48 +0100 | [diff] [blame] | 92 | # Set "physical" mapping |
| 93 | iniset /$Q_PLUGIN_CONF_FILE OVS bridge_mappings "physnet1:$FLAT_NETWORK_BRIDGE" |
Isaku Yamahata | 0dd34df | 2012-12-28 13:15:31 +0900 | [diff] [blame] | 94 | |
Mate Lakat | f652e0f | 2013-05-21 18:12:48 +0100 | [diff] [blame] | 95 | # XEN_INTEGRATION_BRIDGE is the integration bridge in dom0 |
| 96 | iniset /$Q_PLUGIN_CONF_FILE OVS integration_bridge $XEN_INTEGRATION_BRIDGE |
| 97 | |
| 98 | # Set up domU's L2 agent: |
| 99 | |
| 100 | # Create a bridge "br-$GUEST_INTERFACE_DEFAULT" |
| 101 | sudo ovs-vsctl --no-wait -- --may-exist add-br "br-$GUEST_INTERFACE_DEFAULT" |
| 102 | # Add $GUEST_INTERFACE_DEFAULT to that bridge |
| 103 | sudo ovs-vsctl add-port "br-$GUEST_INTERFACE_DEFAULT" $GUEST_INTERFACE_DEFAULT |
| 104 | |
| 105 | # Set bridge mappings to "physnet1:br-$GUEST_INTERFACE_DEFAULT" |
| 106 | iniset "/$Q_PLUGIN_CONF_FILE.domU" OVS bridge_mappings "physnet1:br-$GUEST_INTERFACE_DEFAULT" |
| 107 | # Set integration bridge to domU's |
| 108 | iniset "/$Q_PLUGIN_CONF_FILE.domU" OVS integration_bridge $OVS_BRIDGE |
| 109 | # Set root wrap |
| 110 | iniset "/$Q_PLUGIN_CONF_FILE.domU" AGENT root_helper "$Q_RR_COMMAND" |
Isaku Yamahata | 0dd34df | 2012-12-28 13:15:31 +0900 | [diff] [blame] | 111 | fi |
| 112 | } |
| 113 | |
| 114 | function quantum_plugin_configure_service() { |
| 115 | if [[ "$ENABLE_TENANT_TUNNELS" = "True" ]]; then |
| 116 | iniset /$Q_PLUGIN_CONF_FILE OVS tenant_network_type gre |
| 117 | iniset /$Q_PLUGIN_CONF_FILE OVS tunnel_id_ranges $TENANT_TUNNEL_RANGES |
| 118 | elif [[ "$ENABLE_TENANT_VLANS" = "True" ]]; then |
| 119 | iniset /$Q_PLUGIN_CONF_FILE OVS tenant_network_type vlan |
| 120 | else |
| 121 | echo "WARNING - The openvswitch plugin is using local tenant networks, with no connectivity between hosts." |
| 122 | fi |
| 123 | |
| 124 | # Override ``OVS_VLAN_RANGES`` and ``OVS_BRIDGE_MAPPINGS`` in ``localrc`` |
| 125 | # for more complex physical network configurations. |
| 126 | if [[ "$OVS_VLAN_RANGES" = "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]]; then |
| 127 | OVS_VLAN_RANGES=$PHYSICAL_NETWORK |
| 128 | if [[ "$TENANT_VLAN_RANGE" != "" ]]; then |
| 129 | OVS_VLAN_RANGES=$OVS_VLAN_RANGES:$TENANT_VLAN_RANGE |
| 130 | fi |
| 131 | fi |
| 132 | if [[ "$OVS_VLAN_RANGES" != "" ]]; then |
| 133 | iniset /$Q_PLUGIN_CONF_FILE OVS network_vlan_ranges $OVS_VLAN_RANGES |
| 134 | fi |
| 135 | |
| 136 | # Enable tunnel networks if selected |
| 137 | if [[ $OVS_ENABLE_TUNNELING = "True" ]]; then |
| 138 | iniset /$Q_PLUGIN_CONF_FILE OVS enable_tunneling True |
| 139 | fi |
Jiajun Liu | e6f2ee5 | 2013-05-14 09:48:15 +0000 | [diff] [blame] | 140 | |
| 141 | _quantum_ovs_base_configure_firewall_driver |
Isaku Yamahata | 0dd34df | 2012-12-28 13:15:31 +0900 | [diff] [blame] | 142 | } |
| 143 | |
| 144 | function quantum_plugin_setup_interface_driver() { |
| 145 | local conf_file=$1 |
| 146 | iniset $conf_file DEFAULT interface_driver quantum.agent.linux.interface.OVSInterfaceDriver |
| 147 | } |
| 148 | |
Akihiro MOTOKI | 3452f8e | 2013-03-21 14:11:27 +0900 | [diff] [blame] | 149 | function has_quantum_plugin_security_group() { |
| 150 | return 0 |
| 151 | } |
| 152 | |
armando-migliaccio | 7c025fe | 2013-05-08 11:33:07 -0700 | [diff] [blame] | 153 | function quantum_plugin_check_adv_test_requirements() { |
| 154 | is_service_enabled q-agt && is_service_enabled q-dhcp && return 0 |
| 155 | } |
| 156 | |
Isaku Yamahata | 0dd34df | 2012-12-28 13:15:31 +0900 | [diff] [blame] | 157 | # Restore xtrace |
Dean Troyer | 8d55be3 | 2013-02-07 17:16:35 -0600 | [diff] [blame] | 158 | $MY_XTRACE |