blob: d5d4f102f6e2d8e3fa2940db60035ed4c1addce8 [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() {
Akihiro MOTOKI3452f8e2013-03-21 14:11:27 +090011 _quantum_ovs_base_configure_nova_vif_driver
Isaku Yamahata0dd34df2012-12-28 13:15:31 +090012 if [ "$VIRT_DRIVER" = 'xenserver' ]; then
13 iniset $NOVA_CONF DEFAULT xenapi_vif_driver nova.virt.xenapi.vif.XenAPIOpenVswitchDriver
Mate Lakatf652e0f2013-05-21 18:12:48 +010014 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 Yamahata0dd34df2012-12-28 13:15:31 +090017 fi
18}
19
20function quantum_plugin_install_agent_packages() {
21 _quantum_ovs_base_install_agent_packages
22}
23
24function 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
31function quantum_plugin_configure_debug_command() {
32 _quantum_ovs_base_configure_debug_command
33}
34
35function quantum_plugin_configure_dhcp_agent() {
Dan Wendlandtadcb18f2013-02-22 07:27:26 -080036 iniset $Q_DHCP_CONF_FILE DEFAULT dhcp_agent_manager quantum.agent.dhcp_agent.DhcpAgentWithStateReport
Isaku Yamahata0dd34df2012-12-28 13:15:31 +090037}
38
39function quantum_plugin_configure_l3_agent() {
40 _quantum_ovs_base_configure_l3_agent
Akihiro MOTOKI09d61852013-03-03 01:24:45 +090041 iniset $Q_L3_CONF_FILE DEFAULT l3_agent_manager quantum.agent.l3_agent.L3NATAgentWithStateReport
Isaku Yamahata0dd34df2012-12-28 13:15:31 +090042}
43
44function quantum_plugin_configure_plugin_agent() {
45 # Setup integration bridge
Isaku Yamahata0dd34df2012-12-28 13:15:31 +090046 _quantum_ovs_base_setup_bridge $OVS_BRIDGE
Akihiro MOTOKI3452f8e2013-03-21 14:11:27 +090047 _quantum_ovs_base_configure_firewall_driver
Isaku Yamahata0dd34df2012-12-28 13:15:31 +090048
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 Ueno07115eb2013-02-26 12:38:18 -080055 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 +090056 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 Lakatf652e0f2013-05-21 18:12:48 +010076 # 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 Newbya8f7a622013-05-01 20:48:54 +000080 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 Yamahata0dd34df2012-12-28 13:15:31 +090087 # 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 Lakatf652e0f2013-05-21 18:12:48 +010092 # Set "physical" mapping
93 iniset /$Q_PLUGIN_CONF_FILE OVS bridge_mappings "physnet1:$FLAT_NETWORK_BRIDGE"
Isaku Yamahata0dd34df2012-12-28 13:15:31 +090094
Mate Lakatf652e0f2013-05-21 18:12:48 +010095 # 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 Yamahata0dd34df2012-12-28 13:15:31 +0900111 fi
112}
113
114function 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 Liue6f2ee52013-05-14 09:48:15 +0000140
141 _quantum_ovs_base_configure_firewall_driver
Isaku Yamahata0dd34df2012-12-28 13:15:31 +0900142}
143
144function 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 MOTOKI3452f8e2013-03-21 14:11:27 +0900149function has_quantum_plugin_security_group() {
150 return 0
151}
152
armando-migliaccio7c025fe2013-05-08 11:33:07 -0700153function quantum_plugin_check_adv_test_requirements() {
154 is_service_enabled q-agt && is_service_enabled q-dhcp && return 0
155}
156
Isaku Yamahata0dd34df2012-12-28 13:15:31 +0900157# Restore xtrace
Dean Troyer8d55be32013-02-07 17:16:35 -0600158$MY_XTRACE