Skip to content

Commit

Permalink
Merge pull request #4061 from zowe/v3.x/feature/diagnose
Browse files Browse the repository at this point in the history
`zwe diagnose` in JS only
  • Loading branch information
MarkAckert authored Nov 5, 2024
2 parents 20638b8 + 626a474 commit 6aecbd2
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 102 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ All notable changes to the Zowe Installer will be documented in this file.
## `3.0.1`
- Bugfix: When `--log-dir` parameter for `zwe` command is a file, there might be an error "InternalError: stack overflow". [#40nn](https://github.com/zowe/zowe-install-packaging/pull/40nn)
- Enhancement: new javascript funtion `getStatvfs()` to obtain information about the file sysytem [#3994](https://github.com/zowe/zowe-install-packaging/pull/3994)
- Enhancement: command `zwe diagnose` in javascript only [#4061](https://github.com/zowe/zowe-install-packaging/pull/4061)
- Enhancement: schema validation update for `zowe.job.name` and `zowe.job.prefix` [#4060](https://github.com/zowe/zowe-install-packaging/pull/4060)

## `3.0.0`
Expand Down
57 changes: 1 addition & 56 deletions bin/commands/diagnose/index.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,59 +11,4 @@
# Copyright Contributors to the Zowe Project.
#######################################################################

USE_CONFIGMGR=$(check_configmgr_enabled)
if [ "${USE_CONFIGMGR}" = "true" ]; then
_CEE_RUNOPTS="XPLINK(ON),HEAPPOOLS(OFF),HEAPPOOLS64(OFF)" ${ZWE_zowe_runtimeDirectory}/bin/utils/configmgr -script "${ZWE_zowe_runtimeDirectory}/bin/commands/diagnose/cli.js"
else

error_code="${ZWE_CLI_PARAMETER_ERROR_CODE}"

print_message ""

if echo $error_code | grep -q -E "^[zZ][wW][eE][AaSsDdLl][A-Za-z]?[0-9]{3,4}[A-Za-z]$"; then
server_code=$(echo "${error_code}" | cut -c4)
if [[ "$server_code" == [Dd] ]]; then
print_message "This code corresponds to the errors related to the ZOWE Desktop and the App Server."
print_message ""
print_message "To find the description of this error code, refer to the:"
print_message ""
print_message " Zowe documentation for Application framework"
print_message " https://docs.zowe.org/stable/troubleshoot/app-framework/appserver-error-codes"
elif [[ "$server_code" == [Ss] ]]; then
print_message "This code corresponds to the errors related to the Zowe Subsystem Services (ZSS) and Zowe Installation Services (ZIS)."
print_message ""
print_message "To find the description of this error code, refer to the:"
print_message ""
print_message " Zowe documentation for ZSS"
print_message " https://docs.zowe.org/stable/troubleshoot/app-framework/zss-error-codes"
print_message " Zowe documentation for ZIS"
print_message " https://docs.zowe.org/stable/troubleshoot/app-framework/zis-error-codes"
elif [[ "$server_code" == [Aa] ]]; then
print_message "This code corresponds to the errors related to the Zowe API Mediation Layer (APIML)."
print_message ""
print_message "To find the description of this error code, refer to the:"
print_message ""
print_message " Zowe documentation for API Mediation Layer"
print_message " https://docs.zowe.org/stable/troubleshoot/troubleshoot-apiml-error-codes"
elif [[ "$server_code" == [Ll] ]]; then
print_message "This code corresponds to the errors related to the Zowe Launcher and ZWE."
print_message ""
print_message "To find the description of this error code, refer to the:"
print_message ""
print_message " Zowe documentation for Launcher"
print_message " https://docs.zowe.org/stable/troubleshoot/launcher/launcher-error-codes"
print_message " Launcher error codes"
print_message " https://github.com/zowe/launcher/blob/v2.x/master/src/msg.h"
print_message " Zowe documentation for ZWE"
print_message " https://docs.zowe.org/stable/appendix/zwe_server_command_reference/zwe/"
fi
print_message ""
print_message "You may also explore reports from other users experiencing the same error by searching"
print_message "https://github.com/search?q=org%3Azowe+${error_code}&type=discussions"
else
print_error_and_exit "ZWEL0102E: Invalid parameter --error-code='${error_code}'" "" 102
fi

print_message ""

fi
_CEE_RUNOPTS="XPLINK(ON)" ${ZWE_zowe_runtimeDirectory}/bin/utils/configmgr -script "${ZWE_zowe_runtimeDirectory}/bin/commands/diagnose/cli.js"
91 changes: 45 additions & 46 deletions bin/commands/diagnose/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,65 +3,64 @@
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 common from '../../libs/common';

const THIS_CODE = "\nThis code corresponds to the errors related to the";
const FIND_DESC = "To find the description of this error code, refer to the:\n ";
const URL = {
apiML: "https://docs.zowe.org/stable/troubleshoot/troubleshoot-apiml-error-codes",
appFW : "https://docs.zowe.org/stable/troubleshoot/app-framework/appserver-error-codes",
launcher: "https://docs.zowe.org/stable/troubleshoot/launcher/launcher-error-codes",
launcherGit: "https://github.com/zowe/launcher/blob/v2.x/master/src/msg.h",
zss: "https://docs.zowe.org/stable/troubleshoot/app-framework/zss-error-codes",
zis: "https://docs.zowe.org/stable/troubleshoot/app-framework/zis-error-codes",
zwe: "https://docs.zowe.org/stable/appendix/zwe_server_command_reference/zwe/"
}

function thisCodeCorrespondsTo(component: string){
common.printMessage(`${THIS_CODE} ${component}.\n`);
common.printMessage(`${FIND_DESC}`);
const COMPONENTS = {
a: {
title: 'Zowe API Mediation Layer (APIML)',
urls: [
{ text: 'API Mediation Layer', link: 'https://docs.zowe.org/stable/troubleshoot/troubleshoot-apiml-error-codes' }
]
},
d: {
title: 'Zowe Desktop and the App Server',
urls: [
{ text: 'Application framework', link: 'https://docs.zowe.org/stable/troubleshoot/app-framework/appserver-error-codes' }
]
},
l: {
title: 'Zowe Launcher and zwe',
urls: [
{ text: 'Launcher', link: 'https://docs.zowe.org/stable/troubleshoot/launcher/launcher-error-codes' },
{ text: 'Launcher error codes', link: `https://github.com/zowe/launcher/blob/v${common.getZoweVersion().substring(0,1)}.x/master/src/msg.h`, git: true },
{ text: 'zwe', link: 'https://docs.zowe.org/stable/appendix/zwe_server_command_reference/zwe/' },
]
},
s: {
title: 'Zowe Subsystem Services (ZSS) and Zowe Installation Services (ZIS)',
urls: [
{ text: 'ZSS', link: 'https://docs.zowe.org/stable/troubleshoot/app-framework/zss-error-codes' },
{ text: 'ZIS', link: 'https://docs.zowe.org/stable/troubleshoot/app-framework/zis-error-codes' }
]
}
}

function printLinks(description: string, link: string){
if (link.indexOf('github') > 0)
common.printMessage(` ${description}`)
else
common.printMessage(` Zowe documentation for ${description}`)
common.printMessage(` ${link}`);
function printComponent(component: any): void {
common.printMessage(`\nThis code corresponds to the errors related to the ${component.title}.\n`);
common.printMessage(`To find the description of this error code, refer to the:\n`);
for (let url in component.urls) {
let zoweDocFor = component.urls[url].git ? '' : 'Zowe documentation for ';
common.printMessage(` ${zoweDocFor}${component.urls[url].text}`);
common.printMessage(` ${component.urls[url].link}`);
}
}

export function execute() {
export function execute(): void {
const errorCode = std.getenv('ZWE_CLI_PARAMETER_ERROR_CODE');
if (/^[zZ][wW][eE][AaSsDdLl][A-Za-z]?[0-9]{3,4}[A-Za-z]$/.test(errorCode)) {
const serverCode = errorCode.charAt(3);
if (serverCode.toLowerCase() === 'd') {
thisCodeCorrespondsTo('ZOWE Desktop and the App Server');
printLinks('Application framework', `${URL.appFW}`);
}
else if (serverCode.toLowerCase() === 's') {
thisCodeCorrespondsTo('Zowe Subsystem Services (ZSS) and Zowe Installation Services (ZIS)');
printLinks('ZSS', `${URL.zss}`);
printLinks('ZIS', `${URL.zis}`);
}
else if (serverCode.toLowerCase() === 'a') {
thisCodeCorrespondsTo('Zowe API Mediation Layer (APIML)');
printLinks('API Mediation Layer', `${URL.apiML}`);
const serverCode = errorCode.charAt(3).toLowerCase();
if ('adls'.includes(serverCode)) {
printComponent(COMPONENTS[serverCode]);
common.printMessage(`\nYou may also explore reports from other users experiencing the same error by searching\nhttps://github.com/search?q=org%3Azowe+${errorCode}&type=discussions\n`);
}
else if (serverCode.toLowerCase() === 'l') {
thisCodeCorrespondsTo('Zowe Launcher and ZWE');
printLinks('Launcher', `${URL.launcher}`);
printLinks('Launcher error codes', `${URL.launcherGit}`);
printLinks('ZWE', `${URL.zwe}`);
}
common.printMessage(`\nYou may also explore reports from other users experiencing the same error by searching\nhttps://github.com/search?q=org%3Azowe+${errorCode}&type=discussions\n`);
}
else {
} else {
common.printErrorAndExit(`ZWEL0102E: Invalid parameter --error-code='${errorCode}'`, undefined, 102);
}
}

0 comments on commit 6aecbd2

Please sign in to comment.