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

   ### Description
   
   Quota tariffs have been extended to make it possible to define the order of 
their execution. To achieve this, the `position` parameter was added to the 
`quotaTariffCreate` and `quotaTariffUpdate` APIs. This parameter is used to 
define the tariff execution sequence of tariffs with the same usage type. This 
order is ascending, that is, a tariff with `position` equal to 1 will be 
executed before a tariff with `position` equal to 2. If two tariffs of the same 
usage type have equal positions, the most recent one will be executed first.
   
   During the processing of Quota tariffs, ACS will execute them in the defined 
order and inject the values ​​into subsequent rates. To enable tariff 
injection, the preset variable `lastTariffs` was created. It will have a list 
of objects containing the `id` and `value` attributes of the tariffs executed 
before it. Below is an example of the variable value when executing 3 tariffs 
(`A`, `B` and `C`) of the same usage type:
    
   - When executing tariff `A`, the value of `lastTariffs` will be:
   ```
   [ ]
   ```
   
   - When executing rule `B`, `lastTariffs` will have the value:
   ```
   [
     {
       "id": <A_uuid>,
       "value": <A_result>
     }
   ]
   ```
   
   - When executing rule `C`, `lastTariffs` will have the values:
   ```
   [
     {
       "id": <A_uuid>,
       "value": <A_result>
     },
     {
       "id": <B_uuid>,
       "value": <B_result>
     }
   ]
   ```
   ### 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
   
   ### Feature/Enhancement Scale or Bug Severity
   
   #### Feature/Enhancement Scale
   
   - [ ] Major
   - [X] Minor
   
   
   
   ### How Has This Been Tested?
   
   About the `quotaTariffCreate` and `quotaTariffUpdate` APIs
   | Num | Test | Result | Expected result? |
   |--|--|--|--|
   |1|Create a tariff informing the position | Tariff was created with the 
position informed |Y|
   |2|Create a tariff without informing the position | Tariff was created with 
default position 1 |Y|
   |3|Edit a tariff by entering a new position | Tariff was edited with the 
position given |Y|
   |4|Edit a tariff without entering a new position | Tariff was edited 
maintaining the previous position |Y|
   
   About the `lastTariffs` preset variable:
   I created three tariffs with activation rules:
    - the first with position 1 and always returning 10 
    - the second with position 2 and the rule: `lastTariffs[0].value + 7`
    - the third with position 3 and the rule: `lastTariffs[0].value + 
lastTariffs[1].value`. 
    
    When running `quotaUpdate`, I looked in the logs for which values were 
calculated according to the tariffs, the first returned 10, the second 17 and 
the third 27.


-- 
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: commits-unsubscr...@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to