Skip to content

Commit 07a5c97

Browse files
authored
Merge pull request #249 from pcoop/branch1
First chunk of code for cmd line options
2 parents 5a9c23a + 78771c9 commit 07a5c97

35 files changed

+951
-104
lines changed

__tests__/api/BundlePush/BundlePusher.test.ts

Lines changed: 239 additions & 59 deletions
Large diffs are not rendered by default.

docs/pages/cdp/CLIReadme.md

Lines changed: 101 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ the target group of CICS regions\.
2020

2121
zowe cics-deploy deploy bundle [options]
2222

23-
#### Required Options
23+
#### cics-deploy Options
2424

2525
* `--name` | `-n` *(string)*
2626

@@ -31,8 +31,6 @@ the target group of CICS regions\.
3131

3232
* Specifies the location of the CICS bundle (up to 255 characters) on zFS\.
3333

34-
#### Options
35-
3634
* `--cicsplex` | `--cp` *(string)*
3735

3836
* Specifies the CICSplex (up to 8 characters) to target\. Use this parameter if
@@ -61,7 +59,7 @@ the target group of CICS regions\.
6159
bundle is undeployed, the definition is removed\. The \-\-csd\-group and
6260
\-\-res\-group options are mutually exclusive\.
6361

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

6664
* Specifies the high\-level qualifier (up to 35 characters) at which the CICS
6765
datasets can be found in the target environment\. Use this parameter if you have
@@ -144,7 +142,7 @@ required\.
144142

145143
zowe cics-deploy generate bundle [options]
146144

147-
#### Options
145+
#### cics-deploy Options
148146

149147
* `--bundle-id` | `-b` | `--id` | `--bundleid` *(string)*
150148

@@ -217,7 +215,7 @@ Push a CICS bundle from the working directory to a target CICSplex\.
217215

218216
zowe cics-deploy push bundle [options]
219217

220-
#### Required Options
218+
#### cics-deploy Options
221219

222220
* `--name` | `-n` *(string)*
223221

@@ -229,8 +227,6 @@ Push a CICS bundle from the working directory to a target CICSplex\.
229227
* Specifies the target zFS location in which the CICS bundle is to be created (up
230228
to 255 characters)
231229

232-
#### Options
233-
234230
* `--cicsplex` | `--cp` *(string)*
235231

236232
* Specifies the CICSplex (up to 8 characters) to target\. Use this parameter if
@@ -259,7 +255,7 @@ Push a CICS bundle from the working directory to a target CICSplex\.
259255
bundle is undeployed, the definition is removed\. The \-\-csd\-group and
260256
\-\-res\-group options are mutually exclusive\.
261257

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

264260
* Specifies the high\-level qualifier (up to 35 characters) at which the CICS
265261
datasets can be found in the target environment\. Use this parameter if you have
@@ -307,8 +303,99 @@ Push a CICS bundle from the working directory to a target CICSplex\.
307303
* Enable or disable the ability to replace an existing bundle directory or bundle
308304
on the remote system\.
309305

306+
#### Zosmf Connection Options
307+
308+
* `--zosmf-host` | `--zh` *(string)*
309+
310+
* The z/OSMF server host name\.
311+
312+
* `--zosmf-port` | `--zp` *(number)*
313+
314+
* The z/OSMF server port\.
315+
316+
* `--zosmf-user` | `--zu` *(string)*
317+
318+
* Mainframe (z/OSMF) user name, which can be the same as your TSO login\.
319+
320+
* `--zosmf-password` | `--zpw` *(string)*
321+
322+
* Mainframe (z/OSMF) password, which can be the same as your TSO password\.
323+
324+
* `--zosmf-reject-unauthorized` | `--zru` *(boolean)*
325+
326+
* Reject self\-signed certificates\.
327+
328+
* `--zosmf-base-path` | `--zbp` *(string)*
329+
330+
* The base path for your API mediation layer instance\. Specify this option to
331+
prepend the base path to all z/OSMF resources when making REST requests\. Do not
332+
specify this option if you are not using an API mediation layer\.
333+
334+
#### z/OS Ssh Connection Options
335+
336+
* `--ssh-host` | `--sh` *(string)*
337+
338+
* The z/OS SSH server host name\.
339+
340+
* `--ssh-port` | `--sp` *(number)*
341+
342+
* The z/OS SSH server port\.
343+
344+
* `--ssh-user` | `--su` *(string)*
345+
346+
* Mainframe user name, which can be the same as your TSO login\.
347+
348+
* `--ssh-password` | `--spw` *(string)*
349+
350+
* Mainframe password, which can be the same as your TSO password\.
351+
352+
* `--ssh-private-key` | `--spk` *(string)*
353+
354+
* Path to a file containing your private key, that must match a public key stored
355+
in the server for authentication
356+
357+
* `--ssh-key-passphrase` | `--skp` *(string)*
358+
359+
* Private key passphrase, which unlocks the private key\.
360+
361+
* `--ssh-handshake-timeout` | `--sht` *(number)*
362+
363+
* How long in milliseconds to wait for the SSH handshake to complete\.
364+
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+
310393
#### Profile Options
311394

