3838 SECURITY
3939"""
4040
41+ TEXT_TO_KEEP = """/* Service path */
42+ MOUNT FILESYSTEM('{0}')
43+ TYPE(ZFS) MODE(RDWR) AUTOMOVE
44+ MOUNTPOINT('/Service')
45+ """
46+
4147SHELL_EXECUTABLE = "/bin/sh"
4248
4349
@@ -315,6 +321,75 @@ def test_basic_mount_with_bpx_no_utf_8_characters(ansible_zos_module, volumes_on
315321 stdin = "" ,
316322 )
317323
324+ def test_basic_mount_with_persistent_keep_dataset (ansible_zos_module , volumes_on_systems ):
325+ hosts = ansible_zos_module
326+ volumes = Volume_Handler (volumes_on_systems )
327+ volume_1 = volumes .get_available_vol ()
328+ srcfn = create_sourcefile (hosts , volume_1 )
329+
330+ tmp_file_filename = "/tmp/testfile.txt"
331+
332+ hosts .all .shell (
333+ cmd = "touch {0}" .format (tmp_file_filename )
334+ )
335+
336+ dest = get_tmp_ds_name ()
337+ dest_path = dest + "(AUTO1)"
338+
339+ hosts .all .zos_blockinfile (path = tmp_file_filename , insertafter = "EOF" , block = TEXT_TO_KEEP .format (srcfn ))
340+
341+ hosts .all .shell (
342+ cmd = "dtouch -tpdse {0}" .format (dest )
343+ )
344+
345+ hosts .all .zos_copy (
346+ src = tmp_file_filename ,
347+ dest = dest_path ,
348+ binary = True ,
349+ remote_src = True ,
350+ )
351+
352+ try :
353+ mount_result = hosts .all .zos_mount (
354+ src = srcfn ,
355+ path = "/pythonx" ,
356+ fs_type = "zfs" ,
357+ state = "mounted" ,
358+ persistent = dict (name = dest_path ),
359+ )
360+
361+ for result in mount_result .values ():
362+ assert result .get ("rc" ) == 0
363+ assert result .get ("changed" ) is True
364+
365+ result_cat = hosts .all .shell (
366+ cmd = "dcat '{0}'" .format (dest_path ),
367+ )
368+
369+ for result in result_cat .contacted .values ():
370+ print (result )
371+ assert srcfn in result .get ("stdout" )
372+ assert "Service path" in result .get ("stdout" )
373+ finally :
374+ hosts .all .zos_mount (
375+ src = srcfn ,
376+ path = "/pythonx" ,
377+ fs_type = "zfs" ,
378+ state = "absent" ,
379+ )
380+ hosts .all .shell (
381+ cmd = "drm " + DataSet .escape_data_set_name (srcfn ),
382+ executable = SHELL_EXECUTABLE ,
383+ stdin = "" ,
384+ )
385+ hosts .all .file (path = tmp_file_filename , state = "absent" )
386+ hosts .all .file (path = "/pythonx/" , state = "absent" )
387+ hosts .all .shell (
388+ cmd = "drm " + dest ,
389+ executable = SHELL_EXECUTABLE ,
390+ stdin = "" ,
391+ )
392+
318393def test_basic_mount_with_bpx_marker_backup (ansible_zos_module , volumes_on_systems ):
319394 hosts = ansible_zos_module
320395 volumes = Volume_Handler (volumes_on_systems )
@@ -326,13 +401,6 @@ def test_basic_mount_with_bpx_marker_backup(ansible_zos_module, volumes_on_syste
326401 hosts .all .zos_copy (
327402 content = INITIAL_PRM_MEMBER ,
328403 dest = tmp_file_filename ,
329- binary = True ,
330- )
331- # Make it readable at console
332- hosts .all .shell (
333- cmd = "chtag -t -c ISO8859-1 " + tmp_file_filename ,
334- executable = SHELL_EXECUTABLE ,
335- stdin = "" ,
336404 )
337405
338406 # Dump the values of the file once copied to the target(s)
@@ -356,7 +424,6 @@ def test_basic_mount_with_bpx_marker_backup(ansible_zos_module, volumes_on_syste
356424 hosts .all .zos_copy (
357425 src = tmp_file_filename ,
358426 dest = dest_path ,
359- binary = True ,
360427 remote_src = True ,
361428 )
362429
@@ -375,25 +442,16 @@ def test_basic_mount_with_bpx_marker_backup(ansible_zos_module, volumes_on_syste
375442 marker = ["bpxtablemarker - try this" , "second line of marker" ],
376443 ),
377444 )
378- # copying from dataset to make editable copy on target
379- test_tmp_file_filename = tmp_file_filename + "-a"
380-
381- hosts .all .zos_copy (
382- src = dest_path ,
383- dest = test_tmp_file_filename ,
384- binary = True ,
385- remote_src = True ,
386- )
445+
387446 results = hosts .all .shell (
388- cmd = "cat " + test_tmp_file_filename , executable = SHELL_EXECUTABLE , stdin = ""
447+ cmd = "dcat '{0}'" . format ( dest_path ),
389448 )
390- data = ""
391- for result in results .values ():
449+
450+ for result in results .contacted . values ():
392451 print ("\n bcb-postmount result: {0}\n " .format (result .get ("stdout" )))
393452 data += result .get ("stdout" )
394453
395454 print ("\n ====================================================\n " )
396-
397455 for result in mount_result .values ():
398456 assert result .get ("rc" ) == 0
399457 assert result .get ("changed" ) is True
@@ -414,7 +472,6 @@ def test_basic_mount_with_bpx_marker_backup(ansible_zos_module, volumes_on_syste
414472 )
415473
416474 hosts .all .file (path = tmp_file_filename , state = "absent" )
417- hosts .all .file (path = test_tmp_file_filename , state = "absent" )
418475 hosts .all .file (path = "/pythonx/" , state = "absent" )
419476 hosts .all .shell (cmd = f"drm { dest } " )
420477
0 commit comments