blob: 8df12461e9a22e74ab8b1d2c3bbf0dfd808bfb14 [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
Akihiro MOTOKI09d61852013-03-03 01:24:45 +090039 iniset $Q_L3_CONF_FILE DEFAULT l3_agent_manager quantum.agent.l3_agent.L3NATAgentWithStateReport
Isaku Yamahata0dd34df2012-12-28 13:15:31 +090040}
41
42function quantum_plugin_configure_plugin_agent() {
43 # Setup integration bridge
44 OVS_BRIDGE=${OVS_BRIDGE:-br-int}
45 _quantum_ovs_base_setup_bridge $OVS_BRIDGE
46
47 # Setup agent for tunneling
48 if [[ "$OVS_ENABLE_TUNNELING" = "True" ]]; then
49 # Verify tunnels are supported
50 # REVISIT - also check kernel module support for GRE and patch ports
51 OVS_VERSION=`ovs-vsctl --version | head -n 1 | awk '{print $4;}'`
52 if [ $OVS_VERSION \< "1.4" ] && ! is_service_enabled q-svc ; then
53 echo "You are running OVS version $OVS_VERSION."
54 echo "OVS 1.4+ is required for tunneling between multiple hosts."
55 exit 1
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
76 # Nova will always be installed along with quantum for a domU
77 # devstack install, so it should be safe to rely on nova.conf
78 # for xenapi configuration.
Maru Newbya1a61c82013-02-13 19:20:03 +000079 Q_RR_DOM0_COMMAND="$QUANTUM_DIR/bin/quantum-rootwrap-xen-dom0 $NOVA_CONF"
Isaku Yamahata0dd34df2012-12-28 13:15:31 +090080 # Under XS/XCP, the ovs agent needs to target the dom0
81 # integration bridge. This is enabled by using a root wrapper
82 # that executes commands on dom0 via a XenAPI plugin.
83 iniset /$Q_PLUGIN_CONF_FILE AGENT root_helper "$Q_RR_DOM0_COMMAND"
84
85 # FLAT_NETWORK_BRIDGE is the dom0 integration bridge. To
86 # ensure the bridge lacks direct connectivity, set
87 # VM_VLAN=-1;VM_DEV=invalid in localrc
88 iniset /$Q_PLUGIN_CONF_FILE OVS integration_bridge $FLAT_NETWORK_BRIDGE
89
90 # The ovs agent needs to ensure that the ports associated with
91 # a given network share the same local vlan tag. On
92 # single-node XS/XCP, this requires monitoring both the dom0
93 # bridge, where VM's are attached, and the domU bridge, where
94 # dhcp servers are attached.
95 if is_service_enabled q-dhcp; then
96 iniset /$Q_PLUGIN_CONF_FILE OVS domu_integration_bridge $OVS_BRIDGE
97 # DomU will use the regular rootwrap
98 iniset /$Q_PLUGIN_CONF_FILE AGENT domu_root_helper "$Q_RR_COMMAND"
99 # Plug the vm interface into the domU integration bridge.
100 sudo ip addr flush dev $GUEST_INTERFACE_DEFAULT
101 sudo ip link set $OVS_BRIDGE up
102 # Assign the VM IP only if it has been set explicitly
103 if [[ "$VM_IP" != "" ]]; then
104 sudo ip addr add $VM_IP dev $OVS_BRIDGE
105 fi
106 sudo ovs-vsctl add-port $OVS_BRIDGE $GUEST_INTERFACE_DEFAULT
107 fi
108 fi
109}
110
111function quantum_plugin_configure_service() {
112 if [[ "$ENABLE_TENANT_TUNNELS" = "True" ]]; then
113 iniset /$Q_PLUGIN_CONF_FILE OVS tenant_network_type gre
114 iniset /$Q_PLUGIN_CONF_FILE OVS tunnel_id_ranges $TENANT_TUNNEL_RANGES
115 elif [[ "$ENABLE_TENANT_VLANS" = "True" ]]; then
116 iniset /$Q_PLUGIN_CONF_FILE OVS tenant_network_type vlan
117 else
118 echo "WARNING - The openvswitch plugin is using local tenant networks, with no connectivity between hosts."
119 fi
120
121 # Override ``OVS_VLAN_RANGES`` and ``OVS_BRIDGE_MAPPINGS`` in ``localrc``
122 # for more complex physical network configurations.
123 if [[ "$OVS_VLAN_RANGES" = "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]]; then
124 OVS_VLAN_RANGES=$PHYSICAL_NETWORK
125 if [[ "$TENANT_VLAN_RANGE" != "" ]]; then
126 OVS_VLAN_RANGES=$OVS_VLAN_RANGES:$TENANT_VLAN_RANGE
127 fi
128 fi
129 if [[ "$OVS_VLAN_RANGES" != "" ]]; then
130 iniset /$Q_PLUGIN_CONF_FILE OVS network_vlan_ranges $OVS_VLAN_RANGES
131 fi
132
133 # Enable tunnel networks if selected
134 if [[ $OVS_ENABLE_TUNNELING = "True" ]]; then
135 iniset /$Q_PLUGIN_CONF_FILE OVS enable_tunneling True
136 fi
137}
138
139function quantum_plugin_setup_interface_driver() {
140 local conf_file=$1
141 iniset $conf_file DEFAULT interface_driver quantum.agent.linux.interface.OVSInterfaceDriver
142}
143
144# Restore xtrace
Dean Troyer8d55be32013-02-07 17:16:35 -0600145$MY_XTRACE