Global setting to allow/disallow users to force stop a vm#9569
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #9569 +/- ##
============================================
+ Coverage 15.55% 15.57% +0.02%
- Complexity 12011 12056 +45
============================================
Files 5500 5506 +6
Lines 481889 482919 +1030
Branches 62240 61451 -789
============================================
+ Hits 74966 75231 +265
- Misses 398637 399376 +739
- Partials 8286 8312 +26
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
|
@blueorangutan package |
|
@abh1sar a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 10751 |
|
@blueorangutan test |
|
@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
|
[SF] Trillian test result (tid-11144)
|
shwstppr
left a comment
There was a problem hiding this comment.
Functionality looks okay, left some comments
| @Param(description = "true if users can see all accounts within the same domain, false otherwise") | ||
| private boolean allowUserViewAllDomainAccounts; | ||
|
|
||
| @SerializedName("allowuserforcestopvm") |
There was a problem hiding this comment.
Better to define it in ApiConstants
| response.setAllowUserExpungeRecoverVM((Boolean)capabilities.get("allowUserExpungeRecoverVM")); | ||
| response.setAllowUserExpungeRecoverVolume((Boolean)capabilities.get("allowUserExpungeRecoverVolume")); | ||
| response.setAllowUserViewAllDomainAccounts((Boolean)capabilities.get("allowUserViewAllDomainAccounts")); | ||
| response.setAllowUserForceStopVM((Boolean)capabilities.get("allowUserForceStopVM")); |
There was a problem hiding this comment.
Use key from ApiConstants?
| capabilities.put("allowUserExpungeRecoverVM", allowUserExpungeRecoverVM); | ||
| capabilities.put("allowUserExpungeRecoverVolume", allowUserExpungeRecoverVolume); | ||
| capabilities.put("allowUserViewAllDomainAccounts", allowUserViewAllDomainAccounts); | ||
| capabilities.put("allowUserForceStopVM", allowUserForceStopVM); |
|
@blueorangutan package |
|
@abh1sar a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
|
Packaging result [SF]: ✖️ el8 ✖️ el9 ✔️ debian ✖️ suse15. SL-JID 10777 |
|
@blueorangutan package |
|
@abh1sar a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 10780 |
|
@blueorangutan test |
|
@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
|
[SF] Trillian test result (tid-11175)
|
sureshanaparti
left a comment
There was a problem hiding this comment.
minor comment, changes lgtm
Co-authored-by: Suresh Kumar Anaparti <sureshkumar.anaparti@gmail.com>
bernardodemarco
left a comment
There was a problem hiding this comment.
LGTM, manually tested in a local environment, here are the test descriptions.
Test Descriptions
I created two User accounts, u1 and u2. Then, I set the allow.user.force.stop.vm setting to true for the u1 account and to false for the u2 account.
Tests with u1 account
UI
I selected the option to stop a running VM and, as expected, the Force input field was rendered on the confirmation form.
CloudMonkey
I executed the stopVirtualMachine API, with the parameter forced set to true, and the virtual machine was stopped successfully.
Tests with u2 account
UI
I selected the option to stop a running VM and, as expected, the Force input field was not rendered on the confirmation form.
CloudMonkey
I executed the stopVirtualMachine API, with the parameter forced set to true, and received the following response:
(localcloud) 🐱 > stop virtualmachine id="de80cbfc-e736-413d-be78-113e093955de" forced="true"
{
"account": "u2",
"accountid": "80cc6bd6-6bc5-43d7-85b9-84557ef7501f",
"cmd": "org.apache.cloudstack.api.command.user.vm.StopVMCmd",
"completed": "2024-09-01T13:55:56+0000",
"created": "2024-09-01T13:55:56+0000",
"domainid": "6b5335fb-4b6f-11ef-87b4-cec422422af1",
"domainpath": "ROOT",
"jobid": "f47b1388-6ed5-4c6b-b6f8-9754fbae3863",
"jobinstanceid": "de80cbfc-e736-413d-be78-113e093955de",
"jobinstancetype": "VirtualMachine",
"jobprocstatus": 0,
"jobresult": {
"errorcode": 530,
"errortext": "Account does not have the permission to force stop the vm."
},
"jobresultcode": 530,
"jobresulttype": "object",
"jobstatus": 2,
"userid": "852c7737-b9eb-479c-8613-e366e165b6e2"
}
🙈 Error: async API failed for job f47b1388-6ed5-4c6b-b6f8-9754fbae3863As can be seen, the operation was not completed successfully, which is the expected behavior.
Co-authored-by: Bernardo De Marco Gonçalves <bernardomg2004@gmail.com>
…ache#9569) Global setting to allow/disallow users to force stop a vm Fixes apache#6629 Co-authored-by: Suresh Kumar Anaparti <sureshkumar.anaparti@gmail.com> Co-authored-by: Rohit Yadav <rohityadav89@gmail.com> Co-authored-by: Bernardo De Marco Gonçalves <bernardomg2004@gmail.com>


Description
Fixes #6629
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
How did you try to break this feature and the system with this change?