]> xenbits.xensource.com Git - xcp/xen-api.git/commitdiff
Add host.reset_networking API call
authorRob Hoes <rob.hoes@citrix.com>
Mon, 23 Aug 2010 12:23:54 +0000 (13:23 +0100)
committerRob Hoes <rob.hoes@citrix.com>
Mon, 23 Aug 2010 12:23:54 +0000 (13:23 +0100)
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>
ocaml/idl/datamodel.ml
ocaml/xapi/message_forwarding.ml
ocaml/xapi/xapi_host.ml
ocaml/xapi/xapi_host.mli

index d0bbd2902afdfe585f141996aa125cdd63acdd72..adee5c3efe1c43b62b2b064d39daeb1fff5aeaa6 100644 (file)
@@ -2503,7 +2503,7 @@ let host_refresh_pack_info = call
   ~params:[Ref _host, "host", "The Host to modify"]
   ~allowed_roles:_R_POOL_OP
   () 
-  
+    
 (* ------------------------------------------------------------------------------------------------------------
    VDI Management
    ------------------------------------------------------------------------------------------------------------ *)
@@ -3576,7 +3576,6 @@ let host_apply_edition = call ~flags:[`Session]
   ~allowed_roles:_R_POOL_OP
   ()
  
-  
 let host_set_power_on_mode = call
   ~name:"set_power_on_mode"
   ~in_product_since:rel_midnight_ride
@@ -3609,6 +3608,15 @@ let host_reset_cpu_features = call ~flags:[`Session]
   ]
   ~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 =
@@ -3681,6 +3689,7 @@ let host =
                 host_set_power_on_mode;
                 host_set_cpu_features;
                 host_reset_cpu_features;
+                host_reset_networking;
                 ]
       ~contents:
         ([ uid _host;
@@ -3991,7 +4000,6 @@ let pif_db_introduce = call
   ~allowed_roles:_R_POOL_OP
   ()
 
-
 let pif_db_forget = call
   ~name:"db_forget"
   ~in_oss_since:None
index ecf03d9aabb905e3785c77fd4ca8ebb0cf830a1f..3f801fef726ead33e529e42a9987e5ab54899f97 100644 (file)
@@ -2168,6 +2168,10 @@ module Forward = functor(Local: Custom_actions.CUSTOM_ACTIONS) -> struct
       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
index 160b9c6702aef495e7de652fc471f135c84fd7fc..494551413aea0c7033f3b0c130b3bc1f38be6bf7 100644 (file)
@@ -1272,6 +1272,30 @@ let refresh_pack_info ~__context ~host =
        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";
index a1848903cc82774239c6d1b77ac35f62c5cface5..59727a5d73b6ef1befe943e52eed07100d24b54b 100644 (file)
@@ -251,3 +251,6 @@ val set_cpu_features : __context:Context.t -> host:API.ref_host -> features:stri
 (** 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
+