|
1 | 1 | #!/usr/bin/python |
2 | 2 | # -*- coding: utf-8 -*- |
3 | 3 |
|
4 | | -# Copyright (c) IBM Corporation 2019 - 2023 |
| 4 | +# Copyright (c) IBM Corporation 2019 - 2024 |
5 | 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | # you may not use this file except in compliance with the License. |
7 | 7 | # You may obtain a copy of the License at |
|
283 | 283 | - If C(src) is a directory and ends with "/", the contents of it will be copied |
284 | 284 | into the root of C(dest). If it doesn't end with "/", the directory itself |
285 | 285 | 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. |
286 | 288 | - If C(src) is a VSAM data set, C(dest) must also be a VSAM. |
287 | 289 | - Wildcards can be used to copy multiple PDS/PDSE members to another |
288 | 290 | PDS/PDSE. |
@@ -1705,33 +1707,56 @@ def copy_to_pdse( |
1705 | 1707 | existing_members = datasets.list_members(dest) # fyi - this list includes aliases |
1706 | 1708 | overwritten_members = [] |
1707 | 1709 | new_members = [] |
| 1710 | + bulk_src_members = "" |
| 1711 | + result = dict() |
1708 | 1712 |
|
1709 | 1713 | for src_member, destination_member in zip(src_members, dest_members): |
1710 | 1714 | if destination_member in existing_members: |
1711 | 1715 | overwritten_members.append(destination_member) |
1712 | 1716 | else: |
1713 | 1717 | 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 | + """ |
1715 | 1741 | result = self.copy_to_member( |
1716 | | - src_member, |
1717 | | - "{0}({1})".format(dest, destination_member), |
| 1742 | + bulk_src_members, |
| 1743 | + dest, |
1718 | 1744 | src_ds_type |
1719 | 1745 | ) |
1720 | 1746 |
|
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 | + ) |
1735 | 1760 |
|
1736 | 1761 | def copy_to_member( |
1737 | 1762 | self, |
|
0 commit comments