Skip to content

Commit d038816

Browse files
ghernadirp-
authored andcommitted
MultiSnap: Add support for new API
Create snapshots of multiple resources in one API
1 parent 9b0c363 commit d038816

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

linstor-common

linstor/linstorapi.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3203,6 +3203,35 @@ def snapshot_create(self, node_names, rsc_name, snapshot_name, async_msg=False):
32033203
body
32043204
)
32053205

3206+
def snapshot_create_multi(self, node_names, rsc_names, snapshot_name):
3207+
"""
3208+
Create a snapshot.
3209+
3210+
:param list[str] node_names: Names of the nodes, if empty or None snapshot will be created on all nodes.
3211+
:param list[str] rsc_names: Name of the resources.
3212+
:param str snapshot_name: Name of the new snapshot.
3213+
:return: A list containing ApiCallResponses from the controller.
3214+
:rtype: list[ApiCallResponse]
3215+
"""
3216+
self._require_version("1.18.0")
3217+
3218+
snapshots = []
3219+
for rsc_name in rsc_names:
3220+
snap = {"name": snapshot_name, "resource_name": rsc_name}
3221+
if node_names:
3222+
snap["nodes"] = node_names
3223+
snapshots.append(snap)
3224+
3225+
body = {
3226+
"snapshots": snapshots
3227+
}
3228+
3229+
return self._rest_request(
3230+
apiconsts.API_CRT_SNAPSHOT_MULTI,
3231+
"POST", "/v1/actions/snapshot/multi",
3232+
body
3233+
)
3234+
32063235
def snapshot_volume_definition_restore(self, from_resource, from_snapshot, to_resource):
32073236
"""
32083237
Create volume definitions from a snapshot.

linstor/resource.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ class Volume(object):
6868
6969
:param size: String parsable by linstor.SizeCalc or size in bytes.
7070
"""
71+
7172
def __init__(self, size):
7273
# external properties
7374
self._size = self._size_to_bytes(size)

0 commit comments

Comments
 (0)