Skip to content

Commit 5890a3a

Browse files
committed
cmd overrides for cics profile
Signed-off-by: Paul Cooper <[email protected]>
1 parent 77a5bc6 commit 5890a3a

File tree

10 files changed

+378
-68
lines changed

10 files changed

+378
-68
lines changed

__tests__/api/BundlePush/BundlePusher.test.ts

Lines changed: 116 additions & 33 deletions
Large diffs are not rendered by default.

docs/pages/cdp/CLIReadme.md

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ the target group of CICS regions\.
5959
bundle is undeployed, the definition is removed\. The \-\-csd\-group and
6060
\-\-res\-group options are mutually exclusive\.
6161

62-
* `--cics-hlq` | `--ch` | `--cicshlq` *(string)*
62+
* `--cics-hlq` | `--cq` | `--cicshlq` *(string)*
6363

6464
* Specifies the high\-level qualifier (up to 35 characters) at which the CICS
6565
datasets can be found in the target environment\. Use this parameter if you have
@@ -255,7 +255,7 @@ Push a CICS bundle from the working directory to a target CICSplex\.
255255
bundle is undeployed, the definition is removed\. The \-\-csd\-group and
256256
\-\-res\-group options are mutually exclusive\.
257257

258-
* `--cics-hlq` | `--ch` | `--cicshlq` *(string)*
258+
* `--cics-hlq` | `--cq` | `--cicshlq` *(string)*
259259

260260
* Specifies the high\-level qualifier (up to 35 characters) at which the CICS
261261
datasets can be found in the target environment\. Use this parameter if you have
@@ -362,6 +362,34 @@ Push a CICS bundle from the working directory to a target CICSplex\.
362362

363363
* How long in milliseconds to wait for the SSH handshake to complete\.
364364

365+
#### CICS Connection Options
366+
367+
* `--cics-host` | `--ch` *(string)*
368+
369+
* The CMCI server host name\.
370+
371+
* `--cics-port` | `--cpo` *(number)*
372+
373+
* The CICS server port\.
374+
375+
* `--cics-user` | `--cu` *(string)*
376+
377+
* Mainframe (CICS) user name, which can be the same as your TSO login\.
378+
379+
* `--cics-password` | `--cpw` *(string)*
380+
381+
* Mainframe (CICS) password, which can be the same as your TSO password\.
382+
383+
* `--cics-reject-unauthorized` | `--cru` *(boolean)*
384+
385+
* Reject self\-signed certificates\.
386+
387+
* `--cics-protocol` | `--cpr` *(string)*
388+
389+
* Specifies CMCI protocol (http or https)\.
390+
391+
Allowed values: http, https
392+
365393
#### Profile Options
366394

367395
* `--cics-deploy-profile` | `--cics-deploy-p` *(string)*
@@ -383,7 +411,7 @@ Push a CICS bundle from the working directory to a target CICSplex\.
383411
### Examples
384412

385413
* Push a CICS bundle from the working directory by using
386-
default cics-deploy, ssh and zosmf profiles:
414+
default cics-deploy, cics, ssh and zosmf profiles:
387415

388416
* `$ zowe cics-deploy push bundle --name EXAMPLE --target-directory /u/example/bundles`
389417

@@ -443,7 +471,7 @@ target group of CICS regions\.
443471
bundle is undeployed, the definition is removed\. The \-\-csd\-group and
444472
\-\-res\-group options are mutually exclusive\.
445473

446-
* `--cics-hlq` | `--ch` | `--cicshlq` *(string)*
474+
* `--cics-hlq` | `--cq` | `--cicshlq` *(string)*
447475

448476
* Specifies the high\-level qualifier (up to 35 characters) at which the CICS
449477
datasets can be found in the target environment\. Use this parameter if you have
@@ -539,7 +567,7 @@ actions\.
539567
* Specifies the name of the CICS System, or CICS System Group (up to 8 characters)
540568
to target\.
541569

