Skip to content

Commit

Permalink
Release notes for DSL v3722 (#399)
Browse files Browse the repository at this point in the history
Description:

Release note for DSL v3.7.2.2

(cherry picked from commit 53c8133d544c941801177ee685322c00c53361e9)
  • Loading branch information
dwivediprab committed Apr 25, 2024
1 parent b87bcb7 commit ac9dded
Show file tree
Hide file tree
Showing 8 changed files with 347 additions and 50 deletions.
44 changes: 44 additions & 0 deletions docs/Blueprints/ahv_update_config/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
Supports addition of action in patch configs (update configs) for AHV using `AhvUpdateConfigAttrs` class. For further details about this class refer [here](../../../release-notes/3.3.0/README.md#ahvupdateconfigattrs)

#### Example
```python
class AhvUpdateAttrs(AhvUpdateConfigAttrs):
memory = PatchField.Ahv.memory(value="2", operation="equal", max_val=0, min_val=0, editable=False)
vcpu = PatchField.Ahv.vcpu(value="2", operation="equal", max_val=0, min_val=0)
numsocket = PatchField.Ahv.numsocket(value="2", operation="equal", max_val=0, min_val=0)
disk_delete = True
categories_delete = True
nic_delete = True
categories_add = True
nics = [
PatchField.Ahv.Nics.delete(index=1, editable=True),
PatchField.Ahv.Nics.add(
AhvVmNic.DirectNic.ingress(
subnet="nested_vms", cluster="auto_cluster_prod_1a5e1b6769ad"
),
editable=False,
),
]
disks = [
PatchField.Ahv.Disks.delete(index=1),
PatchField.Ahv.Disks.modify(
index=2, editable=True, value="2", operation="equal", max_val=4, min_val=1
),
PatchField.Ahv.Disks.add(
AhvVmDisk.Disk.Pci.allocateOnStorageContainer(10),
editable=False,
),
]
categories = [
PatchField.Ahv.Category.add({"TemplateType": "Vm"}),
PatchField.Ahv.Category.delete({"AppFamily": "Demo", "AppType": "Default"}),
]

@action
def app_edit_action_first():
Task.Exec.escript(name="Task1", script="print 'Hello!'")
Task.Exec.escript(name="Task2", script="print 'Hello2!'")
Task.Exec.escript(name="Task3", script="print 'Hello3!'")
```

Note: only sequential tasks are supported in action.
19 changes: 19 additions & 0 deletions docs/Blueprints/downloadable_images/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
For details on Simple Blueprint Models refer [here](../../../release-notes/3.2.0/README.md#simpleblueprint-model)

Allows you to add `packages` attribute which specifies downloadable images to be used in blueprint. See following example to use downloadable images in simple blueprint model:

```
DISK_IMAGE_SOURCE = "<url_of_image_source>"
DownloadableDiskPackage = vm_disk_package(
name="<name_of_disk>",
config={"image": {"source": DISK_IMAGE_SOURCE}},
)
class SampleSimpleBlueprint(SimpleBlueprint):
"""SimpleBlueprint configuration"""
deployments = [MySqlDeployment]
environments = [Ref.Environment(name=ENV_NAME)]
packages = [DownloadableDiskPackage] # add downloadable image packages here
```
24 changes: 24 additions & 0 deletions docs/Blueprints/snapshot_restore/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
For AHV snapshot restore refer [here](../../../release-notes/3.3.0/README.md)

For VMware snapshot restore refer below:

1. `AppProtection.SnapshotConfig`: Contains classes `AppProtection.SnapshotConfig.Ahv` and `AppProtection.SnapshotConfig.Vmware` for nutanix and vmware provider respectively. `AppProtection.SnapshotConfig` defaults to Ahv class for backware compatibility.

2. `AppProtection.RestoreConfig`: Contains classes `AppProtection.RestoreConfig.Ahv` and `AppProtection.RestoreConfig.Vmware` for nutanix and vmware provider respectively. `AppProtection.RestoreConfig` defaults to Ahv class for backware compatibility.

Sample Profile class containing snapshot/restore configs for VMWARE provider.
```python
from calm.dsl.builtins import AppProtection
class VmwareProfile(Profile):

deployments = [VmwDeployment]
restore_configs = [
AppProtection.RestoreConfig.Vmware(name="r1",
target=ref(VmwDeployment))
]
snapshot_configs = [
AppProtection.SnapshotConfig.Vmware(name="s1",
restore_config=ref(restore_configs[0]),
policy=AppProtection.ProtectionPolicy("policy1", rule_name="rule_name"))
]
```
51 changes: 51 additions & 0 deletions docs/Job_scheduler/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
For further details on Job scheduler refer [here](../../release-notes/3.4.0/README.md)

#### Recurring Job in Scheduler with non expiration Application Action as an executable

- The Runbook `test_no_expiration_app_job` will be executed from `2022-03-01 23:17:15` with no expiry time.
- Skip passing expiry_time parameter to set no expiration in job.

from calm.dsl.builtins import Job, JobScheduler

start_date = "2022-03-01 23:17:15"
cron = "50 23 * * *"
time_zone = "Asia/Calcutta"

APP_NAME = "job_recurring_no_expiration_app_action"

class JobRecurring(Job):
"""
Recurring Job with no expiration to Start action on app.
Note: Skip passing expiry_time parameter to set no expiration in job.
"""

name = "test_no_expiration_app_job"
schedule_info = JobScheduler.ScheduleInfo.recurring(
cron, start_date, time_zone=time_zone
)
executable = JobScheduler.Exec.app_action(APP_NAME, "Start")

#### Recurring Job in Scheduler with non expiration Runbook as an executable.

- The Runbook `job_recurring_no_expiration_runbook` will be executed from March 08 2022 Asia/Calcutta with no expiry time.
- Skip passing expiry_time parameter to set no expiration in job.

from calm.dsl.builtins import Job, JobScheduler

start_date = "2022-03-08 19:14:00"
cron = "50 23 * * *"
time_zone = "Asia/Calcutta"

RUNBOOK_NAME = "job_recurring_no_expiration_runbook"

class JobRecurring(Job):
"""
Recurring job with no expiration to execute runbook.
Note: Skip passing expiry_time parameter to set no expiration in job.
"""

name = "test_no_expiration_rb_job"
schedule_info = JobScheduler.ScheduleInfo.recurring(
cron, start_date, time_zone=time_zone
)
executable = JobScheduler.Exec.runbook(RUNBOOK_NAME, False)
152 changes: 152 additions & 0 deletions docs/Power-Actions-in-Blueprint/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
# VM Power actions support in DSL

1. Allows you to provide the Power On, Power Off option in the config for AHV, VMWARE providers
2. Allows you to create post create actions in substrate
3. Allows you to add VM Power ON/ Power Off/ Check Login actions in Custom actions for AHV, VMWARE, AZURE, AWS, GCP at service/profile level
4. Allows you to create VM Power ON/ Power Off/ Check Login actions in Post Create tasks.

## Support to provide the Power On, Power Off option in the config for AHV, VMWARE providers

To enable power state in ahv, vmware config similar to below, you can use power_on, power_off attributes of AhvVmResources class for AHV only or specify in yaml for AHV, VMware.

![power_state](images/power_state.png "power_state_image")

```python

class ResourceClass(AhvVmResources):
memory = 1
vCPUs = 1
cores_per_vCPU = 1
disks = [AhvVmDisk.Disk.Scsi.cloneFromImageService(CENTOS_CI, bootable=True)]
nics = [AhvVmNic.NormalNic.ingress(SUBNET_NAME, cluster=CLUSTER)]
power_state = "ON" # specify it here

```

```yaml
resources:
account_uuid: f87469b4-cc06-4f0e-b51b-99b9b3fa8b41
power_state: poweron # specify it here
controller_list: []
cpu_hot_add: false
disk_list: []
memory_hot_plug: false
memory_size_mib: 3072
nic_list:
- net_name: key-vim.host.PortGroup-vlan.112
nic_type: e1000
type: ''
num_sockets: 1
num_vcpus_per_socket: 1

```

Note:
- Valid power state values for vmware: [ON, OFF, poweron, poweroff]
- Valid power state values for ahv: [ON, OFF]

This is with reference to what fields of power state are supported in CALM Backend.

## Support to create post create actions in substrate

Added `__post_create__` function in Substrate class. This will allow user to create tasks that will be executed post vm creation. To add tasks in post create follow below example:

```python
class VM1(Substrate):
"""AHV VM Substrate"""

provider_type = "AHV_VM"
provider_spec = AhvVm1

@action
def __post_create__():
Task.Exec.escript(
name="Task1", script="print 'Post create task runs after VM is created'"
)
```

## Support to add VM Power ON/ Power Off/ Check Login actions in Custom actions for AHV, VMWARE, AZURE, AWS, GCP at service/profile level

Supports `__vm_power_on`, `__vm_power_off__`, `__vm_restart__`, `__vm_check_login__` functions in Substrate class to create actions containing runbook for action_poweron, action_poweroff, action_restart, action_check_login these are default system level actions which are called as runbook reference while inserting vm power actions in custom actions at profile/service level. This support is provided for AHV, VMWARE, AZURE, AWS, GCP cloud providers.

Use the following example to create vm power actions at service/profile level:

```python

class VM1(Substrate):

provider_type = "AHV_VM"
provider_spec = AhvVm1

@action
def __vm_power_on__():
pass

@action
def __vm_power_off__():
pass

@action
def __vm_restart__():
pass

@action
def __vm_check_login__():
pass


class Profile1(Profile):

deployments = [Deployment1]

@action
def custom_profile_action_1():
VM1.__vm_power_off__(name="VM1PowerOffTask")
VM1.__vm_power_on__(name="VM1PowerOnTask")
VM1.__vm_restart__(name="VM1PowerRestart")
VM1.__vm_check_login__(name="VM1CheckLogin")
```

- `__vm_power_on__` and other vm power actions should be defined at Substrate class to use it further in profile/service level.
- If these vm power actions are not defined at Substrate class they can’t be used in other classes to create custom actions.
- Default definition of vm power actions is given above it should not be modified. Any overriding of these methods will raise an - error stating override not allowed.
- Default definition itself takes care of addition of necessary tasks needed for proper functioning.
- Use following rule to create custom action at service/profile level

```python
@action
def <action_name>():
<Substrate_class_name>.<__power_action_name__>(name="Task Name", target=ref(<Target_class_name>))

# For example:
@action
def action1():
Substrate1.__power_on__(name="Task1", target=ref(Service1))

```

- action_name is valid name of action that contains task to call vm power actions. This mimics the behaviour of UI side.
- If target is omitted it will take service that is coupled with substrate by default

- Valid targets are:
- Service class name for a substrate at service/profile level actions
- Deployment class name for a substrate at profile level actions
- Profile level actions can have both deployment and service target. By default service target will be used.

## Support to create post create actions in substrate

Post create actions of substrate as defined above can also contain vm power actions in them. For example:

```python
class VM1(Substrate):

provider_type = "AHV_VM"
provider_spec = AhvVm1

@action
def __post_create__():
VM1.__vm_power_off__(name="PowerOnTask", target=ref(VM1))
```

Note: Target for this should always be the Substrate class containing it.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 0 additions & 50 deletions release-notes/3.4.0/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,56 +60,6 @@
)
executable = JobScheduler.Exec.app_action("app_name", "Restore Action")

### Recurring Job in Scheduler with non expiration Application Action as an executable

- The Runbook `test_no_expiration_app_job` will be executed from `2022-03-01 23:17:15` with no expiry time.
- Skip passing expiry_time parameter to set no expiration in job.

from calm.dsl.builtins import Job, JobScheduler

start_date = "2022-03-01 23:17:15"
cron = "50 23 * * *"
time_zone = "Asia/Calcutta"

APP_NAME = "job_recurring_no_expiration_app_action"

class JobRecurring(Job):
"""
Recurring Job with no expiration to Start action on app.
Note: Skip passing expiry_time parameter to set no expiration in job.
"""

name = "test_no_expiration_app_job"
schedule_info = JobScheduler.ScheduleInfo.recurring(
cron, start_date, time_zone=time_zone
)
executable = JobScheduler.Exec.app_action(APP_NAME, "Start")

### Recurring Job in Scheduler with non expiration Runbook as an executable.

- The Runbook `job_recurring_no_expiration_runbook` will be executed from March 08 2022 Asia/Calcutta with no expiry time.
- Skip passing expiry_time parameter to set no expiration in job.

from calm.dsl.builtins import Job, JobScheduler

start_date = "2022-03-08 19:14:00"
cron = "50 23 * * *"
time_zone = "Asia/Calcutta"

RUNBOOK_NAME = "job_recurring_no_expiration_runbook"

class JobRecurring(Job):
"""
Recurring job with no expiration to execute runbook.
Note: Skip passing expiry_time parameter to set no expiration in job.
"""

name = "test_no_expiration_rb_job"
schedule_info = JobScheduler.ScheduleInfo.recurring(
cron, start_date, time_zone=time_zone
)
executable = JobScheduler.Exec.runbook(RUNBOOK_NAME, False)

# Dynamic Credential

## CLI commands
Expand Down
Loading

0 comments on commit ac9dded

Please sign in to comment.