Skip to content

Commit

Permalink
zwe support in typescript (#4147)
Browse files Browse the repository at this point in the history
* Initial commit

Signed-off-by: Martin Zeithaml <[email protected]>

* Missing cli

Signed-off-by: Martin Zeithaml <[email protected]>

* Missing import

Signed-off-by: Martin Zeithaml <[email protected]>

* Typo in import

Signed-off-by: Martin Zeithaml <[email protected]>

* Help update and types

Signed-off-by: Martin Zeithaml <[email protected]>

* Wrong error code

Signed-off-by: Martin Zeithaml <[email protected]>

* Do not exit if called from support

Signed-off-by: Martin Zeithaml <[email protected]>

* Zss PC check

Signed-off-by: Martin Zeithaml <[email protected]>

* Remove item

Signed-off-by: Martin Zeithaml <[email protected]>

* Grep update

Signed-off-by: Martin Zeithaml <[email protected]>

* Node fix

Signed-off-by: Martin Zeithaml <[email protected]>

* zOSMF check

Signed-off-by: Martin Zeithaml <[email protected]>

* zOSMF check in help

Signed-off-by: Martin Zeithaml <[email protected]>

* Changelog update

Signed-off-by: Martin Zeithaml <[email protected]>

* PARMLIB example

Signed-off-by: Martin Zeithaml <[email protected]>

* Node check

Signed-off-by: Martin Zeithaml <[email protected]>

* Typo and indentation

Signed-off-by: Martin Zeithaml <[email protected]>

* Check java version to match defined MIN

Signed-off-by: Martin Zeithaml <[email protected]>

* Move independent java function to separate module

Signed-off-by: Martin Zeithaml <[email protected]>

* Missing update

Signed-off-by: Martin Zeithaml <[email protected]>

* Verify java version

Signed-off-by: Martin Zeithaml <[email protected]>

* update fingerprints to use JAVA_HOME from playbooks

Signed-off-by: MarkAckert <[email protected]>

* empty output means no issues found via comm, print it

Signed-off-by: MarkAckert <[email protected]>

* add note to changelog

Signed-off-by: MarkAckert <[email protected]>

* Member name ZWEYAML in example

Signed-off-by: Martin Zeithaml <[email protected]>

---------

Signed-off-by: Martin Zeithaml <[email protected]>
Signed-off-by: Martin Zeithaml <[email protected]>
Signed-off-by: MarkAckert <[email protected]>
Co-authored-by: Mark Ackert <[email protected]>
Co-authored-by: MarkAckert <[email protected]>
  • Loading branch information
3 people authored Feb 6, 2025
1 parent 825c17e commit 2d18f6c
Show file tree
Hide file tree
Showing 18 changed files with 556 additions and 326 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
All notable changes to the Zowe Installer will be documented in this file.

## `3.2.0`
- Enhancement: `zwe support` command collecting more environment details [#4147](https://github.com/zowe/zowe-install-packaging/pull/4147)
- Enhancement: Added new library function formatZosVersion() [#4134](https://github.com/zowe/zowe-install-packaging/pull/4134)
- `zwe support verify-fingerprints` no longer requires a `zowe.yaml` to be passed as a command-line parameter.

## `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)
Expand Down
3 changes: 2 additions & 1 deletion bin/commands/internal/start/prepare/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import * as config from '../../../../libs/config';
import * as component from '../../../../libs/component';
import * as varlib from '../../../../libs/var';
import * as java from '../../../../libs/java';
import * as javaCI from '../../../../libs/java_ci';
import * as node from '../../../../libs/node';
import * as zosmf from '../../../../libs/zosmf';

Expand Down Expand Up @@ -148,7 +149,7 @@ function globalValidate(enabledComponents:string[]): void {
// validate java for some core components
//TODO this should be a manifest parameter that you require java, not a hardcoded list. What if extensions require it?
if (enabledComponents.includes('gateway') || enabledComponents.includes('zaas') || enabledComponents.includes('discovery') || enabledComponents.includes('api-catalog') || enabledComponents.includes('caching-service')) {
let javaOk = java.validateJavaHome();
let javaOk = javaCI.validateJavaHome();
if (!javaOk) {
privateErrors++;
common.printFormattedError('ZWELS', "zwe-internal-start-prepare,global_validate", `Could not validate java home`);
Expand Down
2 changes: 2 additions & 0 deletions bin/commands/support/.errors
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ZWEL0150E|150|Failed to find file %s. Zowe runtimeDirectory is invalid.
ZWEL0151E|151|Failed to create temporary file %s. Please check permission or volume free space.
5 changes: 5 additions & 0 deletions bin/commands/support/.examples
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
zwe support -c /path/to/zowe.yaml

zwe support -c /path/to/zowe.yaml --target-dir /path/to/save/support/results

zwe support --config 'FILE(/path/to/zowe.yaml):PARMLIB(ZOWE.PARMLIB(ZWEYAML))'
5 changes: 4 additions & 1 deletion bin/commands/support/.help
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ This command will collect these information:
- Environment
* z/OS version
* Java version
* Java keytool TLS information
* Node.js version
* zOSMF status
* External Security Manager
* CEE Runtime Options
* Filesystem flags
* ZSS Program Controlled extended attribute
- Zowe configurations
* Zowe manifest.json
* Zowe configuration file
Expand All @@ -17,5 +21,4 @@ This command will collect these information:
* Zowe APIML static registration files under "`zowe.workspaceDirectory`/api-mediation/api-defs"
- Zowe runtime
* Active running Zowe processes
* Zowe job log
- Zowe fingerprints and validation result
14 changes: 14 additions & 0 deletions bin/commands/support/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
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';

index.execute();
134 changes: 1 addition & 133 deletions bin/commands/support/index.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,136 +11,4 @@
# Copyright Contributors to the Zowe Project.
#######################################################################

print_message_file() {
msg="${1}"
out_file="${2}"
print_message "- ${msg}"
echo "${msg}" >> "${out_file}"
}

print_level0_message "Collect information for Zowe support"

###############################
# constants
DATE=`date +%Y-%m-%d-%H-%M-%S`
target_dir="${ZWE_CLI_PARAMETER_TARGET_DIR}"
if [ -z "${target_dir}" ]; then
target_dir=$(get_tmp_dir)
else
curr_pwd=$(pwd)
cd "${target_dir}"
target_dir=$(pwd)
cd "${curr_pwd}"
fi
tmp_file_prefix=zwe-support
tmp_pax="${target_dir}/${tmp_file_prefix}.${DATE}.pax"
tmp_dir=$(create_tmp_file "${tmp_file_prefix}" "${target_dir}")

###############################
# validate
require_java
require_node
require_zowe_yaml

###############################
print_message "Started at ${DATE}"
mkdir "${tmp_dir}"
chmod 700 "${tmp_dir}"
print_debug "Temporary directory created: ${tmp_dir}"
print_message

###############################
print_level1_message "Collecting various environment information"
ENVIRONMENT_FILE="${tmp_dir}/environment_output"
echo "[Environment information]" > "${ENVIRONMENT_FILE}"
ZOS_VERSION=`operator_command "D IPLINFO" | grep -i release | xargs`
if [ -z "${ZOS_VERSION}" ]; then
ZOS_VERSION=`sysvar SYSOSLVL`
fi
JAVA_VERSION=`${JAVA_HOME}/bin/java -version 2>&1 | head -n 1`
NODE_VERSION=`${NODE_HOME}/bin/node --version`
ESM=`"${ZWE_zowe_runtimeDirectory}/bin/utils/getesm"`
CEE_OPTIONS=`tsocmd "OMVS RUNOPTS('RPTOPTS(ON)')" 2>&1`

print_message_file "z/OS version: ${ZOS_VERSION}" "${ENVIRONMENT_FILE}"
print_message_file "Java version: ${JAVA_VERSION}" "${ENVIRONMENT_FILE}"
print_message_file "NodeJS version: ${NODE_VERSION}" "${ENVIRONMENT_FILE}"
print_message_file "External Security Manager: ${ESM}" "${ENVIRONMENT_FILE}"
print_message_file "CEE Runtime Options: ${CEE_OPTIONS}" "${ENVIRONMENT_FILE}"
print_message

###############################
print_level1_message "Collecting Zowe configurations"
print_message "- manifest.json"
cp "${ZWE_zowe_runtimeDirectory}/manifest.json" "${tmp_dir}"
print_message "- zowe.yaml"
cp "${ZWE_CLI_PARAMETER_CONFIG}" "${tmp_dir}"
ZWE_zowe_workspaceDirectory=$(read_yaml "${ZWE_CLI_PARAMETER_CONFIG}" ".zowe.workspaceDirectory")
if [ -d "${ZWE_zowe_workspaceDirectory}/.env" ]; then
print_message "- <workspace>/.env"
mkdir -p "${tmp_dir}/workspace"
cp -r "${ZWE_zowe_workspaceDirectory}/.env" "${tmp_dir}/workspace"
fi
if [ -d "${ZWE_zowe_workspaceDirectory}/api-mediation/api-defs" ]; then
print_message "- <workspace>/api-mediation/api-defs"
mkdir -p "${tmp_dir}/workspace"
cp -r "${ZWE_zowe_workspaceDirectory}/api-mediation/api-defs" "${tmp_dir}/workspace"
fi
ZWE_zowe_setup_certificate_pkcs12_directory=$(read_yaml "${ZWE_CLI_PARAMETER_CONFIG}" ".zowe.setup.certificate.pkcs12.directory")
if [ -d "${ZWE_zowe_setup_certificate_pkcs12_directory}" ]; then
print_message "- ${ZWE_zowe_setup_certificate_pkcs12_directory}"
mkdir -p "${tmp_dir}/keystore"
cp -r "${ZWE_zowe_setup_certificate_pkcs12_directory}" "${tmp_dir}/keystore"
fi
print_message

###############################
print_level1_message "Collecting Zowe file fingerprints"
print_message "- copy original fingerprints"
cp -r "${ZWE_zowe_runtimeDirectory}/fingerprint" "${tmp_dir}"
print_message "- verify fingerprints"
result=$(export ZWE_PRIVATE_LOG_FILE="${tmp_dir}/verify-fingerprints.log" && export ZWE_PRIVATE_LOG_LEVEL_ZWELS=TRACE && touch "${ZWE_PRIVATE_LOG_FILE}" && . "${ZWE_zowe_runtimeDirectory}/bin/commands/support/verify-fingerprints/index.sh" 2>/dev/null 1>/dev/null)
print_message

###############################
job_name=$(read_yaml "${ZWE_CLI_PARAMETER_CONFIG}" ".zowe.job.name")
job_prefix=$(read_yaml "${ZWE_CLI_PARAMETER_CONFIG}" ".zowe.job.prefix")
print_level1_message "Collecting current process information based on the job prefix ${job_prefix} and job name ${job_name}"
PS_OUTPUT_FILE=${tmp_dir}"/ps_output"

# Collect process information
print_message "- Adding ${PS_OUTPUT_FILE}"
ps -A -o pid,ppid,time,etime,user,jobname,args | grep -e "^[[:space:]]*PID" -e "${job_prefix}" -e "${job_name}" > $PS_OUTPUT_FILE
print_message

###############################
# TODO: job log
# To avoid of using SDSF, we used to use TSO output command to export job log
# but it always fails with below error for me:
# IKJ56328I JOB ZWE1SV REJECTED - JOBNAME MUST BE YOUR USERID OR MUST START WITH YOUR USERID
# REF: https://www.ibm.com/docs/en/zos/2.3.0?topic=subcommands-output-command
# REF: https://www.ibm.com/docs/en/zos/2.3.0?topic=ikj-ikj56328i

###############################
# Collect instance logs
log_dir=$(read_yaml "${ZWE_CLI_PARAMETER_CONFIG}" ".zowe.logDirectory")
print_level1_message "Collecting logs from ${log_dir}"
if [ -d "${log_dir}" ]; then
cp -r "${log_dir}" "${tmp_dir}"
fi
print_message

###############################
print_level1_message "Create support package and clean up"
curr_pwd=$(pwd)
cd "${tmp_dir}"
pax -w -v -o saveext -f "${tmp_pax}" .
compress "${tmp_pax}"
chmod 700 "${tmp_pax}"*
cd "${curr_pwd}"
rm -fr "${tmp_dir}"
print_message

###############################
# exit message
print_level1_message "Zowe support package is generated as ${tmp_pax}.Z"
_CEE_RUNOPTS="XPLINK(ON)" ${ZWE_zowe_runtimeDirectory}/bin/utils/configmgr -script "${ZWE_zowe_runtimeDirectory}/bin/commands/support/cli.js"
Loading

0 comments on commit 2d18f6c

Please sign in to comment.