-
Notifications
You must be signed in to change notification settings - Fork 50
Add support for snapshot policies #223
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://cloudstack.apache.org/api/apidocs-4.21/apis/updateSnapshotPolicy.html
Suppose i change max_snaps via terraform after a resource is deployed
its not actually changed in the cloudstack , the terraform.tfstate contains
"max_snaps": 2,
resource "cloudstack_snapshot_policy" "frequent_backup" {
volume_id = "fc2e91ee-699c-489d-b005-f0afafdcbf41"
interval_type = "HOURLY"
max_snaps = 2
schedule = "2"
timezone = "UTC"
tags = {
Environment = "demo"
}
}
terraform apply
cloudstack_snapshot_policy.frequent_backup_DAILY: Refreshing state... [id=b070fba3-f751-4528-989b-785cf445d5bb]
cloudstack_snapshot_policy.frequent_backup: Refreshing state... [id=b070fba3-f751-4528-989b-785cf445d5bb]
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
~ update in-place
Terraform will perform the following actions:
# cloudstack_snapshot_policy.frequent_backup will be updated in-place
~ resource "cloudstack_snapshot_policy" "frequent_backup" {
id = "b070fba3-f751-4528-989b-785cf445d5bb"
~ max_snaps = 1 -> 2
~ schedule = "00:00" -> "2"
tags = {
"Environment" = "demo"
}
~ zone_ids = [
- "05d9863d-bd94-41c2-bba8-251aab44637a",
]
# (3 unchanged attributes hidden)
}
# cloudstack_snapshot_policy.frequent_backup_DAILY will be updated in-place
~ resource "cloudstack_snapshot_policy" "frequent_backup_DAILY" {
id = "b070fba3-f751-4528-989b-785cf445d5bb"
tags = {
"Environment" = "demo"
}
~ zone_ids = [
- "05d9863d-bd94-41c2-bba8-251aab44637a",
]
# (5 unchanged attributes hidden)
}
Plan: 0 to add, 2 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
cloudstack_snapshot_policy.frequent_backup_DAILY: Modifying... [id=b070fba3-f751-4528-989b-785cf445d5bb]
cloudstack_snapshot_policy.frequent_backup: Modifying... [id=b070fba3-f751-4528-989b-785cf445d5bb]
cloudstack_snapshot_policy.frequent_backup: Modifications complete after 1s [id=b070fba3-f751-4528-989b-785cf445d5bb]
cloudstack_snapshot_policy.frequent_backup_DAILY: Modifications complete after 1s [id=b070fba3-f751-4528-989b-785cf445d5bb]
Apply complete! Resources: 0 added, 2 changed, 0 destroyed.
Outputs:
deployment_summary = {
"snapshot_policies" = {
"daily_policy_id" = "b070fba3-f751-4528-989b-785cf445d5bb"
"hourly_policy_id" = "b070fba3-f751-4528-989b-785cf445d5bb"
}
}
…-provider into support-snapshot-policies
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, tested manually, was able to create snapshot policy and also update it
resource "cloudstack_snapshot_policy" "frequent_backup" {
volume_id = "fc2e91ee-699c-489d-b005-f0afafdcbf41"
interval_type = "HOURLY"
max_snaps = 2
schedule = "1"
timezone = "UTC"
tags = {
Environment = "demo"
}
}
resource "cloudstack_snapshot_policy" "frequent_backup_DAILY" {
volume_id = "fc2e91ee-699c-489d-b005-f0afafdcbf41"
interval_type = "DAILY"
max_snaps = 3
schedule = "00:00"
timezone = "UTC"
tags = {
Environment = "demo"
}
}
output "deployment_summary" {
description = "Summary of deployed resources"
value = {
snapshot_policies = {
hourly_policy_id = cloudstack_snapshot_policy.frequent_backup.id
daily_policy_id = cloudstack_snapshot_policy.frequent_backup_DAILY.id
}
}
}
terraform apply
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
# cloudstack_snapshot_policy.frequent_backup will be created
+ resource "cloudstack_snapshot_policy" "frequent_backup" {
+ id = (known after apply)
+ interval_type = "HOURLY"
+ max_snaps = 1
+ schedule = "1"
+ tags = {
+ "Environment" = "demo"
}
+ timezone = "UTC"
+ volume_id = "fc2e91ee-699c-489d-b005-f0afafdcbf41"
}
# cloudstack_snapshot_policy.frequent_backup_DAILY will be created
+ resource "cloudstack_snapshot_policy" "frequent_backup_DAILY" {
+ id = (known after apply)
+ interval_type = "DAILY"
+ max_snaps = 1
+ schedule = "00:00"
+ tags = {
+ "Environment" = "demo"
}
+ timezone = "UTC"
+ volume_id = "fc2e91ee-699c-489d-b005-f0afafdcbf41"
}
Plan: 2 to add, 0 to change, 0 to destroy.
Changes to Outputs:
+ deployment_summary = {
+ snapshot_policies = {
+ daily_policy_id = (known after apply)
+ hourly_policy_id = (known after apply)
}
}
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
cloudstack_snapshot_policy.frequent_backup_DAILY: Creating...
cloudstack_snapshot_policy.frequent_backup: Creating...
cloudstack_snapshot_policy.frequent_backup: Creation complete after 1s [id=a54f053a-48b4-48fe-94f8-f181446b8b28]
cloudstack_snapshot_policy.frequent_backup_DAILY: Creation complete after 1s [id=a54f053a-48b4-48fe-94f8-f181446b8b28]
Apply complete! Resources: 2 added, 0 changed, 0 destroyed.
Outputs:
deployment_summary = {
"snapshot_policies" = {
"daily_policy_id" = "a54f053a-48b4-48fe-94f8-f181446b8b28"
"hourly_policy_id" = "a54f053a-48b4-48fe-94f8-f181446b8b28"
}
}
╭─ ~/Desktop/cloudstack-India-demo/cloudstack-terraform copy ✔ ╱ 3s ╱ Azure subscription 1 ╱ 11:19:12 AM
╰─ terraform apply
cloudstack_snapshot_policy.frequent_backup_DAILY: Refreshing state... [id=a54f053a-48b4-48fe-94f8-f181446b8b28]
cloudstack_snapshot_policy.frequent_backup: Refreshing state... [id=a54f053a-48b4-48fe-94f8-f181446b8b28]
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
-/+ destroy and then create replacement
Terraform will perform the following actions:
# cloudstack_snapshot_policy.frequent_backup must be replaced
-/+ resource "cloudstack_snapshot_policy" "frequent_backup" {
~ id = "a54f053a-48b4-48fe-94f8-f181446b8b28" -> (known after apply)
~ interval_type = "DAILY" -> "HOURLY" # forces replacement
~ max_snaps = 1 -> 2 # forces replacement
~ schedule = "00:00" -> "1" # forces replacement
tags = {
"Environment" = "demo"
}
- zone_ids = [ # forces replacement
- "05d9863d-bd94-41c2-bba8-251aab44637a",
] -> null
# (2 unchanged attributes hidden)
}
# cloudstack_snapshot_policy.frequent_backup_DAILY must be replaced
-/+ resource "cloudstack_snapshot_policy" "frequent_backup_DAILY" {
~ id = "a54f053a-48b4-48fe-94f8-f181446b8b28" -> (known after apply)
~ max_snaps = 1 -> 3 # forces replacement
tags = {
"Environment" = "demo"
}
- zone_ids = [ # forces replacement
- "05d9863d-bd94-41c2-bba8-251aab44637a",
] -> null
# (4 unchanged attributes hidden)
}
Plan: 2 to add, 0 to change, 2 to destroy.
Changes to Outputs:
~ deployment_summary = {
~ snapshot_policies = {
~ daily_policy_id = "a54f053a-48b4-48fe-94f8-f181446b8b28" -> (known after apply)
~ hourly_policy_id = "a54f053a-48b4-48fe-94f8-f181446b8b28" -> (known after apply)
}
}
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
cloudstack_snapshot_policy.frequent_backup: Destroying... [id=a54f053a-48b4-48fe-94f8-f181446b8b28]
cloudstack_snapshot_policy.frequent_backup_DAILY: Destroying... [id=a54f053a-48b4-48fe-94f8-f181446b8b28]
cloudstack_snapshot_policy.frequent_backup: Destruction complete after 0s
cloudstack_snapshot_policy.frequent_backup_DAILY: Destruction complete after 0s
cloudstack_snapshot_policy.frequent_backup: Creating...
cloudstack_snapshot_policy.frequent_backup_DAILY: Creating...
cloudstack_snapshot_policy.frequent_backup_DAILY: Creation complete after 1s [id=3c2f9ade-f66e-42eb-9947-a6f4d2342eef]
cloudstack_snapshot_policy.frequent_backup: Creation complete after 1s [id=3c2f9ade-f66e-42eb-9947-a6f4d2342eef]
Apply complete! Resources: 2 added, 0 changed, 2 destroyed.
Outputs:
deployment_summary = {
"snapshot_policies" = {
"daily_policy_id" = "3c2f9ade-f66e-42eb-9947-a6f4d2342eef"
"hourly_policy_id" = "3c2f9ade-f66e-42eb-9947-a6f4d2342eef"
}
}
@Pearl1594 could you please look at the acceptance tests |
@DaanHoogland could you please review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clgtm (thought smaller methods are always better ;)
Tested with following config: