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

Enhancement, improve load module and program object support in zos_copy #804

Conversation

AndreMarcel99
Copy link
Collaborator

@AndreMarcel99 AndreMarcel99 commented Jun 12, 2023

SUMMARY

To improve load of executable files from uss file or dataset to any dataset or uss file also cover the variables in cat to change permissions and adjust how the module create a respective library to execute the file in case the dataset of target don't exists also cover files to add execution to the owner and in case of directory cover the permissions by setting the execution permissions with or to all files if the user set is_excutable to true.

Fixing #652

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

Add is_executable option to the user set true or false.
Pass throw the validations inside the module check if the user give information of the creation of target add or ensure the record_format and type ensure the target the creation of an executable or modify permissions on the file.

IMPORTANT NOTES

The enhanced could had problems with ZOAU 1.2.3 but with latest (1.2.4) works fine.

ADDITIONAL INFORMATION
  • Add is_executable option to the user set true or false been false the default.
  • Pass throw the validations inside the module check if the user give information of the creation of target add or ensure the record_format and type ensure the target the creation of an executable.
  • In a dataset with no more information of a target than name ensure the record_format and type.
  • Add to handles is executable as an option as the is_binary added.
  • In case a USS file is executable ensure the mode by an or to mode of owner can execute the file.
    Cover cases:
  1. EXE is on REMOTE USS, zos_copy to ---> USS
  2. EXE is on REMOTE USS, zos_copy to ---> Data Set (Do not exist the target member)
  3. EXE is on REMOTE DS, zos_copy to ---> Data Set (Do not exist the target member)
  4. EXE is on REMOTE DS, zos_copy to ---> USS

is_executable_files_and_playbook.zip

TASK [Copy an executable to Library to create] ****************************************************************************************************************************
changed: [zvm]

TASK [Result] *************************************************************************************************************************************************************
ok: [zvm] => {
    "msg": {
        "changed": true,
        "dest": "ANSIBLE.COBOL.LOADLIB3(HELLOSRC)",
        "dest_created": true,
        "destination_attributes": {
            "block_size": 32760,
            "record_format": "U",
            "record_length": 1028,
            "space_primary": 1977,
            "space_secondary": 198,
            "space_type": "K",
            "type": "PDSE"
        },
        "failed": false,
        "is_binary": false,
        "src": "ANSIBLE.COBOL.LOADLIB(HELLOSRC)"
    }
}

TASK [Run the cobol program] **********************************************************************************************************************************************
changed: [zvm]

TASK [Result for job HELLOPGM3] *******************************************************************************************************************************************

