|
126 | 126 | os_linux = 'Linux'
|
127 | 127 | password_offset = 33
|
128 | 128 | password_length = 15
|
| 129 | +enhanced_policy_type = "v2" |
| 130 | +standard_policy_type = "v1" |
129 | 131 | # pylint: disable=too-many-function-args
|
130 | 132 |
|
131 | 133 |
|
@@ -1004,16 +1006,24 @@ def update_policy_for_item(cmd, client, resource_group_name, vault_name, item, p
|
1004 | 1006 | vm_item_properties.policy_id = policy.id
|
1005 | 1007 | vm_item_properties.source_resource_id = item.properties.source_resource_id
|
1006 | 1008 | vm_item = ProtectedItemResource(properties=vm_item_properties)
|
| 1009 | + existing_policy = common.show_policy(protection_policies_cf(cmd.cli_ctx), resource_group_name, vault_name, |
| 1010 | + item.properties.policy_name) |
1007 | 1011 | if is_critical_operation:
|
1008 |
| - existing_policy = common.show_policy(protection_policies_cf(cmd.cli_ctx), resource_group_name, vault_name, |
1009 |
| - item.properties.policy_name) |
1010 | 1012 | if cust_help.is_retention_duration_decreased(existing_policy, policy, "AzureIaasVM"):
|
1011 | 1013 | # update the payload with critical operation and add auxiliary header for cross tenant case
|
1012 | 1014 | if tenant_id is not None:
|
1013 | 1015 | client = get_mgmt_service_client(cmd.cli_ctx, RecoveryServicesBackupClient,
|
1014 | 1016 | aux_tenants=[tenant_id]).protected_items
|
1015 | 1017 | vm_item.properties.resource_guard_operation_requests = [cust_help.get_resource_guard_operation_request(
|
1016 | 1018 | cmd.cli_ctx, resource_group_name, vault_name, "updateProtection")]
|
| 1019 | + |
| 1020 | + # Raise warning for standard->enhanced policy |
| 1021 | + existing_policy_type = enhanced_policy_type if existing_policy.properties.policy_type.lower() == "v2" else standard_policy_type |
| 1022 | + new_policy_type = enhanced_policy_type if policy.properties.policy_type.lower() == "v2" else standard_policy_type |
| 1023 | + if (new_policy_type == enhanced_policy_type and existing_policy_type == existing_policy_type): |
| 1024 | + logger.warning('Upgrading to enhanced policy can incur additional charges. Once upgraded to the enhanced ' |
| 1025 | + 'policy, it is not possible to revert back to the standard policy.') |
| 1026 | + |
1017 | 1027 | # Update policy
|
1018 | 1028 | result = client.create_or_update(vault_name, resource_group_name, fabric_name,
|
1019 | 1029 | container_uri, item_uri, vm_item, cls=cust_help.get_pipeline_response)
|
|
0 commit comments