type network_ops = {
kind: kind;
- add: string -> unit;
+ add: string -> ?uuid:string -> unit;
del: string -> unit;
list: unit -> string list;
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 =
| "" -> []
| 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" ]
(** 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. *)
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 () =
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