Skip to content

Commit 06adb4b

Browse files
committed
Introduce new methods for custom uefi certs
- `Pool.set/get_custom_uefi_certificates` - `Pool/Host.set_uefi_certificates` deprecated - `Pool.get_uefi_certificates` return the certificates used by the pool Signed-off-by: BenjiReis <benjamin.reis@vates.fr>
1 parent 7a1840c commit 06adb4b

File tree

8 files changed

+70
-19
lines changed

8 files changed

+70
-19
lines changed

ocaml/idl/datamodel_pool.ml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1024,10 +1024,31 @@ let disable_repository_proxy =
10241024
~allowed_roles:(_R_POOL_OP ++ _R_CLIENT_CERT)
10251025
()
10261026

1027+
let get_uefi_certificates =
1028+
call ~name:"get_uefi_certificates"
1029+
~lifecycle:[]
1030+
~doc:"Gets the UEFI certificates used by a pool and all its hosts."
1031+
~params:[(Ref _pool, "self", "The pool")]
1032+
~allowed_roles:_R_POOL_ADMIN ()
1033+
~result:(String, "The pool's UEFI certificates")
1034+
10271035
let set_uefi_certificates =
10281036
call ~name:"set_uefi_certificates"
10291037
~lifecycle:[(Published, "22.16.0", "")]
1030-
~doc:"Sets the UEFI certificates for a pool and all its hosts"
1038+
~doc:
1039+
"Sets the UEFI certificates for a pool and all its hosts. Deprecated: \
1040+
use set_custom_uefi_certificates instead"
1041+
~params:
1042+
[
1043+
(Ref _pool, "self", "The pool")
1044+
; (String, "value", "The certificates to apply to the pool and its hosts")
1045+
]
1046+
~allowed_roles:_R_POOL_ADMIN ()
1047+
1048+
let set_custom_uefi_certificates =
1049+
call ~name:"set_custom_uefi_certificates"
1050+
~lifecycle:[(Published, "0.0.0", "")]
1051+
~doc:"Sets custom UEFI certificates for a pool and all its hosts"
10311052
~params:
10321053
[
10331054
(Ref _pool, "self", "The pool")
@@ -1193,7 +1214,9 @@ let t =
11931214
; disable_client_certificate_auth
11941215
; configure_repository_proxy
11951216
; disable_repository_proxy
1217+
; get_uefi_certificates
11961218
; set_uefi_certificates
1219+
; set_custom_uefi_certificates
11971220
; set_https_only
11981221
; set_telemetry_next_collection
11991222
; reset_telemetry_uuid
@@ -1382,6 +1405,10 @@ let t =
13821405
]
13831406
~default_value:(Some (VString "")) "uefi_certificates"
13841407
"The UEFI certificates allowing Secure Boot"
1408+
; field ~qualifier:StaticRO ~ty:String
1409+
~lifecycle:[]
1410+
~default_value:(Some (VString "")) "custom_uefi_certificates"
1411+
"Custom UEFI certificates allowing Secure Boot"
13851412
; field ~in_product_since:rel_stockholm_psr ~qualifier:RW ~ty:Bool
13861413
~default_value:(Some (VBool false)) "is_psr_pending"
13871414
"True if either a PSR is running or we are waiting for a PSR to be \

ocaml/idl/schematest.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ let hash x = Digest.string x |> Digest.to_hex
22

33
(* BEWARE: if this changes, check that schema has been bumped accordingly in
44
ocaml/idl/datamodel_common.ml, usually schema_minor_vsn *)
5-
let last_known_schema_hash = "95077aed35b715c362c7cf98902de578"
5+
let last_known_schema_hash = "153e7b9b01531b10d3babe0b1a8d7770"
66

77
let current_schema_hash : string =
88
let open Datamodel_types in

