blob: 374172014b79edb6cdca6ba8816a594752288023 [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
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
Isaku Yamahata0dd34df2012-12-28 13:15:31 +090044 _quantum_ovs_base_setup_bridge $OVS_BRIDGE
Akihiro MOTOKI3452f8e2013-03-21 14:11:27 +090045 _quantum_ovs_base_configure_firewall_driver
Isaku Yamahata0dd34df2012-12-28 13:15:31 +090046
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
Nachi Ueno07115eb2013-02-26 12:38:18 -080053 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 +090054 fi
55 iniset /$Q_PLUGIN_CONF_FILE OVS enable_tunneling True
56 iniset /$Q_PLUGIN_CONF_FILE OVS local_ip $HOST_IP
57 fi
58
59 # Setup physical network bridge mappings. Override
60 # ``OVS_VLAN_RANGES`` and ``OVS_BRIDGE_MAPPINGS`` in ``localrc`` for more
61 # complex physical network configurations.
62 if [[ "$OVS_BRIDGE_MAPPINGS" = "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]] && [[ "$OVS_PHYSICAL_BRIDGE" != "" ]]; then
63 OVS_BRIDGE_MAPPINGS=$PHYSICAL_NETWORK:$OVS_PHYSICAL_BRIDGE
64
65 # Configure bridge manually with physical interface as port for multi-node
66 sudo ovs-vsctl --no-wait -- --may-exist add-br $OVS_PHYSICAL_BRIDGE
67 fi
68 if [[ "$OVS_BRIDGE_MAPPINGS" != "" ]]; then
69 iniset /$Q_PLUGIN_CONF_FILE OVS bridge_mappings $OVS_BRIDGE_MAPPINGS
70 fi
71 AGENT_BINARY="$QUANTUM_DIR/bin/quantum-openvswitch-agent"
72
73 if [ "$VIRT_DRIVER" = 'xenserver' ]; then
Maru Newbya8f7a622013-05-01 20:48:54 +000074 Q_RR_DOM0_COMMAND="$QUANTUM_DIR/bin/quantum-rootwrap-xen-dom0 $Q_RR_CONF_FILE"
75
76 # For now, duplicate the xen configuration already found in nova.conf
77 iniset $Q_RR_CONF_FILE XENAPI xenapi_connection_url "$XENAPI_CONNECTION_URL"
78 iniset $Q_RR_CONF_FILE XENAPI xenapi_connection_username "$XENAPI_USER"
79 iniset $Q_RR_CONF_FILE XENAPI xenapi_connection_password "$XENAPI_PASSWORD"
80
Isaku Yamahata0dd34df2012-12-28 13:15:31 +090081 # Under XS/XCP, the ovs agent needs to target the dom0
82 # integration bridge. This is enabled by using a root wrapper
83 # that executes commands on dom0 via a XenAPI plugin.
84 iniset /$Q_PLUGIN_CONF_FILE AGENT root_helper "$Q_RR_DOM0_COMMAND"
85
86 # FLAT_NETWORK_BRIDGE is the dom0 integration bridge. To
87 # ensure the bridge lacks direct connectivity, set
88 # VM_VLAN=-1;VM_DEV=invalid in localrc
89 iniset /$Q_PLUGIN_CONF_FILE OVS integration_bridge $FLAT_NETWORK_BRIDGE
90
91 # The ovs agent needs to ensure that the ports associated with
92 # a given network share the same local vlan tag. On
93 # single-node XS/XCP, this requires monitoring both the dom0
94 # bridge, where VM's are attached, and the domU bridge, where
95 # dhcp servers are attached.
96 if is_service_enabled q-dhcp; then
97 iniset /$Q_PLUGIN_CONF_FILE OVS domu_integration_bridge $OVS_BRIDGE
98 # DomU will use the regular rootwrap
99 iniset /$Q_PLUGIN_CONF_FILE AGENT domu_root_helper "$Q_RR_COMMAND"
100 # Plug the vm interface into the domU integration bridge.
101 sudo ip addr flush dev $GUEST_INTERFACE_DEFAULT
102 sudo ip link set $OVS_BRIDGE up
103 # Assign the VM IP only if it has been set explicitly
104 if [[ "$VM_IP" != "" ]]; then
105 sudo ip addr add $VM_IP dev $OVS_BRIDGE
106 fi
107 sudo ovs-vsctl add-port $OVS_BRIDGE $GUEST_INTERFACE_DEFAULT
108 fi
109 fi
110}
111
112function quantum_plugin_configure_service() {
113 if [[ "$ENABLE_TENANT_TUNNELS" = "True" ]]; then
114 iniset /$Q_PLUGIN_CONF_FILE OVS tenant_network_type gre
115 iniset /$Q_PLUGIN_CONF_FILE OVS tunnel_id_ranges $TENANT_TUNNEL_RANGES
116 elif [[ "$ENABLE_TENANT_VLANS" = "True" ]]; then
117 iniset /$Q_PLUGIN_CONF_FILE OVS tenant_network_type vlan
118 else
119 echo "WARNING - The openvswitch plugin is using local tenant networks, with no connectivity between hosts."
120 fi
121
122 # Override ``OVS_VLAN_RANGES`` and ``OVS_BRIDGE_MAPPINGS`` in ``localrc``
123 # for more complex physical network configurations.
124 if [[ "$OVS_VLAN_RANGES" = "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]]; then
125 OVS_VLAN_RANGES=$PHYSICAL_NETWORK
126 if [[ "$TENANT_VLAN_RANGE" != "" ]]; then
127 OVS_VLAN_RANGES=$OVS_VLAN_RANGES:$TENANT_VLAN_RANGE
128 fi
129 fi
130 if [[ "$OVS_VLAN_RANGES" != "" ]]; then
131 iniset /$Q_PLUGIN_CONF_FILE OVS network_vlan_ranges $OVS_VLAN_RANGES
132 fi
133
134 # Enable tunnel networks if selected
135 if [[ $OVS_ENABLE_TUNNELING = "True" ]]; then
136 iniset /$Q_PLUGIN_CONF_FILE OVS enable_tunneling True
137 fi
138}
139
140function quantum_plugin_setup_interface_driver() {
141 local conf_file=$1
142 iniset $conf_file DEFAULT interface_driver quantum.agent.linux.interface.OVSInterfaceDriver
143}
144
Akihiro MOTOKI3452f8e2013-03-21 14:11:27 +0900145function has_quantum_plugin_security_group() {
146 return 0
147}
148
armando-migliaccio7c025fe2013-05-08 11:33:07 -0700149function quantum_plugin_check_adv_test_requirements() {
150 is_service_enabled q-agt && is_service_enabled q-dhcp && return 0
151}
152
Isaku Yamahata0dd34df2012-12-28 13:15:31 +0900153# Restore xtrace
Dean Troyer8d55be32013-02-07 17:16:35 -0600154$MY_XTRACE