185
185
186
186
import string
187
187
import math
188
+ import traceback
189
+
188
190
from ansible_collections .ibm .ibm_zos_core .plugins .module_utils .data_set import is_member
189
191
from ansible_collections .ibm .ibm_zos_cics .plugins .module_utils ._data_set import (
190
192
MEGABYTES ,
196
198
WARM ,
197
199
DataSet
198
200
)
199
- from ansible_collections .ibm .ibm_zos_cics .plugins .module_utils ._data_set_utils import _read_data_set_content , _write_jcl_to_data_set
201
+ from ansible_collections .ibm .ibm_zos_cics .plugins .module_utils ._data_set_utils import _read_data_set_content
200
202
from ansible_collections .ibm .ibm_zos_core .plugins .module_utils .dd_statement import DatasetDefinition
201
203
from ansible_collections .ibm .ibm_zos_cics .plugins .module_utils ._jcl_helper import (
202
204
JCLHelper , DLM , DD_INSTREAM , CONTENT , END_INSTREAM , JOB_CARD , EXECS , JOB_NAME , DDS , NAME
203
205
)
204
- from ansible_collections .ibm .ibm_zos_cics .plugins .module_utils ._response import MVSExecutionException
206
+ from ansible_collections .ibm .ibm_zos_cics .plugins .module_utils ._response import (
207
+ MVSExecutionException ,
208
+ _execution
209
+ )
205
210
from ansible_collections .ibm .ibm_zos_cics .plugins .module_utils ._data_set_utils import _run_listds
206
211
212
+ from ansible_collections .ibm .ibm_zos_core .plugins .module_utils .import_handler import (
213
+ ZOAUImportError
214
+ )
215
+
216
+ try :
217
+ from zoautil_py import datasets , exceptions
218
+ except Exception :
219
+ # Use ibm_zos_core's approach to handling zoautil_py imports so sanity tests pass
220
+ datasets = ZOAUImportError (traceback .format_exc ())
221
+ exceptions = ZOAUImportError (traceback .format_exc ())
222
+
223
+ from ansible_collections .ibm .ibm_zos_cics .plugins .module_utils ._response import (
224
+ MVSExecutionException ,
225
+ )
226
+
207
227
208
228
DFHSTART = "dfhstart"
209
229
SPACE_PRIMARY_DEFAULT = 5
@@ -354,7 +374,7 @@ def create_data_set(self): # type: () -> None
354
374
primary_unit = self .primary_unit ,
355
375
secondary_unit = self .secondary_unit ,
356
376
volumes = self .volumes ,
357
- block_size = 4096 ,
377
+ block_size = 32720 ,
358
378
record_length = 80 ,
359
379
record_format = "FB" ,
360
380
disposition = "NEW" ,
@@ -373,7 +393,7 @@ def generate_jcl(self):
373
393
374
394
def write_jcl (self ):
375
395
try :
376
- jcl_writer_execution = _write_jcl_to_data_set (self .jcl , self .name )
396
+ jcl_writer_execution = self . _write_jcl_to_data_set (self .jcl , self .name )
377
397
self .executions .extend (jcl_writer_execution )
378
398
self .changed = True
379
399
except MVSExecutionException as e :
@@ -671,6 +691,35 @@ def _find_sit_parm_key(input_string):
671
691
else :
672
692
return None
673
693
694
+ @staticmethod
695
+ def _write_jcl_to_data_set (jcl , data_set_name ):
696
+ """Writes generated JCL content to the specified data set
697
+ """
698
+ executions = []
699
+
700
+ try :
701
+ rc = datasets .write (data_set_name , jcl )
702
+ # If rc != 0, ZOAU raises an exception
703
+ executions .append (
704
+ _execution (
705
+ name = "Copy JCL contents to data set" ,
706
+ rc = rc ,
707
+ stdout = "" ,
708
+ stderr = ""
709
+ )
710
+ )
711
+ except exceptions .DatasetWriteException as e :
712
+ raise MVSExecutionException ("Failed to copy JCL content to data set" , [
713
+ _execution (
714
+ name = "Copy JCL contents to data set" ,
715
+ rc = e .response .rc ,
716
+ stdout = e .response .stdout_response ,
717
+ stderr = e .response .stderr_response
718
+ )
719
+ ])
720
+
721
+ return executions
722
+
674
723
@staticmethod
675
724
def init_argument_spec (): # type: () -> dict
676
725
return {
0 commit comments