This call purges all network-related metadata associated with the given host (PIFs, VLANs, bonds, tunnels). This call is used by the emergency network reset functionality. It should normally not be used directly, and is hidden from the API docs.
Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
~params:[Ref _host, "host", "The Host to modify"]
~allowed_roles:_R_POOL_OP
()
-
+
(* ------------------------------------------------------------------------------------------------------------
VDI Management
------------------------------------------------------------------------------------------------------------ *)
~allowed_roles:_R_POOL_OP
()
-
let host_set_power_on_mode = call
~name:"set_power_on_mode"
~in_product_since:rel_midnight_ride
]
~allowed_roles:_R_POOL_OP
()
+
+let host_reset_networking = call
+ ~name:"reset_networking"
+ ~lifecycle:[]
+ ~doc:"Purge all network-related metadata associated with the given host."
+ ~params:[Ref _host, "host", "The Host to modify"]
+ ~allowed_roles:_R_POOL_OP
+ ~hide_from_docs:true
+ ()
(** Hosts *)
let host =
host_set_power_on_mode;
host_set_cpu_features;
host_reset_cpu_features;
+ host_reset_networking;
]
~contents:
([ uid _host;
~allowed_roles:_R_POOL_OP
()
-
let pif_db_forget = call
~name:"db_forget"
~in_oss_since:None
info "Host.reset_cpu_features: host = '%s'" (host_uuid ~__context host);
let local_fn = Local.Host.reset_cpu_features ~host in
do_op_on ~local_fn ~__context ~host (fun session_id rpc -> Client.Host.reset_cpu_features rpc session_id host)
+
+ let reset_networking ~__context ~host =
+ info "Host.reset_networking: host = '%s'" (host_uuid ~__context host);
+ Local.Host.reset_networking ~__context ~host
end
module Host_crashdump = struct
debug "Refreshing software_version";
let software_version = Create_misc.make_software_version () in
Db.Host.set_software_version ~__context ~self:host ~value:software_version
+
+let reset_networking ~__context ~host =
+ debug "Resetting networking";
+ let local_pifs = List.filter (fun pif -> Db.PIF.get_host ~__context ~self:pif = host) (Db.PIF.get_all ~__context) in
+ let bond_is_local bond =
+ List.fold_left (fun a pif -> Db.Bond.get_master ~__context ~self:bond = pif || a) false local_pifs
+ in
+ let vlan_is_local vlan =
+ List.fold_left (fun a pif -> Db.VLAN.get_untagged_PIF ~__context ~self:vlan = pif || a) false local_pifs
+ in
+ let tunnel_is_local tunnel =
+ List.fold_left (fun a pif -> Db.Tunnel.get_access_PIF ~__context ~self:tunnel = pif || a) false local_pifs
+ in
+ let bonds = List.filter bond_is_local (Db.Bond.get_all ~__context) in
+ List.iter (fun bond -> debug "destroying bond %s" (Db.Bond.get_uuid ~__context ~self:bond);
+ Db.Bond.destroy ~__context ~self:bond) bonds;
+ let vlans = List.filter vlan_is_local (Db.VLAN.get_all ~__context) in
+ List.iter (fun vlan -> debug "destroying VLAN %s" (Db.VLAN.get_uuid ~__context ~self:vlan);
+ Db.VLAN.destroy ~__context ~self:vlan) vlans;
+ let tunnels = List.filter tunnel_is_local (Db.Tunnel.get_all ~__context) in
+ List.iter (fun tunnel -> debug "destroying tunnel %s" (Db.Tunnel.get_uuid ~__context ~self:tunnel);
+ Db.Tunnel.destroy ~__context ~self:tunnel) tunnels;
+ List.iter (fun pif -> debug "destroying PIF %s" (Db.PIF.get_uuid ~__context ~self:pif);
+ Db.PIF.destroy ~__context ~self:pif) local_pifs
let set_cpu_features ~__context ~host ~features =
debug "Set CPU features";
(** Remove the feature mask, such that after a reboot all features of the CPU are enabled. *)
val reset_cpu_features : __context:Context.t -> host:API.ref_host -> unit
+(** Purge all network-related metadata associated with the given host. *)
+val reset_networking : __context:Context.t -> host:API.ref_host -> unit
+