bernardodemarco opened a new pull request, #9534:
URL: https://github.com/apache/cloudstack/pull/9534

   ### Description
   
   This PR proposes to persist IP addresses related to VM access via CPVM. 
Specifically, it stores the IP address of the client accessing a VM and the IP 
address of the console endpoint creator. To achieve this, the 
`cloud.console_session` table was extended with two new columns: 
`client_address`, which stores the client's IP address, and 
`console_endpoint_creator_address`, which captures the IP address of the 
console endpoint creator.
   
   These IP addresses were already being captured for logging and validation 
purposes. The console endpoint creator's IP is captured here, at the start of 
the `CreateConsoleEndpointCmd` execution:
   
   
https://github.com/apache/cloudstack/blob/47a6b7011d7e42be86a748af50b87633147b5a90/api/src/main/java/org/apache/cloudstack/api/command/user/consoleproxy/CreateConsoleEndpointCmd.java#L65-L68
   
   The client address is captured by calling 
`session.getRemoteAddress().getAddress().getHostAddress()` in this method, that 
gets executed when the client connects to the console:
   
   
https://github.com/apache/cloudstack/blob/47a6b7011d7e42be86a748af50b87633147b5a90/services/console-proxy/server/src/main/java/com/cloud/consoleproxy/ConsoleProxyNoVNCHandler.java#L157-L160
   
   ### Types of changes
   
   - [ ] Breaking change (fix or feature that would cause existing 
functionality to change)
   - [ ] New feature (non-breaking change which adds functionality)
   - [ ] Bug fix (non-breaking change which fixes an issue)
   - [X] Enhancement (improves an existing feature and functionality)
   - [ ] Cleanup (Code refactoring and cleanup, that may add test cases)
   - [ ] build/CI
   - [ ] test (unit or integration test code)
   
   ### Feature/Enhancement Scale or Bug Severity
   
   #### Feature/Enhancement Scale
   
   - [ ] Major
   - [X] Minor
   
   ### Screenshots (if appropriate):
   
   ### How Has This Been Tested?
   
   1. I manually added the `client_address` and 
`console_endpoint_creator_address` columns to the `cloud.console_session` table.
   2. I generated a VM console endpoint.
   3. I executed the following query in order to validate whether the stored IP 
was correct.
   
   
   <details>
       <summary>
       <code>SELECT * FROM `cloud`.`console_session` ORDER BY created DESC 
LIMIT 1;</code>
       </summary>
   
   | id | uuid | created | account_id | user_id | instance_id | host_id | 
acquired | removed | client_address | console_endpoint_creator_address |
   | -- | ---- | ---- |    ---- |       ---- |     ---- |       ---- |      
---- |    ---- |    ---- | ---- |
   | 2  | 77f08cea-8068-471f-9464-44810e1ef545 |2024-08-06 17:57:05 |2 | 2 | 14 
| 1 | NULL | NULL | NULL | 192.168.122.1 |
   
   </details>
   
   As can be noticed, the `console_endpoint_creator_address` column was 
populated accordingly, whereas the `client_adress` was still empty since the VM 
had not been accessed yet.
   
   4. I accessed the VM via CPVM.
   5. I executed the following query in order to validate whether the client 
stored IP was correct.
   
   <details>
       <summary>
       <code>SELECT * FROM `cloud`.`console_session` ORDER BY created DESC 
LIMIT 1;</code>
       </summary>
   
   | id | uuid | created | account_id | user_id | instance_id | host_id | 
acquired | removed | client_address | console_endpoint_creator_address |
   | -- | ---- | ---- |    ---- |       ---- |     ---- |       ---- |      
---- |    ---- |    ---- | ---- | 
   | 2  | 77f08cea-8068-471f-9464-44810e1ef545 |2024-08-06 17:57:05 |2 | 2 | 14 
| 1 | NULL | NULL | 192.168.122.1 | 192.168.122.1 |
   
   </details>
   
   As can be noticed, the IP address of the client that accessed the VM through 
CPVM was persisted correctly.


-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to