Skip to content

Commit 08a27e3

Browse files
mayankmani-sdefernandofloresgRohitcodes28rexemin
authored
[Enhancement][zos_data_set]Support for NOSCRATCH option when deleting datasets (#2210)
* add nonscratch parameter in main module * added support for nonscratch in module_utils * added test case * added fragments * FIXED * changed in fragments * Updated changelogs * reviewed comments * fixed * removed print statement * removed extra validation * [Enabler] [2053] [zos_data_set] Add_support_for_noscratch_option (#2202) * add nonscratch parameter in main module * added support for nonscratch in module_utils * added test case * added fragments * FIXED * changed in fragments * Updated changelogs * reviewed comments * fixed * removed print statement * removed extra validation --------- Co-authored-by: Fernando Flores <[email protected]> * [Enhancement] SYSIN DDs support for zos_job_output (#2207) * adding sysin support * Adding the test case * changelog addition * sanity issue resolving * removing redundant files * review comments incorporation * [Tests] [Ansible 2.19] Fix conditionals failures when executing playbooks in test cases (#2213) * editing and testing modules * changelog addition * Update and rename 2202-zos_data_set-Support-noscratch-options.yml to 2210-zos_data_set-Support-noscratch-options.yml as this branch was already merged in staging now creating new PR to merge in dev so i chnage the pull request no in fragments * [zos_job_submit] Fix TYPRUN=COPY, TYPRUN=HOLD and TYPRUN=JCLHOLD handling (#2229) * Fix TYPRUN handling * Add changelog fragment * Remove commented code * Update module documentation * Updated changelogs * Updated changelogs * Update zos_job_submit calls * Corrected some more zos_job_submit calls * Updated test * Updated changelogs * Updated changelogs * Added comment in tests * Updated wrong zos_copy call --------- Co-authored-by: Fernando Flores <[email protected]> Co-authored-by: Rohitash Goyal <[email protected]> Co-authored-by: Alex Moreno <[email protected]>
1 parent ae042ba commit 08a27e3

File tree

10 files changed

+291
-83
lines changed

10 files changed

+291
-83
lines changed

changelogs/fragments/2207-SYSIN-support-zos_job_output.yml

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
minor_changes:
2+
- zos_data_set - Adds `noscratch` option to allow uncataloging
3+
a data set without deleting it from the volume's VTOC.
4+
(https://github.com/ansible-collections/ibm_zos_core/pull/2210)
5+
trivial:
6+
- data_set - Internal updates to support the noscratch option.
7+
https://github.com/ansible-collections/ibm_zos_core/pull/2210)
8+
- test_zos_data_set_func - added test case to verify the `noscratch` option
9+
functionality in zos_data_set module.
10+
(https://github.com/ansible-collections/ibm_zos_core/pull/2210).
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1+
minor_changes:
2+
- zos_job_output - Adds support to query SYSIN DDs from a job with new option input.
3+
(https://github.com/ansible-collections/ibm_zos_core/pull/2215)
14
trivial:
25
- test_zos_copy_func.py - modified test case `test_job_script_async`
36
to resolve porting issues to ansible 2.19.
4-
(https://github.com/ansible-collections/ibm_zos_core/pull/2213).
7+
(https://github.com/ansible-collections/ibm_zos_core/pull/2215).
58

69
- test_zos_job_submit_func.py - modified test case `test_job_submit_async`
710
to resolve porting issues to ansible 2.19.
8-
(https://github.com/ansible-collections/ibm_zos_core/pull/2213).
11+
(https://github.com/ansible-collections/ibm_zos_core/pull/2215).
912

1013
- test_zos_script_func.py - modified test case `test_job_script_async`
1114
to resolve porting issues to ansible 2.19.
12-
(https://github.com/ansible-collections/ibm_zos_core/pull/2213).
15+
(https://github.com/ansible-collections/ibm_zos_core/pull/2215).
1316

1417
- test_zos_unarchive_func.py - modified test case `test_zos_unarchive_async`
1518
to resolve porting issues to ansible 2.19.
16-
(https://github.com/ansible-collections/ibm_zos_core/pull/2213).
19+
(https://github.com/ansible-collections/ibm_zos_core/pull/2215).

docs/source/modules/zos_job_submit.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,9 @@ jobs
765765

766766
Job status `TYPRUN=SCAN` indicates that the job had the TYPRUN parameter with SCAN option.
767767

768-
Job status `NOEXEC` indicates that the job had the TYPRUN parameter with COPY option.
768+
Job status `TYPRUN=COPY` indicates that the job had the TYPRUN parameter with COPY option.
769+
770+
Job status `HOLD` indicates that the job had the TYPRUN parameter with either the HOLD or JCLHOLD options.
769771

770772
Jobs where status can not be determined will result in None (NULL).
771773

plugins/action/zos_job_submit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def run(self, tmp=None, task_vars=None):
150150
src=source_full,
151151
dest=dest_file,
152152
mode="0666",
153-
force=True,
153+
replace=True,
154154
encoding=module_args.get('encoding'),
155155
remote_src=False,
156156
)

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

plugins/modules/zos_data_set.py

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,15 @@
298298
type: bool
299299
required: false
300300
default: false
301+
noscratch:
302+
description:
303+
- "When C(state=absent), specifies whether to keep the data set's entry in the VTOC."
304+
- If C(noscratch=True), the data set is uncataloged but not physically removed from the volume.
305+
The Data Set Control Block is not removed from the VTOC.
306+
- This is the equivalent of using C(NOSCRATCH) in an C(IDCAMS DELETE) command.
307+
type: bool
308+
required: false
309+
default: false
301310
volumes:
302311
description:
303312
- >
@@ -575,6 +584,15 @@
575584
type: bool
576585
required: false
577586
default: false
587+
noscratch:
588+
description:
589+
- "When C(state=absent), specifies whether to keep the data set's entry in the VTOC."
590+
- If C(noscratch=True), the data set is uncataloged but not physically removed from the volume.
591+
The Data Set Control Block is not removed from the VTOC.
592+
- This is the equivalent of using C(NOSCRATCH) in an C(IDCAMS DELETE) command.
593+
type: bool
594+
required: false
595+
default: false
578596
extended:
579597
description:
580598
- Sets the I(extended) attribute for Generation Data Groups.
@@ -734,6 +752,12 @@
734752
name: someds.name.here
735753
state: absent
736754
755+
- name: Uncatalog a data set but do not remove it from the volume.
756+
zos_data_set:
757+
name: someds.name.here
758+
state: absent
759+
noscratch: true
760+
737761
- name: Delete a data set if it exists. If data set not cataloged, check on volume 222222 for the data set, and then catalog and delete if found.
738762
zos_data_set:
739763
name: someds.name.here
@@ -1404,7 +1428,7 @@ def get_data_set_handler(**params):
14041428
)
14051429

14061430

1407-
def perform_data_set_operations(data_set, state, replace, tmp_hlq, force):
1431+
def perform_data_set_operations(data_set, state, replace, tmp_hlq, force, noscratch):
14081432
"""Calls functions to perform desired operations on
14091433
one or more data sets. Returns boolean indicating if changes were made.
14101434
@@ -1439,7 +1463,7 @@ def perform_data_set_operations(data_set, state, replace, tmp_hlq, force):
14391463
elif state == "absent" and data_set.data_set_type == "gdg":
14401464
changed = data_set.ensure_absent(force=force)
14411465
elif state == "absent":
1442-
changed = data_set.ensure_absent(tmp_hlq=tmp_hlq)
1466+
changed = data_set.ensure_absent(tmp_hlq=tmp_hlq, noscratch=noscratch)
14431467
elif state == "cataloged":
14441468
changed = data_set.ensure_cataloged(tmp_hlq=tmp_hlq)
14451469
elif state == "uncataloged":
@@ -1586,6 +1610,11 @@ def parse_and_validate_args(params):
15861610
required=False,
15871611
default=False,
15881612
),
1613+
noscratch=dict(
1614+
type="bool",
1615+
required=False,
1616+
default=False,
1617+
),
15891618
),
15901619
),
15911620
# For individual data set args
@@ -1676,6 +1705,11 @@ def parse_and_validate_args(params):
16761705
required=False,
16771706
default=False,
16781707
),
1708+
noscratch=dict(
1709+
type="bool",
1710+
required=False,
1711+
default=False,
1712+
),
16791713
mutually_exclusive=[
16801714
["batch", "name"],
16811715
# ["batch", "state"],
@@ -1788,6 +1822,11 @@ def run_module():
17881822
required=False,
17891823
default=False,
17901824
),
1825+
noscratch=dict(
1826+
type="bool",
1827+
required=False,
1828+
default=False,
1829+
),
17911830
),
17921831
),
17931832
# For individual data set args
@@ -1868,6 +1907,11 @@ def run_module():
18681907
required=False,
18691908
default=False
18701909
),
1910+
noscratch=dict(
1911+
type="bool",
1912+
required=False,
1913+
default=False
1914+
),
18711915
)
18721916
result = dict(changed=False, message="", names=[])
18731917

@@ -1895,6 +1939,8 @@ def run_module():
18951939
module.params["replace"] = None
18961940
if module.params.get("record_format") is not None:
18971941
module.params["record_format"] = None
1942+
if module.params.get("noscratch") is not None:
1943+
module.params["noscratch"] = None
18981944
elif module.params.get("type") is not None:
18991945
if module.params.get("type") in DATA_SET_TYPES_VSAM:
19001946
# For VSAM types set the value to nothing and let the code manage it
@@ -1921,6 +1967,7 @@ def run_module():
19211967
replace=data_set_params.get("replace"),
19221968
tmp_hlq=data_set_params.get("tmp_hlq"),
19231969
force=data_set_params.get("force"),
1970+
noscratch=data_set_params.get("noscratch"),
19241971
)
19251972
result["changed"] = result["changed"] or current_changed
19261973
except Exception as e:

0 commit comments

Comments
 (0)