member_restore

This building block copies artifacts from a backup PDS to a PDS.

It is run on the artifacts that are listed under the step that it implements in The deployment plan.

To trigger the execution of this building block, you can enter the following code in the deployment method from which the deployment plan is generated. See How to trigger the execution of a building block. The following code is an example.
actions:
    - name: RESTORE ARTIFACTS FROM A BACKUP PDS
      short_name: RESTORE_ARTIFACTS 
      steps:
      - name: TEST FOR MEMBER_RESTORE
        short_name: TEST_RESTORE
        properties:
        - key: template
          value: member_restore

types:
  - name: 'LOAD'
  - name: 'DBRM'
  - name: 'CICSLOAD'
  - name: 'JCL'
is_artifact: True
This building block is related to the following artifact types:
  • Load module, CICS load module, DBRM, and JCL for CICS Db2 applications
  • IMS load module, Message Format Service (MFS) source, IMS program specification block (PSB), and IMS database descriptor (DBD) for IMS applications
The names that you give to these artifact types correspond to the extensions of these artifacts in the package file. You can freely choose these extension names.

To run correctly, this building block requires environment variables. Indicate them in a .yml file. Indicate The generic environment variables for the Ansible and Python building blocks and adapt their values to your target z/OS environment. Indicate also the variables that are specific to this building block.

The Ansible variables

To run this building block, indicate the following specific variables in an Ansible environment variables file:
common_pds_load_spec:
  type: LIBRARY
  space_primary: 10
  space_secondary: 20
  space_type: CYL
  record_format: U
  record_length: 0

common_pds_binary_spec:
  type: LIBRARY
  space_primary: 10
  space_secondary: 20
  space_type: CYL
  record_format: FB
  record_length: 80
  
common_pds_text_spec:
  type: LIBRARY
  space_primary: 5
  space_secondary: 10
  space_type: CYL
  record_format: FB
  record_length: 80


hlq: 'NAZARE.WDEPLOY.ANSIBLE'

default_types: 'types'
default_copy_by_folder: False

types:
  - type: 'LOAD'
    copy_by_folder: '{{default_copy_by_folder}}'
    pds: 
      name: '{{ hlq }}.LOADLIB'
      spec: "{{common_pds_load_spec}}"
      backup: '{{ hlq }}.BACK.LOADLIB'
    is_load: True
    aliases: True
    force_lock: True
#   use_native_copy : True
#   native_copy_options: "-X"
  - type: 'DBRM'
    copy_by_folder: '{{default_copy_by_folder}}'
    pds: 
      name: '{{ hlq }}.DBRM'
      spec: "{{common_pds_binary_spec}}"
      backup: '{{ hlq }}.BACK.DBRM'
    is_binary: True 
    force_lock: True
#   use_native_copy : True
  - type: 'CICSLOAD'
    copy_by_folder: '{{default_copy_by_folder}}'
    pds: 
      name: '{{ hlq }}.LOADLIB'
      spec: "{{common_pds_load_spec}}"
      backup: '{{ hlq }}.BACK.LOADLIB'
    is_load: True
    aliases: True
    force_lock: True
#   use_native_copy : True
#   native_copy_options: "-X" 
  - type: 'JCL'
    copy_by_folder: '{{default_copy_by_folder}}'
    pds: 
      name: '{{ hlq }}.JCL'
      spec: "{{common_pds_text_spec}}"
      backup: '{{ hlq }}.BACK.JCL'
    force_lock: True
    encoding:
      from: UTF-8
      to: IBM-1047
