Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance Installation Stage to Run 'zwe init mvs' #83

Merged
merged 10 commits into from
Nov 28, 2023
62 changes: 57 additions & 5 deletions src/actions/InstallationHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,25 @@ class Installation {
const uploadYaml = await this.uploadYaml(connectionArgs, installationArgs.installationDir);
ProgressStore.set('installation.uploadYaml', uploadYaml.status);

if(!uploadYaml.status){
return {status: false, details: `Error uploading yaml configuration: ${uploadYaml.details}`};
}

let download;
if(installationArgs.installationType === "download"){
console.log("downloading...", version);
download = await this.downloadPax(version);
ProgressStore.set('installation.download', download.status);
} else {
download = {status: true}
//if the user has selected an SMPE or opted to upload their own pax, we simply set this status to true as no download is required
download = {status: true, details: ''}
ProgressStore.set('installation.download', true);
}

if(!download.status){
return {status: false, details: `Error downloading pax: ${download.details}`};
}

console.log("uploading...");
let upload;
if(installationArgs.installationType === "upload"){
Expand All @@ -58,15 +67,48 @@ class Installation {
}
ProgressStore.set('installation.upload', upload.status);

if(!upload.status){
return {status: false, details: `Error uploading pax: ${upload.details}`};
}

console.log("unpaxing...");
const unpax = await this.unpax(connectionArgs, installationArgs.installationDir);
ProgressStore.set('installation.unpax', unpax.status);

console.log("installing...");
const install = await this.install(connectionArgs, installationArgs.installationDir);
ProgressStore.set('installation.install', install.status);
if(!unpax.status){
return {status: false, details: `Error unpaxing Zowe archive: ${unpax.details}`};
}

let installation;
if(installationArgs.installationType !== "smpe"){
console.log("installing...");
installation = await this.install(connectionArgs, installationArgs.installationDir);
ProgressStore.set('installation.install', installation.status);
} else {
//If the user has opted to perform an SMPE installation, they must run 'zwe install' manually and therefore we set this to true
installation = {status: true, details: ''}
ProgressStore.set('installation.install', true);
}

if(!installation.status){
return {status: false, details: `Error running zwe install: ${installation.details}`};
}

return {status: download.status && uploadYaml.status && upload.status && unpax.status && install.status, details: ''};
let initMvs;
if(installation.status){
console.log("running zwe init mvs...");
initMvs = await this.initMVS(connectionArgs, installationArgs.installationDir);
ProgressStore.set('installation.initMVS', initMvs.status);
} else {
initMvs = {status: false, details: `zwe install step failed, unable to run zwe init mvs.`}
ProgressStore.set('installation.initMVS', false);
}

if(!initMvs.status){
return {status: false, details: `Error running zwe init mvs: ${initMvs.details}`};
}

return {status: download.status && uploadYaml.status && upload.status && unpax.status && installation.status && initMvs.status, details: 'Zowe install successful.'};
} catch (error) {
return {status: false, details: error.message};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code does not properly present errors to users.

We have a try { } catch { } here, but not all failures go to the catch { } block.

If init mvs fails, there is no exception but the return would say {status: false, details: ''}.
There would be no way to differentiate that from a zwe install or extract step failure.

You should set details to what actually failed.
In fact, initMVS() is returning a details, so it could be formatted.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This return statement existed prior to this PR, I'd be happy to fix it but I think it should be a separate ticket to enhance the error detailing of this stage @1000TurquoisePogs

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
Expand Down Expand Up @@ -108,6 +150,10 @@ class Installation {
async install(connectionArgs: IIpcConnectionArgs, installDir: string): Promise<IResponse> {
throw new Error('Method not implemented.');
}

async initMVS(connectionArgs: IIpcConnectionArgs, installDir: string): Promise<IResponse> {
throw new Error('Method not implemented.');
}
}

export class FTPInstallation extends Installation {
Expand Down Expand Up @@ -157,6 +203,12 @@ export class FTPInstallation extends Installation {
return {status: result.rc === 0, details: result.jobOutput}
}

async initMVS(connectionArgs: IIpcConnectionArgs, installDir: string) {
const script = `cd ${installDir}/runtime/bin;\n./zwe init mvs -c ${installDir}/zowe.yaml`;
const result = await new Script().run(connectionArgs, script);
return {status: result.rc === 0, details: result.jobOutput}
}

async checkInstallData(args: Array<any>) {
// FIXME: Refine installation data validation
}
Expand Down
8 changes: 7 additions & 1 deletion src/renderer/components/stages/installation/Installation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import ContainerCard from '../../common/ContainerCard';
import JsonForm from '../../common/JsonForms';
import EditorDialog from "../../common/EditorDialog";
import Ajv from "ajv";
import { alertEmitter } from "../../Header";

const Installation = () => {

Expand All @@ -42,7 +43,8 @@ const Installation = () => {
download: false,
upload: false,
unpax: false,
install: false
install: false,
initMVS: false
});

const installationArgs = useAppSelector(selectInstallationArgs);
Expand Down Expand Up @@ -108,6 +110,9 @@ const Installation = () => {
toggleProgress(true);
dispatch(setLoading(false));
window.electron.ipcRenderer.installButtonOnClick(connectionArgs, installationArgs, version).then((res: IResponse) => {
if(!res.status){ //errors during runInstallation()
alertEmitter.emit('showAlert', res.details, 'error');
}
dispatch(setNextStepEnabled(res.status));
clearInterval(timer);
}).catch(() => {
Expand Down Expand Up @@ -178,6 +183,7 @@ const Installation = () => {
<ProgressCard label={`Upload to pax file to ${installationArgs.installationDir}`} id="upload-progress-card" status={installationProgress.upload}/>
<ProgressCard label="Unpax installation files" id="unpax-progress-card" status={installationProgress.unpax}/>
<ProgressCard label="Run installation script (zwe install)" id="install-progress-card" status={installationProgress.install}/>
<ProgressCard label="Run MVS dataset initialization script (zwe init mvs)" id="install-progress-card" status={installationProgress.initMVS}/>
</React.Fragment>
}
</Box>
Expand Down
3 changes: 2 additions & 1 deletion src/storage/ProgressStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ const storeDefault = {
"download": false,
"upload": false,
"unpax": false,
"install": false
"install": false,
"initMVS": false
}
};

Expand Down
Loading