ocaml/tests/common/test_common.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,8 @@ let make_pool ~__context ~master ?(name_label = "") ?(name_description = "")
287287
?(ha_cluster_stack = !Xapi_globs.cluster_stack_default)
288288
?(guest_agent_config = []) ?(cpu_info = [])
289289
?(policy_no_vendor_device = false) ?(live_patching_disabled = false)
290-
?(uefi_certificates = "") ?(repositories = [])
291-
?(client_certificate_auth_enabled = false)
290+
?(uefi_certificates = "") ?(custom_uefi_certificates = "")
291+
?(repositories = []) ?(client_certificate_auth_enabled = false)
292292
?(client_certificate_auth_name = "") ?(repository_proxy_url = "")
293293
?(repository_proxy_username = "") ?(repository_proxy_password = Ref.null)
294294
?(migration_compression = false) ?(coordinator_bias = true)
@@ -306,8 +306,8 @@ let make_pool ~__context ~master ?(name_label = "") ?(name_description = "")
306306
~vswitch_controller ~igmp_snooping_enabled ~current_operations
307307
~allowed_operations ~restrictions ~other_config ~ha_cluster_stack
308308
~guest_agent_config ~cpu_info ~policy_no_vendor_device
309-
~live_patching_disabled ~uefi_certificates ~is_psr_pending:false
310-
~tls_verification_enabled:false ~repositories
309+
~live_patching_disabled ~uefi_certificates ~custom_uefi_certificates
310+
~is_psr_pending:false ~tls_verification_enabled:false ~repositories
311311
~client_certificate_auth_enabled ~client_certificate_auth_name
312312
~repository_proxy_url ~repository_proxy_username ~repository_proxy_password
313313
~migration_compression ~coordinator_bias ~telemetry_uuid

ocaml/xapi/dbsync_master.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ let create_pool_record ~__context =
4242
~other_config:[Xapi_globs.memory_ratio_hvm; Xapi_globs.memory_ratio_pv]
4343
~ha_cluster_stack:"xhad" ~guest_agent_config:[] ~cpu_info:[]
4444
~policy_no_vendor_device:false ~live_patching_disabled:false
45-
~uefi_certificates:"" ~is_psr_pending:false
45+
~uefi_certificates:"" ~custom_uefi_certificates:"" ~is_psr_pending:false
4646
~tls_verification_enabled:false ~repositories:[]
4747
~client_certificate_auth_enabled:false ~client_certificate_auth_name:""
4848
~repository_proxy_url:"" ~repository_proxy_username:""

ocaml/xapi/message_forwarding.ml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,12 +1093,22 @@ functor
10931093
(pool_uuid ~__context self) ;
10941094
Local.Pool.disable_repository_proxy ~__context ~self
10951095

1096+
let get_uefi_certificates ~__context ~self =
1097+
info "Pool.get_uefi_certificates: pool='%s'" (pool_uuid ~__context self) ;
1098+
Local.Pool.get_uefi_certificates ~__context ~self
1099+
10961100
let set_uefi_certificates ~__context ~self ~value =
10971101
info "Pool.set_uefi_certificates: pool='%s' value='%s'"
10981102
(pool_uuid ~__context self)
10991103
value ;
11001104
Local.Pool.set_uefi_certificates ~__context ~self ~value
11011105

1106+
let set_custom_uefi_certificates ~__context ~self ~value =
1107+
info "Pool.set_custom_uefi_certificates: pool='%s' value='%s'"
1108+
(pool_uuid ~__context self)
1109+
value ;
1110+
Local.Pool.set_custom_uefi_certificates ~__context ~self ~value
1111+
11021112
let set_https_only ~__context ~self ~value =
11031113
info "Pool.set_https_only: pool='%s' value='%B'"
11041114
(pool_uuid ~__context self)

