583
583
string, list of strings and when using a YAML block indicator.
584
584
required: true
585
585
type: raw
586
+ reserved_cols:
587
+ description:
588
+ - Determines how many columns at the beginning of the content are reserved with
589
+ empty spaces.
590
+ type: int
591
+ required: false
592
+ default: 2
586
593
return_content:
587
594
description:
588
595
- Determines how content should be returned to the user.
1195
1202
string, list of strings and when using a YAML block indicator.
1196
1203
required: true
1197
1204
type: raw
1205
+ reserved_cols:
1206
+ description:
1207
+ - Determines how many columns at the beginning of the content are reserved with
1208
+ empty spaces.
1209
+ type: int
1210
+ required: false
1211
+ default: 2
1198
1212
return_content:
1199
1213
description:
1200
1214
- Determines how content should be returned to the user.
1607
1621
VOLUMES(222222) -
1608
1622
UNIQUE)
1609
1623
1624
+ - name: Simple FTP connection using frist and second columns.
1625
+ zos_mvs_raw:
1626
+ program_name: AMAPDUPL
1627
+ auth: true
1628
+ dds:
1629
+ - dd_output:
1630
+ dd_name: sysprint
1631
+ return_content:
1632
+ type: text
1633
+ - dd_data_set:
1634
+ dd_name: SYSUT1
1635
+ data_set_name: myhlq.ds1.output
1636
+ disposition: shr
1637
+ - dd_input:
1638
+ dd_name: sysin
1639
+ reserved_cols: 0
1640
+ content: |
1641
+ USERID=anonymous
1642
+ PASSWORD=anonymous
1643
+ TARGET_SYS=testcase.boulder.ibm.com
1644
+ TARGET_DSN=wessamp.bigfile
1645
+
1610
1646
- name: List data sets matching pattern in catalog,
1611
1647
save output to a new generation of gdgs.
1612
1648
zos_mvs_raw:
@@ -1785,6 +1821,7 @@ def run_module():
1785
1821
1786
1822
dd_input_base = dict (
1787
1823
content = dict (type = "raw" , required = True ),
1824
+ reserved_cols = dict (type = "int" , required = False , default = 2 ),
1788
1825
return_content = dict (
1789
1826
type = "dict" ,
1790
1827
options = dict (
@@ -2045,7 +2082,8 @@ def parse_and_validate_args(params):
2045
2082
)
2046
2083
2047
2084
dd_input_base = dict (
2048
- content = dict (type = dd_content , required = True ),
2085
+ content = dict (type = dd_content , required = True , dependencies = ["reserved_cols" ]),
2086
+ reserved_cols = dict (type = "int" , required = False , default = 2 ),
2049
2087
return_content = dict (
2050
2088
type = "dict" ,
2051
2089
options = dict (
@@ -2301,15 +2339,16 @@ def dd_content(contents, dependencies):
2301
2339
return None
2302
2340
if contents is not None :
2303
2341
# Empty string can be passed for content but not modify to ensure proper entry
2342
+ spaces = dependencies .get ("reserved_cols" )
2304
2343
if len (contents ) > 0 :
2305
- contents = modify_contents (contents )
2344
+ contents = modify_contents (contents , spaces )
2306
2345
return contents
2307
2346
if isinstance (contents , list ):
2308
2347
return "\n " .join (contents )
2309
2348
return contents
2310
2349
2311
2350
2312
- def modify_contents (contents ):
2351
+ def modify_contents (contents , spaces ):
2313
2352
"""Return the content of dd_input to a valid form for a JCL program.
2314
2353
2315
2354
Parameters
@@ -2324,18 +2363,20 @@ def modify_contents(contents):
2324
2363
"""
2325
2364
if not isinstance (contents , list ):
2326
2365
contents = list (contents .split ("\n " ))
2327
- contents = prepend_spaces (contents )
2366
+ contents = prepend_spaces (contents , spaces )
2328
2367
contents = "\n " .join (contents )
2329
2368
return contents
2330
2369
2331
2370
2332
- def prepend_spaces (lines ):
2371
+ def prepend_spaces (lines , spaces = 2 ):
2333
2372
"""Return the array with two spaces at the beggining.
2334
2373
2335
2374
Parameters
2336
2375
----------
2337
2376
lines : list
2338
2377
The list with a line of a program.
2378
+ spaces : int
2379
+ The number of columns to add as left padding to the content.
2339
2380
2340
2381
Raises
2341
2382
-------
@@ -2351,17 +2392,15 @@ def prepend_spaces(lines):
2351
2392
for index , line in enumerate (lines ):
2352
2393
if len (line ) > 0 :
2353
2394
if len (line ) > 80 :
2354
- msg = """Length of line {0} is over 80 characters. The maximum length allowed is 80 characters, including 2 spaces at the beginning.
2355
- If the two spaces are not present, the module will add them to ensure columns 1 and 2 are blank. """
2395
+ msg = """Length of line {0} is over 80 characters. The maximum length allowed is 80 characters. """
2356
2396
module .fail_json (msg = msg .format (line ))
2357
2397
else :
2358
- if len (line ) > 1 and line [0 ] != " " and line [1 ] != " " :
2359
- if len (line ) > 78 :
2360
- msg = """Length of line {0} is over 80 characters. The maximum length allowed is 80 characters, including 2 spaces at the beginning.
2361
- If the two spaces are not present, the module will add them to ensure columns 1 and 2 are blank. """
2362
- module .fail_json (msg = msg .format (line ))
2363
- else :
2364
- lines [index ] = " {0}" .format (line )
2398
+ len_line = len (line )
2399
+ lines [index ] = line .rjust (len_line + spaces , " " )
2400
+ if len (lines [index ]) > 80 :
2401
+ msg = """Length of line {0} is over 80 characters. The maximum length allowed is 80 characters. Including the spaces at the beginning.
2402
+ Be aware that the module has reserved {1} columns to the left for JCL processing this value can be modified if the program allows for it."""
2403
+ module .fail_json (msg = msg .format (line , spaces ))
2365
2404
return lines
2366
2405
2367
2406
0 commit comments