pyzkiln_core/zutils/fsutils.py
def allocate_zfs_by_datatype(fs_name: str, fs_size: int, extended_size=0,
                             volume='default', data_type='default'):
    """
    Create a zFS Aggregate and File System by a specified data type.

        Parameters:
                  fs_name (str): aggregate name for new zFS file system
                  fs_size (int): secondary size in megabytesfor VSAM data set
            extended_size (int): volume the VSAM linear data set can have space
                                 Optional, default = 0
                   volume (str): size in megabytes for the VSAM linear data set
                                 Optional, default = no volume specified
                data_type (str): data type for defining the size of the ds
                                 can be one of: cylinders, kilobytes, megabytes,
                                 records, tracks
                                 Optional, default = megabytes
        Returns:
            Resulting return code of zfsadm define command
            1 = allocation of data set failed
            -1 = invalid data_type parameter
            -2 = invalid fs_size or extended_size parameter
        Note: The issuer of the zfsadm define command requires sufficient
              authority to create the VSAM linear data set
        Doc:
            https://www.ibm.com/docs/en/zos/2.4.0?topic=commands-zfsadm-define
    """
    cmd_list = ['zfsadm', 'define', '-aggregate', fs_name]

    if volume != 'default':
        cmd_list.append('-volumes')
        cmd_list.append(volume)

    data_type = data_type.lower()
    data_type_allowed = ['cylinders', 'kilobytes', 'megabytes', 'records', 'tracks']

    if data_type in data_type_allowed:
        cmd_list.append('-' + data_type)
    elif data_type == 'default':
        cmd_list.append('-megabytes')
    else:
        logging.error(f"Invalid value {data_type} for parameter data_type passed to zfsadm define command")
        logging.error(f"Expected one of {data_type_allowed}")
        return -1

    if fs_size > 0:
        cmd_list.append(str(fs_size))
    else:
        return -2

    if extended_size > 0:
        cmd_list.append(str(extended_size))
    elif extended_size < 0:
        return -2

    logging.debug(cmd_list)

    if dry_run_flag:
        cmd_str = ''
        for cmd in cmd_list:
            cmd_str = cmd_str + str(cmd) + ' '
        logging.info(f"DRY RUN COMMAND: {cmd_str}")
        return 0
    else:
        alloc_cmd = subprocess.run(cmd_list)
        return alloc_cmd.returncode

    Create a zFS Aggregate and File System by a specified data type.

        Parameters:
                  fs_name (str): aggregate name for new zFS file system
                  fs_size (int): secondary size in megabytesfor VSAM data set
            extended_size (int): volume the VSAM linear data set can have space
                                 Optional, default = 0
                   volume (str): size in megabytes for the VSAM linear data set
                                 Optional, default = no volume specified
                data_type (str): data type for defining the size of the ds
                                 can be one of: cylinders, kilobytes, megabytes,
                                 records, tracks
                                 Optional, default = megabytes
        Returns:
            Resulting return code of zfsadm define command
            1 = allocation of data set failed
            -1 = invalid data_type parameter
            -2 = invalid fs_size or extended_size parameter
        Note: The issuer of the zfsadm define command requires sufficient
              authority to create the VSAM linear data set
        Doc:
            https://www.ibm.com/docs/en/zos/2.4.0?topic=commands-zfsadm-define
    
Create a zFS Aggregate and File System by a specified data type.
Create a zFS Aggregate and File System by a specified data type .
def allocate_zfs_by_datatype(fs_name: str, fs_size: int, extended_size=0,
                             volume='default', data_type='default'):
    cmd_list = ['zfsadm', 'define', '-aggregate', fs_name]
    if volume != 'default':
        cmd_list.append('-volumes')
        cmd_list.append(volume)
    data_type = data_type.lower()
    data_type_allowed = ['cylinders', 'kilobytes', 'megabytes', 'records', 'tracks']
    if data_type in data_type_allowed:
        cmd_list.append('-' + data_type)
    elif data_type == 'default':
        cmd_list.append('-megabytes')
    else:
        logging.error(f"Invalid value {data_type} for parameter data_type passed to zfsadm define command")
        logging.error(f"Expected one of {data_type_allowed}")
        return -1
    if fs_size > 0:
        cmd_list.append(str(fs_size))
    else:
        return -2
    if extended_size > 0:
        cmd_list.append(str(extended_size))
    elif extended_size < 0:
        return -2
    logging.debug(cmd_list)
    if dry_run_flag:
        cmd_str = ''
        for cmd in cmd_list:
            cmd_str = cmd_str + str(cmd) + ' '
        logging.info(f"DRY RUN COMMAND: {cmd_str}")
        return 0
    else:
        alloc_cmd = subprocess.run(cmd_list)
        return alloc_cmd.returncode
def allocate_zfs_by_datatype ( fs_name : str , fs_size : int , extended_size = 0 , volume = 'default' , data_type = 'default' ) : cmd_list = [ 'zfsadm' , 'define' , '-aggregate' , fs_name ] if volume != 'default' : cmd_list . append ( '-volumes' ) cmd_list . append ( volume ) data_type = data_type . lower ( ) data_type_allowed = [ 'cylinders' , 'kilobytes' , 'megabytes' , 'records' , 'tracks' ] if data_type in data_type_allowed : cmd_list . append ( '-' + data_type ) elif data_type == 'default' : cmd_list . append ( '-megabytes' ) else : logging . error ( f"Invalid value {data_type} for parameter data_type passed to zfsadm define command" ) logging . error ( f"Expected one of {data_type_allowed}" ) return - 1 if fs_size > 0 : cmd_list . append ( str ( fs_size ) ) else : return - 2 if extended_size > 0 : cmd_list . append ( str ( extended_size ) ) elif extended_size < 0 : return - 2 logging . debug ( cmd_list ) if dry_run_flag : cmd_str = '' for cmd in cmd_list : cmd_str = cmd_str + str ( cmd ) + ' ' logging . info ( f"DRY RUN COMMAND: {cmd_str}" ) return 0 else : alloc_cmd = subprocess . run ( cmd_list ) return alloc_cmd . returncode
Create a zFS Aggregate and File System by a specified data type.
Create a zFS Aggregate and File System by a specified data type .
"""
    Create a zFS Aggregate and File System by a specified data type.

        Parameters:
                  fs_name (str): aggregate name for new zFS file system
                  fs_size (int): secondary size in megabytesfor VSAM data set
            extended_size (int): volume the VSAM linear data set can have space
                                 Optional, default = 0
                   volume (str): size in megabytes for the VSAM linear data set
                                 Optional, default = no volume specified
                data_type (str): data type for defining the size of the ds
                                 can be one of: cylinders, kilobytes, megabytes,
                                 records, tracks
                                 Optional, default = megabytes
        Returns:
            Resulting return code of zfsadm define command
            1 = allocation of data set failed
            -1 = invalid data_type parameter
            -2 = invalid fs_size or extended_size parameter
        Note: The issuer of the zfsadm define command requires sufficient
              authority to create the VSAM linear data set
        Doc:
            https://www.ibm.com/docs/en/zos/2.4.0?topic=commands-zfsadm-define
    """
fs_name
str
fs_size
int
extended_size
volume
data_type