ocaml/xapi/xapi_host.ml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2795,24 +2795,18 @@ let write_uefi_certificates_to_disk ~__context ~host =
27952795
let@ path = with_empty_dir !Xapi_globs.varstore_dir in
27962796
(* get from pool for consistent results across hosts *)
27972797
let pool_uefi_certs =
2798-
Db.Pool.get_uefi_certificates ~__context
2798+
Db.Pool.get_custom_uefi_certificates ~__context
27992799
~self:(Helpers.get_pool ~__context)
28002800
in
28012801
really_write_uefi_certificates_to_disk ~__context ~host
28022802
~value:pool_uefi_certs ;
28032803
check_valid_uefi_certs_in path
28042804

28052805
let set_uefi_certificates ~__context ~host ~value =
2806-
match !Xapi_globs.allow_custom_uefi_certs with
2807-
| false ->
2808-
raise Api_errors.(Server_error (Api_errors.operation_not_allowed, [""]))
2809-
| true ->
2810-
Db.Host.set_uefi_certificates ~__context ~self:host ~value ;
2811-
Helpers.call_api_functions ~__context (fun rpc session_id ->
2812-
Client.Client.Pool.set_uefi_certificates ~rpc ~session_id
2813-
~self:(Helpers.get_pool ~__context)
2814-
~value
2815-
)
2806+
let msg =
2807+
"To set UEFI certificates use: `Pool.set_custom_uefi_certificates`"
2808+
in
2809+
raise Api_errors.(Server_error (Api_errors.operation_not_allowed, [msg]))
28162810

28172811
let set_iscsi_iqn ~__context ~host ~value =
28182812
if value = "" then

ocaml/xapi/xapi_pool.ml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3567,7 +3567,22 @@ let disable_repository_proxy ~__context ~self =
35673567
Db.Secret.destroy ~__context ~self:old_secret_ref
35683568
)
35693569

3570+
let get_uefi_certificates ~__context ~self =
3571+
let custom_certs = Db.Pool.get_custom_uefi_certificates ~__context ~self in
3572+
match (!Xapi_globs.allow_custom_uefi_certs, custom_certs) with
3573+
| false, _ | true, "" ->
3574+
Db.Pool.get_uefi_certificates ~__context ~self
3575+
| true, _ ->
3576+
custom_certs
3577+
35703578
let set_uefi_certificates ~__context ~self ~value =
3579+
let msg =
3580+
"Setting UEFI certificates is depreacted, please use \
3581+
`set_custom_uefi_certificates`"
3582+
in
3583+
raise Api_errors.(Server_error (operation_not_allowed, [msg]))
3584+
3585+
let set_custom_uefi_certificates ~__context ~self ~value =
35713586
match !Xapi_globs.allow_custom_uefi_certs with
35723587
| false ->
35733588
let msg =
@@ -3576,7 +3591,7 @@ let set_uefi_certificates ~__context ~self ~value =
35763591
in
35773592
raise Api_errors.(Server_error (operation_not_allowed, [msg]))
35783593
| true ->
3579-
Db.Pool.set_uefi_certificates ~__context ~self ~value ;
3594+
Db.Pool.set_custom_uefi_certificates ~__context ~self ~value ;
35803595
Helpers.call_api_functions ~__context (fun rpc session_id ->
35813596
List.iter
35823597
(fun host ->

ocaml/xapi/xapi_pool.mli

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,9 +385,14 @@ val configure_repository_proxy :
385385

386386
val disable_repository_proxy : __context:Context.t -> self:API.ref_pool -> unit
387387

388+
val get_uefi_certificates : __context:Context.t -> self:API.ref_pool -> string
389+
388390
val set_uefi_certificates :
389391
__context:Context.t -> self:API.ref_pool -> value:string -> unit
390392

393+
val set_custom_uefi_certificates :
394+
__context:Context.t -> self:API.ref_pool -> value:string -> unit
395+
391396
val set_https_only :
392397
__context:Context.t -> self:API.ref_pool -> value:bool -> unit
393398

0 commit comments

Comments
 (0)