ansible-collections / ibm_zos_core

Red Hat Ansible Certified Content for IBM Z
77 stars 44 forks source link

[Bug] [zos_copy] Defaults seem off for data sets which don't exist. #921

Open ddimatos opened 1 year ago

ddimatos commented 1 year ago

Is there an existing issue for this?

Are the dependencies a supported version?

IBM Z Open Automation Utilities

v1.2.3

IBM Enterprise Python

v3.10.x

IBM z/OS Ansible core Version

v1.7.0

ansible-version

v2.14.x

z/OS version

v2.5

Ansible module

zos_copy

Bug description

This could be a documentation bug it it leans towards possibly some development and might be a bug in the code, so lets treat it as a bug for now.

When I read the documentation zos_copy documentation below, with regard to a dest not existing a few outcomes can happen.

If will depend on src, which is fine, if the src is a uss file the dest will have a fixed block (FB) record format, to me when i read the code it will have a VB format. See below why I say this.

Doc:

If dest is a nonexistent data set, the attributes assigned will depend on the type of src. If src is a USS file, dest will have a Fixed Block (FB) record format and the remaining attributes will be computed. If src is binary, dest will have a Fixed Block (FB) record format with a record length of 80, block size of 32760, and the remaining attributes will be computed.

Noticed that the record format is only set for Binary and executable meaning the default value in get_data_set_attributes will be used which is VB. See also other code further down.

This issue is to evaluate if only the documentation needs updating, if Code:

       elif src_ds_type == "USS":
            if os.path.isfile(src):
                # This is almost the same as allocating a sequential dataset.
                size = os.stat(src).st_size
                record_format = record_length = None

                if not is_binary:
                    record_format = "FB"
                    record_length = get_file_record_length(src)

                if executable:
                    record_format = "U"

                dest_params = get_data_set_attributes(
                    dest,
                    size,
                    is_binary,
                    record_format=record_format,
                    record_length=record_length,
                    type="LIBRARY" if executable else "PDSE",
                    volume=volume
                )

I saw nothing that overrides the record_format default VB in the code, thus i think our doc is off, we need from this issue an evaluation of what I see and what was the intended format , VB or FB?

def get_data_set_attributes(
    name,
    size,
    is_binary,
    record_format="VB",
    record_length=1028,
    type="SEQ",
    volume=None
):

Playbook verbosity output.

No response

Ansible configuration.

No response

Contents of the inventory

No response

Contents of group_vars or host_vars

No response

ketankelkar commented 1 year ago

maybe related to #924

ketankelkar commented 1 year ago

https://www.ibm.com/docs/en/zos/2.1.0?topic=server-data-set-creation-attributes-syntax

pay special attention to recf - V, VB, VS, VBS and blocksizes too!

 F | FB         blksize = lrecl
 V | VB         blksize = lrecl + 4 
VS | VBS        blksize = 6160