Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azure_rm_backupazurevm: add option for recovery point expiry time #1057

Merged
merged 3 commits into from
Jan 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions plugins/modules/azure_rm_backupazurevm.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@
- Backup Policy ID present under Recovery Service Vault mentioned in recovery_vault_name field.
required: true
type: str
recovery_point_expiry_time:
description:
- Recovery Point Expiry Time in UTC.
- This used if C(state) parameter is C(backup).
required: false
type: str
version_added: '1.15.0'
state:
description:
- Assert the state of the protection item.
Expand Down Expand Up @@ -98,6 +105,7 @@
resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/testVM'
backup_policy_id: '/subscriptions/00000000-0000-0000-0000-000000000000/ \
resourceGroups/myResourceGroup/providers/microsoft.recoveryservices/vaults/testVault/backupPolicies/ProdPolicy'
recovery_point_expiry_time: '2023-02-09T06:00:00Z'
state: 'backup'
'''

Expand Down Expand Up @@ -141,6 +149,9 @@ def __init__(self):
type='str',
required=True
),
recovery_point_expiry_time=dict(
type='str'
),
state=dict(
type='str',
default='create',
Expand All @@ -152,6 +163,7 @@ def __init__(self):
self.recovery_vault_name = None
self.resource_id = None
self.backup_policy_id = None
self.recovery_point_expiry_time = None
self.state = None

self.results = dict(changed=False)
Expand Down Expand Up @@ -206,12 +218,15 @@ def get_body(self):
}
}
elif self.state == 'backup':
return {
body = {
"properties": {
"objectType": "IaasVMBackupRequest",
"recoveryPointExpiryTimeInUTC": ""
"objectType": "IaasVMBackupRequest"
}
}
if self.recovery_point_expiry_time:
body["properties"]["recoveryPointExpiryTimeInUTC"] = self.recovery_point_expiry_time

return body
elif self.state == 'stop':
return {
"properties": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
recovery_vault_name: "{{ recovery_vault_name }}"
resource_id: "{{ resource_id }}"
backup_policy_id: "{{ backup_policy_id }}"
recovery_point_expiry_time: "2025-02-03T05:00:00Z"
state: "backup"
register: output

Expand Down