Skip to content

Commit b1179b3

Browse files
authored
[enabler] [1378] [zos_mount] special charactersupport (#1631)
* initial commit to get pr number * updated pr number, added innersource references to zos_mount * added dataset class to enable escape function * added a series of symbols to test-aggregate file creation This should test all scenarios for all 4 characters. * added escape call on generated data set name * trying to return base/non-escaped string to pass into mount. working around a better-arg-parser error. * added pretty print to test output to check on remount pre-test * corrected pretty print call * expanding display of results to first mount and unmount. * it looks like the test assumes absent=unmounted, which is not always true I'm switching prior testst absent->unmounted, to see if that moves the issue. * found issue where 'absent' did not delete the aggregate set tests back to use absent, and left print/pp in * changing test/create source file * removing sybols in test to see if the mount still has issues. * expanding output of pre-process files * removed escape function from main zos_mount in one or more of the calls, it is interfering with tso command generation * adding delete into end of first test. * changed dataset.delete to shell drm in first test * corrected ALL tests to use shell/drm to make sure system stays cleaned up * added symbols in test * the shell delete required the dsname to be escaped, while mount did not All mount tests now escape dsname for removal * cleanup of test output messages cleanup of escape calls in zos_mount * removed unused import in mount. Updated text in the changelog. * removed unused 'innersource' variables from mount routine, since they were no longer needed. * removed self-reference of src=src, cause when removing innersrc * renamed fragment to contain PR#
1 parent 9fc0d97 commit b1179b3

File tree

3 files changed

+57
-11
lines changed

3 files changed

+57
-11
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
minor_changes:
2+
- zos_mount - Added support for data set names with special characters ($, /#, /- and @).
3+
This is for both src and backup data set names.
4+
(https://github.com/ansible-collections/ibm_zos_core/pull/1631).

plugins/modules/zos_mount.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,9 +546,7 @@
546546
better_arg_parser,
547547
data_set,
548548
backup as Backup,
549-
550549
)
551-
552550
from ansible_collections.ibm.ibm_zos_core.plugins.module_utils.copy import (
553551
copy_ps2uss,
554552
copy_uss2mvs,
@@ -740,6 +738,7 @@ def run_module(module, arg_def):
740738
res_args = dict()
741739

742740
src = parsed_args.get("src")
741+
743742
path = parsed_args.get("path")
744743
fs_type = parsed_args.get("fs_type").upper()
745744
state = parsed_args.get("state")

tests/functional/modules/test_zos_mount_func.py

Lines changed: 52 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111

1212
from ibm_zos_core.tests.helpers.volumes import Volume_Handler
1313
from ibm_zos_core.tests.helpers.dataset import get_tmp_ds_name
14-
14+
from ansible_collections.ibm.ibm_zos_core.plugins.module_utils.data_set import (
15+
DataSet,
16+
)
1517

1618
INITIAL_PRM_MEMBER = """/* Initial file to look like BPXPRM */
1719
/* some settings at the top */
@@ -29,7 +31,6 @@
2931
AUTOMOVE
3032
"""
3133

32-
# SHELL_EXECUTABLE = "/usr/lpp/rsusr/ported/bin/bash"
3334
SHELL_EXECUTABLE = "/bin/sh"
3435

3536

@@ -57,29 +58,34 @@ def populate_tmpfile():
5758

5859

5960
def create_sourcefile(hosts, volume):
61+
# returns un-escaped source file name, but uses escaped file name for shell commands
62+
# this is intentionally done to test escaping of data set names
6063
starter = get_sysname(hosts).split(".")[0].upper()
6164
if len(starter) < 2:
6265
starter = "IMSTESTU"
63-
thisfile = starter + ".TTT.MNT.ZFS"
66+
basefile = starter + ".A@$#TO.MNT.ZFS"
67+
thisfile = DataSet.escape_data_set_name(basefile)
6468
print(
65-
"csf: starter={0} thisfile={1} is type {2}".format(
69+
"\ncsf: starter={0} thisfile={1} is type {2}".format(
6670
starter, thisfile, str(type(thisfile))
6771
)
6872
)
6973

70-
hosts.all.shell(
74+
mount_result = hosts.all.shell(
7175
cmd="zfsadm define -aggregate "
7276
+ thisfile
7377
+ " -volumes {0} -cylinders 200 1".format(volume),
7478
executable=SHELL_EXECUTABLE,
7579
stdin="",
7680
)
77-
hosts.all.shell(
81+
82+
mount_result = hosts.all.shell(
7883
cmd="zfsadm format -aggregate " + thisfile,
7984
executable=SHELL_EXECUTABLE,
8085
stdin="",
8186
)
82-
return thisfile
87+
88+
return basefile
8389

8490

8591
def test_basic_mount(ansible_zos_module, volumes_on_systems):
@@ -102,8 +108,13 @@ def test_basic_mount(ansible_zos_module, volumes_on_systems):
102108
fs_type="zfs",
103109
state="absent",
104110
)
105-
hosts.all.file(path="/pythonx/", state="absent")
111+
hosts.all.shell(
112+
cmd="drm " + DataSet.escape_data_set_name(srcfn),
113+
executable=SHELL_EXECUTABLE,
114+
stdin="",
115+
)
106116

117+
hosts.all.file(path="/pythonx/", state="absent")
107118

108119

109120
def test_double_mount(ansible_zos_module, volumes_on_systems):
@@ -128,6 +139,12 @@ def test_double_mount(ansible_zos_module, volumes_on_systems):
128139
fs_type="zfs",
129140
state="absent",
130141
)
142+
hosts.all.shell(
143+
cmd="drm " + DataSet.escape_data_set_name(srcfn),
144+
executable=SHELL_EXECUTABLE,
145+
stdin="",
146+
)
147+
131148
hosts.all.file(path="/pythonx/", state="absent")
132149

133150

@@ -137,20 +154,29 @@ def test_remount(ansible_zos_module, volumes_on_systems):
137154
volume_1 = volumes.get_available_vol()
138155
srcfn = create_sourcefile(hosts, volume_1)
139156
try:
157+
mount_results = hosts.all.zos_mount(src=srcfn, path="/pythonx", fs_type="zfs", state="mounted")
158+
140159
hosts.all.zos_mount(src=srcfn, path="/pythonx", fs_type="zfs", state="mounted")
160+
141161
mount_result = hosts.all.zos_mount(
142162
src=srcfn, path="/pythonx", fs_type="zfs", state="remounted"
143163
)
144164
for result in mount_result.values():
145165
assert result.get("rc") == 0
146166
assert result.get("changed") is True
147167
finally:
148-
hosts.all.zos_mount(
168+
mount_result = hosts.all.zos_mount(
149169
src=srcfn,
150170
path="/pythonx",
151171
fs_type="zfs",
152172
state="absent",
153173
)
174+
hosts.all.shell(
175+
cmd="drm " + DataSet.escape_data_set_name(srcfn),
176+
executable=SHELL_EXECUTABLE,
177+
stdin="",
178+
)
179+
154180
hosts.all.file(path="/pythonx/", state="absent")
155181

156182

@@ -212,6 +238,11 @@ def test_basic_mount_with_bpx_nocomment_nobackup(ansible_zos_module, volumes_on_
212238
fs_type="zfs",
213239
state="absent",
214240
)
241+
hosts.all.shell(
242+
cmd="drm " + DataSet.escape_data_set_name(srcfn),
243+
executable=SHELL_EXECUTABLE,
244+
stdin="",
245+
)
215246
hosts.all.file(path=tmp_file_filename, state="absent")
216247
hosts.all.file(path="/pythonx/", state="absent")
217248
hosts.all.zos_data_set(
@@ -329,6 +360,12 @@ def test_basic_mount_with_bpx_comment_backup(ansible_zos_module, volumes_on_syst
329360
fs_type="zfs",
330361
state="absent",
331362
)
363+
hosts.all.shell(
364+
cmd="drm " + DataSet.escape_data_set_name(srcfn),
365+
executable=SHELL_EXECUTABLE,
366+
stdin="",
367+
)
368+
332369
hosts.all.file(path=tmp_file_filename, state="absent")
333370
hosts.all.file(path=test_tmp_file_filename, state="absent")
334371
hosts.all.file(path="/pythonx/", state="absent")
@@ -367,6 +404,12 @@ def test_basic_mount_with_tmp_hlq_option(ansible_zos_module, volumes_on_systems)
367404
tmp_hlq=tmphlq,
368405
persistent=dict(data_store=persist_data_set, backup=True)
369406
)
407+
hosts.all.shell(
408+
cmd="drm " + DataSet.escape_data_set_name(srcfn),
409+
executable=SHELL_EXECUTABLE,
410+
stdin="",
411+
)
412+
370413
hosts.all.zos_data_set(name=persist_data_set, state="absent")
371414
for result in unmount_result.values():
372415
assert result.get("rc") == 0

0 commit comments

Comments
 (0)