WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-api

[Xen-API] [PATCH] Improve network recreation on pool join

To: xen-api@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-API] [PATCH] Improve network recreation on pool join
From: David Scott <dave.scott@xxxxxxxxxxxxx>
Date: Thu, 8 Jul 2010 14:50:39 +0100
Delivery-date: Thu, 08 Jul 2010 07:08:33 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-api-request@lists.xensource.com?subject=help>
List-id: Discussion of API issues surrounding Xen <xen-api.lists.xensource.com>
List-post: <mailto:xen-api@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-api-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mercurial-patchbomb/1.4.3
# HG changeset patch
# User Rob Hoes <rob.hoes@xxxxxxxxxx>
# Date 1278596871 -3600
# Node ID ac96f047a434dd212f15587dff046cd547d3e366
# Parent  678148a831694194bbb37f5b043d868187f1a5e0
Improve network recreation on pool join

When joining a new host to a pool:
* Networks of physical interfaces are copied to the pool's DB if they do not 
yet exists; matching is done based on the bridge name (xenbr0, xenbr1, ...).
* All other networks are recreated on the pool. The bridge (xapi0, xapi1, ...) 
is renamed such that it is unique on the pool. All other network fields are 
copied from the host's network object.

(related to CA-39461)

Signed-off-by: Rob Hoes <rob.hoes@xxxxxxxxxx>

diff -r 678148a83169 -r ac96f047a434 ocaml/xapi/xapi_pool.ml
--- a/ocaml/xapi/xapi_pool.ml   Thu Jul 08 14:43:16 2010 +0100
+++ b/ocaml/xapi/xapi_pool.ml   Thu Jul 08 14:47:51 2010 +0100
@@ -15,6 +15,7 @@
 open Db_filter_types
 open Pervasiveext
 open Threadext
+open Stringext
 
 module L = Debug.Debugger(struct let name="license" end)
 module D=Debug.Debugger(struct let name="xapi" end)
@@ -387,18 +388,36 @@
        new_vdi_ref
 
 let create_or_get_network_on_master __context rpc session_id (network_ref, 
network) : API.ref_network =
-       let my_name = network.API.network_name_label in
+       let my_bridge = network.API.network_bridge in
 
        let new_network_ref =
-               try List.hd (Client.Network.get_by_name_label ~rpc ~session_id 
~label:my_name)
-               with _ ->
-                       debug "Found no network with name_label = '%s' on the 
master, so creating one." my_name;
-                       Client.Network.pool_introduce ~rpc ~session_id
-                               ~name_label:my_name
+               if String.startswith "xenbr" my_bridge then
+                       (* Physical network: try to join an existing one with 
the same bridge name, or create one.
+                        * This relies on the convention that PIFs with the 
same label need to be connected. *)
+                       try
+                               let pool_networks = 
Client.Network.get_all_records ~rpc ~session_id in
+                               let net_ref, _ = List.find (fun (_, net) -> 
net.API.network_bridge = my_bridge) pool_networks in
+                               net_ref
+                       with _ ->
+                               debug "Found no network with bridge = '%s' on 
the master, so creating one." my_bridge;
+                               Client.Network.pool_introduce ~rpc ~session_id
+                                       
~name_label:network.API.network_name_label
+                                       
~name_description:network.API.network_name_description
+                                       ~mTU:network.API.network_MTU
+                                       
~other_config:network.API.network_other_config
+                                       ~bridge:network.API.network_bridge
+               else begin
+                       debug "Recreating network '%s' as internal network." 
network.API.network_name_label;
+                       (* This call will generate a new 'xapi#' bridge name 
rather than keeping the
+                        * current, possibly colliding one. *)
+                       Client.Network.create ~rpc ~session_id
+                               ~name_label:network.API.network_name_label
                                
~name_description:network.API.network_name_description
                                ~mTU:network.API.network_MTU
                                ~other_config:network.API.network_other_config
-                               ~bridge:network.API.network_bridge in
+                               ~tags:network.API.network_tags
+               end
+       in
 
        new_network_ref
 
 ocaml/xapi/xapi_pool.ml |  33 ++++++++++++++++++++++++++-------
 1 files changed, 26 insertions(+), 7 deletions(-)


Attachment: xen-api.hg.patch
Description: Text Data

_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api
<Prev in Thread] Current Thread [Next in Thread>