-
Notifications
You must be signed in to change notification settings - Fork 1.2k
API to list console sessions #11016
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
API to list console sessions #11016
Conversation
@blueorangutan package |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #11016 +/- ##
============================================
+ Coverage 16.57% 16.59% +0.02%
- Complexity 13968 13997 +29
============================================
Files 5743 5745 +2
Lines 510470 510769 +299
Branches 62074 62091 +17
============================================
+ Hits 84615 84785 +170
- Misses 416393 416518 +125
- Partials 9462 9466 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
@blueorangutan package |
@bernardodemarco 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 13755 |
79f6d2d
to
ad7af57
Compare
@blueorangutan package |
@bernardodemarco 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clgtm, only doubt, is the active parameter needed? would we ever want to list no longer available sessions?
Packaging result [SF]: ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 13766 |
Packaging result [SF]: ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 13771 |
@DaanHoogland, thanks for the review!
Yes, listing removed sessions is useful for audit and analysis purposes, as it allows users to track who generated a console endpoint, who accessed it, and when it was generated, acquired, and removed. Listing only active sessions, on the other hand, is helpful for verifying whether someone is currently using a VM. |
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 13777 |
@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-13527)
|
@blueorangutan test ol8 vmware-70u3 keepEnv |
@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + vmware-70u3) has been kicked to run smoke tests |
[SF] Trillian test result (tid-13531)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clgtm
ad7af57
to
3e28b99
Compare
@blueorangutan package |
@bernardodemarco 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. |
@blueorangutan package |
@DaanHoogland 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 13897 |
...rc/main/java/org/apache/cloudstack/api/command/user/consoleproxy/ListConsoleSessionsCmd.java
Outdated
Show resolved
Hide resolved
Domain domain = ApiDBUtils.findDomainById(consoleSession.getDomainId()); | ||
if (domain != null) { | ||
consoleSessionResponse.setDomain(domain.getName()); | ||
consoleSessionResponse.setDomainPath(domain.getPath()); | ||
consoleSessionResponse.setDomainId(domain.getUuid()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be extracted to a new method which also checks for NPE on consoleSession? Same for user, account and host setters below
server/src/main/java/org/apache/cloudstack/consoleproxy/ConsoleAccessManagerImpl.java
Outdated
Show resolved
Hide resolved
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 13898 |
@blueorangutan test ol8 vmware-70u3 keepEnv |
…leproxy/ListConsoleSessionsCmd.java Co-authored-by: Nicolas Vazquez <nicovazquez90@gmail.com>
…eAccessManagerImpl.java Co-authored-by: Nicolas Vazquez <nicovazquez90@gmail.com>
Hi @bernardodemarco thanks for the feature! I'll try to test it soon |
@nvazquez okay, many thanks for the review! I'll apply this suggestion #11016 (comment) ASAP |
Description
Currently, details about console sessions are stored in the
cloud.console_session
table in the database. Operators can only access this information by querying the database directly, while end users have no way to view console session data at all.To address this, this PR proposes to create the
listConsoleSessions
API. It allows listing the console sessions, with optional filters by domain, account, user, host, instance, IP address, and date. The API is accessible to all account types and, thus, performs proper access validation on the queried resources.The API supports the following parameters:
id
activeonly
true
. Active sessions are the ones that have been acquired and have not been removed.isrecursive
false
.clientaddress
consoleendpointcreatoraddress
hostid
instanceid
startdate
enddate
domainid
accountid
userid
page
pagesize
.pagesize
page
.This PR only encompasses the creation of the API
listConsoleSessions
API. UI support will be implemented in a future PR.Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Screenshots (if appropriate):
How Has This Been Tested?
Tests Setup
listConsoleSessions
testsadmin
account, verified that the API lists console sessions correctly according to the specified parametersu1
account, verified that it is only possible to access the account's console sessionsd2-admin
account, verified that it is only possible to list the console sessions of thed2
domaind1-admin
account, verified that it is only possible to list the console sessions of thed1
andd1/d1-d1
domainsd1-user
account, verified that it is only possible to list thed1-user
console sessionsd1-d1-admin
account, verified that it is only possible to list the console sessions of thed1/d1-d1
domaind1-d1-user
account, verified that it is only possible to list thed1-d1-user
console sessionsUser
type, verified that thehostid
parameter is not considered in the API workflowUser
type, verified that thehostid
andhostname
response attributes are not included in the API's return