From 3de448f3484b87f17e03917c7eddbaeeb0b643ab Mon Sep 17 00:00:00 2001 From: abhijeetkaurav1st Date: Wed, 3 Nov 2021 22:35:31 +0530 Subject: [PATCH] Minor fixes regarding release-notes and some command name fixes --- calm/dsl/cli/protection_policy_commands.py | 2 +- calm/dsl/cli/vm_recovery_point_commands.py | 9 +- .../AHV_CONFIG/snapshot_restore/README.md | 2 +- release-notes/3.3.0/README.md | 85 ++++++++++++++++--- tests/cli/test_protection_policy_commands.py | 2 +- 5 files changed, 81 insertions(+), 19 deletions(-) diff --git a/calm/dsl/cli/protection_policy_commands.py b/calm/dsl/cli/protection_policy_commands.py index 7125dd56..eaa23ad2 100644 --- a/calm/dsl/cli/protection_policy_commands.py +++ b/calm/dsl/cli/protection_policy_commands.py @@ -7,7 +7,7 @@ LOG = get_logging_handle(__name__) -@get.command("protection_policies") +@get.command("protection-policies") @click.option("--limit", "-l", default=20, help="Number of results to return") @click.option( "--offset", "-o", default=0, help="Offset results by the specified amount" diff --git a/calm/dsl/cli/vm_recovery_point_commands.py b/calm/dsl/cli/vm_recovery_point_commands.py index d30b7603..5d5f2c8c 100644 --- a/calm/dsl/cli/vm_recovery_point_commands.py +++ b/calm/dsl/cli/vm_recovery_point_commands.py @@ -11,8 +11,7 @@ LOG = get_logging_handle(__name__) -# TODO break command suffix -@get.command("vm_recovery_points") +@get.command("vm-recovery-points") @click.option( "--name", "-n", default=None, help="Search for vm recovery points by name" ) @@ -61,7 +60,11 @@ def get_vm_recovery_points(name, limit, offset, quiet, out, project_name, accoun account_uuid = account_detail["account"]["uuid"] LOG.info("Using account '{}' for listing brownfield vms".format(account_name)) - payload = {"filter": "account_uuid=={}".format(account_uuid)} + payload = { + "filter": "account_uuid=={}".format(account_uuid), + "length": limit, + "offset": offset + } if name: payload["filter"] += ";name=={}".format(name) diff --git a/examples/AHV_CONFIG/snapshot_restore/README.md b/examples/AHV_CONFIG/snapshot_restore/README.md index fc7d1289..ea3f732e 100644 --- a/examples/AHV_CONFIG/snapshot_restore/README.md +++ b/examples/AHV_CONFIG/snapshot_restore/README.md @@ -27,7 +27,7 @@ ##### Input Parameters - name -- rule_name - name of the protection rule (from `calm get protection_policies`) +- rule_name - name of the protection rule (from `calm get protection-policies`) ### Usage diff --git a/release-notes/3.3.0/README.md b/release-notes/3.3.0/README.md index 50d860ef..3586d865 100644 --- a/release-notes/3.3.0/README.md +++ b/release-notes/3.3.0/README.md @@ -1,23 +1,18 @@ -# Brownfield Application - -## CLI commands - -- `calm get brownfield vms -p -a `: Added account cli option, that user should provide if there are multiple accounts in the given project. - -- `calm launch bp -b -n `. Command will launch existing blueprint using brownfield deployments to create brownfield application. Sample file look [here](examples/Brownfield/separate_file_example/brownfield_deployments.py). # Snapshot Restore Adding a snapshot (or restore) config in a profile will auto-generate a profile-level snapshot (or restore) action - Snapshot_ (or Restore_) - which can be run using `calm run action`. +- As of now we suport for snapshot-restore for `nutanix` provider. +- Sample [Blueprint](examples/AHV_CONFIG/snapshot_restore/demo_blueprint.py) containg snapshot-restore configuration. ## CLI commands -- `calm get protection_policies -p `: Lists protection policies corresponding to the project (create/update/delete using DSL not supported in this release) +- `calm get protection-policies -p `: Lists protection policies corresponding to the project (create/update/delete using DSL not supported in this release) ## Built-in Models ### AppProtection.ProtectionPolicy #### Input Parameters - name -- rule_name - name of the protection rule (from `calm get protection_policies`) +- rule_name - name of the protection rule (from `calm get protection-policies`) ### AppProtection.SnapshotConfig #### Input Parameters @@ -47,8 +42,6 @@ class HelloProfile(Profile): snapshot_configs = [AppProtection.SnapshotConfig("Sample Config2", policy=AppProtection.ProtectionPolicy("policy1"), restore_config=ref(restore_configs[0]))] ``` -[Sample Blueprint](examples/AHV_CONFIG/snapshot_restore/demo_blueprint.py). - ## Running Snapshot and Restore Actions Snapshot and Restore Actions can be run like any other profile-level action using `calm run action`. ``` @@ -58,8 +51,9 @@ calm run action Restore_ -a Snapshot name is supplied as a runtime argument while running the snapshot action, and similarly, recovery group can be chosen while running the restore action. # App edit -Adding a update config in a profile will auto-generate a profile-level patch action - - which can be run using `calm update app `. -- As of now we suport for app edit for `nutanix` provider +Adding a update config in a profile will auto-generate a profile-level patch action - - which can be run using `calm update app `. +- As of now we suport for app edit for `nutanix` provider. +- Sample [Blueprint](examples/multivm_app_edit/blueprint.py) containing app-edit configuration ## Built-in Models ### AhvUpdateConfigAttrs @@ -168,3 +162,68 @@ class HelloProfile(Profile): ``` calm update app example_app example_update_config ``` + +# *Brownfield Application + +## CLI commands + +- `calm get brownfield vms -p -a `: Added account cli option, that user should provide if there are multiple accounts in the given project. + +- `calm launch bp -b -n `. Command will launch existing blueprint using brownfield deployments to create brownfield application. Sample file look [here](examples/Brownfield/separate_file_example/brownfield_deployments.py). Note: Name of deployment which user wants to override should be available in blueprint. + + +# *Vm Recovery Points + + From Calm v3.3.0, user can create and launch a blueprint having vm-recovery-point instead of vm-configuration for ahv substrates. Note: Only CrashConsistent vm_recovery_point are allowed. Sample file look [here](tests/vm_recovery_point/blueprint.py) + + ## CLI commands + + - `calm get vm-recovery-points -p -a `: Command will list the vm recovery points for given account in a project. + +## Builtin-Models + +- Added `AhvVmRecoveryResources` model which specify the vm resources to be overrided after recovery of vm. + +``` +class MyAhvVmResources(AhvVmRecoveryResources): + """ + [NumVcpusPerSocket, NumSockets, MemorySizeMb, NicList, GPUList, vm_name] can be overrided + """ + + memory = 4 + vCPUs = 2 + cores_per_vCPU = 1 + nics = [AhvVmNic(NETWORK1)] +``` + +- Added `Ref.RecoveryPoint(name, uuid)` which consumes name/uuid of recovery point and returns ref object for recovery point. + +``` +Ref.RecoveryPoint(name=VM_RECOVERY_POINT_NAME) +``` + +- Added `ahv_vm_recovery_spec` helper which consumes vm-recovery-point details and returns the ahv-vm-recovery-spec object. + +``` +ahv_vm_recovery_spec( + recovery_point=Ref.RecoveryPoint(name=VM_RECOVERY_POINT_NAME), + vm_name="AhvRestoredVm", + vm_override_resources=MyAhvVmResources, +) +``` + +- Added `vm_recovery_spec` attribute which specify the vm_recovery_spec used for the given substrare. + +``` +class AhvVmSubstrate(Substrate): + """AHV VM config given by reading a spec file""" + + provider_type = "AHV_VM" + vm_recovery_spec = ahv_vm_recovery_spec( + recovery_point=Ref.RecoveryPoint(name=VM_RECOVERY_POINT_NAME), + vm_name="AhvRestoredVm", + vm_override_resources=MyAhvVmResources, + ) +``` + +*: Features are Calm-DSL specific. No support for UX/UI is available in Calm v3.3.0. diff --git a/tests/cli/test_protection_policy_commands.py b/tests/cli/test_protection_policy_commands.py index cb6bdfa6..b2b323e8 100644 --- a/tests/cli/test_protection_policy_commands.py +++ b/tests/cli/test_protection_policy_commands.py @@ -13,7 +13,7 @@ class TestProtectionPolicyCommands: def test_protection_policies_list(self): runner = CliRunner() - result = runner.invoke(cli, ["get", "protection_policies"]) + result = runner.invoke(cli, ["get", "protection-policies"]) if result.exit_code: cli_res_dict = {"Output": result.output, "Exception": str(result.exception)} LOG.debug(