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?
It was added unit tests 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. In the [last section](#variables), is presented the table with
the available variables.
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';
}
```
#### <section id="variables"> Variables available for the heuristic
rules</section>
The table below presents the possible values for each resource when
executing the JS rule. The variables of the secondary storage are available to
all types of resources; whereas, the variables for snapshots, ISOs, templates
and volumes are only available for each respective resource types, according to
the `purpose` parameter of the API `createSecondaryStorageSelector`.
<table>
<thead>
<tr>
<th>Resource</th>
<th>Variables</th>
</tr>
</thead>
<tbody>
<tr>
<td rowspan="4"><br><br><br>Secondary Storage<br></td>
<td><code>uuid</code></td>
</tr>
<tr>
<td><code>usedDiskSize</code></td>
</tr>
<tr>
<td><code>totalDiskSize</code><br></td>
</tr>
<tr>
<td><code>protocol</code></td>
</tr>
<tr>
<td rowspan="2"><br>Snapshot<br></td>
<td><code>size</code></td>
</tr>
<tr>
<td><code>hypervisorType</code></td>
</tr>
<tr>
<td rowspan="2"><br>ISO/Template</td>
<td><code>format</code></td>
</tr>
<tr>
<td><code>hypervisorType</code></td>
</tr>
<tr>
<td rowspan="2"><br>Volume</td>
<td><code>size</code></td>
</tr>
<tr>
<td><code>format</code></td>
</tr>
</tbody>
</table>
--
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]