ok: [zvm] => {
    "msg": {
        "changed": true,
        "checksum": "2d1ca79c96df0ba23f6eb857023201280da1d17a",
        "dest": "/tmp/ansible.5owbbmbx",
        "duration": 0,
        "failed": false,
        "gid": 1,
        "group": "OMVSGRP",
        "jobs": [
            {
                "asid": "0",
                "class": "A",
                "content_type": "",
                "creation_datetime": "2023-06-16T11:38:26",
                "ddnames": [
                    {
                        "byte_count": "133",
                        "content": [
                            "1                       J E S 2  J O B  L O G  --  S Y S T E M  S T L 1  --  N O D E  S T L 1",
                            "0     ",
                            " 11.38.26 JOB00777 ---- FRIDAY,    16 JUN 2023 ----",
                            " 11.38.26 JOB00777  IRR010I  USERID OMVSADM  IS ASSIGNED TO THIS JOB.",
                            " 11.38.27 JOB00777  ICH70001I OMVSADM  LAST ACCESS AT 11:38:25 ON FRIDAY, JUNE 16, 2023",
                            " 11.38.27 JOB00777  $HASP373 HELLOPGM STARTED - INIT 8    - CLASS A        - SYS STL1",
                            " 11.38.27 JOB00777  SMF000I  HELLOPGM    STEP1       HELLOSRC    0000",
                            " 11.38.27 JOB00777  $HASP395 HELLOPGM ENDED - RC=0000",
                            "0------ JES2 JOB STATISTICS ------",
                            "-  16 JUN 2023 JOB EXECUTION DATE",
                            "-            7 CARDS READ",
                            "-           53 SYSOUT PRINT RECORDS",
                            "-            0 SYSOUT PUNCH RECORDS",
                            "-            6 SYSOUT SPOOL KBYTES",
                            "-         0.00 MINUTES EXECUTION TIME"
                        ],
                        "ddname": "JESMSGLG",
                        "id": "2",
                        "proctep": null,
                        "record_count": "15",
                        "stepname": "JES2"
                    },
                    {
                        "byte_count": "136",
                        "content": [
                            "        1 //HELLOPGM  JOB MSGCLASS=H,MSGLEVEL=(1,1),NOTIFY=&SYSUID,REGION=0M      JOB00777",
                            "          //***************************************************",
                            "          IEFC653I SUBSTITUTION JCL - MSGCLASS=H,MSGLEVEL=(1,1),NOTIFY=OMVSADM,REGION=0M",
                            "        2 //STEP1    EXEC PGM=HELLOSRC",
                            "        3 //STEPLIB DD DSN=ANSIBLE.COBOL.LOADLIB3,DISP=SHR",
                            "        4 //SYSPRINT DD SYSOUT=*",
                            "        5 //SYSOUT   DD SYSOUT=*",
                            "        6 //SYSIN     DD *               GENERATED STATEMENT"
                        ],
                        "ddname": "JESJCL",
                        "id": "3",
                        "proctep": null,
                        "record_count": "8",
                        "stepname": "JES2"
                    },
                    {
                        "byte_count": "137",
                        "content": [
                            " ICH70001I OMVSADM  LAST ACCESS AT 11:38:25 ON FRIDAY, JUNE 16, 2023",
                            " IEF043I Actions taken by SMFLIMxx parmlib policy for HELLOPGM STEP1",
                            "         Step shared page limit set to 2147483647 by policy - SMFLIM00 0001",
                            " IEFA111I HELLOPGM IS USING THE FOLLOWING JOB RELATED SETTINGS:",
                            "          SWA=BELOW,TIOT SIZE=32K,DSENQSHR=DISALLOW,GDGBIAS=JOB",
                            " IEF236I ALLOC. FOR HELLOPGM STEP1",
                            " IEF237I 0941 ALLOCATED TO STEPLIB",
                            " IEF237I JES2 ALLOCATED TO SYSPRINT",
                            " IEF237I JES2 ALLOCATED TO SYSOUT",
                            " IEF237I JES2 ALLOCATED TO SYSIN",
                            " IEF142I HELLOPGM STEP1 - STEP WAS EXECUTED - COND CODE 0000",
                            " IEF285I   ANSIBLE.COBOL.LOADLIB3                       KEPT",
                            " IEF285I   VOL SER NOS= 222222.",
                            " IEF285I   OMVSADM.HELLOPGM.JOB00777.D0000102.?         SYSOUT",
                            " IEF285I   OMVSADM.HELLOPGM.JOB00777.D0000103.?         SYSOUT",
                            " IEF285I   OMVSADM.HELLOPGM.JOB00777.D0000101.?         SYSIN",
                            " IEF373I STEP/STEP1   /START 2023167.1138",
                            " IEF032I STEP/STEP1   /STOP  2023167.1138",
                            "         CPU:     0 HR  00 MIN  00.00 SEC    SRB:     0 HR  00 MIN  00.00 SEC",
                            "         VIRT:    72K  SYS:   336K  EXT:     5192K  SYS:    12248K",
                            "         ATB- REAL:                  1032K  SLOTS:                     0K",
                            "              VIRT- ALLOC:      11M SHRD:       0M",
                            " IEF375I  JOB/HELLOPGM/START 2023167.1138",
                            " IEF033I  JOB/HELLOPGM/STOP  2023167.1138",
                            "         CPU:     0 HR  00 MIN  00.00 SEC    SRB:     0 HR  00 MIN  00.00 SEC"
                        ],
                        "ddname": "JESYSMSG",
                        "id": "4",
                        "proctep": null,
                        "record_count": "25",
                        "stepname": "JES2"
                    },
                    {
                        "byte_count": "121",
                        "content": [
                            " SIMPLE HELLO WORLD"
                        ],
                        "ddname": "SYSOUT",
                        "id": "103",
                        "proctep": null,
                        "record_count": "1",
                        "stepname": "STEP1"
                    }
                ],
                "duration": 0,
                "job_class": "A",
                "job_id": "JOB00777",
                "job_name": "HELLOPGM",
                "owner": "OMVSADM",
                "priority": "1",
                "queue_position": "0",
                "ret_code": {
                    "code": 0,
                    "msg": "CC 0000",
                    "msg_code": "0000",
                    "msg_text": "CC",
                    "steps": [
                        {
                            "step_cc": 0,
                            "step_name": "STEP1"
                        }
                    ]
                },
                "subsystem": "STL1",
                "svc_class": "?",
                "system": "STL1"
            }
        ],
        "md5sum": "25ff1171e9db5b1e5f0e0908d02baf58",
        "mode": "0600",
        "owner": "BPXROOT",
        "size": 1168,
        "src": "/.ansible/tmp/ansible-tmp-1686940693.3591611-8785-50528188756219/source",
        "state": "file",
        "uid": 0
    }
}

