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:55 +0100
Delivery-date: Thu, 08 Jul 2010 07:08:47 -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 1278597044 -3600
# Node ID c7e5d6589c970128f50b00a983382d6b728942c2
# Parent  ac96f047a434dd212f15587dff046cd547d3e366
Improve import of networks/VIFs on pool join

Metadata export+import is used to recreate VIFs on the pool, when a host joins. 
VIFs are linked to networks on the receiving pool by matching the name_label of 
the network on the two pools. If the name_label does not exist, this has to be 
because an existing physical network on the receiving pool is used; in this 
case, we match on bridge name. This is a sensible fall-back option for imports 
in general.

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

diff -r ac96f047a434 -r c7e5d6589c97 ocaml/xapi/import.ml
--- a/ocaml/xapi/import.ml      Thu Jul 08 14:47:51 2010 +0100
+++ b/ocaml/xapi/import.ml      Thu Jul 08 14:50:44 2010 +0100
@@ -383,17 +383,25 @@
   let net = 
     match possibilities, config.vm_metadata_only with
       | [], true ->
-             (* In vm_metadata_only_mode the network must exist *)
-             let msg = 
-            Printf.sprintf "Unable to find Network with name_label = '%s'" 
-                 net_record.API.network_name_label 
-          in
-               error "%s" msg;
-               raise (Failure msg)
+          begin try
+            (* Lookup by bridge name as fallback *)
+            let nets = Client.Network.get_all_records rpc session_id in
+            let net, _ =
+              List.find (fun (_, netr) -> netr.API.network_bridge = 
net_record.API.network_bridge) nets in
+            net
+          with _ ->
+               (* In vm_metadata_only_mode the network must exist *)
+               let msg = 
+              Printf.sprintf "Unable to find Network with name_label = '%s' 
nor bridge = '%s'" 
+                   net_record.API.network_name_label 
net_record.API.network_bridge
+            in
+                 error "%s" msg;
+                 raise (Failure msg)
+             end
       | [], false ->
              (* In normal mode we attempt to create any networks which are 
missing *)
              let net = 
-            log_reraise ("failed to create Network with name-label " ^ 
net_record.API.network_name_label)
+            log_reraise ("failed to create Network with name_label " ^ 
net_record.API.network_name_label)
                  (fun value -> Client.Network.create_from_record rpc 
session_id value) net_record 
           in
             (* Only add task flag to networks which get created in this import 
*)
 ocaml/xapi/import.ml |  24 ++++++++++++++++--------
 1 files changed, 16 insertions(+), 8 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>