542-
* `--cics-hlq` | `--ch` | `--cicshlq` *(string)*
570+
* `--cics-hlq` | `--cq` | `--cicshlq` *(string)*
543571

544572
* Specifies the High Level Qualifier (up to 35 characters) at which the CICS
545573
datasets can be found in the target environment\.
@@ -645,7 +673,7 @@ actions\.
645673
if a bundle is undeployed then the definition is removed\. The \-\-csd\-group
646674
and \-\-res\-group options are mutually exclusive\.
647675

648-
* `--cics-hlq` | `--ch` | `--cicshlq` *(string)*
676+
* `--cics-hlq` | `--cq` | `--cicshlq` *(string)*
649677

650678
* Specifies the High Level Qualifier (up to 35 characters) at which the CICS
651679
datasets can be found in the target environment\.

src/api/BundlePush/BundlePusher.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { Bundle } from "../BundleContent/Bundle";
1919
import { SubtaskWithStatus } from "./SubtaskWithStatus";
2020
import { ZosmfConfig } from "./ZosmfConfig";
2121
import { SshConfig } from "./SshConfig";
22+
import { CmciConfig } from "./CmciConfig";
2223

2324

2425
/**
@@ -75,13 +76,22 @@ export class BundlePusher {
7576
}
7677

7778
// Get the profiles
78-
const zosMFProfile = this.getProfile("zosmf", true);
79-
const sshProfile = this.getProfile("ssh", true);
80-
const cicsProfile = this.getProfile("cics", false);
79+
const zosMFProfile = this.getProfile("zosmf");
80+
const sshProfile = this.getProfile("ssh");
81+
let cicsProfile = this.getProfile("cics");
8182
ZosmfConfig.mergeProfile(zosMFProfile, this.params);
8283
SshConfig.mergeProfile(sshProfile, this.params);
84+
CmciConfig.mergeProfile(cicsProfile, this.params);
85+
86+
// The cics profile is optional, detect whether it has been set (or constructed)
87+
if (Object.keys(cicsProfile).length === 0) {
88+
cicsProfile = undefined;
89+
}
90+
91+
// Now detect any mismatches between the values from the profiles
8392
this.validateProfiles(zosMFProfile, sshProfile, cicsProfile);
8493

94+
8595
// Create a zOSMF session
8696
const zosMFSession = await this.createZosMFSession(zosMFProfile);
8797
// Create an SSH session
@@ -188,10 +198,10 @@ export class BundlePusher {
188198
}
189199
}
190200

191-
private getProfile(type: string, required: boolean): IProfile {
201+
private getProfile(type: string): IProfile {
192202
let profile = this.params.profiles.get(type);
193203

194-
if (required && profile === undefined) {
204+
if (profile === undefined) {
195205
profile = {};
196206
}
197207

@@ -231,7 +241,7 @@ export class BundlePusher {
231241
if (sameHostAndUser) {
232242
if (sshProfile.password !== undefined) {
233243
if (zosmfProfile.password !== sshProfile.password) {
234-
throw new Error("Incompatible security credentials exist in the zosmf and ssh configurations.");
244+
throw new Error("Different passwords are specified for the same user ID in the zosmf and ssh configurations.");
235245
}
236246
}
237247
}
@@ -250,7 +260,7 @@ export class BundlePusher {
250260

251261
if (sameHostAndUser) {
252262
if (zosmfProfile.password !== cicsProfile.password) {
253-
throw new Error("Incompatible security credentials exist in the zosmf and cics configurations.");
263+
throw new Error("Different passwords are specified for the same user ID in the zosmf and cics configurations.");
254264
}
255265
}
256266
}

src/api/BundlePush/CmciConfig.ts

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/*
2+
* This program and the accompanying materials are made available under the terms of the
3+
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
4+
* https://www.eclipse.org/legal/epl-v20.html
5+
*
6+
* SPDX-License-Identifier: EPL-2.0
7+
*
8+
* Copyright IBM Corp, 2019
9+
*
10+
*/
11+
12+
"use strict";
13+
14+
import { IHandlerParameters, IProfile } from "@zowe/imperative";
15+
16+
17+
/**
18+
* Class to implement CMCI configuration.
19+
*
20+
* @export
21+
* @class CmciConfig
22+
*/
23+
export class CmciConfig {
24+
25+
/**
26+
* Merge command line overrides together with the optional cmciProfile into a
27+
* composite whole
28+
*/
29+
public static mergeProfile(cmciProfile: IProfile, params: IHandlerParameters) {
30+
31+
if (params.arguments.ch !== undefined) {
32+
cmciProfile.host = params.arguments.ch;
33+
cmciProfile.H = params.arguments.ch;
34+
}
35+
36+
if (params.arguments.cpo !== undefined) {
37+
cmciProfile.port = params.arguments.cpo;
38+
cmciProfile.P = params.arguments.cpo;
39+
}
40+
41+
if (params.arguments.cu !== undefined) {
42+
cmciProfile.user = params.arguments.cu;
43+
cmciProfile.u = params.arguments.cu;
44+
}
45+
46+
if (params.arguments.cpw !== undefined) {
47+
cmciProfile.password = params.arguments.cpw;
48+
cmciProfile.pw = params.arguments.cpw;
49+
}
50+
51+
if (params.arguments.cru !== undefined) {
52+
cmciProfile.rejectUnauthorized = params.arguments.cru;
53+
cmciProfile.ru = params.arguments.cru;
54+
}
55+
56+
if (params.arguments.cpr !== undefined) {
57+
cmciProfile.protocol = params.arguments.cpr;
58+
cmciProfile.u = params.arguments.cpr;
59+
}
60+
61+
// The CICS profile is optional, only validate it further if there is some content
62+
if (Object.keys(cmciProfile).length > 0) {
63+
CmciConfig.validateRequired(cmciProfile);
64+
}
65+
}
66+
67+
private static DEFAULT_CMCI_PORT = 443;
68+
private static validateRequired(cmciProfile: IProfile) {
69+
this.checkValueFound(cmciProfile.host, "cics-host");
70+
this.checkValueFound(cmciProfile.user, "cics-user");
71+
this.checkValueFound(cmciProfile.password, "cics-password");
72+
73+
// Now implement the default value for the port
74+
if (cmciProfile.port === undefined) {
75+
cmciProfile.port = CmciConfig.DEFAULT_CMCI_PORT;
76+
cmciProfile.P = CmciConfig.DEFAULT_CMCI_PORT;
77+
}
78+
79+
// Note, default values for protocol and rejectUnauthorized are implemented
80+
// in the underlying cics-plugin.
81+
}
82+
83+
private static checkValueFound(value: string, parm: string) {
84+
if (value === undefined) {
85+
throw new Error("Partial cics plug-in configuration encountered, --" + parm + " is not set.");
86+
}
87+
}
88+
}

