Skip to content

Commit

Permalink
Add formatZosVersion() in bin/libs/zos.ts
Browse files Browse the repository at this point in the history
Signed-off-by: CZ667581 <[email protected]>
  • Loading branch information
CZ667581 authored and CZ667581 committed Jan 15, 2025
1 parent 9022cdc commit b204278
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

All notable changes to the Zowe Installer will be documented in this file.

## `3.2.0`
- Enhancement: Added new library function formatZosVersion() [#4134](https://github.com/zowe/zowe-install-packaging/pull/4134)

## `3.1.0`
- Bugfix: When logging `zwe` command, sometimes the log has wrong file tag and the log is unreadable. [#4071](https://github.com/zowe/zowe-install-packaging/pull/4071)
- Bugfix: When `--log-dir` parameter for `zwe` command is a file, there might be an error "InternalError: stack overflow". [#4064](https://github.com/zowe/zowe-install-packaging/pull/4064)
Expand Down
38 changes: 38 additions & 0 deletions bin/libs/zos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,41 @@ export function operatorCommand(command: string): { rc: number, out: string } {
//we strip the '.' we added above
return { rc: result.rc, out: result.out ? result.out.substring(0, result.out.length-1) : '' };
}

export function formatZosVersion(format?: string, versionNumber?: string | number): string {
const ZOS_VERS = {
'Z1030100': { 'osname': 'z/OS', 'hbb': 'HBB77E0', 'major': '3', 'minor': '1' },
'Z1020500': { 'osname': 'z/OS', 'hbb': 'HBB77D0', 'major': '2', 'minor': '5' },
'Z1020400': { 'osname': 'z/OS', 'hbb': 'HBB77C0', 'major': '2', 'minor': '4' },
'Z1020300': { 'osname': 'z/OS', 'hbb': 'HBB77B0', 'major': '2', 'minor': '3' },
'Z1020200': { 'osname': 'z/OS', 'hbb': 'HBB77A0', 'major': '2', 'minor': '2' },
// 'Z01020100': search for 'ECVTPSEQ' in IBM document to find more versions to be supported
};
const DEF_FORMAT = '{major}.{minor}';

common.printDebug(`formatZosVersion format=${format}, versionNumber=${versionNumber}`);

if (!format || typeof format !== 'string') {
format = DEF_FORMAT;
}
if (versionNumber === undefined) {
// getZosVersion must return a number
versionNumber = zos.getZosVersion();
}
if (typeof versionNumber === 'number') {
versionNumber = `Z${versionNumber.toString(16)}`;
}

common.printDebug(`formatZosVersion parameter resvolution format=${format}, versionNumber=${versionNumber}`);

let zosVer = ZOS_VERS[versionNumber];
if (!zosVer) {
//TODO: should throw exception?
zosVer = { 'osname': '?', 'hbb': '?', 'major': '?', 'minor': '?' };
common.printError(`Unsupported z/OS version: ${versionNumber}`);
}
return format.replace(/\{\s*osname\s*\}/g, zosVer.osname)
.replace(/\{\s*hbb\s*\}/g, zosVer.hbb)
.replace(/\{\s*major\s*\}/g, zosVer.major)
.replace(/\{\s*minor\s*\}/g, zosVer.minor);
}

0 comments on commit b204278

Please sign in to comment.