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

Init MVS could skip some steps #4192

Open
wants to merge 4 commits into
base: user/markackert/feat-v3-jcl-rebase
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions INSTALLATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ When the JCL is prepared, the following jobs can be submitted to perform the fol

|Task|Description|Sample JCL|
|---|---|---|
|Create Instance Datasets|**Purpose:** Create datasets for Zowe's PARMLIB content and non-ZFS extension content for a given Zowe Instance<br><br>**Action:**<br>1) Allocate PDSE FB80 dataset with at least 15 tracks named from Zowe parameter `zowe.setup.dataset.parmlib`<br>2) Allocate PDSE FB80 dataset with at least 30 tracks named from Zowe parameter `zowe.setup.dataset.authPluginLib`<br>3) Copy ZWESIP00 member from `zowe.setup.dataset.prefix`.SZWESAMP into `zowe.setup.dataset.parmlib`|[ZWEIMVS](https://github.com/zowe/zowe-install-packaging/tree/feature/v3/jcl/files/SZWESAMP/ZWEIMVS)|
|Create Instance Datasets|**Purpose:** Create datasets for Zowe's PARMLIB content and non-ZFS extension content for a given Zowe Instance<br><br>**Action:**<br>1) Allocate PDSE FB80 dataset with at least 15 tracks named from Zowe parameter `zowe.setup.dataset.parmlib`<br>2) Allocate PDSE FB80 dataset with at least 30 tracks named from Zowe parameter `zowe.setup.dataset.authPluginLib`<br>3) Copy ZWESIP00 member from `zowe.setup.dataset.prefix`.SZWESAMP into `zowe.setup.dataset.parmlib`|[ZWEIMVS](https://github.com/zowe/zowe-install-packaging/tree/feature/v3/jcl/files/SZWESAMP/ZWEIMVS)<br/><br/>[ZWEIMVS1](https://github.com/zowe/zowe-install-packaging/tree/feature/v3/jcl/files/SZWESAMP/ZWEIMVS1)|
|APF Authorize privileged content|**Purpose:** Zowe contains one privileged component, ZIS, which enables the security model by which the majority of Zowe is unprivileged and in key 8. The load library for the ZIS component and its extension library must be set APF authorized and run in key 4 to use ZIS and components that depend upon it.<br><br>**Action:**<br>1) APF authorize the datasets defined at `zowe.setup.dataset.authLoadlib` and `zowe.setup.dataset.authPluginLib`.<br>2) Define PPT entries for the members ZWESIS01 and ZWESAUX as Key 4, NOSWAP in the SCHEDxx member of the system PARMLIB.|[ZWEIAPF](https://github.com/zowe/zowe-install-packaging/tree/feature/v3/jcl/files/SZWESAMP/ZWEIAPF)|
|Grant SAF permissions|The STC accounts for Zowe need permissions for operating servers, and users need permissions for interacting with the servers.<br><br>**Action:** [Set SAF permissions for accounts](https://docs.zowe.org/stable/user-guide/assign-security-permissions-to-users#security-permissions-reference-table)|RACF: [ZWEIRAC](https://github.com/zowe/zowe-install-packaging/tree/feature/v3/jcl/files/SZWESAMP/ZWEIRAC)<br><br>TSS: [ZWEITSS](https://github.com/zowe/zowe-install-packaging/tree/feature/v3/jcl/files/SZWESAMP/ZWEITSS)<br><br>ACF2: [ZWEIACF](https://github.com/zowe/zowe-install-packaging/tree/feature/v3/jcl/files/SZWESAMP/SZWIACF)|
|Copy STC JCL to PROCLIB|**Purpose**: ZWESLSTC is the job for running Zowe's webservers, and ZWESISTC is for running the APF authorized cross-memory server. The ZWESASTC job is started by ZWESISTC on an as-needed basis.<br><br>**Action**: Copy the members ZWESLSTC, ZWESISTC, and ZWESASTC into your desired PROCLIB. If the job names are customized, also modify the YAML values of them in `zowe.setup.security.stcs`|[ZWEISTC](https://github.com/zowe/zowe-install-packaging/tree/feature/v3/jcl/files/SZWESAMP/ZWEISTC)|
Expand Down Expand Up @@ -157,7 +157,8 @@ zowe:
JCL samples for removing Zowe configuration also exist.
|Action|Sample JCL|
|---|---|
|Remove Instance Datasets|[ZWERMVS](https://github.com/zowe/zowe-install-packaging/tree/feature/v3/jcl/files/SZWESAMP/ZWERMVS)|
|Remove Instance Parmlib Dataset|[ZWERMVS](https://github.com/zowe/zowe-install-packaging/tree/feature/v3/jcl/files/SZWESAMP/ZWERMVS)|
|Remove Instance ZIS Plugins Dataset|[ZWERMVS1](https://github.com/zowe/zowe-install-packaging/tree/feature/v3/jcl/files/SZWESAMP/ZWERMVS1)|
|Remove SAF Permissions|[ZWENOSEC](https://github.com/zowe/zowe-install-packaging/tree/feature/v3/jcl/files/SZWESAMP/ZWENOSEC)|
|Remove Keyring|[ZWENOKR](https://github.com/zowe/zowe-install-packaging/tree/feature/v3/jcl/files/SZWESAMP/ZWENOKR)|
|Remove Caching Service VSAM Dataset|[ZWECSRVS](https://github.com/zowe/zowe-install-packaging/tree/feature/v3/jcl/files/SZWESAMP/ZWECSRVS)|
Expand Down
4 changes: 2 additions & 2 deletions bin/commands/init/.help
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ review what Zowe would do before doing it.
The following are the JCL submitted by each command as needed

- `zwe init mvs`
- ZWEIMVS
- (If `--allow-overwrite` specified and old datasets exist) ZWERMVS
- ZWEIMVS2, ZWEIMVS, ZWEIMVS1
- (If `--allow-overwrite` specified and old datasets exist) ZWERMVS, ZWERMVS1
- (If `zowe.setup.dataset.authLoadLib` is not named prefix + ZWELOAD) ZWEIMVS2
- (If above is true, and the dataset exists, and `--allow-overwrite` is set) ZWERMVS2
- `zwe init vsam`
Expand Down
6 changes: 4 additions & 2 deletions bin/commands/init/generate/.help
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ For example, if you run `zwe init generate --dry-run`, a dry run of the operatio
The following JCL will be created into the jcllib, using the content of the same name from within the SZWESAMP dataset:

Instance dataset creation:
- ZWEIMVS: Creates Zowe instance datasets
- ZWERMVS: Removes these datasets
- ZWEIMVS: Creates Zowe instance Parmlib dataset
- ZWERMVS: Removes this dataset
- ZWEIMVS1: Creates Zowe instance ZIS Plugins dataset
- ZWERMVS1: Removes this dataset
- ZWEIMVS2: Creates the `zowe.setup.dataset.authLoadLib` dataset if you have customized its name. This is not recommended, it is best to leave it as default.
- ZWERMVS2: Removes the above customized dataset.

Expand Down
2 changes: 1 addition & 1 deletion bin/commands/init/mvs/.help
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Below data sets will be initialized by this command:
this data set.
This loadlib requires APF authorize.
- `zowe.setup.dataset.authPluginLib` is the user custom APF PLUGINLIB.
You can install Zowe ZIS plugins into this load library.
This field is optional. You can install Zowe ZIS plugins into this load library.
This loadlib requires APF authorize.

NOTE: Existing members in custom data sets will not be overwritten by default.
Expand Down
148 changes: 57 additions & 91 deletions bin/commands/init/mvs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,38 @@
under the terms of the Eclipse Public License v2.0 which
accompanies this distribution, and is available at
https://www.eclipse.org/legal/epl-v20.html

SPDX-License-Identifier: EPL-2.0

Copyright Contributors to the Zowe Project.
*/

import * as std from 'cm_std';
import * as xplatform from 'xplatform';
import * as fs from '../../../libs/fs';
import * as shell from '../../../libs/shell';
import * as zoslib from '../../../libs/zos';
import * as zosJes from '../../../libs/zos-jes';
import * as zosdataset from '../../../libs/zos-dataset';
import * as common from '../../../libs/common';
import * as config from '../../../libs/config';
import * as stringlib from '../../../libs/string';
import * as initGenerate from '../generate/index';

export function execute(allowOverwrite?: boolean) {
common.printLevel1Message(`Initialize Zowe custom data sets`);
common.requireZoweYaml();
const ZOWE_CONFIG = config.getZoweConfig();

const datasets = ['parmlib', 'authLoadlib', 'authPluginLib'];

const prefix = ZOWE_CONFIG.zowe.setup?.dataset?.prefix;
if (!prefix) {
common.printErrorAndExit(`Error ZWEL0157E: Zowe dataset prefix (zowe.setup.dataset.prefix) is not defined in Zowe YAML configuration file.`, undefined, 157);
}

const zssEnabled = ZOWE_CONFIG.components.zss.enabled; // In defaults, this property is always defined
const parmlib = ZOWE_CONFIG.zowe.setup?.dataset?.parmlib ? ZOWE_CONFIG.zowe.setup.dataset.parmlib : undefined;
if (zssEnabled && parmlib == undefined) {
common.printErrorAndExit(`Error ZWEL0157E: zowe.setup.dataset.parmlib is not defined in Zowe YAML configuration file.`, undefined, 157);
}

// check if user passed --generate
const forceGen = !!std.getenv('ZWE_CLI_PARAMETER_GENERATE')
const forceGen = !!std.getenv('ZWE_CLI_PARAMETER_GENERATE')
if (forceGen) {
initGenerate.execute();
}
Expand All @@ -44,100 +44,66 @@ export function execute(allowOverwrite?: boolean) {
common.printErrorAndExit(`Error ZWEL0319E: zowe.setup.dataset.jcllib does not exist, cannot run. Run 'zwe init', 'zwe init generate', or submit JCL ${prefix}.SZWESAMP(ZWEGENER) before running this command.`, undefined, 319);
}

let runALoadlibCreate: boolean;

common.printMessage(`Create data sets if they do not exist`);
let skippedDatasets: boolean = false;
let needCleanup: boolean = false;
let needAuthCleanup: boolean = false;

for (let i = 0; i < datasets.length; i++) {
let key = datasets[i];
// read def and validate
let skip: boolean = false;
const ds = ZOWE_CONFIG.zowe.setup?.dataset ? ZOWE_CONFIG.zowe.setup.dataset[key] : undefined;
if (!ds) {
// authLoadlib can be empty
if (key == 'authLoadlib') {
skip=true;
} else {
common.printErrorAndExit(`Error ZWEL0157E: ${key} (zowe.setup.dataset.${key}) is not defined in Zowe YAML configuration file.`, undefined, 157);
}
}
if (!skip) {
if (key == 'authLoadlib') {
runALoadlibCreate = ds == (prefix+'.SZWEAUTH') ? false : true;
}

const datasetExists=zosdataset.isDatasetExists(ds);
if (datasetExists) {
if (allowOverwrite) {
if (key != 'authLoadlib') {
needCleanup = true;
common.printMessage(`Warning ZWEL0300W: ${ds} already exists. Members in this data set will be overwritten.`);
} else if (ds != (prefix+'.SZWEAUTH')) {
//Do not delete the shipped auth load lib.
needAuthCleanup = true;
}
// If authLoadlib is not defined, we'll use "zowe.setup.dataset.prefix.SZWEAUTH"
// This dataset will be kept (allow-overwrite has no effect)
const authLoadlibDefaults = `${prefix}.SZWEAUTH`
const authLoadlibConfig = ZOWE_CONFIG.zowe.setup?.dataset ? ZOWE_CONFIG.zowe.setup.dataset.authLoadlib : undefined;

let actions = {
parmlib: {
ds: parmlib,
jclSuffix: '',
exist: false, create: false, delete: false
},
authloadlib: {
ds: authLoadlibDefaults == authLoadlibConfig ? undefined : authLoadlibConfig,
jclSuffix: '2',
exist: false, create: false, delete: false
},
authpluginlib: {
ds: ZOWE_CONFIG.zowe.setup?.dataset ? ZOWE_CONFIG.zowe.setup.dataset.authPluginLib : undefined,
jclSuffix: '1',
exist: false, create: false, delete: false
}
}

let skipDatasets = false;
for (let a in actions) {
if (actions[a].ds) {
actions[a].exist = zosdataset.isDatasetExists(actions[a].ds);
}
actions[a].delete = actions[a].exist && allowOverwrite;
if (actions[a].delete) {
actions[a].create = true;
common.printMessage(`Warning ZWEL0300W: ${actions[a].ds} already exists. Members in this data set will be overwritten.`);
} else {
if (actions[a].ds) {
if (actions[a].exist) {
common.printMessage(`Warning ZWEL0301W: ${actions[a].ds} already exists and will not be overwritten. For upgrades, you must use --allow-overwrite.`);
skipDatasets = true;
} else {
skippedDatasets = true;
common.printMessage(`Warning ZWEL0301W: ${ds} already exists and will not be overwritten. For upgrades, you must use --allow-overwrite.`);
actions[a].create = true;
}
}
}
}

if (skippedDatasets && !allowOverwrite) {
if (skipDatasets) {
common.printMessage(`Skipped writing to a dataset. To write, you must use --allow-overwrite.`);
} else {
if (allowOverwrite && needCleanup) {
zosJes.printAndHandleJcl(`//'${jcllib}(ZWERMVS)'`, `ZWERMVS`, jcllib, prefix, false, true);
}
if (allowOverwrite && needAuthCleanup) {
zosJes.printAndHandleJcl(`//'${jcllib}(ZWERMVS2)'`, `ZWERMVS2`, jcllib, prefix, false, true);
}

const zisParmlib = ZOWE_CONFIG.zowe.setup?.dataset?.parmlibMembers?.zis;

if (zisParmlib && (zisParmlib != 'ZWESIP00')) {

const COMMAND_LIST = std.getenv('ZWE_CLI_COMMANDS_LIST');
const tmpfile = fs.createTmpFile(`zwe ${COMMAND_LIST}`.replace(new RegExp('\ ', 'g'), '-'));
common.printDebug(`- Copy ${jcllib}(ZWEIMVS) to ${tmpfile}`);
const jclContent = shell.execOutSync('sh', '-c', `cat "//'${stringlib.escapeDollar(jcllib)}(ZWEIMVS)'" 2>&1`);
if (jclContent.out && jclContent.rc == 0) {
common.printDebug(` * Succeeded`);
common.printTrace(` * Output:`);
common.printTrace(stringlib.paddingLeft(jclContent.out, " "));

const tmpFileContent = jclContent.out.replace("ZWESIP00,", "ZWESIP00," + zisParmlib.toUpperCase());
xplatform.storeFileUTF8(tmpfile, xplatform.AUTO_DETECT, tmpFileContent);
common.printTrace(` * Stored:`);
common.printTrace(stringlib.paddingLeft(tmpFileContent, " "));

shell.execSync('chmod', '700', tmpfile);
} else {
common.printDebug(` * Failed`);
common.printError(` * Exit code: ${jclContent.rc}`);
common.printError(` * Output:`);
if (jclContent.out) {
common.printError(stringlib.paddingLeft(jclContent.out, " "));
}
std.exit(1);
}
if (!fs.fileExists(tmpfile)) {
common.printErrorAndExit(`Error ZWEL0159E: Failed to modify ZWEIMVS`, undefined, 159);
}

zosJes.printAndHandleJcl(tmpfile, `ZWEIMVS`, jcllib, prefix, true);
common.printLevel2Message(`Zowe custom data sets are initialized successfully.`);
std.exit(0);
}


} else {
zosJes.printAndHandleJcl(`//'${jcllib}(ZWEIMVS)'`, `ZWEIMVS`, jcllib, prefix);
for (let a in actions) {
if (actions[a].delete) {
const jclJobName = `ZWERMVS${actions[a].jclSuffix}`
zosJes.printAndHandleJcl(`//'${jcllib}(${jclJobName})'`, jclJobName, jcllib, prefix);
}
if (runALoadlibCreate === true) {
zosJes.printAndHandleJcl(`//'${jcllib}(ZWEIMVS2)'`, `ZWEIMVS2`, jcllib, prefix);
if (actions[a].create) {
const jclJobName = `ZWEIMVS${actions[a].jclSuffix}`
zosJes.printAndHandleJcl(`//'${jcllib}(${jclJobName})'`, jclJobName, jcllib, prefix);
}
}

Expand Down
4 changes: 2 additions & 2 deletions bin/libs/zos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ export function verifyGeneratedJcl(config:any): string | undefined {
if (!jcllib) {
return undefined;
}
const expectedMember = jcllib+'(ZWEIMVS)';
// read JCL library and validate using expected member ZWEIMVS (init mvs command)
const expectedMember = jcllib+'(ZWEIMVS2)';
// read JCL library and validate using expected member ZWEIMVS2 (init mvs command)
let doesJclExist: boolean = zosDataset.isDatasetExists(expectedMember);
if (!doesJclExist) {
initGenerate.execute();
Expand Down
28 changes: 15 additions & 13 deletions files/SZWESAMP/ZWEIMVS
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@
//* Instances represent a configuration of Zowe, different from the
//* "runtime" datasets that are created upon install of Zowe / SMPE.
//*
//* Consider if the Zowe Cross Memory Server
//* - is used: run this and consider to run ZWEIMVS1
//* - not used: you can skip this JCL
//*
//* If your chosen value of 'zowe.setup.dataset.authLoadlib' is not
//* equal to 'zowe.setup.dataset.prefix' + 'SZWEAUTH',
//* then you must also run "ZWEIMVS2".
//* then you must also run ZWEIMVS2.
//*
//*********************************************************************
//MKPDSE EXEC PGM=IKJEFT01
Expand All @@ -26,16 +30,14 @@
ALLOC NEW DA('{zowe.setup.dataset.parmlib}') +
dsntype(library) dsorg(po) recfm(f b) lrecl(80) +
unit(sysallda) space(15,15) tracks

ALLOC NEW DA('{zowe.setup.dataset.authPluginLib}') +
dsntype(library) dsorg(po) recfm(u) lrecl(0) +
blksize(32760) unit(sysallda) space(30,15) tracks
//*
//MEMBCPY EXEC PGM=IEBCOPY
//SYSPRINT DD SYSOUT=A
//SYSUT1 DD DSN={zowe.setup.dataset.prefix}.SZWESAMP,DISP=SHR
//SYSUT2 DD DSN={zowe.setup.dataset.parmlib},DISP=OLD
//SYSIN DD *
COPY OUTDD=SYSUT2,INDD=SYSUT1
SELECT MEMBER=((ZWESIP00,,R))
/*
//MEMBCPY EXEC PGM=IKJEFT01
// SET OUTPARM={zowe.setup.dataset.parmlibMembers.zis}
//SYSTSPRT DD SYSOUT=A
//PARMIN DD DISP=SHR,
// DSN={zowe.setup.dataset.prefix}.SZWESAMP(ZWESIP00)
//PARMOUT DD DISP=SHR,
// DSN={zowe.setup.dataset.parmlib}(&OUTPARM)
//SYSTSIN DD *
REPRO INFILE(PARMIN) OUTFILE(PARMOUT)
//*
33 changes: 33 additions & 0 deletions files/SZWESAMP/ZWEIMVS1
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//ZWEIMVS1 JOB {zowe.environments.jclHeader}
//*
//* This program and the accompanying materials are made available
//* under the terms of the Eclipse Public License v2.0 which
//* accompanies this distribution, and is available at
//* https://www.eclipse.org/legal/epl-v20.html
//*
//* SPDX-License-Identifier: EPL-2.0
//*
//* Copyright Contributors to the Zowe Project. 2020, 2020
//*
//*********************************************************************
//*
//* This job is used to create datasets used by a Zowe "instance"
//* Instances represent a configuration of Zowe, different from the
//* "runtime" datasets that are created upon install of Zowe / SMPE.
//*
//* Consider if the Zowe Cross Memory Server
//* - is used: run this and ZWEIMVS
//* - not used: you can skip this JCL
//*
//* If your chosen value of 'zowe.setup.dataset.authLoadlib' is not
//* equal to 'zowe.setup.dataset.prefix' + 'SZWEAUTH',
//* then you must also run ZWEIMVS2.
//*
//*********************************************************************
//MKPDSE EXEC PGM=IKJEFT01
//SYSTSPRT DD SYSOUT=A
//SYSTSIN DD *
ALLOC NEW DA('{zowe.setup.dataset.authPluginLib}') +
dsntype(library) dsorg(po) recfm(u) lrecl(0) +
blksize(32760) unit(sysallda) space(30,15) tracks
/*
5 changes: 3 additions & 2 deletions files/SZWESAMP/ZWEIMVS2
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
//* 'zowe.setup.dataset.authLoadlib' is equal to
//* 'zowe.setup.dataset.prefix' + 'SZWEAUTH'.
//*
//* When running this job, you should also run ZWEIMVS
//* When running this job, you should also consider
//* to run ZWEIMVS and ZWEIMVS1.
//*
//*********************************************************************
//MKPDSE EXEC PGM=IKJEFT01
Expand All @@ -25,7 +26,7 @@
ALLOC NEW DA('{zowe.setup.dataset.authLoadlib}') +
dsntype(library) dsorg(po) recfm(u) lrecl(0) +
blksize(32760) unit(sysallda) space(30,15) tracks
//*
/*
//AUTHCPY EXEC PGM=BPXBATCH
//BPXPRINT DD SYSOUT=*
//STDOUT DD SYSOUT=*
Expand Down
7 changes: 3 additions & 4 deletions files/SZWESAMP/ZWERMVS
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@
//*
//* If your chosen value of 'zowe.setup.dataset.authLoadlib' is not
//* equal to 'zowe.setup.dataset.prefix' + 'SZWEAUTH',
//* then you must also run "ZWERMVS2".
//* then you must also run ZWERMVS2.
//*
//*********************************************************************
//RMPDSE EXEC PGM=IKJEFT01
//SYSTSPRT DD SYSOUT=A
//SYSTSIN DD *
DELETE ('{zowe.setup.dataset.parmlib}', +
'{zowe.setup.dataset.authPluginLib}') +
DELETE '{zowe.setup.dataset.parmlib}' +
SCRATCH NONVSAM
//*
/*
Loading
Loading