PLAY RECAP ****************************************************************************************************************************************************************
zvm                        : ok=30   changed=22   unreachable=0    failed=0    skipped=0    rescued=0    ignored=0 
Captura de pantalla 2023-06-26 a la(s) 20 49 35 Captura de pantalla 2023-06-26 a la(s) 20 50 38

@ddimatos ddimatos added the Do not Merge When a pull request should not be merged for issue noted reasons label Jun 23, 2023
@ddimatos
Copy link
Collaborator

This is a 1.8 item but if its in good shape we can release it in 1.7 but I would like to also be part of the review list. I labeled it with do not merge only because it needs some extra reviews since its a 1.8 item but great work on finishing early.

@AndreMarcel99 AndreMarcel99 marked this pull request as ready for review June 27, 2023 02:51
Copy link
Collaborator

@fernandofloresg fernandofloresg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good, the quality of your PRs has improved. Left my comments inline

@@ -1490,21 +1520,12 @@ def copy_to_member(
if self.is_binary:
opts["options"] = "-B"

if self.is_executable:
opts["options"] = "-X"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted as comment, Marcel and I discussed about the use of "I" option. This will keep aliases when copying, currently version 1.2.3 has some bugs with it, 1.2.4 appears to have fixed some of it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree I will add and run the pipeline again.

else:
dest_params["record_format"] = "U"
dest_params["type"] = "LIBRARY"
data_set.DataSet.ensure_present(replace=force, **dest_params)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can simplify to one if

elif dest_ds_type in data_set.DataSet.MVS_SEQ:
volumes = [volume] if volume else None
data_set.DataSet.ensure_absent(dest, volumes=volumes)

if src_ds_type == "USS":
# Taking the temp file when a local file was copied with sftp.
create_seq_dataset_from_file(src, dest, force, is_binary, volume=volume)
create_seq_dataset_from_file(src, dest, force, is_binary, is_executable, volume=volume)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_executable is not used in this function

@AndreMarcel99
Copy link
Collaborator Author

Captura de pantalla 2023-07-05 a la(s) 15 45 36

New pipeline run with -IX as option of copy

Copy link
Collaborator

@ketankelkar ketankelkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, SOLID work here @AndreMarcel99, this PR turned out to be much more complex than initially expected. A few generic comments:

  1. Not a deal-breaker, but why was the parameter name changed from is_executable to executable? The original issue description and even the PR description refers to is_executable. It seems more consistent to me to use is_executable, similar to is_binary. Curious to know if there was a particular reason for removing the is_ prefix.

  2. Would be good to include an example in the EXAMPLES section (feel free to change below example for more clarity/accuracy):

- name: Copy a Program Object on remote system to a new PDSE.
  zos_copy:
    src: HLQ.COBOLSRC.PDSE(TESTPGM)
    dest: HLQ.NEW.PDSE
    remote_src: true
    executable: true

plugins/modules/zos_copy.py Outdated Show resolved Hide resolved
plugins/modules/zos_copy.py Outdated Show resolved Hide resolved
plugins/modules/zos_copy.py Show resolved Hide resolved
plugins/action/zos_copy.py Outdated Show resolved Hide resolved
plugins/modules/zos_copy.py Show resolved Hide resolved
plugins/modules/zos_copy.py Outdated Show resolved Hide resolved
plugins/modules/zos_copy.py Show resolved Hide resolved
@AndreMarcel99
Copy link
Collaborator Author

is_executable was the first version but the suggestion was to change it

Copy link
Collaborator

@ketankelkar ketankelkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All docs stuff here

  1. In the notes section of DOCUMENTATION - change is_executable to executable
  2. In the example task - modify the example slightly.
  3. Edit dest option description to include info about executable option.
  4. From executable option description, remove irrelevant lines, add Demetri's suggested lines.
  5. In module_utils/action/copy.py - update copyright years (2019-2023).

(2)

- name: Copy a Program Object on remote system to a new PDSE member MYCOBOL.
  zos_copy:
    src: HLQ.COBOLSRC.PDSE(TESTPGM)
    dest: HLQ.NEW.PDSE(MYCOBOL)
    remote_src: true
    executable: true

(3) The edit adds one sentence to the end of the existing line:

- If C(dest) is a nonexistent data set, the attributes assigned will depend on the type of
 C(src). If C(src) is a USS file, C(dest) will have a Fixed Block (FB) record format and the 
 remaining attributes will be computed. If I(is_binary=true), C(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. If I(executable=true),C(dest) will have an Undefined (U) record 
 format with a record length of 0, block size of 32760, and the remaining attributes will be 
 computed.

(4)

 executable:
    description:
      - <REMOVE> If C(dest) is a nonexistent data set, the attributes assigned will depend
        on the type of C(src). If C(src) is a USS file, C(dest) will have a
        Fixed Block (FB) record format and the remaining attributes will be computed.
      - <REMOVE> If I(executable=true),C(dest) will have a Undefined (U)record format
        with a record length of 0, block size of 32760, and the remaining
        attributes will be computed.
      - <REMOVE> When C(dest) is a data set, precedence rules apply. If C(dest_data_set)
        is set, this will take precedence over an existing data set. If C(dest)
        is an empty data set, the empty data set will be written with the
        expectation its attributes satisfy the copy.
      - <ADD> If set to C(true), indicates that the file or library to be copied is an executable. 
      - <ADD> If the C(src) executable has an alias, the alias information is also copied. If the 
      C(dest) is Unix, the alias is not visible in Unix, even though the information is there and 
      will be visible if copied to a library.
      - <ADD> If I(executable=true), and C(dest) is a data set, it must be a PDS or PDSE (library). 
      - <ADD> If C(dest) is a nonexistent data set, the library attributes assigned will be 
      Undefined (U) record format with a record length of 0, block size of 32760 and the 
      remaining attributes will be computed.
      - If C(dest) is a file, execute permission for the user will be added to the file (``u+x``).

@AndreMarcel99
Copy link
Collaborator Author

Captura de pantalla 2023-08-25 a la(s) 18 30 50

Copy link
Collaborator

@fernandofloresg fernandofloresg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have one question and one change requested. Thanks Ketan and Marcel for improving this, this is looking real good

plugins/modules/zos_copy.py Show resolved Hide resolved
plugins/modules/zos_copy.py Show resolved Hide resolved
@ketankelkar ketankelkar added Ready to Merge Pull request review complete could be blocked still by a do not merge Changes Requested and removed Changes Requested Ready to Merge Pull request review complete could be blocked still by a do not merge labels Aug 28, 2023
@AndreMarcel99
Copy link
Collaborator Author

Captura de pantalla 2023-08-29 a la(s) 9 30 25

Copy link
Collaborator

@fernandofloresg fernandofloresg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_executable vs executable question resolved. Approved

@fernandofloresg fernandofloresg dismissed ddimatos’s stale review August 29, 2023 16:18

Demetri's changes requested were addressed by Ketan and Marcel. D is on vacations hence dismiss the review to be able to merge.

@fernandofloresg fernandofloresg merged commit 9d6704d into dev Aug 29, 2023
@fernandofloresg fernandofloresg deleted the enhancement/652/Improved_load_module_and_program_object_support branch August 29, 2023 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants