Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mvs to non existent mvs copy destination attrs match up #1066

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
bugfixes:
- zos_copy - Module calculated incorrectly the attributes of the source dataset
when making a copy with executables and aliases and the target did not exist.
Fix now creates the target dataset with the same attributes as the source.
(https://github.com/ansible-collections/ibm_zos_core/pull/1066).
8 changes: 7 additions & 1 deletion plugins/module_utils/data_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def ensure_uncataloged(name):
return False

@staticmethod
def allocate_model_data_set(ds_name, model, asa_text=False, vol=None):
def allocate_model_data_set(ds_name, model, executable=False, asa_text=False, vol=None):
"""Allocates a data set based on the attributes of a 'model' data set.
Useful when a data set needs to be created identical to another. Supported
model(s) are Physical Sequential (PS), Partitioned Data Sets (PDS/PDSE),
Expand All @@ -291,6 +291,7 @@ def allocate_model_data_set(ds_name, model, asa_text=False, vol=None):
must be used. See extract_dsname(ds_name) in data_set.py
model {str} -- The name of the data set whose allocation parameters
should be used to allocate the new data set 'ds_name'
executable {bool} -- Whether the new data set should support executables
asa_text {bool} -- Whether the new data set should support ASA control
characters (have record format FBA)
vol {str} -- The volume where data set should be allocated
Expand Down Expand Up @@ -327,6 +328,11 @@ def allocate_model_data_set(ds_name, model, asa_text=False, vol=None):
alloc_cmd = """{0} -
RECFM(F,B,A)""".format(alloc_cmd)

if executable:
alloc_cmd = """{0} -
RECFM(U) -
DSNTYPE(LIBRARY)""".format(alloc_cmd)

rc, out, err = mvs_cmd.ikjeft01(alloc_cmd, authorized=True)
if rc != 0:
raise MVSCmdExecError(rc, out, err)
Expand Down
20 changes: 1 addition & 19 deletions plugins/modules/zos_copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -2337,25 +2337,7 @@ def allocate_destination_data_set(
elif dest_ds_type in data_set.DataSet.MVS_PARTITIONED and not dest_exists:
# Taking the src as model if it's also a PDSE.
if src_ds_type in data_set.DataSet.MVS_PARTITIONED:
if executable:
src_attributes = datasets.listing(src_name)[0]
size = int(src_attributes.total_space)
record_format = "U"
record_length = 0

dest_params = get_data_set_attributes(
dest,
size,
is_binary,
asa_text,
record_format=record_format,
record_length=record_length,
type="LIBRARY",
volume=volume
)
data_set.DataSet.ensure_present(replace=force, **dest_params)
else:
data_set.DataSet.allocate_model_data_set(ds_name=dest, model=src_name, asa_text=asa_text, vol=volume)
data_set.DataSet.allocate_model_data_set(ds_name=dest, model=src_name, executable=executable, asa_text=asa_text, vol=volume)
elif src_ds_type in data_set.DataSet.MVS_SEQ:
src_attributes = datasets.listing(src_name)[0]
# The size returned by listing is in bytes.
Expand Down