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

[Xen-API] [PATCH 1 of 3] Add host.reset_networking API call


  • To: xen-api@xxxxxxxxxxxxxxxxxxx
  • From: Rob Hoes <rob.hoes@xxxxxxxxxx>
  • Date: Tue, 10 Aug 2010 17:10:29 +0100
  • Delivery-date: Tue, 10 Aug 2010 09:11:41 -0700
  • List-id: Discussion of API issues surrounding Xen <xen-api.lists.xensource.com>

# HG changeset patch
# User Rob Hoes <rob.hoes@xxxxxxxxxx>
# Date 1281455264 -3600
# Node ID df2566c65c388924a9e096228ba5478e08c8fffe
# Parent  54e961818b3d63add54ad085cb059e23eeec1fcd
Add host.reset_networking API call

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@xxxxxxxxxx>

diff -r 54e961818b3d -r df2566c65c38 ocaml/idl/datamodel.ml
--- a/ocaml/idl/datamodel.ml
+++ b/ocaml/idl/datamodel.ml
@@ -2524,7 +2524,7 @@
   ~params:[Ref _host, "host", "The Host to modify"]
   ~allowed_roles:_R_POOL_OP
   () 
-  
+    
 (* 
------------------------------------------------------------------------------------------------------------
    VDI Management
    
------------------------------------------------------------------------------------------------------------
 *)
@@ -3605,7 +3605,6 @@
   ~allowed_roles:_R_POOL_OP
   ()
  
-  
 let host_set_power_on_mode = call
   ~name:"set_power_on_mode"
   ~in_product_since:rel_midnight_ride
@@ -3659,6 +3658,14 @@
        ~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 =
@@ -3734,6 +3741,7 @@
                 host_reset_cpu_features;
                 host_enable_local_storage_caching;
                 host_disable_local_storage_caching;
+                host_reset_networking;
                 ]
       ~contents:
         ([ uid _host;
diff -r 54e961818b3d -r df2566c65c38 ocaml/xapi/message_forwarding.ml
--- a/ocaml/xapi/message_forwarding.ml
+++ b/ocaml/xapi/message_forwarding.ml
@@ -2195,6 +2195,10 @@
                let local_fn = Local.Host.disable_local_storage_caching ~host in
                do_op_on ~local_fn ~__context ~host (fun session_id rpc -> 
Client.Host.disable_local_storage_caching 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
diff -r 54e961818b3d -r df2566c65c38 ocaml/xapi/xapi_host.ml
--- a/ocaml/xapi/xapi_host.ml
+++ b/ocaml/xapi/xapi_host.ml
@@ -1287,6 +1287,30 @@
        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";
diff -r 54e961818b3d -r df2566c65c38 ocaml/xapi/xapi_host.mli
--- a/ocaml/xapi/xapi_host.mli
+++ b/ocaml/xapi/xapi_host.mli
@@ -252,6 +252,9 @@
 (** 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
+
 (** Control the local caching behaviour of the host *)
 val enable_local_storage_caching : __context:Context.t -> host:API.ref_host -> 
unit
 val disable_local_storage_caching : __context:Context.t -> host:API.ref_host 
-> unit
 ocaml/idl/datamodel.ml           |  12 ++++++++++--
 ocaml/xapi/message_forwarding.ml |   4 ++++
 ocaml/xapi/xapi_host.ml          |  24 ++++++++++++++++++++++++
 ocaml/xapi/xapi_host.mli         |   3 +++
 4 files changed, 41 insertions(+), 2 deletions(-)


Attachment: xen-api.hg-1.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®.