Skip to content

Commit

Permalink
CA-397599 XSI-1704 implement setter for blocked ops manually
Browse files Browse the repository at this point in the history
Currently the setter for field VM.blocked_oeprations is auto generated.
Implement this explicitly such that we can update allowed operations
which currently is not happening. Allowed operations are used by
XenCenter to disable operations; this has led to operations becoming
unavaliable because allowed operations where not aligned with blocked
operations when blocked operations were updated.

Signed-off-by: Christian Lindig <[email protected]>
  • Loading branch information
Christian Lindig authored and lindig committed Sep 16, 2024
1 parent 7ae0080 commit ada0dc7
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 1 deletion.
42 changes: 41 additions & 1 deletion ocaml/idl/datamodel_vm.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1628,6 +1628,43 @@ let operations =
]
)

let set_blocked_operations =
call ~name:"set_blocked_operations"
~in_product_since:rel_orlando (* but updated 2024 *)
~doc:
"Update list of operations which have been explicitly blocked and an \
error code"
~params:
[
(Ref _vm, "self", "The VM")
; (Map (operations, String), "value", "Blocked operations")
]
~allowed_roles:_R_VM_ADMIN ()

let add_to_blocked_operations =
call ~name:"add_to_blocked_operations"
~in_product_since:rel_orlando (* but updated 2024 *)
~doc:
"Update list of operations which have been explicitly blocked and an \
error code"
~params:
[
(Ref _vm, "self", "The VM")
; (operations, "key", "Blocked operation")
; (String, "value", "Error code")
]
~allowed_roles:_R_VM_ADMIN ()

let remove_from_blocked_operations =
call ~name:"remove_from_blocked_operations"
~in_product_since:rel_orlando (* but updated 2024 *)
~doc:
"Update list of operations which have been explicitly blocked and an \
error code"
~params:
[(Ref _vm, "self", "The VM"); (operations, "key", "Blocked operation")]
~allowed_roles:_R_VM_ADMIN ()

let assert_operation_valid =
call ~in_oss_since:None ~in_product_since:rel_rio
~name:"assert_operation_valid"
Expand Down Expand Up @@ -1909,6 +1946,9 @@ let t =
; restart_device_models
; set_uefi_mode
; get_secureboot_readiness
; set_blocked_operations
; add_to_blocked_operations
; remove_from_blocked_operations
]
~contents:
([uid _vm]
Expand Down Expand Up @@ -2086,7 +2126,7 @@ let t =
~default_value:(Some (VSet [])) ~ty:(Set String) "tags"
"user-specified tags for categorization purposes"
; field ~in_product_since:rel_orlando ~default_value:(Some (VMap []))
~qualifier:RW
~qualifier:StaticRO
~ty:(Map (operations, String))
"blocked_operations"
"List of operations which have been explicitly blocked and an \
Expand Down
17 changes: 17 additions & 0 deletions ocaml/xapi/message_forwarding.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3097,6 +3097,23 @@ functor
let get_secureboot_readiness ~__context ~self =
info "VM.get_secureboot_readiness: self = '%s'" (vm_uuid ~__context self) ;
Local.VM.get_secureboot_readiness ~__context ~self

let set_blocked_operations ~__context ~self ~value =
info "VM.set_blocked_operations: self = '%s'" (vm_uuid ~__context self) ;
Local.VM.set_blocked_operations ~__context ~self ~value ;
Xapi_vm_lifecycle.update_allowed_operations ~__context ~self

let add_to_blocked_operations ~__context ~self ~key ~value =
info "VM.add_to_blocked_operations: self = '%s'"
(vm_uuid ~__context self) ;
Local.VM.add_to_blocked_operations ~__context ~self ~key ~value ;
Xapi_vm_lifecycle.update_allowed_operations ~__context ~self

let remove_from_blocked_operations ~__context ~self ~key =
info "VM.remove_from_blocked_operations: self = '%s'"
(vm_uuid ~__context self) ;
Local.VM.remove_from_blocked_operations ~__context ~self ~key ;
Xapi_vm_lifecycle.update_allowed_operations ~__context ~self
end

module VM_metrics = struct end
Expand Down
12 changes: 12 additions & 0 deletions ocaml/xapi/xapi_vm.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1601,6 +1601,18 @@ let set_domain_type ~__context ~self ~value =
Db.VM.set_HVM_boot_policy ~__context ~self
~value:(derive_hvm_boot_policy ~domain_type:value)

let set_blocked_operations ~__context ~self ~value =
debug "%s" __FUNCTION__ ;
Db.VM.set_blocked_operations ~__context ~self ~value

let add_to_blocked_operations ~__context ~self ~key ~value =
debug "%s" __FUNCTION__ ;
Db.VM.add_to_blocked_operations ~__context ~self ~key ~value

let remove_from_blocked_operations ~__context ~self ~key =
debug "%s" __FUNCTION__ ;
Db.VM.remove_from_blocked_operations ~__context ~self ~key

let set_HVM_boot_policy ~__context ~self ~value =
Db.VM.set_domain_type ~__context ~self
~value:(derive_domain_type ~hVM_boot_policy:value) ;
Expand Down
16 changes: 16 additions & 0 deletions ocaml/xapi/xapi_vm.mli
Original file line number Diff line number Diff line change
Expand Up @@ -428,3 +428,19 @@ val set_uefi_mode :

val get_secureboot_readiness :
__context:Context.t -> self:API.ref_VM -> API.vm_secureboot_readiness

val set_blocked_operations :
__context:Context.t
-> self:API.ref_VM
-> value:(API.vm_operations * string) list
-> unit

val add_to_blocked_operations :
__context:Context.t
-> self:API.ref_VM
-> key:API.vm_operations
-> value:string
-> unit

val remove_from_blocked_operations :
__context:Context.t -> self:API.ref_VM -> key:API.vm_operations -> unit

0 comments on commit ada0dc7

Please sign in to comment.