]> xenbits.xensource.com Git - xcp/xen-api.git/commitdiff
vswitch: pass network uuid to vswitch when creating an internal network
authorIan Campbell <ian.campbell@citrix.com>
Thu, 8 Jul 2010 13:35:13 +0000 (14:35 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Thu, 8 Jul 2010 13:35:13 +0000 (14:35 +0100)
For external networks this is taken care of by interface-reconfigure
but in the internal network case there is currently no callout so
simply pass the network uuid when creating calling out to create the
bridge.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
ocaml/netdev/netdev.ml
ocaml/netdev/netdev.mli
ocaml/xapi/xapi_network.ml

index d31d8dc6b543093453ac7f058a17c3f7c44a65bb..768dd3b8fbe5910e73cb8657599ec33264a89e0f 100644 (file)
@@ -18,7 +18,7 @@ type kind = Bridge | Vswitch
 
 type network_ops = { 
   kind: kind;
-  add: string -> unit;
+  add: string -> ?uuid:string -> unit;
   del: string -> unit;
   list: unit -> string list;
 
@@ -99,7 +99,7 @@ module Bridge = struct
 external _add : Unix.file_descr -> string -> unit = "stub_bridge_add"
 external _del : Unix.file_descr -> string -> unit = "stub_bridge_del"
 
-let add name =
+let add name ?uuid = 
        Internal.with_fd (fun fd -> _add fd name)
 
 let del name =
@@ -224,7 +224,11 @@ let vsctl args =
     | "" -> []
     | s -> Stringext.String.split '\n' s
 
-let add name = ignore(vsctl ["add-br" ; name])
+let add name ?uuid = 
+  let extra = match uuid with
+    | Some uuid' -> ["--"; "br-set-external-id"; name; "network-uuids"; uuid']
+    | None -> ["--"; "foo"] in
+  ignore(vsctl (["add-br" ; name] @ extra))
 let del name = ignore(vsctl ["del-br" ; name])
 let list () = vsctl [ "list-br" ]
 
index aaa19c570f86e069cd979ecbc9df47ad7f58ebf1..07ce7198a963003b7799f4fa45571e568ebe4ba5 100644 (file)
@@ -21,7 +21,7 @@ type kind =
 (** Possible operations on each network backend type. *)
 type network_ops = {
   kind : kind;                              (** The type of network backend. *)
-  add : string -> unit;                     (** Add a bridge. *)
+  add : string -> ?uuid:string -> unit;     (** Add a bridge. *)
   del : string -> unit;                     (** Remove a bridge. *)
   list : unit -> string list;               (** List all bridges. *)
   exists : string -> bool;                  (** Query the existance of a bridge. *)
index 79de059fdbe03e3e01d76d3153e5befce4d03806..d1b63776237903e2f8e531aad0c6e0f6d0cace5f 100644 (file)
@@ -24,10 +24,10 @@ open Db_filter
 let get_allowed_messages ~__context ~self = []
 *)
 
-let create_internal_bridge ~bridge =
-  debug "Creating internal bridge %s" bridge;
+let create_internal_bridge ~bridge ~uuid =
+  debug "Creating internal bridge %s (uuid:%s)" bridge uuid;
   let current = Netdev.network.Netdev.list () in
-  if not(List.mem bridge current) then Netdev.network.Netdev.add bridge;
+  if not(List.mem bridge current) then Netdev.network.Netdev.add bridge ?uuid:(Some uuid);
   if not(Netdev.Link.is_up bridge) then Netdev.Link.up bridge
 
 let attach_internal ?(management_interface=false) ~__context ~self () =
@@ -36,10 +36,11 @@ let attach_internal ?(management_interface=false) ~__context ~self () =
     Xapi_network_attach_helpers.assert_can_attach_network_on_host ~__context ~self ~host ~overide_management_if_check:management_interface in
 
   let bridge = Db.Network.get_bridge ~__context ~self in
+  let uuid = Db.Network.get_uuid ~__context ~self in
 
   (* Ensure internal bridge exists and is up. external bridges will be
      brought up by call to interface-reconfigure. *)
-  if List.length(local_pifs) = 0 then create_internal_bridge ~bridge;
+  if List.length(local_pifs) = 0 then create_internal_bridge ~bridge ~uuid;
 
   (* Check if we're a guest-installer network: *)
   let other_config = Db.Network.get_other_config ~__context ~self in