[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-API] [PATCH 4 of 7] [PATCH] vswitch: do not access XenAPI from VIF hotplug script



# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1278595821 -3600
# Node ID 55274f6110830e7d64685be8f0a02d50eb05aab5
# Parent  e57360c174aa2444c491abc67a52e90064071a91
[PATCH] vswitch: do not access XenAPI from VIF hotplug script

>From 31afafc599ec9806e7a56e947a6ca0cd7af055f1 Mon Sep 17 00:00:00 2001
Date: Fri, 26 Feb 2010 13:25:09 -0800
XenAPI accesses must go through the pool master which introduces a
scalability issue.  All but one of the required values are already
present in xenstore for this reason

The only exception is the network UUID for an internal network. Rather
than working around the lack of callout to interface-reconfigure for
these networks simply pass the network uuid when creating calling out
to create the bridge.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
---
 scripts/vif |   48 ++++++++++++++++++++++++++++++----
 1 files changed, 42 insertions(+), 6 deletions(-)

diff -r e57360c174aa -r 55274f611083 scripts/vif
--- a/scripts/vif       Thu Jul 08 14:30:21 2010 +0100
+++ b/scripts/vif       Thu Jul 08 14:30:21 2010 +0100
@@ -66,6 +66,43 @@
     fi
 }
 
+set_vif_external_id()
+{
+    local key=$1
+    local value=$2
+
+    logger -t scripts-vif "vif${DOMID}.${DEVID} 
external-ids:\"${key}\"=\"${value}\""
+
+    echo "-- set interface vif${DOMID}.${DEVID} 
external-ids:\"${key}\"=\"${value}\""
+}
+
+handle_vswitch_vif_details()
+{
+    local vif_details=
+    local net_uuid=$(xenstore-read "${PRIVATE}/network-uuid" 2>/dev/null)
+    if [ -n "${net_uuid}" ] ; then
+       set_vif_external_id "xs-network-uuid" "${net_uuid}"
+    fi
+
+    local address=$(xenstore-read "/local/domain/$DOMID/device/vif/$DEVID/mac" 
2>/dev/null)
+    if [ -n "${address}" ] ; then
+       set_vif_external_id "xs-vif-mac" "${address}"
+    fi
+
+    local vif_uuid=$(xenstore-read "${PRIVATE}/vif-uuid" 2>/dev/null)
+    if [ -n "${vif_uuid}" ] ; then
+       set_vif_external_id "xs-vif-uuid" "${vif_uuid}"
+    fi
+
+    local vm=$(xenstore-read "/local/domain/$DOMID/vm" 2>/dev/null)
+    if [ $? -eq 0 -a -n "${vm}" ] ; then
+       local vm_uuid=$(xenstore-read "$vm/uuid" 2>/dev/null)
+    fi
+    if [ -n "${vm_uuid}" ] ; then
+       set_vif_external_id "xs-vm-uuid" "${vm_uuid}"
+    fi
+}
+
 add_to_bridge()
 {
     local address=$(xenstore-read "${PRIVATE}/bridge-MAC")
@@ -92,12 +129,11 @@
            ${BRCTL} addif "${bridge}" "${dev}"                 || logger -t 
scripts-vif "Failed to brctl addif ${bridge} ${dev}"
            ;;
        vswitch)
-               local vif_details=$($dump_vif_details $DOMID $DEVID)
-               if [ $? -ne 0 -o -z "${vif_details}" ]; then
-                       logger -t scripts-vif "Failed to retrieve vif details 
for vswitch"
-               fi
+           if [ "$TYPE" = "vif" ] ; then
+               local vif_details=$(handle_vswitch_vif_details)
+           fi
 
-               $vsctl -- --if-exists del-port $dev -- add-port $bridge $dev 
$vif_details
+           $vsctl -- --if-exists del-port $dev -- add-port $bridge $dev 
$vif_details
            ;;
     esac
            
@@ -111,7 +147,7 @@
            # Nothing to do
            ;;
        vswitch)
-        $vsctl del-port $bridge $dev
+           $vsctl del-port $bridge $dev
            ;;
     esac
 }
 scripts/vif |  48 ++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 42 insertions(+), 6 deletions(-)


Attachment: vswitch_do_not_access_XenAPI_from_VIF_hotplug_script.patch
Description: Text Data

_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.