src/api/BundlePush/SshConfig.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,21 @@ export class SshConfig {
7070
SshConfig.validateRequired(sshProfile);
7171
}
7272

73+
private static DEFAULT_SSH_PORT = 22;
7374
private static validateRequired(sshProfile: IProfile) {
74-
if (sshProfile.host === undefined) {
75-
throw new Error("Required parameter --ssh-host is not set.");
76-
}
75+
this.checkValueFound(sshProfile.host, "ssh-host");
76+
this.checkValueFound(sshProfile.user, "ssh-user");
77+
78+
// Now implement the default value for the port
7779
if (sshProfile.port === undefined) {
78-
throw new Error("Required parameter --ssh-port is not set.");
79-
}
80-
if (sshProfile.user === undefined) {
81-
throw new Error("Required parameter --ssh-user is not set.");
80+
sshProfile.port = SshConfig.DEFAULT_SSH_PORT;
81+
sshProfile.P = SshConfig.DEFAULT_SSH_PORT;
8282
}
8383
}
8484

85+
private static checkValueFound(value: string, parm: string) {
86+
if (value === undefined) {
87+
throw new Error("Required parameter --" + parm + " is not set.");
88+
}
89+
}
8590
}

src/api/BundlePush/ZosmfConfig.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,22 +62,28 @@ export class ZosmfConfig {
6262
ZosmfConfig.validateRequired(zosmfProfile);
6363
}
6464