#   use_native_copy : True
Among all the variables that are shown in this extract, only some of them are used by this building block. The other variables are included so that you can copy and paste all the variables that might be relevant for other building blocks. To run this building block, you must declare the following variables:
  • The variables related to the artifact types.

    Enter the name of the root that lists the types and characteristics of the artifacts to be deployed, if the building block applies to artifacts. By default, the root name is types but you can enter any other name if you define a var_type property in the deployment method step that is implemented by the building block. See The types variable.

    Under this root, create a type variable for each artifact type that relates to this building block in the generated deployment plan. The value of each artifact type comes from the deployment method, where it is freely chosen.

    For each type variable, enter the following variables:
    • A pds variable with the following embedded variables:
      • A name variable to specify the name of the PDS where each artifact type is stored.
      • A backup variable to specify the name of the backup PDS where each artifact type is stored.
    • An is_load or is_binary variable that is set to True to specify the artifact type.

      As the artifact types can be freely chosen in the deployment method (and are therefore present in the deployment plan), you need to enter a variable in the environment variables file to specify their nature. So, under each artifact type, you must specify is_load: True if it is a load module, is_binary: True if it is a binary file such as a DBRM, and no variable if it is a text artifact type such as a JCL.

    • An aliases variable for the load module artifacts (is_load: True).

      If this variable is set to True (default value), then all the aliases that are found in the PDS/E library or member are to be preserved during the copy operation.

      As this is applicable to executable files, aliases that are set to True must be combined with is_load: True.

    • A force_lock variable for all the artifacts.

      This variable is used to authorize or forbid the copy when a task is accessing the target dataset.

      If this variable is set to False (default value) and if the target dataset is in use, the building block fails with a message that indicates that it is not possible to write to the target dataset because a task is accessing the dataset. To check whether the dataset is used, a command is issued for which the user needs to have authority. See Installing and configuring ZOAU in the Z Open Automation Utilities documentation.

      If this variable is set to True, then the copy is attempted, even if a task is accessing the target dataset.

      The value True is ineffective with is_asa_text:True or with use_native_copy:True.

    • An is_asa_text variable for the artifacts that contain ASA control characters.

      If this variable is set to True, the copy will preserve ASA control characters in the destination. The default value is False.

      This variable is incompatible with the encoding variable.

      The force_lock variable is ineffective with is_asa_text.

    • A use_native_copy variable for all the artifacts.

      If this variable is set to True, the copy step is faster because it uses the native UNIX System Services shell cp command instead of IBM Z Open Automation Utilities (ZOAU). The default value is False.

      This variable is incompatible with the is_asa_text variable.

      If you set the use_native_copy to True, you can use the native_copy_options variable to enter copy options. If you do not indicate copy options, the copy command runs with the following default values:
      • "-F bin" for the binary files (is_binary: True)
      • -XI for the load modules and their preserved aliases (is_load: True and aliases: True)
      • -X for the load modules without their preserved aliases (is_load: True and aliases: False)
      • -T for the others files
      Note: The native UNIX System Services shell cp command has fewer capabilities than the corresponding ZOAU APIs. If the backup PDS does not exist, the module will fail.

      The force_lock variable is ineffective if you use a use_native_copy variable.

    • A rename_subs variable if you want to rename some artifacts for the deployment. Then, the building block will process these artifacts under names that are different from the names in the application package.
      In the following example, pattern and replace are regular expressions.
      - type: 'JCL'
        copy_by_folder: '{{default_copy_by_folder}}'
        pds:
          name: '{{ hlq }}.JCL'
          spec: "{{common_pds_text_spec}}"
          backup: '{{ hlq }}.BACK.JCL'
        encoding:
          from: UTF-8
          to: IBM-1047
        rename_subs:
        - pattern: "CDRD(.*)"
          replace: "CDRP\1"

The Python variables

To run this building block, indicate the following specific variables in a Python environment variables file. The whole path to this file is indicated in the --envFile argument of The Python deployment command.

common_pds_load_spec:
   type: LIBRARY
   primary_space: 10CYL
   secondary_space: 20CYL
   record_format: U
   record_length: 0
common_pds_binary_spec:
   type: LIBRARY
   primary_space: 10CYL
   secondary_space: 20CYL
   record_format: FB
   record_length: 80
common_pds_txt_spec:
   type: LIBRARY
   primary_space: 10CYL
   secondary_space: 20CYL
   record_format: FB
   record_length: 80

hlq: 'NAZARE.WDEPLOY.PYTHON'
  
types:
  - pattern: .*\.LOAD$
    dataset: "{{ hlq }}.LOADLIB"
    dataset_backup: "{{ hlq }}.BACK.LOADLIB"
    spec: "{{ common_pds_load_spec }}"
    is_load: True
    aliases: True
    force_lock: True
#   use_native_copy : True
#   native_copy_options: "-X"
  - pattern: .*\.CICSLOAD$
    dataset: "{{ hlq }}.LOADLIB"
    dataset_backup: "{{ hlq }}.BACK.LOADLIB"
    spec: "{{ common_pds_load_spec }}"
    is_load: True
    aliases: True
    force_lock: True
