Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ocaml/idl/datamodel_vm.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1521,6 +1521,7 @@ let set_groups =
(Ref _vm, "self", "The VM")
; (Set (Ref _vm_group), "value", "The VM groups to set")
]
~errs:[Api_errors.operation_not_allowed]
~allowed_roles:_R_VM_ADMIN ()

let call_plugin =
Expand Down
14 changes: 14 additions & 0 deletions ocaml/xapi/xapi_vm.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1443,6 +1443,20 @@ let set_appliance ~__context ~self ~value =

let set_groups ~__context ~self ~value =
Pool_features.assert_enabled ~__context ~f:Features.VM_group ;
if
Db.VM.get_is_control_domain ~__context ~self
|| Db.VM.get_is_a_template ~__context ~self
|| Db.VM.get_is_a_snapshot ~__context ~self
then
raise
(Api_errors.Server_error
( Api_errors.operation_not_allowed
, [
"Control domains, templates, and snapshots cannot be added to VM \
groups."
]
)
) ;
if List.length value > 1 then
raise Api_errors.(Server_error (Api_errors.too_many_groups, [])) ;
Db.VM.set_groups ~__context ~self ~value
Expand Down