Skip to content

Commit 6958310

Browse files
added support for nonscratch in module_utils
1 parent 7bf97fd commit 6958310

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

plugins/module_utils/data_set.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ def ensure_present(
241241
return True
242242

243243
@staticmethod
244-
def ensure_absent(name, volumes=None, tmphlq=None):
244+
def ensure_absent(name, volumes=None, tmphlq=None, noscratch=False):
245245
"""Deletes provided data set if it exists.
246246
247247
Parameters
@@ -252,13 +252,15 @@ def ensure_absent(name, volumes=None, tmphlq=None):
252252
The volumes the data set may reside on.
253253
tmphlq : str
254254
High Level Qualifier for temporary datasets.
255+
noscratch : bool
256+
If True, the data set is uncataloged but not physically removed from the volume.
255257
256258
Returns
257259
-------
258260
bool
259261
Indicates if changes were made.
260262
"""
261-
changed, present = DataSet.attempt_catalog_if_necessary_and_delete(name, volumes, tmphlq=tmphlq)
263+
changed, present = DataSet.attempt_catalog_if_necessary_and_delete(name, volumes, tmphlq=tmphlq, noscratch=noscratch)
262264
return changed
263265

264266
# ? should we do additional check to ensure member was actually created?
@@ -1003,7 +1005,7 @@ def attempt_catalog_if_necessary(name, volumes, tmphlq=None):
10031005
return present, changed
10041006

10051007
@staticmethod
1006-
def attempt_catalog_if_necessary_and_delete(name, volumes, tmphlq=None):
1008+
def attempt_catalog_if_necessary_and_delete(name, volumes, tmphlq=None, noscratch=False):
10071009
"""Attempts to catalog a data set if not already cataloged, then deletes
10081010
the data set.
10091011
This is helpful when a data set currently cataloged is not the data
@@ -1019,6 +1021,8 @@ def attempt_catalog_if_necessary_and_delete(name, volumes, tmphlq=None):
10191021
The volumes the data set may reside on.
10201022
tmphlq : str
10211023
High Level Qualifier for temporary datasets.
1024+
noscratch : bool
1025+
If True, the data set is uncataloged but not physically removed from the volume.
10221026
10231027
Returns
10241028
-------
@@ -1039,7 +1043,7 @@ def attempt_catalog_if_necessary_and_delete(name, volumes, tmphlq=None):
10391043
present = DataSet.data_set_cataloged(name, volumes, tmphlq=tmphlq)
10401044

10411045
if present:
1042-
DataSet.delete(name)
1046+
DataSet.delete(name,noscratch=noscratch)
10431047
changed = True
10441048
present = False
10451049
else:
@@ -1074,7 +1078,7 @@ def attempt_catalog_if_necessary_and_delete(name, volumes, tmphlq=None):
10741078

10751079
if present:
10761080
try:
1077-
DataSet.delete(name)
1081+
DataSet.delete(name, noscratch=noscratch)
10781082
except DatasetDeleteError:
10791083
try:
10801084
DataSet.uncatalog(name, tmphlq=tmphlq)
@@ -1101,14 +1105,14 @@ def attempt_catalog_if_necessary_and_delete(name, volumes, tmphlq=None):
11011105
present = DataSet.data_set_cataloged(name, volumes, tmphlq=tmphlq)
11021106

11031107
if present:
1104-
DataSet.delete(name)
1108+
DataSet.delete(name, noscratch=noscratch)
11051109
changed = True
11061110
present = False
11071111
else:
11081112
present = DataSet.data_set_cataloged(name, None, tmphlq=tmphlq)
11091113
if present:
11101114
try:
1111-
DataSet.delete(name)
1115+
DataSet.delete(name, noscratch=noscratch)
11121116
changed = True
11131117
present = False
11141118
except DatasetDeleteError:
@@ -1414,7 +1418,7 @@ def create(
14141418
return changed
14151419

14161420
@staticmethod
1417-
def delete(name):
1421+
def delete(name, noscratch=False):
14181422
"""A wrapper around zoautil_py
14191423
datasets.delete() to raise exceptions on failure.
14201424
@@ -1428,7 +1432,7 @@ def delete(name):
14281432
DatasetDeleteError
14291433
When data set deletion fails.
14301434
"""
1431-
rc = datasets.delete(name)
1435+
rc = datasets.delete(name, noscratch=noscratch)
14321436
if rc > 0:
14331437
raise DatasetDeleteError(name, rc)
14341438

@@ -2721,7 +2725,7 @@ def ensure_present(self, tmp_hlq=None, replace=False, force=False):
27212725
self.set_state("present")
27222726
return rc
27232727

2724-
def ensure_absent(self, tmp_hlq=None):
2728+
def ensure_absent(self, tmp_hlq=None, noscratch=False):
27252729
"""Removes the data set.
27262730
27272731
Parameters
@@ -2734,7 +2738,7 @@ def ensure_absent(self, tmp_hlq=None):
27342738
int
27352739
Indicates if changes were made.
27362740
"""
2737-
rc = DataSet.ensure_absent(self.name, self.volumes, tmphlq=tmp_hlq)
2741+
rc = DataSet.ensure_absent(self.name, self.volumes, tmphlq=tmp_hlq, noscratch=noscratch)
27382742
if rc == 0:
27392743
self.set_state("absent")
27402744
return rc

0 commit comments

Comments
 (0)