From 2298ca4f705e28dcc4b2aa605b73470612f6bb61 Mon Sep 17 00:00:00 2001 From: Maru Newby Date: Thu, 25 Oct 2012 23:46:42 +0000 Subject: [PATCH] Add limited support for Quantum+OVS on XS/XCP. * Add priliminary support for running the OVS L2 and DHCP agents in domU: * Configure Nova to use the correct vif driver and integration bridge. * Configure the ovs agent to target the dom0 integration bridge. * Install a xapi plugin supporting dom0 execution of ovs agent commands. * Config doc: http://wiki.openstack.org/QuantumDevstackOvsXcp * Supports blueprint xenapi-ovs Change-Id: If5ab07daab1dc3918004eb4bfb6fed6cab0a71fd --- lib/quantum | 46 ++++++++++++++++++++++++++++++++++-- tools/xen/install_os_domU.sh | 13 ++++++++++ 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/lib/quantum b/lib/quantum index 9c06f45725..bfea2b55a7 100644 --- a/lib/quantum +++ b/lib/quantum @@ -212,6 +212,10 @@ function create_nova_conf_quantum() { if [[ "$Q_PLUGIN" = "openvswitch" ]]; then NOVA_VIF_DRIVER=${NOVA_VIF_DRIVER:-"nova.virt.libvirt.vif.LibvirtHybridOVSBridgeDriver"} + if [ "$VIRT_DRIVER" = 'xenserver' ]; then + add_nova_opt "xenapi_vif_driver=nova.virt.xenapi.vif.XenAPIOpenVswitchDriver" + add_nova_opt "xenapi_ovs_integration_bridge=$FLAT_NETWORK_BRIDGE" + fi elif [[ "$Q_PLUGIN" = "linuxbridge" ]]; then NOVA_VIF_DRIVER=${NOVA_VIF_DRIVER:-"nova.virt.libvirt.vif.QuantumLinuxBridgeVIFDriver"} elif [[ "$Q_PLUGIN" = "ryu" ]]; then @@ -536,6 +540,11 @@ function _configure_quantum_metadata_agent() { # _configure_quantum_plugin_agent() - Set config files for quantum plugin agent # It is called when q-agt is enabled. function _configure_quantum_plugin_agent() { + + # Specify the default root helper prior to agent configuration to + # ensure that an agent's configuration can override the default. + iniset /$Q_PLUGIN_CONF_FILE AGENT root_helper "$Q_RR_COMMAND" + # Configure agent for plugin if [[ "$Q_PLUGIN" = "openvswitch" ]]; then _configure_quantum_plugin_agent_openvswitch @@ -544,8 +553,6 @@ function _configure_quantum_plugin_agent() { elif [[ "$Q_PLUGIN" = "ryu" ]]; then _configure_quantum_plugin_agent_ryu fi - - iniset /$Q_PLUGIN_CONF_FILE AGENT root_helper "$Q_RR_COMMAND" } function _configure_quantum_plugin_agent_linuxbridge() { @@ -593,6 +600,41 @@ function _configure_quantum_plugin_agent_openvswitch() { iniset /$Q_PLUGIN_CONF_FILE OVS bridge_mappings $OVS_BRIDGE_MAPPINGS fi AGENT_BINARY="$QUANTUM_DIR/bin/quantum-openvswitch-agent" + + if [ "$VIRT_DRIVER" = 'xenserver' ]; then + # Nova will always be installed along with quantum for a domU + # devstack install, so it should be safe to rely on nova.conf + # for xenapi configuration. + Q_RR_DOM0_COMMAND="$QUANTUM_DIR/bin/quantum-rootwrap-dom0 $NOVA_CONF" + # Under XS/XCP, the ovs agent needs to target the dom0 + # integration bridge. This is enabled by using a root wrapper + # that executes commands on dom0 via a XenAPI plugin. + iniset /$Q_PLUGIN_CONF_FILE AGENT root_helper "$Q_RR_DOM0_COMMAND" + + # FLAT_NETWORK_BRIDGE is the dom0 integration bridge. To + # ensure the bridge lacks direct connectivity, set + # VM_VLAN=-1;VM_DEV=invalid in localrc + iniset /$Q_PLUGIN_CONF_FILE OVS integration_bridge $FLAT_NETWORK_BRIDGE + + # The ovs agent needs to ensure that the ports associated with + # a given network share the same local vlan tag. On + # single-node XS/XCP, this requires monitoring both the dom0 + # bridge, where VM's are attached, and the domU bridge, where + # dhcp servers are attached. + if is_service_enabled q-dhcp; then + iniset /$Q_PLUGIN_CONF_FILE OVS domu_integration_bridge $OVS_BRIDGE + # DomU will use the regular rootwrap + iniset /$Q_PLUGIN_CONF_FILE AGENT domu_root_helper "$Q_RR_COMMAND" + # Plug the vm interface into the domU integration bridge. + sudo ip addr flush dev $GUEST_INTERFACE_DEFAULT + sudo ip link set $OVS_BRIDGE up + # Assign the VM IP only if it has been set explicitly + if [[ "$VM_IP" != "" ]]; then + sudo ip addr add $VM_IP dev $OVS_BRIDGE + fi + sudo ovs-vsctl add-port $OVS_BRIDGE $GUEST_INTERFACE_DEFAULT + fi + fi } function _configure_quantum_plugin_agent_ryu() { diff --git a/tools/xen/install_os_domU.sh b/tools/xen/install_os_domU.sh index e270e59b37..b4fbb699ef 100755 --- a/tools/xen/install_os_domU.sh +++ b/tools/xen/install_os_domU.sh @@ -68,6 +68,19 @@ if [ ! -d $XAPI_PLUGIN_DIR ]; then XAPI_PLUGIN_DIR=/usr/lib/xcp/plugins/ fi cp -pr ./nova/*/plugins/xenserver/xenapi/etc/xapi.d/plugins/* $XAPI_PLUGIN_DIR + +# Install the netwrap xapi plugin to support agent control of dom0 networking +if [[ "$ENABLED_SERVICES" =~ "q-agt" && "$Q_PLUGIN" = "openvswitch" ]]; then + if [ -f ./quantum ]; then + rm -rf ./quantum + fi + # get quantum + QUANTUM_ZIPBALL_URL=${QUANTUM_ZIPBALL_URL:-$(echo $QUANTUM_REPO | sed "s:\.git$::;s:$:/zipball/$QUANTUM_BRANCH:g")} + wget $QUANTUM_ZIPBALL_URL -O quantum-zipball --no-check-certificate + unzip -o quantum-zipball -d ./quantum + cp -pr ./quantum/*/quantum/plugins/openvswitch/agent/xenapi/etc/xapi.d/plugins/* $XAPI_PLUGIN_DIR +fi + chmod a+x ${XAPI_PLUGIN_DIR}* mkdir -p /boot/guest