65+
private static DEFAULT_ZOSMF_PORT = 443;
6566
private static validateRequired(zosmfProfile: IProfile) {
66-
if (zosmfProfile.host === undefined) {
67-
throw new Error("Required parameter --zosmf-host is not set.");
68-
}
67+
this.checkValueFound(zosmfProfile.host, "zosmf-host");
68+
this.checkValueFound(zosmfProfile.user, "zosmf-user");
69+
this.checkValueFound(zosmfProfile.password, "zosmf-password");
70+
71+
// Now implement the default value for the port
6972
if (zosmfProfile.port === undefined) {
70-
throw new Error("Required parameter --zosmf-port is not set.");
71-
}
72-
if (zosmfProfile.user === undefined) {
73-
throw new Error("Required parameter --zosmf-user is not set.");
74-
}
75-
if (zosmfProfile.password === undefined) {
76-
throw new Error("Required parameter --zosmf-password is not set.");
73+
zosmfProfile.port = ZosmfConfig.DEFAULT_ZOSMF_PORT;
74+
zosmfProfile.P = ZosmfConfig.DEFAULT_ZOSMF_PORT;
7775
}
76+
77+
// And for reject-unauthorized
7878
if (zosmfProfile.rejectUnauthorized === undefined) {
79-
throw new Error("Required parameter --zosmf-reject-unauthorized is not set.");
79+
zosmfProfile.rejectUnauthorized = true;
80+
zosmfProfile.ru = true;
8081
}
8182
}
8283

84+
private static checkValueFound(value: string, parm: string) {
85+
if (value === undefined) {
86+
throw new Error("Required parameter --" + parm + " is not set.");
87+
}
88+
}
8389
}

src/cli/push/bundle/PushBundle.definition.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { VerboseOption } from "../../shared/Verbose.option";
2626
import { OverwriteOption } from "./options/Overwrite.option";
2727
import { ZosmfOptions } from "./options/ZosmfOptions";
2828
import { SshOptions } from "./options/SshOptions";
29+
import { CmciOptions } from "./options/CmciOptions";
2930

3031
/**
3132
* Imperative command for the Bundle sub-option of Push.
@@ -42,11 +43,12 @@ export const PushBundleDefinition: ICommandDefinition = {
4243
CicshlqOption, CpsmhlqOption, DescriptionOption, JobcardOption, TimeoutOption, TargetStateOption,
4344
VerboseOption, OverwriteOption ]
4445
.concat(ZosmfOptions.CICS_DEPLOY_ZOSMF_CONNECTION_OPTIONS)
45-
.concat(SshOptions.CICS_DEPLOY_SSH_CONNECTION_OPTIONS),
46+
.concat(SshOptions.CICS_DEPLOY_SSH_CONNECTION_OPTIONS)
47+
.concat(CmciOptions.CICS_DEPLOY_CMCI_CONNECTION_OPTIONS),
4648
profile: { optional: ["cics-deploy", "zosmf", "ssh", "cics"] },
4749
examples: [
4850
{
49-
description: "Push a CICS bundle from the working directory by using default cics-deploy, ssh and zosmf profiles",
51+
description: "Push a CICS bundle from the working directory by using default cics-deploy, cics, ssh and zosmf profiles",
5052
options: `--name EXAMPLE --target-directory /u/example/bundles`
5153
},
5254
{

0 commit comments

Comments
 (0)