-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add TS code from #3135 and adapt to new init stype
Signed-off-by: 1000TurquoisePogs <[email protected]>
- Loading branch information
1 parent
6f4f0cf
commit 02e3f7d
Showing
20 changed files
with
803 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
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. | ||
*/ | ||
|
||
import * as index from './index'; | ||
import * as configmgr from '../../../libs/configmgr'; | ||
|
||
index.execute(); | ||
|
||
configmgr.cleanupTempDir(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
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. | ||
*/ | ||
|
||
import * as zosJes from '../../../libs/zos-jes'; | ||
import * as zoslib from '../../../libs/zos'; | ||
import * as common from '../../../libs/common'; | ||
import * as config from '../../../libs/config'; | ||
|
||
export function execute() { | ||
|
||
common.printLevel1Message(`APF authorize load libraries`); | ||
|
||
// Validation | ||
common.requireZoweYaml(); | ||
const ZOWE_CONFIG = config.getZoweConfig(); | ||
|
||
// read prefix and validate | ||
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); | ||
} | ||
|
||
// read JCL library and validate | ||
const jcllib = zoslib.verifyGeneratedJcl(ZOWE_CONFIG); | ||
if (!jcllib) { | ||
return common.printErrorAndExit(`Error ZWEL0999E: 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, 999); | ||
} | ||
|
||
|
||
['authLoadlib', 'authPluginLib'].forEach((key)=> { | ||
if (!ZOWE_CONFIG.zowe?.setup?.dataset || !ZOWE_CONFIG.zowe?.setup?.dataset[key]) { | ||
common.printErrorAndExit(`Error ZWEL0157E: zowe.setup.dataset.${key} is not defined in Zowe YAML configuration file.`, undefined, 157); | ||
} | ||
}); | ||
|
||
|
||
zosJes.printAndHandleJcl(`//'${jcllib}(ZWEIAPF)'`, `ZWEIAPF`, jcllib, prefix); | ||
common.printLevel2Message(`Zowe load libraries are APF authorized successfully.`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
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. | ||
*/ | ||
|
||
import * as std from 'cm_std'; | ||
import * as index from './index'; | ||
import * as configmgr from '../../libs/configmgr'; | ||
|
||
index.execute(std.getenv("ZWE_CLI_PARAMETER_ALLOW_OVERWRITE") == 'true', std.getenv('ZWE_CLI_PARAMETER_SECURITY_DRY_RUN') == 'true', std.getenv('ZWE_CLI_PARAMETER_IGNORE_SECURITY_FAILURES') == 'true', std.getenv("ZWE_CLI_PARAMETER_UPDATE_CONFIG") == 'true'); | ||
|
||
configmgr.cleanupTempDir(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
/* | ||
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. | ||
*/ | ||
|
||
import * as std from 'cm_std'; | ||
import * as shell from '../../libs/shell'; | ||
import * as zoslib from '../../libs/zos'; | ||
import * as json from '../../libs/json'; | ||
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 node from '../../libs/node'; | ||
import * as java from '../../libs/java'; | ||
|
||
import * as initGenerate from './generate/index'; | ||
import * as initMvs from './mvs/index'; | ||
import * as initVsam from './vsam/index'; | ||
import * as initApfAuth from './apfauth/index'; | ||
import * as initSecurity from './security/index'; | ||
//import * as initCertificate from './certificate/index'; | ||
import * as initStc from './stc/index'; | ||
|
||
export function execute(allowOverwrite?: boolean, dryRun?: boolean, ignoreSecurityFailures?: boolean, updateConfig?: boolean) { | ||
common.printLevel0Message(`Configure Zowe`); | ||
|
||
// Validation | ||
common.requireZoweYaml(); | ||
|
||
// Read job name and validate | ||
const zoweConfig = config.getZoweConfig(); | ||
|
||
|
||
common.printLevel1Message(`Check if need to update runtime directory, Java and/or node.js settings in Zowe YAML configuration`); | ||
// node.home | ||
let newNodeHome; | ||
const configNodeHome=zoweConfig.node?.home; | ||
// only try to update if it's not defined | ||
if (!configNodeHome || configNodeHome == 'DETECT') { | ||
node.requireNode(); | ||
newNodeHome=std.getenv('NODE_HOME'); | ||
} | ||
|
||
// java.home | ||
let newJavaHome; | ||
const configJavaHome=zoweConfig.java?.home; | ||
// only try to update if it's not defined | ||
if (!configJavaHome || configJavaHome == 'DETECT') { | ||
java.requireJava(); | ||
newJavaHome=std.getenv('JAVA_HOME'); | ||
} | ||
|
||
// zowe.runtimeDirectory | ||
let newZoweRuntimeDir; | ||
// do we have zowe.runtimeDirectory defined in zowe.yaml? | ||
const configRuntimeDir = zoweConfig.zowe?.runtimeDirectory; | ||
if (configRuntimeDir) { | ||
if (configRuntimeDir != std.getenv('ZWE_zowe_runtimeDirectory')) { | ||
common.printErrorAndExit(`Error ZWEL0105E: The Zowe YAML config file is associated to Zowe runtime "${configRuntimeDir}", which is not same as where zwe command is located.`, undefined, 105); | ||
} | ||
} else { | ||
newZoweRuntimeDir = std.getenv('ZWE_zowe_runtimeDirectory'); | ||
} | ||
|
||
if (newNodeHome || newJavaHome || newZoweRuntimeDir) { | ||
if (std.getenv("ZWE_CLI_PARAMETER_UPDATE_CONFIG") == "true") { | ||
let updateObj:any = {}; | ||
if (newNodeHome) { | ||
updateObj.node = {home: newNodeHome}; | ||
} | ||
if (newJavaHome) { | ||
updateObj.java = {home: newJavaHome}; | ||
} | ||
if (newZoweRuntimeDir) { | ||
updateObj.zowe = {runtimeDirectory: newZoweRuntimeDir}; | ||
} | ||
json.updateZoweYamlFromObj(std.getenv('ZOWE_CLI_PARAMETER_CONFIG'), updateObj); | ||
|
||
common.printLevel2Message(`Runtime directory, Java and/or node.js settings are updated successfully.`); | ||
} else { | ||
common.printMessage(`These configurations need to be added to your YAML configuration file:`); | ||
common.printMessage(``); | ||
if (newZoweRuntimeDir) { | ||
common.printMessage(`zowe:`); | ||
common.printMessage(` runtimeDirectory: "${newZoweRuntimeDir}"`); | ||
} | ||
if (newNodeHome) { | ||
common.printMessage(`node:`); | ||
common.printMessage(` home: "${newNodeHome}"`); | ||
} | ||
if (newJavaHome) { | ||
common.printMessage(`java:`); | ||
common.printMessage(` home: "${newJavaHome}"`); | ||
} | ||
|
||
common.printLevel2Message(`Please manually update "${std.getenv('ZWE_CLI_PARAMETER_CONFIG')}" before you start Zowe.`); | ||
} | ||
} else { | ||
common.printLevel2Message(`No need to update runtime directory, Java and node.js settings.`); | ||
} | ||
|
||
initGenerate.execute(dryRun); | ||
initMvs.execute(allowOverwrite); | ||
initVsam.execute(allowOverwrite, dryRun, updateConfig); | ||
if (std.getenv("ZWE_CLI_PARAMETER_SKIP_SECURITY_SETUP") != 'true') { | ||
initApfAuth.execute(); | ||
initSecurity.execute(dryRun, ignoreSecurityFailures); | ||
} | ||
//initCertificate.execute(); | ||
let result = shell.execSync('sh', '-c', `${std.getenv('ZWE_zowe_runtimeDirectory')}/bin/zwe init certificate ${dryRun?'--dry-run':''} ${updateConfig?'--update-config':''} ${allowOverwrite?'--alow-overwrite':''} ${ignoreSecurityFailures?'--ignore-security-failures':''} -c "${std.getenv('ZWE_CLI_PARAMETER_CONFIG')}"`); | ||
initStc.execute(allowOverwrite); | ||
|
||
common.printLevel1Message(`Zowe is configured successfully.`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
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. | ||
*/ | ||
|
||
import * as std from 'cm_std'; | ||
import * as index from './index'; | ||
import * as configmgr from '../../../libs/configmgr'; | ||
|
||
index.execute(std.getenv("ZWE_CLI_PARAMETER_ALLOW_OVERWRITE") == 'true'); | ||
|
||
configmgr.cleanupTempDir(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
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. | ||
*/ | ||
|
||
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'; | ||
|
||
export function execute(allowOverwrite?: boolean) { | ||
common.printLevel1Message(`Initialize Zowe custom data sets`); | ||
common.requireZoweYaml(); | ||
const ZOWE_CONFIG = config.getZoweConfig(); | ||
|
||
const datasets = [ | ||
{ configKey: 'parmlib', | ||
description: 'Zowe parameter library' | ||
}, | ||
{ configKey: 'authLoadlib', | ||
description: 'Zowe authorized load library' | ||
}, | ||
{ configKey: 'authPluginLib', | ||
description: 'Zowe authorized plugin library' | ||
} | ||
]; | ||
|
||
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 jcllib = zoslib.verifyGeneratedJcl(ZOWE_CONFIG); | ||
if (!jcllib) { | ||
common.printErrorAndExit(`Error ZWEL0999E: 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, 999); | ||
} | ||
|
||
let runALoadlibCreate: boolean; | ||
|
||
common.printMessage(`Create data sets if they do not exist`); | ||
let skippedDatasets: boolean = false; | ||
|
||
datasets.forEach((datasetDef) => { | ||
// read def and validate | ||
let skip:boolean = false; | ||
const ds=ZOWE_CONFIG.zowe.setup?.dataset ? ZOWE_CONFIG.zowe.setup.dataset[datasetDef.configKey] : undefined; | ||
if (!ds) { | ||
// authLoadlib can be empty | ||
if (datasetDef.configKey == 'authLoadlib') { | ||
skip=true; | ||
} else { | ||
common.printErrorAndExit(`Error ZWEL0157E: ${datasetDef.configKey} (zowe.setup.dataset.${datasetDef.configKey}) is not defined in Zowe YAML configuration file.`, undefined, 157); | ||
} | ||
} | ||
|
||
if (datasetDef.configKey == 'authLoadlib') { | ||
runALoadlibCreate = ds == prefix+'SZWEAUTH' ? false : true; | ||
} | ||
|
||
if (!skip) { | ||
const datasetExists=zosdataset.isDatasetExists(ds); | ||
if (datasetExists) { | ||
if (allowOverwrite) { | ||
common.printMessage(`Warning ZWEL0300W: ${ds} already exists. Members in this data set will be overwritten.`); | ||
} else { | ||
skippedDatasets = true; | ||
common.printMessage(`Warning ZWEL0301W: ${ds} already exists and will not be overwritten. For upgrades, you must use --allow-overwrite.`); | ||
} | ||
} | ||
} | ||
}); | ||
|
||
if (skippedDatasets && !allowOverwrite) { | ||
common.printMessage(`Skipped writing to a dataset. To write, you must use --allow-overwrite.`); | ||
} else { | ||
zosJes.printAndHandleJcl(`//'${jcllib}(ZWEIMVS)'`, `ZWEIMVS`, jcllib, prefix); | ||
if (runALoadlibCreate === true) { | ||
zosJes.printAndHandleJcl(`//'${jcllib}(ZWEIMVS2)'`, `ZWEIMVS2`, jcllib, prefix); | ||
} | ||
} | ||
|
||
common.printLevel2Message(`Zowe custom data sets are initialized successfully.`); | ||
} |
Oops, something went wrong.