395+
* `--cics-deploy-profile` | `--cics-deploy-p` *(string)*
396+
397+
* The name of a (cics\-deploy) profile to load for this command execution\.
398+
312399
* `--zosmf-profile` | `--zosmf-p` *(string)*
313400

314401
* The name of a (zosmf) profile to load for this command execution\.
@@ -317,18 +404,14 @@ Push a CICS bundle from the working directory to a target CICSplex\.
317404

318405
* The name of a (ssh) profile to load for this command execution\.
319406

320-
* `--cics-deploy-profile` | `--cics-deploy-p` *(string)*
321-
322-
* The name of a (cics\-deploy) profile to load for this command execution\.
323-
324407
* `--cics-profile` | `--cics-p` *(string)*
325408

326409
* The name of a (cics) profile to load for this command execution\.
327410

328411
### Examples
329412

330413
* Push a CICS bundle from the working directory by using
331-
default cics-deploy, ssh and zosmf profiles:
414+
default cics-deploy, cics, ssh and zosmf profiles:
332415

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

@@ -353,15 +436,13 @@ target group of CICS regions\.
353436

354437
zowe cics-deploy undeploy bundle [options]
355438

356-
#### Required Options
439+
#### cics-deploy Options
357440

358441
* `--name` | `-n` *(string)*
359442

360443
* Specifies the name of the CICS BUNDLE resource (up to 8 characters) to deploy or
361444
undeploy\.
362445

363-
#### Options
364-
365446
* `--cicsplex` | `--cp` *(string)*
366447

367448
* Specifies the CICSplex (up to 8 characters) to target\. Use this parameter if
@@ -390,7 +471,7 @@ target group of CICS regions\.
390471
bundle is undeployed, the definition is removed\. The \-\-csd\-group and
391472
\-\-res\-group options are mutually exclusive\.
392473

393-
* `--cics-hlq` | `--ch` | `--cicshlq` *(string)*
474+
* `--cics-hlq` | `--cq` | `--cicshlq` *(string)*
394475

395476
* Specifies the high\-level qualifier (up to 35 characters) at which the CICS
396477
datasets can be found in the target environment\. Use this parameter if you have
@@ -486,7 +567,7 @@ actions\.
486567
* Specifies the name of the CICS System, or CICS System Group (up to 8 characters)
487568
to target\.
488569

489-
* `--cics-hlq` | `--ch` | `--cicshlq` *(string)*
570+
* `--cics-hlq` | `--cq` | `--cicshlq` *(string)*
490571

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

595-
* `--cics-hlq` | `--ch` | `--cicshlq` *(string)*
676+
* `--cics-hlq` | `--cq` | `--cicshlq` *(string)*
596677

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

src/api/BundlePush/BundlePusher.ts

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ import { getResource, IResourceParms } from "@zowe/cics";
1717
import { BundleDeployer } from "../BundleDeploy/BundleDeployer";
1818
import { Bundle } from "../BundleContent/Bundle";
1919
import { SubtaskWithStatus } from "./SubtaskWithStatus";
20+
import { ZosmfConfig } from "./ZosmfConfig";
21+
import { SshConfig } from "./SshConfig";
22+
import { CmciConfig } from "./CmciConfig";
2023

2124

