WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-api

[Xen-API] [PATCH] CA-36381: Suppress grace-license alerts when automatic

To: xen-api <xen-api@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-API] [PATCH] CA-36381: Suppress grace-license alerts when automatically retrying (each hour)
From: Rob Hoes <rob.hoes@xxxxxxxxxx>
Date: Wed, 13 Jan 2010 12:17:17 +0000
Delivery-date: Wed, 13 Jan 2010 04:17:22 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-api-request@lists.xensource.com?subject=help>
List-id: Discussion of API issues surrounding Xen <xen-api.lists.xensource.com>
List-post: <mailto:xen-api@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-api-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Rob Hoes <rob.hoes@xxxxxxxxxx>
CA-36381: Suppress grace-license alerts when automatically retrying (each hour)

Signed-off-by: Rob Hoes <rob.hoes@xxxxxxxxxx>

diff -r 5b9ab15de098 ocaml/license/grace_retry.ml
--- a/ocaml/license/grace_retry.ml      Wed Jan 13 11:36:10 2010 +0000
+++ b/ocaml/license/grace_retry.ml      Wed Jan 13 11:37:36 2010 +0000
@@ -13,6 +13,8 @@
  *)
 (** Helper to keep trying to get a "real" license after a "grace" license was 
checked out.
  *  @group Licensing *)
+ 
+open Client
 
 (** Schedule a timer to call [Host.apply_edition] again after an hour. Call 
this
  *  after getting a "grace" license in order to check whether the license 
server
@@ -27,11 +29,22 @@
                        3600.   (* 5min *)
        in
        let schedule = Xapi_periodic_scheduler.OneShot in
-       let retry_fn () = Server_helpers.exec_with_new_task "grace_retry"
-               (fun __context ->
-                       Helpers.call_api_functions ~__context
-                       (fun rpc session_id -> Client.Client.Host.apply_edition 
rpc session_id host edition)
-               )
+       let retry_fn () = 
+           let now = (Unix.gettimeofday ()) in
+               Server_helpers.exec_with_new_task "grace_retry"
+                       (fun __context ->
+                               Helpers.call_api_functions ~__context (fun rpc 
session_id ->
+                                       Client.Host.apply_edition rpc 
session_id host edition;
+                                       (* Remove any newly generated grace 
alerts *)
+                                       let alerts = Client.Message.get_since 
rpc session_id (Date.of_float now) in
+                                       let check_and_maybe_remove (ref, msg) =
+                                               if msg.API.message_name = 
"GRACE_LICENSE" then
+                                                       
Helpers.call_api_functions ~__context
+                                                               (fun rpc 
session_id -> Client.Message.destroy rpc session_id ref)
+                                       in
+                                       List.iter check_and_maybe_remove alerts
+                               )
+                       )
        in
        Xapi_periodic_scheduler.add_to_queue "retry after obtaining grace 
license" schedule period retry_fn
        
diff -r 5b9ab15de098 ocaml/xapi/cli_operations.ml
--- a/ocaml/xapi/cli_operations.ml      Wed Jan 13 11:36:10 2010 +0000
+++ b/ocaml/xapi/cli_operations.ml      Wed Jan 13 11:37:36 2010 +0000
@@ -2544,11 +2544,11 @@
       Client.Host.add_to_license_server rpc session_id host "port" port
     end
   end;
+  let now = (Unix.gettimeofday ()) in
   try
     Client.Host.apply_edition rpc session_id host edition
   with
   | Api_errors.Server_error (name, args) when name = 
Api_errors.license_checkout_error ->
-    let now = (Unix.gettimeofday ()) in
     let alerts = Client.Message.get_since rpc session_id (Date.of_float now) in
     let print_if_checkout_error (ref, msg) =
       if msg.API.message_name = "LICENSE_NOT_AVAILABLE" || 
msg.API.message_name = "LICENSE_SERVER_UNREACHABLE" then

Attachment: ca-36381
Description: Text document

_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-API] [PATCH] CA-36381: Suppress grace-license alerts when automatically retrying (each hour), Rob Hoes <=