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

   ### Description
   
   Fixes #9775 
   
   This PR adds check to ensure we check for unique hostname for other networks 
in the VPC as well.
   
   This PR also adds another global setting `vm.distinct.hostname.scope` which 
sets the scope of resources for which the VMs should have a unique hostname. 
Default value is `network`.
   
   <details><summary>Details</summary>
   <p>
   
   This pull request introduces several changes to enhance the functionality of 
hostname uniqueness checks within different scopes and refactors related 
methods and imports. The most important changes include adding new methods for 
checking hostname existence in various scopes, updating search criteria, and 
introducing a new configuration key for hostname scope.
   
   Enhancements to hostname uniqueness checks:
   
   * 
[`engine/schema/src/main/java/com/cloud/vm/dao/VMInstanceDao.java`](diffhunk://#diff-647b2e9f37586b34e9e88b3c276818776b135c0b8c7407322f79e4b17077dfc4R148-R151):
 Added methods `hostNameExistsInDomainIds` and 
`hostNameExistsInDomainIdsAccountIds` to the `VMInstanceDao` interface to check 
hostname existence within specified domain and account IDs.
   * 
[`engine/schema/src/main/java/com/cloud/vm/dao/VMInstanceDaoImpl.java`](diffhunk://#diff-9d1115b85406786422d018d2e9755c7b9aeb5aea8a4665bc724bf4f18ffef41cR892-R905):
 Implemented the new methods `hostNameExistsInDomainIds` and 
`hostNameExistsInDomainIdsAccountIds` in the `VMInstanceDaoImpl` class.
   * 
[`server/src/main/java/com/cloud/vm/UserVmManagerImpl.java`](diffhunk://#diff-865f710fe60b9b62ff8c2cbce8a8342e4f6fca658223119762285fd5f7857f08R666-R671):
 Added a new configuration key `VmDistinctHostNameScope` to define the scope 
for hostname uniqueness checks. Updated the `checkIfHostNameUniqueInNtwkDomain` 
method to use the new scope configuration and refactored it to support 
different scopes such as global, domain, subdomain, and account. 
[[1]](diffhunk://#diff-865f710fe60b9b62ff8c2cbce8a8342e4f6fca658223119762285fd5f7857f08R666-R671)
 
[[2]](diffhunk://#diff-865f710fe60b9b62ff8c2cbce8a8342e4f6fca658223119762285fd5f7857f08L4432-R4526)
 
[[3]](diffhunk://#diff-865f710fe60b9b62ff8c2cbce8a8342e4f6fca658223119762285fd5f7857f08R4539-R4540)
   
   Refactoring and imports:
   
   * `engine/schema/src/main/java/com/cloud/vm/dao/VMInstanceDao.java` and 
`engine/schema/src/main/java/com/cloud/vm/dao/VMInstanceDaoImpl.java`: Added 
import statements for `Set` and 
`org.apache.commons.collections.CollectionUtils` to support the new methods. 
[[1]](diffhunk://#diff-647b2e9f37586b34e9e88b3c276818776b135c0b8c7407322f79e4b17077dfc4R23)
 
[[2]](diffhunk://#diff-9d1115b85406786422d018d2e9755c7b9aeb5aea8a4665bc724bf4f18ffef41cR27-R33)
   * 
[`server/src/main/java/com/cloud/vm/UserVmManagerImpl.java`](diffhunk://#diff-865f710fe60b9b62ff8c2cbce8a8342e4f6fca658223119762285fd5f7857f08R55):
 Added import statement for `com.cloud.network.vpc.Vpc` to support VPC-related 
operations in the refactored method.
   
   
   
   </p>
   </details> 
   
   
   <!--- Describe your changes in DETAIL - And how has behaviour functionally 
changed. -->
   
   <!-- For new features, provide link to FS, dev ML discussion etc. -->
   <!-- In case of bug fix, the expected and actual behaviours, steps to 
reproduce. -->
   
   <!-- When "Fixes: #<id>" is specified, the issue/PR will automatically be 
closed when this PR gets merged -->
   <!-- For addressing multiple issues/PRs, use multiple "Fixes: #<id>" -->
   <!-- Fixes: # -->
   
   <!--- 
******************************************************************************* 
-->
   <!--- NOTE: AUTOMATION USES THE DESCRIPTIONS TO SET LABELS AND PRODUCE 
DOCUMENTATION. -->
   <!--- PLEASE PUT AN 'X' in only **ONE** box -->
   <!--- 
******************************************************************************* 
-->
   
   ### 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)
   - [ ] 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
   - [ ] Minor
   
   #### Bug Severity
   
   - [ ] BLOCKER
   - [ ] Critical
   - [ ] Major
   - [ ] Minor
   - [ ] Trivial
   
   ### Screenshots (if appropriate):
   
   ### 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 
-->
   
   #### How did you try to break this feature and the system with this change?
   
   <!-- see how your change affects other areas of the code, etc. -->
   
   <!-- Please read the 
[CONTRIBUTING](https://github.com/apache/cloudstack/blob/main/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.

To unsubscribe, e-mail: [email protected]

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

Reply via email to