Skip to content

Commit

Permalink
Mvs to non existent mvs copy destination attrs match up (#1066)
Browse files Browse the repository at this point in the history
* Fixed error

* Fix identation

* Add fragment

* Modify fragment

* Modify fragment

* Modify fragment
  • Loading branch information
AndreMarcel99 authored Nov 27, 2023
1 parent 7800b6a commit 44754ab
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
bugfixes:
- zos_copy - When copying an executable data set with aliases and destination did not exist,
destination data set was created with wrong attributes. Fix now creates destination data set
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 @@ -2403,25 +2403,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

0 comments on commit 44754ab

Please sign in to comment.