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

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



# 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

 


Rackspace

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