-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IJMP-1668- Fix connection logs (#78)
* handle connection logs Signed-off-by: Anatoli Kalbasin <qwnize@outlook.com>
- Loading branch information
1 parent
db232f4
commit 880cf4b
Showing
6 changed files
with
79 additions
and
19 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
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
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
42 changes: 42 additions & 0 deletions
42
src/main/kotlin/org/zowe/zdevops/utils/ConnectionValidation.kt
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,42 @@ | ||
/* | ||
* 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 IBA Group 2024 | ||
*/ | ||
|
||
package org.zowe.zdevops.utils | ||
|
||
import hudson.AbortException | ||
import org.zowe.kotlinsdk.zowe.client.sdk.core.ZOSConnection | ||
import org.zowe.kotlinsdk.zowe.client.sdk.zosfiles.ZosDsnList | ||
import org.zowe.kotlinsdk.zowe.client.sdk.zosfiles.input.ListParams | ||
import org.zowe.zdevops.Messages | ||
|
||
/** | ||
* Gets a list of datasets | ||
* Calls the listDsn function of ZosDsnList to list data set names. | ||
* Passes a test data set name ('HELLO.THERE'). | ||
* | ||
* @param zosConnection The ZOSConnection object representing the connection to the z/OS system. | ||
*/ | ||
fun getTestDatasetList(zosConnection: ZOSConnection) { | ||
ZosDsnList(zosConnection).listDsn(Messages.zdevops_config_ZOSConnection_validation_testDS(), ListParams()) | ||
} | ||
|
||
/** | ||
* Validates a z/OS connection. | ||
* | ||
* @param zosConnection The ZOSConnection object representing the connection to the z/OS system. | ||
*/ | ||
fun validateConnection(zosConnection: ZOSConnection) { | ||
try { | ||
getTestDatasetList(zosConnection) | ||
} catch (connectException: Exception) { | ||
val connExMessage = "Failed to connect to z/OS (${zosConnection.user}@${zosConnection.host}:${zosConnection.zosmfPort}): ${connectException.message}" | ||
throw AbortException(connExMessage) | ||
} | ||
} |