GitHub user BryanMLima added a comment to the discussion: Instance backups

Hello, pcfriek1987

I apologize for lack of clarity in the section [Direct resources to a specific 
secondary 
storage](https://docs.cloudstack.apache.org/en/latest/adminguide/storage.html#direct-resources-to-a-specific-secondary-storage),
 currently, you can only manage the secondary storage selectors through API, 
which is easier through 
[CloudMonkey](https://github.com/apache/cloudstack-cloudmonkey); it is planned 
to add the management of this feature to the UI in the future, simplifying its 
usage.

For now, you will need to use the APIs 
[createSecondaryStorageSelector](https://cloudstack.apache.org/api/apidocs-4.19/apis/createSecondaryStorageSelector.html),
 
[listSecondaryStorageSelectors](https://cloudstack.apache.org/api/apidocs-4.19/apis/listSecondaryStorageSelectors.html),
 
[removeSecondaryStorageSelector](https://cloudstack.apache.org/api/apidocs-4.19/apis/removeSecondaryStorageSelector.html)
 and 
[updateSecondaryStorageSelector](https://cloudstack.apache.org/api/apidocs-4.19/apis/updateSecondaryStorageSelector.html),
 which are available on `4.19.0.0` and newer versions of ACS.

So, for example, if you want to direct snapshots to a specific secondary 
storage, like you mentioned, you'll need to create the following rule:

```js
if (snapshot.hypervisorType === 'KVM') {
   '7cdd9941-5bb5-4717-9afb-8cf803340253';
}
```

To create this rule through the API `createSecondaryStorageSelector`, you'll 
need to inform the required parameters using CloudMonkey:

**Note that the heuristic rule was formatted to a one string JS script**
```js
(lab) 🐱 > create secondarystorageselector name="kvm-snapshots" 
description="Selector for directing snapshots to an especific secondary 
storage" zoneid=7cdd9941-5bb5-4717-9afb-8cf803340253 purpose=SNAPSHOT 
heuristicrule="if (snapshot.hypervisorType === 'KVM') { 
'7832f261-c602-4e8e-8580-2496ffbbc45d'; }"
{
  "heuristics": {
    "created": "2024-07-09T19:49:07+0000",
    "description": "Selector for directing snapshots to an especific secondary 
storage",
    "heuristicrule": "if (snapshot.hypervisorType === 'KVM') { 
'7832f261-c602-4e8e-8580-2496ffbbc45d'; }",
    "id": "47628716-4ac3-42f4-bbdb-c3afb9a09e24",
    "name": "kvm-snapshots",
    "purpose": "SNAPSHOT",
    "zoneid": "7cdd9941-5bb5-4717-9afb-8cf803340253"
  }
}
```

However, this only directs all snapshots for the hypervisor KVM to the 
specific, other types of secondary storage resources (such as ISOs, templates 
and volumes) can still be allocated to this storage.

Therefore, if you want to dedicate a secondary storage to only store snapshots, 
you'll need to create a selector for the remaining resource types filtering the 
desired secondary storage. Unfortunately, this feature expects that the JS 
output is a valid secondary storage UUID, therefore, you'll need to shuffle the 
UUIDs through the JS script. I will try to improve this part of the feature, to 
simplify the dedication of a resource to a specific secondary storage.

GitHub link: 
https://github.com/apache/cloudstack/discussions/9347#discussioncomment-10002499

----
This is an automatically sent email for users@cloudstack.apache.org.
To unsubscribe, please send an email to: users-unsubscr...@cloudstack.apache.org

Reply via email to