ansible-collections / ibm_zos_core

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

[Enabler][zos_data_set] Add support to GDG and special characters. #1504

Closed fernandofloresg closed 1 month ago

fernandofloresg commented 1 month ago
SUMMARY

Add support of GDG and special characters to perform data set operations.

This includes an architectural change to how the module performs the operations.

Adds new tests for data set with special characters.

New proposed classes that help simplifying data set operations.

MVSDataSet class

Represents a z/OS Data set, wanted to use DataSet name but is taken. During initialization, If the data set name is a GDS relative name it will get resolved into a GDS absolute name.

Although it calls other DataSet class static methods, the importance of this class is that it will help simplify how we handle data sets in modules, instead of having many variables around that belong to the data set attributes we can now encapsulate them into a MVSDataSet object.

data_set = MVSDataSet(
            name=params.get("name"),
            record_format=params.get("record_format", None),
            volumes=params.get("volumes", None),
            data_set_type=params.get("type", None),
            block_size=params.get("block_size", None),
            record_length=params.get("record_length", None),
            space_primary=params.get("space_primary", None),
            space_secondary=params.get("space_secondary", None),
            space_type=params.get("space_type", None),
            directory_blocks=params.get("directory_blocks", None),
            key_length=params.get("key_length", None),
            key_offset=params.get("key_offset", None),
            sms_storage_class=params.get("sms_storage_class", None),
            sms_data_class=params.get("sms_data_class", None),
            sms_management_class=params.get("sms_management_class", None),
        )
data_set.ensure_present()

# get attributes to use in another function 
attributes = vars(data_set)

# delete the created data set
data_set.ensure_absent()

A future improvement is to turn name attribute into an optional parameter to allow just calling MVSDataSet(**attributes) to create a temporary data set. This will allow us to standardize the many functions to create temporary data sets in the modules.

methods: create ensure_present delete ensure_absent ensure_catalog catalog ensure_uncatalog uncatalog set_state

Member class

Represents a data set member, at its current state it only provides methods to create and delete, hope this can be expanded when working on zos_copy.

methods: ensure_absent ensure_present

GenerationDataGroup class

Represents a Generation Data Group base, provides methods to create and remove gdg bases. Provides an interface to easily handle GDGs in the ibm_zos_core collection.

methods create ensure_present ensure_absent clear

Fixes #1371

ISSUE TYPE
COMPONENT NAME

zos_data_set

ADDITIONAL INFORMATION
fernandofloresg commented 1 month ago
Screenshot 2024-05-14 at 6 03 59 AM Screenshot 2024-05-14 at 6 04 22 AM