blob: 726c6c3ed529bb8b44610b57bdc6dc8caebc5a45 [file] [log] [blame]
Isaku Yamahata0dd34df2012-12-28 13:15:31 +09001# Quantum Open vSwtich 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
8source $TOP_DIR/lib/quantum_plugins/ovs_base
9
10function 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
18function quantum_plugin_install_agent_packages() {
19 _quantum_ovs_base_install_agent_packages
20}
21
22function 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
29function quantum_plugin_configure_debug_command() {
30 _quantum_ovs_base_configure_debug_command
31}
32
33function quantum_plugin_configure_dhcp_agent() {
Dan Wendlandtadcb18f2013-02-22 07:27:26 -080034 iniset $Q_DHCP_CONF_FILE DEFAULT dhcp_agent_manager quantum.agent.dhcp_agent.DhcpAgentWithStateReport
Isaku Yamahata0dd34df2012-12-28 13:15:31 +090035}
36
37function quantum_plugin_configure_l3_agent() {
38 _quantum_ovs_base_configure_l3_agent
39}
40
41function 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
52 echo "You are running OVS version $OVS_VERSION."
53 echo "OVS 1.4+ is required for tunneling between multiple hosts."
54 exit 1
55 fi
56 iniset /$Q_PLUGIN_CONF_FILE OVS enable_tunneling True
57 iniset /$Q_PLUGIN_CONF_FILE OVS local_ip $HOST_IP
58 fi
59
60 # Setup physical network bridge mappings. Override
61 # ``OVS_VLAN_RANGES`` and ``OVS_BRIDGE_MAPPINGS`` in ``localrc`` for more
62 # complex physical network configurations.
63 if [[ "$OVS_BRIDGE_MAPPINGS" = "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]] && [[ "$OVS_PHYSICAL_BRIDGE" != "" ]]; then
64 OVS_BRIDGE_MAPPINGS=$PHYSICAL_NETWORK:$OVS_PHYSICAL_BRIDGE
65
66 # Configure bridge manually with physical interface as port for multi-node
67 sudo ovs-vsctl --no-wait -- --may-exist add-br $OVS_PHYSICAL_BRIDGE
68 fi
69 if [[ "$OVS_BRIDGE_MAPPINGS" != "" ]]; then
70 iniset /$Q_PLUGIN_CONF_FILE OVS bridge_mappings $OVS_BRIDGE_MAPPINGS
71 fi
72 AGENT_BINARY="$QUANTUM_DIR/bin/quantum-openvswitch-agent"
73
74 if [ "$VIRT_DRIVER" = 'xenserver' ]; then
75 # Nova will always be installed along with quantum for a domU
76 # devstack install, so it should be safe to rely on nova.conf
77 # for xenapi configuration.
Maru Newbya1a61c82013-02-13 19:20:03 +000078 Q_RR_DOM0_COMMAND="$QUANTUM_DIR/bin/quantum-rootwrap-xen-dom0 $NOVA_CONF"
Isaku Yamahata0dd34df2012-12-28 13:15:31 +090079 # Under XS/XCP, the ovs agent needs to target the dom0
80 # integration bridge. This is enabled by using a root wrapper
81 # that executes commands on dom0 via a XenAPI plugin.
82 iniset /$Q_PLUGIN_CONF_FILE AGENT root_helper "$Q_RR_DOM0_COMMAND"
83
84 # FLAT_NETWORK_BRIDGE is the dom0 integration bridge. To
85 # ensure the bridge lacks direct connectivity, set
86 # VM_VLAN=-1;VM_DEV=invalid in localrc
87 iniset /$Q_PLUGIN_CONF_FILE OVS integration_bridge $FLAT_NETWORK_BRIDGE
88
89 # The ovs agent needs to ensure that the ports associated with
90 # a given network share the same local vlan tag. On
91 # single-node XS/XCP, this requires monitoring both the dom0
92 # bridge, where VM's are attached, and the domU bridge, where
93 # dhcp servers are attached.
94 if is_service_enabled q-dhcp; then
95 iniset /$Q_PLUGIN_CONF_FILE OVS domu_integration_bridge $OVS_BRIDGE
96 # DomU will use the regular rootwrap
97 iniset /$Q_PLUGIN_CONF_FILE AGENT domu_root_helper "$Q_RR_COMMAND"
98 # Plug the vm interface into the domU integration bridge.
99 sudo ip addr flush dev $GUEST_INTERFACE_DEFAULT
100 sudo ip link set $OVS_BRIDGE up
101 # Assign the VM IP only if it has been set explicitly
102 if [[ "$VM_IP" != "" ]]; then
103 sudo ip addr add $VM_IP dev $OVS_BRIDGE
104 fi
105 sudo ovs-vsctl add-port $OVS_BRIDGE $GUEST_INTERFACE_DEFAULT
106 fi
107 fi
108}
109
110function quantum_plugin_configure_service() {
111 if [[ "$ENABLE_TENANT_TUNNELS" = "True" ]]; then
112 iniset /$Q_PLUGIN_CONF_FILE OVS tenant_network_type gre
113 iniset /$Q_PLUGIN_CONF_FILE OVS tunnel_id_ranges $TENANT_TUNNEL_RANGES
114 elif [[ "$ENABLE_TENANT_VLANS" = "True" ]]; then
115 iniset /$Q_PLUGIN_CONF_FILE OVS tenant_network_type vlan
116 else
117 echo "WARNING - The openvswitch plugin is using local tenant networks, with no connectivity between hosts."
118 fi
119
120 # Override ``OVS_VLAN_RANGES`` and ``OVS_BRIDGE_MAPPINGS`` in ``localrc``
121 # for more complex physical network configurations.
122 if [[ "$OVS_VLAN_RANGES" = "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]]; then
123 OVS_VLAN_RANGES=$PHYSICAL_NETWORK
124 if [[ "$TENANT_VLAN_RANGE" != "" ]]; then
125 OVS_VLAN_RANGES=$OVS_VLAN_RANGES:$TENANT_VLAN_RANGE
126 fi
127 fi
128 if [[ "$OVS_VLAN_RANGES" != "" ]]; then
129 iniset /$Q_PLUGIN_CONF_FILE OVS network_vlan_ranges $OVS_VLAN_RANGES
130 fi
131
132 # Enable tunnel networks if selected
133 if [[ $OVS_ENABLE_TUNNELING = "True" ]]; then
134 iniset /$Q_PLUGIN_CONF_FILE OVS enable_tunneling True
135 fi
136}
137
138function quantum_plugin_setup_interface_driver() {
139 local conf_file=$1
140 iniset $conf_file DEFAULT interface_driver quantum.agent.linux.interface.OVSInterfaceDriver
141}
142
143# Restore xtrace
Dean Troyer8d55be32013-02-07 17:16:35 -0600144$MY_XTRACE