Skip to content

Commit a319091

Browse files
committed
Revert "CA-108916: add call to V6rpc.get_current_edition API"
This reverts commit 04f4d92. CA-113278: This commit was causing many testcases to fail. Reverting the commit for now till we figure out a better way to fix the original problem. Signed-off-by: Akshay <[email protected]>
1 parent 2969450 commit a319091

File tree

7 files changed

+11
-96
lines changed

7 files changed

+11
-96
lines changed

ocaml/license/fakev6.ml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,3 @@ let get_version dbg =
3636
Debug.with_thread_associated dbg (fun () -> "") ()
3737

3838
let reopen_logs () = true
39-
40-
let get_current_edition dbg additional =
41-
Debug.with_thread_associated dbg (fun () ->
42-
Edition.(to_string Free, to_features Free, [])) ()

ocaml/license/fakev6.mli

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,3 @@ val get_version : string -> string
2828
(** Close and re-open the log file *)
2929
val reopen_logs : unit -> bool
3030

31-
(** Call the [get_current_edition] function on the v6d *)
32-
val get_current_edition : string -> (string * string) list ->
33-
string * Features.feature list * (string * string) list

ocaml/license/v6client.ml

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ let v6rpc call =
2727
let open Xmlrpc_client in
2828
XMLRPC_protocol.rpc ~srcstr:"xapi" ~dststr:"v6d" ~transport:(Unix socket) ~http:(xmlrpc ~version:"1.0" "/") call
2929