2225
/**
@@ -73,11 +76,22 @@ export class BundlePusher {
7376
}
7477

7578
// Get the profiles
76-
const zosMFProfile = this.getProfile("zosmf", true);
77-
const sshProfile = this.getProfile("ssh", true);
78-
const cicsProfile = this.getProfile("cics", false);
79+
const zosMFProfile = this.getProfile("zosmf");
80+
const sshProfile = this.getProfile("ssh");
81+
let cicsProfile = this.getProfile("cics");
82+
ZosmfConfig.mergeProfile(zosMFProfile, this.params);
83+
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
7992
this.validateProfiles(zosMFProfile, sshProfile, cicsProfile);
8093

94+
8195
// Create a zOSMF session
8296
const zosMFSession = await this.createZosMFSession(zosMFProfile);
8397
// Create an SSH session
@@ -184,11 +198,11 @@ export class BundlePusher {
184198
}
185199
}
186200

187-
private getProfile(type: string, required: boolean): IProfile {
188-
const profile = this.params.profiles.get(type);
201+
private getProfile(type: string): IProfile {
202+
let profile = this.params.profiles.get(type);
189203

190-
if (required && profile === undefined) {
191-
throw new Error("No " + type + " profile found");
204+
if (profile === undefined) {
205+
profile = {};
192206
}
193207

194208
return profile;
@@ -212,13 +226,13 @@ export class BundlePusher {
212226
let sameHostAndUser = true;
213227
if (zosmfProfile.host !== sshProfile.host) {
214228
sameHostAndUser = false;
215-
this.issueWarning("ssh profile --host value '" + sshProfile.host + "' does not match zosmf value '" + zosmfProfile.host + "'.");
229+
this.issueWarning("--ssh-host value '" + sshProfile.host + "' does not match --zosmf-host value '" + zosmfProfile.host + "'.");
216230
}
217231

218232
// Do the required profiles share the same user name?
219233
if (zosmfProfile.user.toUpperCase() !== sshProfile.user.toUpperCase()) {
220234
sameHostAndUser = false;
221-
this.issueWarning("ssh profile --user value '" + sshProfile.user + "' does not match zosmf value '" + zosmfProfile.user + "'.");
235+
this.issueWarning("--ssh-user value '" + sshProfile.user + "' does not match --zosmf-user value '" + zosmfProfile.user + "'.");
222236
}
223237

224238
// If the zoSMF user and host are the same then validate that the passwords are the same too.
@@ -227,7 +241,7 @@ export class BundlePusher {
227241
if (sameHostAndUser) {
228242
if (sshProfile.password !== undefined) {
229243
if (zosmfProfile.password !== sshProfile.password) {
230-
throw new Error("Incompatible security credentials exist in the zosmf and ssh profiles.");
244+
throw new Error("Different passwords are specified for the same user ID in the zosmf and ssh configurations.");
231245
}
232246
}
233247
}
@@ -237,24 +251,18 @@ export class BundlePusher {
237251
sameHostAndUser = true;
238252
if (zosmfProfile.host !== cicsProfile.host) {
239253
sameHostAndUser = false;
240-
this.issueWarning("cics profile --host value '" + cicsProfile.host + "' does not match zosmf value '" + zosmfProfile.host + "'.");
254+
this.issueWarning("--cics-host value '" + cicsProfile.host + "' does not match --zosmf-host value '" + zosmfProfile.host + "'.");
241255
}
242256
if (zosmfProfile.user.toUpperCase() !== cicsProfile.user.toUpperCase()) {
243257
sameHostAndUser = false;
244-
this.issueWarning("cics profile --user value '" + cicsProfile.user + "' does not match zosmf value '" + zosmfProfile.user + "'.");
258+
this.issueWarning("--cics-user value '" + cicsProfile.user + "' does not match --zosmf-user value '" + zosmfProfile.user + "'.");
245259
}
246260

247261
if (sameHostAndUser) {
248262
if (zosmfProfile.password !== cicsProfile.password) {
249-
throw new Error("Incompatible security credentials exist in the zosmf and cics profiles.");
263+
throw new Error("Different passwords are specified for the same user ID in the zosmf and cics configurations.");
250264
}
251265
}
252-
253-
// Do the cics-plexes match?
254-
if (cicsProfile.cicsPlex !== undefined && this.params.arguments.cicsplex !== cicsProfile.cicsPlex) {
255-
this.issueWarning("cics profile --cics-plex value '" + cicsProfile.cicsPlex +
256-
"' does not match --cicsplex value '" + this.params.arguments.cicsplex + "'.");
257-
}
258266
}
259267
}
260268

0 commit comments

Comments
 (0)