Skip to content

Commit d040df6

Browse files
Cherry picked removed hard coded content from staging-v1.9.0-beta.1
Added preferred volumes changes [v1.10.0] [zos_copy] Enhance zos_copy performance when copying multiple PDS members (#1183) * [v1.9.0] [zos_copy] Enhancement/764/copy members (#1176) * Changed member copy into a bulk call * Modified copy to members * Cleaned code * Removed hardcoded content from zos_copy tests * Added fix for uss files * Added distinction between uss and mvs * Added alias fix * Moved the copy section to below * Modified for seq test * Added fix for copy dest lock * Added msgs for debugging * Added final changes to member copy * Added copy for when seq to pdse * Add changelog * Added a line into docs * Modified doc * Modified doc * Update changelog * Created a new changelog * Corrected typo Fix for empty volumes on test_config Added comment to remind uncomment test case in the future Add more validation Add more validation Add more validation Add to config volumes and remove upper case variable name
1 parent 410925d commit d040df6

21 files changed

+1698
-1108
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
minor_changes:
2+
- zos_copy - Improve zos_copy performance when copying multiple members from one PDS/E to another.
3+
(https://github.com/ansible-collections/ibm_zos_core/pull/1183).

plugins/modules/zos_copy.py

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/python
22
# -*- coding: utf-8 -*-
33

4-
# Copyright (c) IBM Corporation 2019 - 2023
4+
# Copyright (c) IBM Corporation 2019 - 2024
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.
77
# You may obtain a copy of the License at
@@ -283,6 +283,8 @@
283283
- If C(src) is a directory and ends with "/", the contents of it will be copied
284284
into the root of C(dest). If it doesn't end with "/", the directory itself
285285
will be copied.
286+
- If C(src) is a directory or a file, file names will be truncated and/or modified
287+
to ensure a valid name for a data set or member.
286288
- If C(src) is a VSAM data set, C(dest) must also be a VSAM.
287289
- Wildcards can be used to copy multiple PDS/PDSE members to another
288290
PDS/PDSE.
@@ -1705,33 +1707,56 @@ def copy_to_pdse(
17051707
existing_members = datasets.list_members(dest) # fyi - this list includes aliases
17061708
overwritten_members = []
17071709
new_members = []
1710+
bulk_src_members = ""
1711+
result = dict()
17081712

17091713
for src_member, destination_member in zip(src_members, dest_members):
17101714
if destination_member in existing_members:
17111715
overwritten_members.append(destination_member)
17121716
else:
17131717
new_members.append(destination_member)
1714-
1718+
bulk_src_members += "{0} ".format(src_member)
1719+
1720+
# Copy section
1721+
if src_ds_type == "USS" or self.asa_text or len(src_members) == 1:
1722+
"""
1723+
USS -> MVS : Was kept on member by member basis bc file names longer than 8
1724+
characters will throw an error when copying to a PDS, because of the member name
1725+
character limit.
1726+
MVS -> MVS (asa only): This has to be copied on member by member basis bc OPUT
1727+
does not allow for bulk member copy or entire PDS to PDS copy.
1728+
"""
1729+
for src_member, destination_member in zip(src_members, dest_members):
1730+
result = self.copy_to_member(
1731+
src_member,
1732+
"{0}({1})".format(dest, destination_member),
1733+
src_ds_type
1734+
)
1735+
else:
1736+
"""
1737+
MVS -> MVS
1738+
Copies a list of members into a PDS, using this list of members greatly
1739+
enhances performance of datasets_copy.
1740+
"""
17151741
result = self.copy_to_member(
1716-
src_member,
1717-
"{0}({1})".format(dest, destination_member),
1742+
bulk_src_members,
1743+
dest,
17181744
src_ds_type
17191745
)
17201746

1721-
if result["rc"] != 0:
1722-
msg = "Unable to copy source {0} to data set member {1}({2})".format(
1723-
new_src,
1724-
dest,
1725-
destination_member
1726-
)
1727-
raise CopyOperationError(
1728-
msg=msg,
1729-
rc=result["rc"],
1730-
stdout=result["out"],
1731-
stderr=result["err"],
1732-
overwritten_members=overwritten_members,
1733-
new_members=new_members
1734-
)
1747+
if result["rc"] != 0:
1748+
msg = "Unable to copy source {0} to {1}.".format(
1749+
new_src,
1750+
dest
1751+
)
1752+
raise CopyOperationError(
1753+
msg=msg,
1754+
rc=result["rc"],
1755+
stdout=result["out"],
1756+
stderr=result["err"],
1757+
overwritten_members=overwritten_members,
1758+
new_members=new_members
1759+
)
17351760

17361761
def copy_to_member(
17371762
self,

tests/conftest.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
from __future__ import absolute_import, division, print_function
1313

1414
__metaclass__ = type
15-
1615
import pytest
1716
from ibm_zos_core.tests.helpers.ztest import ZTestHelper
17+
from ibm_zos_core.tests.helpers.volumes import get_volumes
1818
import sys
1919
from mock import MagicMock
2020
import importlib
@@ -84,6 +84,14 @@ def ansible_zos_module(request, z_python_interpreter):
8484
except Exception:
8585
pass
8686

87+
# Call of the class by the class ls_Volume (volumes.py file) as many times needed
88+
# one time the array is filled
89+
@pytest.fixture(scope="session")
90+
def volumes_on_systems(ansible_zos_module, request):
91+
""" Call the pytest-ansible plugin to check volumes on the system and work properly a list by session."""
92+
path = request.config.getoption("--zinventory")
93+
list_Volumes = get_volumes(ansible_zos_module, path)
94+
yield list_Volumes
8795

8896
# * We no longer edit sys.modules directly to add zoautil_py mock
8997
# * because automatic teardown is not performed, leading to mock pollution
@@ -108,4 +116,4 @@ def perform_imports(imports):
108116
newimp = [importlib.import_module(x) for x in imports]
109117
return newimp
110118

111-
yield (mocker, perform_imports)
119+
yield (mocker, perform_imports)

0 commit comments

Comments
 (0)