30-
let construct_additional ~__context additional =
30+
let rec apply_edition ~__context edition additional =
3131
(* Get localhost's current license state. *)
3232
let host = Helpers.get_localhost ~__context in
3333
let license_server = Db.Host.get_license_server ~__context ~self:host in
@@ -40,13 +40,9 @@ let construct_additional ~__context additional =
4040
let socket_count = List.assoc "socket_count" cpu_info in
4141
let current_license_params =
4242
List.replace_assoc "sockets" socket_count current_license_params in
43+
(* Construct the RPC params to be sent to v6d *)
4344
let additional = ("current_edition", current_edition) ::
4445
license_server @ current_license_params @ additional in
45-
additional
46-
47-
let rec apply_edition ~__context edition additional =
48-
(* Construct the RPC params to be sent to v6d *)
49-
let additional = construct_additional ~__context additional in
5046
let params = [ Rpc.rpc_of_string (Context.string_of_task __context)
5147
; V6rpc.rpc_of_apply_edition_in
5248
{ V6rpc.edition_in = edition
@@ -102,27 +98,3 @@ let get_version dbg =
10298
with _ ->
10399
raise (Api_errors.Server_error (Api_errors.v6d_failure, []))
104100

105-
let get_current_edition ~__context additional =
106-
try
107-
let additional = construct_additional ~__context additional in
108-
let params = [ Rpc.rpc_of_string (Context.string_of_task __context)
109-
; V6rpc.rpc_of_get_current_edition_in additional ] in
110-
111-
let call = Rpc.call "get_current_edition" params in
112-
let response = try v6rpc call with _ -> raise V6DaemonFailure in
113-
114-
debug "response: %s" (Rpc.to_string response.Rpc.contents);
115-
116-
if response.Rpc.success then
117-
(* We reuse apply_edition_out for this RPC call *)
118-
let r = V6rpc.apply_edition_out_of_rpc response.Rpc.contents in
119-
r.V6rpc.edition_out, r.V6rpc.features_out, r.V6rpc.additional_out
120-
else
121-
let e = V6errors.error_of_rpc response.Rpc.contents in
122-
match e with
123-
| s, _ when s = V6errors.v6d_failure ->
124-
raise V6DaemonFailure
125-
| name, args ->
126-
raise (Api_errors.Server_error (name, args))
127-
with _ ->
128-
raise (Api_errors.Server_error (Api_errors.v6d_failure, []))

ocaml/license/v6client.mli

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,3 @@ val get_editions : string -> (string * string * string * int) list
2727
(** Call the [get_version] function on the v6d *)
2828
val get_version : string -> string
2929

30-
(** Call the [get_current_edition] function on the v6d *)
31-
val get_current_edition : __context:Context.t -> (string * string) list ->
32-
string * Features.feature list * (string * string) list

ocaml/license/v6rpc.ml

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,10 @@ type get_editions_out = {
3131
editions: names list;
3232
} with rpc
3333

34-
type get_current_edition_in = (string * string) list with rpc
35-
3634
module type V6api = sig
37-
(* dbg_str -> edition -> additional_params ->
38-
edition * enabled_features * additional_params *)
35+
(* dbg_str -> edition -> additional_params -> enabled_features, additional_params *)
3936
val apply_edition : string -> string -> (string * string) list ->
4037
string * Features.feature list * (string * string) list
41-
(* dbg_str -> edition * enabled_features * additional_params *)
42-
val get_current_edition : string -> (string * string) list ->
43-
string * Features.feature list * (string * string) list
4438
(* dbg_str -> list of editions (name, marketing name, short name) *)
4539
val get_editions : string -> (string * string * string * int) list
4640
(* dbg_str -> result *)
@@ -66,24 +60,6 @@ module V6process = functor(V: V6api) -> struct
6660
let response = rpc_of_apply_edition_out
6761
{edition_out = edition; features_out = features; additional_out = additional_params} in
6862
Rpc.success response
69-
70-
| "get_current_edition" ->
71-
let dbg_rpc, arg_rpc = match call.Rpc.params with
72-
| [a;b] -> (a,b)
73-
| _ ->
74-
debug "Error in get_current_edition rpc" ;
75-
raise (V6errors.Error ("unmarshalling_error", [])) in
76-
let arg = get_current_edition_in_of_rpc arg_rpc in
77-
let dbg = Rpc.string_of_rpc dbg_rpc in
78-
let edition, features, additional_params =
79-
V.get_current_edition dbg arg in
80-
(* We reuse rpc_of_apply_edition_out for this RPC call *)
81-
let response = rpc_of_apply_edition_out
82-
{edition_out = edition;
83-
features_out = features;
84-
additional_out = additional_params} in
85-
Rpc.success response
86-
8763
| "get_editions" ->
8864
let dbg_rpc = match call.Rpc.params with
8965
| [a] -> a

ocaml/license/v6rpc.mli

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,16 @@
1717
(** The RPC interface of the licensing daemon *)
1818
module type V6api =
1919
sig
20-
(* dbg_str -> edition -> additional_params ->
21-
edition * enabled_features * additional_params *)
20+
(* dbg_str -> edition -> additional_params -> enabled_features, additional_params *)
2221
val apply_edition : string -> string -> (string * string) list ->
2322
string * Features.feature list * (string * string) list
24-
(* dbg_str -> edition * enabled_features * additional_params *)
25-
val get_current_edition : string -> (string * string) list ->
26-
string * Features.feature list * (string * string) list
2723
(* dbg_str -> list of editions *)
2824
val get_editions : string -> (string * string * string * int) list
2925
(* dbg_str -> result *)
3026
val get_version : string -> string
3127
(* () -> version *)
3228
val reopen_logs : unit -> bool
33-
end
29+
end
3430

3531
(** RPC handler module *)
3632
module V6process : functor (V : V6api) ->
@@ -85,12 +81,3 @@ val get_editions_out_of_rpc : Rpc.t -> get_editions_out
8581
(** Convert {!get_editions_out} structure into RPC *)
8682
val rpc_of_get_editions_out : get_editions_out -> Rpc.t
8783

88-
89-
(** Definition of [get_current_edition] RPC *)
90-
type get_current_edition_in = (string * string) list
91-
92-
(** Convert RPC into {!get_current_edition_in} structure *)
93-
val get_current_edition_in_of_rpc : Rpc.t -> get_current_edition_in
94-
95-
(** Convert {!get_current_edition_in} structure into RPC *)
96-
val rpc_of_get_current_edition_in : get_current_edition_in -> Rpc.t

ocaml/xapi/xapi_host.ml

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,22 +1148,12 @@ let set_license_params ~__context ~self ~value =
11481148
Db.Host.set_license_params ~__context ~self ~value;
11491149
Pool_features.update_pool_features ~__context
11501150

1151-
let apply_edition_internal ~__context ~host ~edition ~additional =
1152-
let db_update_license edition features additional =
1153-
Db.Host.set_edition ~__context ~self:host ~value:edition;
1154-
copy_license_to_db ~__context ~host ~features ~additional in
1155-
try
1156-
let edition, features, additional =
1157-
V6client.apply_edition ~__context edition additional in
1158-
db_update_license edition features additional
1159-
with e ->
1160-
(* If we catch an exception, retrieve what v6d thinks are the
1161-
current license parameters and rethrow the exception. *)
1162-
let new_edition, features, additional =
1163-
V6client.get_current_edition ~__context additional in
1164-
warn "v6d: couldn't apply '%s' edition; new edition is '%s'" edition new_edition ;
1165-
db_update_license new_edition features additional ;
1166-
raise e
1151+
let apply_edition_internal ~__context ~host ~edition ~additional =
1152+
let edition', features, additional =
1153+
V6client.apply_edition ~__context edition additional
1154+
in
1155+
Db.Host.set_edition ~__context ~self:host ~value:edition';
1156+
copy_license_to_db ~__context ~host ~features ~additional
11671157

11681158
let apply_edition ~__context ~host ~edition ~force =
11691159
(* if HA is enabled do not allow the edition to be changed *)

0 commit comments

Comments
 (0)