@@ -43,6 +43,7 @@ export class BundlePusher {
43
43
* @memberof BundlePusher
44
44
*/
45
45
constructor ( params : IHandlerParameters , localDirectory : string ) {
46
+
46
47
this . params = params ;
47
48
this . localDirectory = localDirectory ;
48
49
this . validateParameters ( ) ;
@@ -130,11 +131,13 @@ export class BundlePusher {
130
131
await this . runAllNpmInstalls ( sshSession , packageJsonFiles ) ;
131
132
132
133
// Run DFHDPLOY to install the bundle
133
- await this . deployBundle ( zosMFSession , bd , cicsSession , bundle ) ;
134
+ const deployMessages = await this . deployBundle ( zosMFSession , bd , cicsSession , bundle ) ;
134
135
135
136
// Complete the progress bar
136
137
this . progressBar . percentComplete = TaskProgress . ONE_HUNDRED_PERCENT ;
137
138
this . endProgressBar ( ) ;
139
+
140
+ this . issueMessage ( deployMessages ) ;
138
141
return "PUSH operation completed." ;
139
142
}
140
143
@@ -341,7 +344,8 @@ export class BundlePusher {
341
344
this . startProgressBar ( ) ;
342
345
}
343
346
344
- private async deployBundle ( zosMFSession : AbstractSession , bd : BundleDeployer , cicsSession : AbstractSession , bundle : Bundle ) {
347
+ private async deployBundle ( zosMFSession : AbstractSession , bd : BundleDeployer ,
348
+ cicsSession : AbstractSession , bundle : Bundle ) : Promise < string > {
345
349
// End the current progress bar so that DEPLOY can create its own
346
350
this . updateStatus ( "Deploying bundle '" + this . params . arguments . name + "' to CICS" ) ;
347
351
const subtask = new SubtaskWithStatus ( this . progressBar , TaskProgress . THIRTY_PERCENT ) ;
@@ -369,16 +373,20 @@ export class BundlePusher {
369
373
this . startProgressBar ( ) ;
370
374
371
375
// Collect general information about the regions in the CICSplex scope
372
- const diagnosticsWorking = await this . outputGeneralDiagnostics ( cicsSession ) ;
373
- if ( diagnosticsWorking && bundle . containsDefinitionsOfType ( "http://www.ibm.com/xmlns/prod/cics/bundle/NODEJSAPP" ) ) {
376
+ let deployMessages = await this . generateGeneralDiagnostics ( cicsSession ) ;
377
+ if ( deployMessages !== "" && bundle . containsDefinitionsOfType ( "http://www.ibm.com/xmlns/prod/cics/bundle/NODEJSAPP" ) ) {
374
378
// Generate additional diagnostic output for Node.js
375
- await this . outputNodejsSpecificDiagnostics ( cicsSession ) ;
379
+ deployMessages += await this . generateNodejsSpecificDiagnostics ( cicsSession ) ;
376
380
}
377
381
378
382
// Now rethrow the original error, if there was one.
379
383
if ( deployError !== undefined ) {
384
+ // If we're going to throw an error then report any messages now
385
+ this . issueMessage ( deployMessages ) ;
380
386
throw deployError ;
381
387
}
388
+
389
+ return deployMessages ;
382
390
}
383
391
384
392
private sshOutput ( data : string ) {
@@ -615,13 +623,13 @@ export class BundlePusher {
615
623
}
616
624
}
617
625
618
- private async outputGeneralDiagnostics ( cicsSession : AbstractSession ) : Promise < boolean > {
619
- let scopeFound = false ;
626
+ private async generateGeneralDiagnostics ( cicsSession : AbstractSession ) : Promise < string > {
627
+ let msgBuffer = "" ;
620
628
try {
621
629
if ( cicsSession !== undefined ) {
622
630
// Attempt to gather additional Node.js specific information from CICS
623
631
this . updateStatus ( "Gathering Scope information" ) ;
624
- scopeFound = await this . gatherGeneralDiagnosticsFromCics ( cicsSession ) ;
632
+ msgBuffer = await this . gatherGeneralDiagnosticsFromCics ( cicsSession ) ;
625
633
}
626
634
}
627
635
catch ( diagnosticsError ) {
@@ -633,15 +641,15 @@ export class BundlePusher {
633
641
logger . debug ( diagnosticsError . message ) ;
634
642
}
635
643
}
636
- return scopeFound ;
644
+ return msgBuffer ;
637
645
}
638
646
639
- private async outputNodejsSpecificDiagnostics ( cicsSession : AbstractSession ) {
640
- let diagnosticsIssued = false ;
647
+ private async generateNodejsSpecificDiagnostics ( cicsSession : AbstractSession ) : Promise < string > {
648
+ let msgBuffer = "" ;
641
649
try {
642
650
// Attempt to gather additional Node.js specific information from CICS
643
651
this . updateStatus ( "Gathering Node.js diagnostics" ) ;
644
- diagnosticsIssued = await this . gatherNodejsDiagnosticsFromCics ( cicsSession ) ;
652
+ msgBuffer = await this . gatherNodejsDiagnosticsFromCics ( cicsSession ) ;
645
653
}
646
654
catch ( diagnosticsError ) {
647
655
// Something went wrong generating diagnostic info. Don't trouble the user
@@ -654,15 +662,16 @@ export class BundlePusher {
654
662
}
655
663
656
664
// We must have a cics profile in order to have got this far, so suggest a command that can be run to figure out more.
657
- if ( diagnosticsIssued === false ) {
658
- const msg = "For further information on the state of your NODEJSAPP resources, consider running the following command:\n\n" +
665
+ if ( msgBuffer === "" ) {
666
+ msgBuffer + = "For further information on the state of your NODEJSAPP resources, consider running the following command:\n\n" +
659
667
"zowe cics get resource CICSNodejsapp --region-name " + this . params . arguments . scope +
660
668
" --criteria \"BUNDLE=" + this . params . arguments . name + "\" --cics-plex " + this . params . arguments . cicsplex + "\n" ;
661
- this . issueMessage ( msg ) ;
662
669
}
670
+
671
+ return msgBuffer ;
663
672
}
664
673
665
- private async gatherGeneralDiagnosticsFromCics ( cicsSession : AbstractSession ) : Promise < boolean > {
674
+ private async gatherGeneralDiagnosticsFromCics ( cicsSession : AbstractSession ) : Promise < string > {
666
675
// Issue a CMCI get to the target CICSplex
667
676
try {
668
677
this . updateStatus ( "Querying Regions in Scope over CMCI" ) ;
@@ -677,27 +686,25 @@ export class BundlePusher {
677
686
throw new Error ( "CICSRegion CMCI output record not found." ) ;
678
687
}
679
688
const outputRegionRecords = cmciRegionResponse . response . records . cicsregion ;
680
- const msg = "CICS Regions in Scope '" + this . params . arguments . scope + "' of CICSplex '" + this . params . arguments . cicsplex + "':\n" ;
681
- this . issueMessage ( msg ) ;
689
+ let msgBuffer = "CICS Regions in Scope '" + this . params . arguments . scope + "' of CICSplex '" + this . params . arguments . cicsplex + "':\n" ;
682
690
683
691
// We may have an array of records if there was more than one Region in the scope
684
692
if ( Array . isArray ( outputRegionRecords ) ) {
685
693
for ( const record of outputRegionRecords ) {
686
- this . reportRegionData ( record ) ;
694
+ msgBuffer = this . reportRegionData ( record , msgBuffer ) ;
687
695
}
688
696
}
689
697
else {
690
- this . reportRegionData ( outputRegionRecords ) ;
698
+ msgBuffer = this . reportRegionData ( outputRegionRecords , msgBuffer ) ;
691
699
}
700
+ return msgBuffer ;
692
701
}
693
702
catch ( error ) {
694
703
throw new Error ( "Failure collecting diagnostics for Bundle " + this . params . arguments . name + ": " + error . message ) ;
695
704
}
696
-
697
- return true ;
698
705
}
699
706
700
- private async gatherNodejsDiagnosticsFromCics ( cicsSession : AbstractSession ) : Promise < boolean > {
707
+ private async gatherNodejsDiagnosticsFromCics ( cicsSession : AbstractSession ) : Promise < string > {
701
708
try {
702
709
// Process each NODEJSAPP in the Scope
703
710
this . updateStatus ( "Querying NODEJSAPP resources over CMCI" ) ;
@@ -714,37 +721,34 @@ export class BundlePusher {
714
721
}
715
722
const outputNodejsRecords = cmciNodejsResponse . response . records . cicsnodejsapp ;
716
723
717
- const msg = "\nNODEJSAPP resources for Bundle '" + this . params . arguments . name + "' in Scope '" + this . params . arguments . scope + "':\n" ;
718
- this . issueMessage ( msg ) ;
724
+ let msgBuffer = "\nNODEJSAPP resources for Bundle '" + this . params . arguments . name + "' in Scope '" + this . params . arguments . scope + "':\n" ;
719
725
720
726
// We may have an array of records if there was more than one NODEJSAPP in the bundle
721
727
if ( Array . isArray ( outputNodejsRecords ) ) {
722
728
for ( const record of outputNodejsRecords ) {
723
- this . reportNODEJSAPPData ( record ) ;
729
+ msgBuffer = this . reportNODEJSAPPData ( record , msgBuffer ) ;
724
730
}
725
731
}
726
732
else {
727
- this . reportNODEJSAPPData ( outputNodejsRecords ) ;
733
+ msgBuffer = this . reportNODEJSAPPData ( outputNodejsRecords , msgBuffer ) ;
728
734
}
735
+ return msgBuffer ;
729
736
}
730
737
catch ( error ) {
731
738
throw new Error ( "Failure collecting diagnostics for Bundle " + this . params . arguments . name + ": " + error . message ) ;
732
739
}
733
-
734
- return true ;
735
740
}
736
741
737
- private reportRegionData ( outputRecord : any ) {
742
+ private reportRegionData ( outputRecord : any , msgBuffer : string ) : string {
738
743
const MAX_LENGTH = 8 ;
739
744
const applid = outputRecord . applid . padEnd ( MAX_LENGTH , " " ) ;
740
745
const jobid = outputRecord . jobid . padEnd ( MAX_LENGTH , " " ) ;
741
746
const jobname = outputRecord . jobname . padEnd ( MAX_LENGTH , " " ) ;
742
747
743
- const msg = " Applid: " + applid + " jobname: " + jobname + " jobid: " + jobid + "\n" ;
744
- this . issueMessage ( msg ) ;
748
+ return msgBuffer + " Applid: " + applid + " jobname: " + jobname + " jobid: " + jobid + "\n" ;
745
749
}
746
750
747
- private reportNODEJSAPPData ( outputRecord : any ) {
751
+ private reportNODEJSAPPData ( outputRecord : any , msgBuffer : string ) {
748
752
const name = outputRecord . name ;
749
753
const enablestatus = outputRecord . enablestatus ;
750
754
const pid = outputRecord . pid ;
@@ -759,10 +763,9 @@ export class BundlePusher {
759
763
stderr = "<not available>" ;
760
764
}
761
765
762
- const msg = "CICS NODEJSAPP resource '" + name + "' is in '" + enablestatus + "' state in region '" +
763
- region + "' with process id '" + pid + "'.\n" +
764
- " stdout: " + stdout + "\n" +
765
- " stderr: " + stderr + "\n" ;
766
- this . issueMessage ( msg ) ;
766
+ return msgBuffer + "CICS NODEJSAPP resource '" + name + "' is in '" + enablestatus + "' state in region '" +
767
+ region + "' with process id '" + pid + "'.\n" +
768
+ " stdout: " + stdout + "\n" +
769
+ " stderr: " + stderr + "\n" ;
767
770
}
768
771
}
0 commit comments