Skip to content
Open
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
41 changes: 40 additions & 1 deletion PyPowerStore/protection.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# Snapshot Rule
SNAPSHOT_RULE_DETAILS_QUERY = {
"select": "id,name,interval,days_of_week,time_of_day,desired_retention,"
"policies(id,name)",
"is_secure,policies(id,name)",
}
# Replication Rule
REPLICATION_RULE_DETAILS_QUERY = {
Expand Down Expand Up @@ -113,6 +113,7 @@ def create_volume_snapshot(
description=None,
performance_policy_id=None,
expiration_timestamp=None,
is_secure=None,
):
"""Create a snapshot of a volume.

Expand All @@ -135,6 +136,9 @@ def create_volume_snapshot(
'12:31:9999T23:59:59.999Z' to set an
expiration to never expire.
:type expiration_timestamp: str
:param is_secure: (optional) Indicates whether the snapshot is a
secure snapshot.
:type is_secure: bool
:return: Volume snapshot details.
:rtype: dict
"""
Expand All @@ -144,6 +148,7 @@ def create_volume_snapshot(
description=description,
performance_policy_id=performance_policy_id,
expiration_timestamp=expiration_timestamp,
is_secure=is_secure,
)
response = self.rest_client.request(
constants.POST,
Expand All @@ -156,6 +161,7 @@ def create_volume_snapshot(

def modify_volume_snapshot(
self, snapshot_id, name=None, description=None, expiration_timestamp=None,
is_secure=None,
):
"""Modify a snapshot of a volume.

Expand All @@ -172,6 +178,10 @@ def modify_volume_snapshot(
the maximum timestamp value of
'12:31:9999T23:59:59.999Z' to set an
expiration to never expire.
:param is_secure: (optional) Indicates whether the snapshot is a
secure snapshot. Once set to True, this is a one-way
operation and cannot be reverted.
:type is_secure: bool
:return: Volume snapshot details.
:rtype: dict
"""
Expand All @@ -180,6 +190,7 @@ def modify_volume_snapshot(
name=name,
description=description,
expiration_timestamp=expiration_timestamp,
is_secure=is_secure,
)
self.rest_client.request(
constants.PATCH,
Expand Down Expand Up @@ -236,6 +247,7 @@ def get_volume_group_snapshot_details(self, snapshot_id):

def create_volume_group_snapshot(
self, volume_group_id, name=None, description=None, expiration_timestamp=None,
is_secure=None,
):
"""Create a snapshot of a volume group.

Expand All @@ -256,6 +268,9 @@ def create_volume_group_snapshot(
yyyy-MM-dd'T'HH:mm:ss.SSSZ. By default,
expiration time will not be set.
:type expiration_timestamp: str
:param is_secure: (optional) Indicates whether the snapshot is a
secure snapshot.
:type is_secure: bool
:return: Volume Group snapshot details.
:rtype: dict
"""
Expand All @@ -264,6 +279,7 @@ def create_volume_group_snapshot(
name=name,
description=description,
expiration_timestamp=expiration_timestamp,
is_secure=is_secure,
)
response = self.rest_client.request(
constants.POST,
Expand All @@ -278,6 +294,7 @@ def create_volume_group_snapshot(

def modify_volume_group_snapshot(
self, snapshot_id, name=None, description=None, expiration_timestamp=None,
is_secure=None,
):
"""Modify a snapshot of a volume group.

Expand All @@ -296,6 +313,10 @@ def modify_volume_group_snapshot(
is yyyy-MM-dd'T'HH:mm:ssZ or
yyyy-MM-dd'T'HH:mm:ss.SSSZ. By default,
expiration time will not be set.
:param is_secure: (optional) Indicates whether the snapshot is a
secure snapshot. Once set to True, this is a one-way
operation and cannot be reverted.
:type is_secure: bool
:return: Volume snapshot details.
:rtype: dict
"""
Expand All @@ -304,6 +325,7 @@ def modify_volume_group_snapshot(
name=name,
description=description,
expiration_timestamp=expiration_timestamp,
is_secure=is_secure,
)
self.rest_client.request(
constants.PATCH,
Expand Down Expand Up @@ -386,6 +408,7 @@ def get_snapshot_rule_details(self, snapshot_rule_id):

def create_snapshot_rule_by_interval(
self, name, desired_retention, interval, days_of_week=None,
is_secure=None,
):
"""Create a new snapshot rule to take snapshots with time interval
between.
Expand All @@ -407,6 +430,9 @@ def create_snapshot_rule_by_interval(
should be applied. Applies only for rules where
the interval parameter is set.
:type days_of_week: list[str]
:param is_secure: (optional) Indicates whether snapshots created by
this rule will be secure snapshots.
:type is_secure: bool
:return: Snapshot rule details.
:rtype: dict
"""
Expand All @@ -416,10 +442,12 @@ def create_snapshot_rule_by_interval(
desired_retention=desired_retention,
interval=interval,
days_of_week=days_of_week,
is_secure=is_secure,
)

def create_snapshot_rule_by_time_of_day(
self, name, desired_retention, time_of_day, days_of_week=None,
is_secure=None,
):
"""Create a new snapshot rule to take daily snapshots at the specified
time of day.
Expand All @@ -439,6 +467,9 @@ def create_snapshot_rule_by_time_of_day(
should be applied. Applies only for rules where
the time_of_day parameter is set.
:type days_of_week: list[str]
:param is_secure: (optional) Indicates whether snapshots created by
this rule will be secure snapshots.
:type is_secure: bool
:return: Snapshot rule details.
:rtype: dict
"""
Expand All @@ -448,6 +479,7 @@ def create_snapshot_rule_by_time_of_day(
desired_retention=desired_retention,
time_of_day=time_of_day,
days_of_week=days_of_week,
is_secure=is_secure,
)

def _create_snapshot_rule(self, **kwargs):
Expand All @@ -474,6 +506,7 @@ def modify_snapshot_rule(
interval=None,
time_of_day=None,
days_of_week=None,
is_secure=None,
):
"""Modify a snapshot rule. If the rule is associated with a policy that
is currently applied to a storage resource, the modified rule is
Expand Down Expand Up @@ -503,6 +536,9 @@ def modify_snapshot_rule(
should be applied. Applies only for rules where
the time_of_day parameter is set.
:type days_of_week: list[str]
:param is_secure: (optional) Indicates whether snapshots created by
this rule will be secure snapshots.
:type is_secure: bool
:return: Snapshot rule details.
:rtype: dict
"""
Expand All @@ -513,6 +549,7 @@ def modify_snapshot_rule(
interval=interval,
time_of_day=time_of_day,
days_of_week=days_of_week,
is_secure=is_secure,
)
self.rest_client.request(
constants.PATCH,
Expand Down Expand Up @@ -1444,6 +1481,7 @@ def _prepare_create_modify_snapshot_payload(**kwargs):
"description",
"performance_policy_id",
"expiration_timestamp",
"is_secure",
):
if kwargs.get(argname) is not None:
payload[argname] = kwargs[argname]
Expand All @@ -1464,6 +1502,7 @@ def _prepare_create_modify_snapshot_rule_payload(**kwargs):
"interval",
"time_of_day",
"days_of_week",
"is_secure",
):
if kwargs.get(argname) is not None:
payload[argname] = kwargs[argname]
Expand Down
4 changes: 2 additions & 2 deletions PyPowerStore/utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
"creator_type, filesystem_type_l10n,"
"access_policy_l10n, locking_policy_l10n,"
"folder_rename_policy_l10n, access_type_l10n,"
"creator_type_l10n,nas_server(name,id),"
"creator_type_l10n,is_secure,nas_server(name,id),"
"protection_policy(name,id)",
}

Expand All @@ -191,7 +191,7 @@
"file_events_publishing_mode,"
"file_events_publishing_mode_l10n,"
"config_type, config_type_l10n,flr_attributes,"
"host_io_size,host_io_size_l10n",
"is_secure,host_io_size,host_io_size_l10n",
}

FILESYSTEM_PRIME = [
Expand Down
Loading