GabrielBrascher opened a new pull request #4276: URL: https://github.com/apache/cloudstack/pull/4276
## Description <!--- Describe your changes in detail --> Recently I opened issue #4267 to understand if it is possible to list all VMs, including those on Projects. Thanks to @rhtyd, I learned that there is a way of listing when `listall=true` and `projectid=-1`. However, looking into the [listVirtualMachines API command documentation](https://cloudstack.apache.org/api/apidocs-4.14/apis/listVirtualMachines.html) there is the following description: > listall: If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false The documentation is clear about the fact that when parameter `listall=true` then `listVirtualMachines` lists resources that the caller is authorized to see. Therefore, this PR considers that the ADMIN is _authorized to see_ all VMs, including those on projects. Fixes: #4267 ## Types of changes <!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] New feature (non-breaking change which adds functionality) - [x] Bug fix (non-breaking change which fixes an issue) - [ ] Enhancement (improves an existing feature and functionality) - [ ] Cleanup (Code refactoring and cleanup, that may add test cases) ## How Has This Been Tested? <!-- Please describe in detail how you tested your changes. --> <!-- Include details of your testing environment, and the tests you ran to --> <!-- see how your change affects other areas of the code, etc. --> I tested it via CloudMonkey and CloudStack UI. CloudMonkey output example: ``` cmk > list virtualmachines filter=id,account,project,name,state listall=true id account project name state 86ba5f14-b783-4e66-b511-ba617ca88d38 gabriel VM-86ba5f14-b783-4e66-b511-ba617ca88d38 Running 717f2e13-c207-4861-af0a-619ba1552f57 admin test-02 Running c15f35aa-2343-47c3-9d57-36b3ba16d885 gabriel VM-c15f35aa-2343-47c3-9d57-36b3ba16d885 Running 1b1047ed-8c29-40f5-bd2d-cd979adc668d admin ha-01-shared Running da787937-e3aa-409b-97b2-36ba4c45eb67 gabriel VM-da787937-e3aa-409b-97b2-36ba4c45eb67 Running a40b8e98-29c7-4bf4-8209-2563d9c3db48 testproject test-01 Running ca76ff8c-36f7-4183-b984-513106391db3 gabriel VM-ca76ff8c-36f7-4183-b984-513106391db3 Running 1f6b4fc6-f44f-4084-8ddd-14b916ada345 gabriel VM-1f6b4fc6-f44f-4084-8ddd-14b916ada345 Running e17b9817-bea1-4b98-a153-7b272ff99745 gabriel VM-e17b9817-bea1-4b98-a153-7b272ff99745 Running 75b2e67e-2bda-4a55-b84a-91e69476a893 gabriel VM-75b2e67e-2bda-4a55-b84a-91e69476a893 Running 4a226a80-8899-4ea7-80ea-220667c2b46d gabriel VM-4a226a80-8899-4ea7-80ea-220667c2b46d Running eebb96fd-7320-4f91-8881-3c75aff9e9cc testproject vm-on-project01 Running 50215261-dbcb-47d7-bb3b-5e7626f1379f admin test-00 Running 7d314232-0c60-4b1f-89b6-e63626134628 admin test-u18-p3 Running 31f087dc-622a-412c-97cf-7e38d51643d0 admin tiny-py3 Running 54aa67ab-d106-47f8-8e3c-26a2496828d8 admin test-vr-py3 Running 85b3b81b-7ce4-4087-b791-a7e92f0c365c admin medium-local Running 701c73fb-35a1-4840-8db6-c90d41b95601 testproject vm-project-02 Running 38a2cfa3-02ba-44bb-92c6-6c5a32e38aa9 gabriel VM-38a2cfa3-02ba-44bb-92c6-6c5a32e38aa9 Running ``` <!-- Please read the [CONTRIBUTING](https://github.com/apache/cloudstack/blob/master/CONTRIBUTING.md) document --> ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
