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

   ### Description
   
   This PR aims to add the possibility to direct resources (Volumes, Templates, 
Snapshots and ISOs) to a specific secondary storage through rules written in 
JavaScript that will only affect new allocated resources. This feature is fully 
described in issue #7654.
   
   Fixes: #7654
   
   ### Types of changes
   
   - [ ] Breaking change (fix or feature that would cause existing 
functionality to change)
   - [x] 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)
   
   ### Feature/Enhancement Scale or Bug Severity
   
   #### Feature/Enhancement Scale
   
   - [x] Major
   - [ ] Minor
   
   ### How Has This Been Tested?
   
   Unit tests were added to validate the functionality of the implemented 
methods. Besides this, the overall functionality was tested in a local lab with 
two secondary storage available, creating basic JS rules and validating that 
the resource was allocated according to the heuristic rule. Below, there are 
some examples used in the tests, based on the variables available for each 
resource type specified in the specification of the feature proposal.
   
   1. Allocate a resource type to a specific secondary storage.
   ```js
   function findStorageWithSpecificUuid(pool) {
        return pool.uuid === '7432f961-c602-4e8e-8580-2496ffbbc45d';
   }
   
   secondaryStorages.filter(findStorageWithSpecificUuid)[0].uuid
   ```
   2. Dedicate storage pools for a type of template format.
   ```js
   function directToDedicatedQCOW2Pool(pool) {
     return pool.uuid === '7432f961-c602-4e8e-8580-2496ffbbc45d';
   }
   
   function directToDedicatedVHDPool(pool) {
     return pool.uuid === '1ea0109a-299d-4e37-8460-3e9823f9f25c';
   }
   
   if (template.format === 'QCOW2') {
     secondaryStorages.filter(directToDedicatedQCOW2Pool)[0].uuid
   } else if (template.format === 'VHD') {
     secondaryStorages.filter(directToDedicatedVHDPool)[0].uuid
   }
   ```
   3. Direct snapshot of volumes with the KVM hypervisor to a specific 
secondary storage.
   ```js
   if (snapshot.hypervisorType === 'KVM') {
     '7432f961-c602-4e8e-8580-2496ffbbc45d';
   }
   ```
   4. Direct resources to a specific domain:
   ```js
   if (account.domain.id == '52d83793-26de-11ec-8dcf-5254005dcdac') {
     '1ea0109a-299d-4e37-8460-3e9823f9f25c'
   } else if (account.domain.id == 'c1186146-5ceb-4901-94a1-dd1d24bd849d') {
     '7432f961-c602-4e8e-8580-2496ffbbc45d'
   }
   ```


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