Skip to content

Commit 70e4784

Browse files
author
Philippe
authored
Merge pull request #43 from openvstorage/cleanup_of_vdisks
Cleanup of vdisks
2 parents f64a240 + 2a66be8 commit 70e4784

File tree

2 files changed

+25
-15
lines changed

2 files changed

+25
-15
lines changed

remove/vdisk.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,24 @@ class VDiskRemover(object):
3030
def __init__(self):
3131
pass
3232

33+
@staticmethod
34+
def remove_vdisks_with_structure(vdisks):
35+
"""
36+
Remove many vdisks at once. Will keep the parent structure in mind
37+
:param vdisks: list of vdisks
38+
:return:
39+
"""
40+
removed_guids = []
41+
for vdisk in vdisks:
42+
if vdisk.guid in removed_guids:
43+
continue
44+
if len(vdisk.child_vdisks_guids) > 0:
45+
for vdisk_child_guid in vdisk.child_vdisks_guids:
46+
VDiskRemover.remove_vdisk(vdisk_child_guid)
47+
removed_guids.append(vdisk_child_guid)
48+
VDiskRemover.remove_vdisk(vdisk.guid)
49+
removed_guids.append(vdisk.guid)
50+
3351
@staticmethod
3452
def remove_snapshot(snapshot_guid, vdisk_name, vpool_name, api, timeout=REMOVE_SNAPSHOT_TIMEOUT):
3553
"""

setup/vdisk.py

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,7 @@ def create_snapshot(snapshot_name, vdisk_name, vpool_name, api, consistent=True,
8686
def create_vdisk(vdisk_name, vpool_name, size, storagerouter_ip, api, timeout=CREATE_VDISK_TIMEOUT):
8787
"""
8888
Create a new vDisk on a certain vPool/storagerouter
89-
90-
:param vdisk_name: location of a vdisk on a vpool
91-
(e.g. /mnt/vpool/test.raw = test.raw, /mnt/vpool/volumes/test.raw = volumes/test.raw )
89+
:param vdisk_name: location of a vdisk on a vpool (e.g. /mnt/vpool/test.raw = test.raw, /mnt/vpool/volumes/test.raw = volumes/test.raw )
9290
:type vdisk_name: str
9391
:param vpool_name: name of a existing vpool
9492
:type vpool_name: str
@@ -171,14 +169,11 @@ def create_clone(vdisk_name, vpool_name, new_vdisk_name, storagerouter_ip, api,
171169
timeout=CREATE_CLONE_TIMEOUT):
172170
"""
173171
Create a new vDisk on a certain vPool/storagerouter
174-
175-
:param vdisk_name: location of a vdisk on a vpool
176-
(e.g. /mnt/vpool/test.raw = test.raw, /mnt/vpool/volumes/test.raw = volumes/test.raw )
172+
:param vdisk_name: location of a vdisk on a vpool (e.g. /mnt/vpool/test.raw = test.raw, /mnt/vpool/volumes/test.raw = volumes/test.raw )
177173
:type vdisk_name: str
178174
:param vpool_name: name of a existing vpool
179175
:type vpool_name: str
180-
:param new_vdisk_name: location of the NEW vdisk on the vpool
181-
(e.g. /mnt/vpool/test.raw = test.raw, /mnt/vpool/volumes/test.raw = volumes/test.raw )
176+
:param new_vdisk_name: location of the NEW vdisk on the vpool (e.g. /mnt/vpool/test.raw = test.raw, /mnt/vpool/volumes/test.raw = volumes/test.raw )
182177
:type new_vdisk_name: str
183178
:param storagerouter_ip: ip address of a existing storagerouter where the clone will be deployed
184179
:type storagerouter_ip: str
@@ -249,7 +244,6 @@ def set_vdisk_as_template(vdisk_name, vpool_name, api, timeout=SET_VDISK_AS_TEMP
249244
:type api: ci.helpers.api.OVSClient
250245
:param timeout: time to wait for the task to complete
251246
"""
252-
253247
# fetch the requirements
254248
vdisk = VDiskHelper.get_vdisk_by_name(vdisk_name, vpool_name)
255249

@@ -273,22 +267,20 @@ def create_from_template(vdisk_name, vpool_name, new_vdisk_name, storagerouter_i
273267
"""
274268
Create a new vDisk on a certain vPool/storagerouter
275269
Set a existing vDisk as vTemplate
276-
277-
:param vdisk_name: location of a vdisk on a vpool
278-
(e.g. /mnt/vpool/test.raw = test.raw, /mnt/vpool/volumes/test.raw = volumes/test.raw )
270+
:param vdisk_name: location of a vdisk on a vpool(e.g. /mnt/vpool/test.raw = test.raw, /mnt/vpool/volumes/test.raw = volumes/test.raw )
279271
:type vdisk_name: str
280272
:param vpool_name: name of a existing vpool
281273
:type vpool_name: str
282-
:param new_vdisk_name: location of the NEW vdisk on the vpool
283-
(e.g. /mnt/vpool/test.raw = test.raw, /mnt/vpool/volumes/test.raw = volumes/test.raw )
274+
:param new_vdisk_name: location of the NEW vdisk on the vpool (e.g. /mnt/vpool/test.raw = test.raw, /mnt/vpool/volumes/test.raw = volumes/test.raw )
284275
:type new_vdisk_name: str
285276
:param storagerouter_ip: ip address of a existing storagerouter where the clone will be deployed
286277
:type storagerouter_ip: str
287278
:param api: specify a valid api connection to the setup
288279
:type api: ci.helpers.api.OVSClient
289280
:param timeout: time to wait for the task to complete
281+
:return: dict with info about the new vdisk {'vdisk_guid': new_vdisk.guid, 'name': new_vdisk.name, 'backingdevice': devicename}
282+
:rtype: dict
290283
"""
291-
292284
# fetch the requirements
293285
vdisk = VDiskHelper.get_vdisk_by_name(vdisk_name, vpool_name)
294286
storagerouter_guid = StoragerouterHelper.get_storagerouter_by_ip(storagerouter_ip).guid

0 commit comments

Comments
 (0)