diff --git a/docs/Blueprints/ahv_update_config/README.md b/docs/Blueprints/ahv_update_config/README.md new file mode 100644 index 00000000..93c97901 --- /dev/null +++ b/docs/Blueprints/ahv_update_config/README.md @@ -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. \ No newline at end of file diff --git a/docs/Blueprints/downloadable_images/README.md b/docs/Blueprints/downloadable_images/README.md new file mode 100644 index 00000000..213ade00 --- /dev/null +++ b/docs/Blueprints/downloadable_images/README.md @@ -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 = "" +DownloadableDiskPackage = vm_disk_package( + name="", + 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 + +``` \ No newline at end of file diff --git a/docs/Blueprints/snapshot_restore/README.md b/docs/Blueprints/snapshot_restore/README.md new file mode 100644 index 00000000..0d2d3c5d --- /dev/null +++ b/docs/Blueprints/snapshot_restore/README.md @@ -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")) + ] +``` \ No newline at end of file diff --git a/docs/Job_scheduler/README.md b/docs/Job_scheduler/README.md new file mode 100644 index 00000000..2dd3c3a1 --- /dev/null +++ b/docs/Job_scheduler/README.md @@ -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) \ No newline at end of file diff --git a/docs/Power-Actions-in-Blueprint/README.md b/docs/Power-Actions-in-Blueprint/README.md new file mode 100644 index 00000000..fbde436f --- /dev/null +++ b/docs/Power-Actions-in-Blueprint/README.md @@ -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 (): + .<__power_action_name__>(name="Task Name", target=ref()) + +# 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. + diff --git a/docs/Power-Actions-in-Blueprint/images/power_state.png b/docs/Power-Actions-in-Blueprint/images/power_state.png new file mode 100644 index 00000000..aab5ea35 Binary files /dev/null and b/docs/Power-Actions-in-Blueprint/images/power_state.png differ diff --git a/release-notes/3.4.0/README.md b/release-notes/3.4.0/README.md index 38292e1a..796fefd0 100644 --- a/release-notes/3.4.0/README.md +++ b/release-notes/3.4.0/README.md @@ -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 diff --git a/release-notes/3.7.2.2/README.md b/release-notes/3.7.2.2/README.md new file mode 100644 index 00000000..790fcebb --- /dev/null +++ b/release-notes/3.7.2.2/README.md @@ -0,0 +1,57 @@ + +# Major Feats + +1. Added support for **project decompilation** [[see details](../../README.md#projects)], **environment decompilation** [[see details](../../README.md#environments)] + +2. Added support to **create vm power actions** in blueprint. [see details](../../docs/Power-Actions-in-Blueprint/README.md) + +3. Added support to create actions in `AhvUpdateConfigAttrs` class (Patch config actions). [see details](../../docs/Blueprints/ahv_update_config/README.md) + +4. Added support to **create vmware snapshot configs**. [see details](../../docs/Blueprints/snapshot_restore/README.md) + +5. Added support for **downloadable images in simple bp model**. [see details](../../docs/Blueprints/downloadable_images/README.md) + +6. [#252](https://github.com/nutanix/calm-dsl/issues/252) Added `calm unpublish marketplace` command to support unpublishing from all projects, specific projects, all versions of marketplace items. + +7. [#264](https://github.com/nutanix/calm-dsl/issues/264) Added no expiration as an option for recurring jobs. [see details](../../docs/Job_scheduler/README.md) + +# Bug Fixes +- [#291](https://github.com/nutanix/calm-dsl/issues/291) **Fixed decompilation of regex strings with backslashes** . Multiline type profile variable with a regex validation string including tokens such as \r, \n, \t will now get properly escaped during decompile. +- [#289](https://github.com/nutanix/calm-dsl/issues/289) Added support to **decompile UEFI boot_type in blueprint** +- [#283](https://github.com/nutanix/calm-dsl/issues/283) **Cluster macro decompile** issue fixed. +- [#273](https://github.com/ideadevice/calm-dsl/issues/273) Added support to **decompile blueprint with vm power actions.** +- [#144](https://github.com/nutanix/calm-dsl/issues/144) Updates version cache when config_file is supplied in cli options. + +- [#213](https://github.com/nutanix/calm-dsl/issues/213) Fix static ip address decompilation assosciated with nics in the schema +- [#255](https://github.com/nutanix/calm-dsl/issues/255) Fixed `--with_endpoints` option when publishing a runbook to retain the endpoints as expected +- [#177](https://github.com/nutanix/calm-dsl/issues/177) Fixed endpoint targets decompile in blueprint tasks. +- Decompile issue fixed when package_element is of type CUSTOM and has call_runbook_tasks. +- Fixed decompile failure for while loop tasks. +- Added support to decompile, compile and create dynamic variables that use http task with basic auth. +- Added `-fc/--force` flag to create projects and environments. +- Fixes for [#192](https://github.com/nutanix/calm-dsl/issues/192), [#226](https://github.com/nutanix/calm-dsl/issues/226), [#150](https://github.com/nutanix/calm-dsl/issues/150), [#50](https://github.com/nutanix/calm-dsl/issues/50) +- Added support of `--all_projects` to command `calm update marketplace` +- Fixed calm get apps command to list apps with delete state. +- Fixed describe project command to list correct quotas assigned to a project. +- Added support which allows to publish bp/runbook to the marketplace attached with all projects and in approval pending state through `--all_projects/-ap` flag. + +           + `calm publish bp -v --all_projects` + + +           + `calm publish runbook -v --all_projects` + +- Added `--remove-project/rp` flag to remove projects while approving an MPI. + +           + `calm approve marketplace bp -v --remove-project ` + + +           + `calm approve marketplace runbook -v --remove-project ` + +- Added option to choose multiple Nutanix accounts associated with the project, if present, while creating AHV provider spec. +- Added `nutanix_pc` as account type to list down nutanix accounts. e.g. `calm get accounts --type nutanix_pc` + +