# HG changeset patch
# User Rob Hoes <rob.hoes@xxxxxxxxxx>
CA-35467: Periodically probe license server after getting grace license
After obtaining a grace license, call Host.apply_edition every hour until a
real license comes out.
Signed-off-by: Rob Hoes <rob.hoes@xxxxxxxxxx>
diff -r 73eaa67bfd3c ocaml/license/grace_retry.ml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/ocaml/license/grace_retry.ml Tue Dec 08 12:29:04 2009 +0000
@@ -0,0 +1,32 @@
+(*
+ * Copyright (C) 2006-2009 Citrix Systems Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *)
+(** Helper to keep trying to get a "real" license after a "grace" license was
checked out.
+ * @group Licensing *)
+
+(** 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
+ * happened to come back. If so, a "real" license will be checked out.
+ * Note: the LPE already does a similar thing, but does not notify the
product (xapi)
+ * if it succeeds to check out a "real" license! *)
+let retry_periodically host edition =
+ let period = 3600. 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)
+ )
+ in
+ Xapi_periodic_scheduler.add_to_queue "retry after obtaining grace
license" schedule period retry_fn
+
diff -r 73eaa67bfd3c ocaml/license/license.ml
--- a/ocaml/license/license.ml Tue Dec 08 12:14:15 2009 +0000
+++ b/ocaml/license/license.ml Tue Dec 08 12:29:04 2009 +0000
@@ -311,7 +311,7 @@
let grace_expiry_str = Unixext.read_whole_file_to_string
Xapi_globs.upgrade_grace_file in
float_of_string grace_expiry_str
with _ -> 0.
-
+
(* xapi calls this function upon startup *)
let initialise ~__context ~host =
let existing_license_params = Db.Host.get_license_params ~__context
~self:host in
@@ -357,9 +357,10 @@
info "Successfully checked out %s license."
existing_edition;
(* delete upgrade-grace file, if it exists *)
Unixext.unlink_safe
Xapi_globs.upgrade_grace_file;
- if !V6client.grace then
+ if !V6client.grace then begin
+ Grace_retry.retry_periodically host
existing_edition;
{existing_license with grace = "regular
grace"; expiry = !V6client.expires}
- else
+ end else
{existing_license with grace = "no";
expiry = !V6client.expires}
end
| "" ->
diff -r 73eaa67bfd3c ocaml/xapi/OMakefile
--- a/ocaml/xapi/OMakefile Tue Dec 08 12:14:15 2009 +0000
+++ b/ocaml/xapi/OMakefile Tue Dec 08 12:29:04 2009 +0000
@@ -229,7 +229,8 @@
certificates \
../license/v6client \
bios_strings \
- xapi_config
+ xapi_config \
+ ../license/grace_retry
OCamlProgram(xapi, $(XAPI_MODULES))
OCamlDocProgram(xapi, $(XAPI_MODULES))
diff -r 73eaa67bfd3c ocaml/xapi/xapi_host.ml
--- a/ocaml/xapi/xapi_host.ml Tue Dec 08 12:14:15 2009 +0000
+++ b/ocaml/xapi/xapi_host.ml Tue Dec 08 12:29:04 2009 +0000
@@ -1241,9 +1241,10 @@
let sku, name = License.sku_and_name_of_edition edition
in
let basic = {default with License.sku = sku;
License.sku_marketing_name = name;
License.expiry = !V6client.expires} in
- if !V6client.grace then
+ if !V6client.grace then begin
+ Grace_retry.retry_periodically host edition;
{basic with License.grace = "regular grace"}
- else
+ end else
basic
end
| _ ->
v6-retry-after-grace
Description: Text document
_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api
|