#   use_native_copy : True
#   native_copy_options: "-X"
  - pattern: .*.DBRM$
    dataset: "{{ hlq }}.DBRM"
    dataset_backup: "{{ hlq }}.BACK.DBRM"
    spec: "{{ common_pds_binary_spec }}"
    is_binary: True
    force_lock: True
#   use_native_copy : True
  - pattern: .*.JCL$
    dataset: "{{ hlq }}.JCL"
    dataset_backup: "{{ hlq }}.BACK.JCL"
    spec: "{{ common_pds_txt_spec }}"
    force_lock: True
    encoding:
      from: UTF-8
      to: IBM-1047
#   use_native_copy : True
Among all the variables that are shown in this extract, only some of them are used by this building block. The other variables are included so that you can copy and paste all the variables that might be relevant for other building blocks. To run this building block, you must declare the following variables:
  • The variables related to the artifact types.

    Enter the name of the root that lists the types and characteristics of the artifacts to be deployed, if the building block applies to artifacts. By default, the root name is types but you can enter any other name if you define a var_type property in the deployment method step that is implemented by the building block. See The types variable.

    Under this root, create a pattern variable for each artifact type that relates to this building block in the deployment plan. The value of each artifact type comes from the deployment method, where it is freely chosen. A pattern is a regular expression that selects the artifacts from their path in The application manifest file.

    Enter the following variables for each pattern variable:
    • A dataset variable for the name of the data set where each artifact type is stored.
    • A dataset_backup variable for the name of the backup data set where each artifact type is stored.
    • An is_load or is_binary variable that is set to True to specify the artifact type.

      As the artifact types can be freely chosen in the deployment method (and are therefore present in the deployment plan), you need to enter a variable in the environment variables file to specify their nature. So, under each artifact type, you must specify is_load: True if it is a load module, is_binary: True if it is a binary file such as a DBRM, and no variable if it is a text artifact type such as a JCL.

    • An aliases variable for the load module artifacts (is_load: True).

      If this variable is set to True (default value), then all the aliases that are found in the PDS/E library or member are to be preserved during the copy operation.

      As this is applicable to executable files, aliases that are set to True must be combined with is_load: True.

    • A force_lock variable for all the artifacts.

      This variable is used to authorize or forbid the copy when a task is accessing the target dataset.

      If this variable is set to False (default value) and if the target dataset is in use, the building block fails with a message that indicates that it is not possible to write to the target dataset because a task is accessing the dataset. To check whether the dataset is used, a command is issued for which the user needs to have authority. See Installing and configuring ZOAU in the Z Open Automation Utilities documentation.

      If this variable is set to True, then the copy is attempted, even if a task is accessing the target dataset.

      The value True is ineffective with is_asa_text:True or with use_native_copy:True.

      Using force_lock can lead to permanent loss of the original target information.

    • An is_asa_text variable for the artifacts that contain ASA control characters.

      If this variable is set to True, the copy will preserve ASA control characters in the destination. The default value is False.

      This variable is incompatible with the encoding variable.

      The force_lock variable is ineffective with is_asa_text.

    • A use_native_copy variable for all the artifacts.

      If this variable is set to True, the copy step is faster because it uses the native UNIX System Services shell cp command instead of IBM Z Open Automation Utilities (ZOAU). The default value is False.

      This variable is incompatible with the is_asa_text variable.

      If you set the use_native_copy to True, you can use the native_copy_options variable to enter copy options. If you do not indicate copy options, the copy command runs with the following default values:
      • "-F bin" for the binary files (is_binary: True)
      • -XI for the load modules and their preserved aliases (is_load: True and aliases: True)
      • -X for the load modules without their preserved aliases (is_load: True and aliases: False)
      • -T for the others files
      Note: The native UNIX System Services shell cp command has fewer capabilities than the corresponding ZOAU APIs.

      The force_lock variable is ineffective if you use a use_native_copy variable.

    • A rename_subs variable if you want to rename some artifacts for the deployment. Then, the building block will process these artifacts under names that are different from the names in the application package.
      In the following example, pattern and replace are regular expressions.
        - pattern: .\*.JCL$
          dataset: "{{ hlq }}.JCL"
          dataset_backup: "{{ hlq }}.BACK.JCL"
          spec: "{{ common_pds_txt_spec }}"
          encoding:
            from: UTF-8
            to: IBM-1047
          rename_subs:
          - pattern: "CDRD(.*)"
            replace: "CDRP\1"

Return values

The result of each building block task is displayed in the evidence file, in The results level that is embedded in step_result.