Skip to content

Commit

Permalink
safety checks for protection rule expiry (#64) (#65)
Browse files Browse the repository at this point in the history
* safety checks for protection rule expiry

* safety checks for protection rule expiry while updating cache
  • Loading branch information
mayank271 committed Sep 1, 2021
1 parent 8ad8e08 commit 5c9395e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
16 changes: 10 additions & 6 deletions calm/dsl/cli/protection_policies.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,18 @@ def get_protection_policies(limit, offset, project_name, quiet):
rule_type = ""
if rule.get("remote_snapshot_retention_policy", {}):
rule_type = "Remote"
expiry = rule["remote_snapshot_retention_policy"][
"snapshot_expiry_policy"
]["multiple"]
expiry = (
rule["remote_snapshot_retention_policy"]
.get("snapshot_expiry_policy", {})
.get("multiple", "")
)
elif rule.get("local_snapshot_retention_policy", {}):
rule_type = "Local"
expiry = rule["local_snapshot_retention_policy"][
"snapshot_expiry_policy"
]["multiple"]
expiry = (
rule["local_snapshot_retention_policy"]
.get("snapshot_expiry_policy", {})
.get("multiple", "")
)
rule_name = rule["name"]
rule_uuid = rule["uuid"]
if not expiry:
Expand Down
16 changes: 10 additions & 6 deletions calm/dsl/db/table_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1539,14 +1539,18 @@ def sync(cls):
rule_type = ""
if rule.get("remote_snapshot_retention_policy", {}):
rule_type = "Remote"
expiry = rule["remote_snapshot_retention_policy"][
"snapshot_expiry_policy"
]["multiple"]
expiry = (
rule["remote_snapshot_retention_policy"]
.get("snapshot_expiry_policy", {})
.get("multiple", "")
)
elif rule.get("local_snapshot_retention_policy", {}):
rule_type = "Local"
expiry = rule["local_snapshot_retention_policy"][
"snapshot_expiry_policy"
]["multiple"]
expiry = (
rule["local_snapshot_retention_policy"]
.get("snapshot_expiry_policy", {})
.get("multiple", "")
)
rule_name = rule["name"]
rule_uuid = rule["uuid"]
cls.create_entry(
Expand Down

0 comments on commit 5c9395e

Please sign in to comment.