blob: 288fa69bf24738bb9a8eed9491e0294851f4e91c [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
Nachi Ueno07115eb2013-02-26 12:38:18 -080052 die $LINENO "You are running OVS version $OVS_VERSION. OVS 1.4+ is required for tunneling between multiple hosts."
Isaku Yamahata0dd34df2012-12-28 13:15:31 +090053 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 Newbya1a61c82013-02-13 19:20:03 +000076 Q_RR_DOM0_COMMAND="$QUANTUM_DIR/bin/quantum-rootwrap-xen-dom0 $NOVA_CONF"
Isaku Yamahata0dd34df2012-12-28 13:15:31 +090077 # 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
108function 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
136function 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 Troyer8d55be32013-02-07 17:16:35 -0600142$MY_XTRACE