BryanMLima opened a new issue, #7654:
URL: https://github.com/apache/cloudstack/issues/7654
##### ISSUE TYPE
* Feature Idea
##### COMPONENT NAME
~~~
API
~~~
##### CLOUDSTACK VERSION
<!--
New line separated list of affected versions, commit ID for issues on main
branch.
-->
~~~
4.18/Main
~~~
##### SUMMARY
Currently, ACS does not allow resources such as ISOs, Volumes, Snapshots,
and Templates to be directed to a specific purpose secondary storage. Thus,
operators are unable to determine to which secondary storage a given resource
will be allocated. This specification aims to extend ACS for operators to be
able to direct these resources to specific secondary storage using a
user-defined rule.
## Table of contents
- [1. Proposed changes](#proposed-changes)
- [2. New APIs](#new-api-proposal)
- [2.1. `createSecondaryStorageSelector`
API](#createSecondaryStorageSelector-API)
- [2.2. `updateSecondaryStorageSelector`
API](#updateSecondaryStorageSelector-API)
- [2.3. `removeSecondaryStorageSelector`
API](#removeSecondaryStorageSelector-API)
- [2.4. `listSecondaryStorageSelectors`
API](#listSecondaryStorageSelectors-API)
## <section id="proposed-changes">1. Proposed changes</section>
This specification proposes to change the way ACS defines which secondary
storage will be used to store some resources. The intent is to make the
Management Server select a secondary storage based on rules written in
JavaScript (JS) that will only affect new resources, i.e. resources previously
allocated on secondary storage will not be changed. The proposed changes are
described in the following subsections.
## <section id="new-api-proposal">2. New API proposal</section>
Create a new API (`createSecondaryStorageSelector`) which will have as
mandatory parameters: (`zoneid: String`, `purpose: String`, `heuristic_rule:
String`), the created rule will determine, based on the return of the
`heuristic_rule`, in which secondary storage a given resource will be allocated.
Regarding the API parameters:
- `zoneid`: Required, since all configurations will only be in the zone
scope;
- `purpose`: Required, this parameter will determine the purpose for which
the heuristic was created, the values accepted by this parameter will be:
`VOLUME`, `SNAPSHOT`, `ISO`, `TEMPLATE`;
- `heuristic_rule`: A script, written in JS, to determine the secondary
storage where the resource will be allocated. This script will take the
following attributes from the secondary storage as input: `id`, `disksizeused`,
`protocol`. For Volumes, we will take the `size` and `format` attributes, for
Snapshots we will take the `hypervisor_type` and `size` attributes and, for
Templates we will take the `format` and `hypervisor_type`.
Furthermore, we propose three additional APIs, one to update a created
heuristic (`updateSecondaryStorageSelector`), that will allow operators to edit
the defined `heuristic_rule`; the second API (`removeSecondaryStorageSelector`)
to disable a previous created heuristic, and the third to list heuristics
created by operators which were defined in a zone
(`listSecondaryStorageSelectors`). The image below presents an overview of the
proposed changes.
<img
src="https://res.cloudinary.com/sc-clouds/image/upload/v1686935719/specs/dynamic-secondary-storage-selection/dsss_c62ebu.png"
alt="Overview of the proposed changes"
style="width: 70%;
height: auto;
display: block;
margin-left: auto;
margin-right: auto;">
To persist the information about the heuristic, a new table (`heuristics`)
will be created in the `cloud` database. Which will have the following columns:
| **Field** | **Type** | **Required** | **Use**
|
|:--------------------:|:------------:|:------------:|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
| uuid | varchar(40) | Yes | A unique identifier
of the heuristic.
|
| name | text | Yes | A unique name for the
heuristic.
|
| description | text | No | Description of the
heuristic.
|
| zone_id | bigint(20) | Yes | Foreign key to the
`cloud.data_center` table.
|
| purpose | varchar(255) | Yes | Whether the heuristic
referenced was created with the purpose to manage resources of type: `VOLUME`,
`TEMPLATE`, `ISO`, or `SNAPSHOT` to be directed to a specific secondary
storage. |
| heuristic_rule | text | Yes | Script implemented in
JS that will determine to which secondary storage a given resource will be
allocated.
|
| created | datetime | Yes | Any date from the
current date. If this parameter is not informed, the default value will be the
current date.
|
| removed | datetime | No | When the heuristic
was removed.
|
## <section id="createSecondaryStorageSelector-API">2.1
`createSecondaryStorageSelector` API</section>
The API `createSecondaryStorageSelector` will have three parameters:
`zoneid`, `purpose` and `heuristic_rule`. The return of the script
`heuristic_rule` will determine where the resource defined in the `purpose`
parameter will be allocated for download or upload resources. The image below
presents the flowchart for this API.
<img
src="https://res.cloudinary.com/sc-clouds/image/upload/v1679941242/specs/dynamic-secondary-storage-selection/createSecondaryStorageSelector_lqrvht.png"
alt="Flow chart createSecondaryStorageSelector API"
style="width: 70%;
height: auto;
display: block;
margin-left: auto;
margin-right: auto;">
## <section id="updateSecondaryStorageSelector-API">2.2
`updateSecondaryStorageSelector` API</section>
The API `updateSecondaryStorageSelector` will have two parameters: `uuid`
and `heuristic_rule`. This API will update the heuristic defined by the given
`uuid` with the new attribute `heuristic_rule`. The image below presents the
flowchart for this API.
<img
src="https://res.cloudinary.com/sc-clouds/image/upload/v1679941242/specs/dynamic-secondary-storage-selection/updateSecondaryStorageSelector_jk7mq6.png"
alt="Flow chart updateSecondaryStorageSelector API"
style="width: 70%;
height: auto;
display: block;
margin-left: auto;
margin-right: auto;">
## <section id="removeSecondaryStorageSelector-API">2.3
`removeSecondaryStorageSelector` API</section>
The API `removeSecondaryStorageSelector` will have 1 parameter: `uuid`. The
image below presents the flowchart for this API.
<img
src="https://res.cloudinary.com/sc-clouds/image/upload/v1679941242/specs/dynamic-secondary-storage-selection/removeSecondaryStorageSelector_xzt9xx.png"
alt="Flow chart removeSecondaryStorageSelector API"
style="width: 70%;
height: auto;
display: block;
margin-left: auto;
margin-right: auto;">
## <section id="listSecondaryStorageSelectors-API">2.4
`listSecondaryStorageSelectors` API</section>
The API `listSecondaryStorageSelectors` will have 2 parameters: `zone_uuid`
and `purpose`. The operator can give a valid purpose and a `zone_uuid`, so that
the list of active heuristics will be filtered with the given purpose and zone.
The image below presents the flowchart for this API.
<img
src="https://res.cloudinary.com/sc-clouds/image/upload/v1679941242/specs/dynamic-secondary-storage-selection/listSecondaryStorageSelectors_x8ryd3.png"
alt="Flow chart listSecondaryStorageSelectors API"
style="width: 70%;
height: auto;
display: block;
margin-left: auto;
margin-right: auto;">
--
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]