Skip to content

Commit

Permalink
CP-4319: Detect socket count in v6client.ml
Browse files Browse the repository at this point in the history
Sending the socket count in the params list to V6client.apply_edition is
a bad idea, since this function also sends the current
Host.license_params, which may also contain the socket count, to v6d.

Instead, we update the license_params map with the socket count before
sending it to v6d.

This also means that the correct socket count is sent to v6d at xapi
startup.

Signed-off-by: John Else <john.else@citrix.com>
  • Loading branch information
johnelse committed Apr 3, 2013
1 parent a00ba4d commit ebddedb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
11 changes: 11 additions & 0 deletions ocaml/license/v6client.ml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
module D=Debug.Debugger(struct let name="v6client" end)
open D

open Listext

exception V6DaemonFailure

let retry = ref true
Expand All @@ -26,10 +28,19 @@ let v6rpc call =
XMLRPC_protocol.rpc ~srcstr:"xapi" ~dststr:"v6d" ~transport:(Unix socket) ~http:(xmlrpc ~version:"1.0" "/") call

let rec apply_edition ~__context edition additional =
(* Get localhost's current license state. *)
let host = Helpers.get_localhost ~__context in
let license_server = Db.Host.get_license_server ~__context ~self:host in
let current_edition = Db.Host.get_edition ~__context ~self:host in
let current_license_params = Db.Host.get_license_params ~__context ~self:host in
(* Make sure the socket count in license_params is correct.
* At first boot, the key won't exist, and it may be wrong if we've restored
* a database dump from a different host. *)
let cpu_info = Db.Host.get_cpu_info ~__context ~self:host in
let socket_count = List.assoc "socket_count" cpu_info in
let current_license_params =
List.replace_assoc "sockets" socket_count current_license_params in
(* Construct the RPC params to be sent to v6d *)
let additional = ("current_edition", current_edition) ::
license_server @ current_license_params @ additional in
let params = [ Rpc.rpc_of_string (Context.string_of_task __context)
Expand Down
5 changes: 1 addition & 4 deletions ocaml/xapi/xapi_host.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1234,11 +1234,8 @@ let apply_edition ~__context ~host ~edition =
if Db.Pool.get_ha_enabled ~__context ~self:pool then
raise (Api_errors.Server_error (Api_errors.ha_is_enabled, []))
else begin
let cpu_info = Db.Host.get_cpu_info ~__context ~self:host in
let socket_count = List.assoc "socket_count" cpu_info in
let edition', features, additional =
V6client.apply_edition ~__context edition
["sockets", socket_count]
V6client.apply_edition ~__context edition []
in
Db.Host.set_edition ~__context ~self:host ~value:edition';
copy_license_to_db ~__context ~host ~features ~additional
Expand Down

0 comments on commit ebddedb

Please sign in to comment.