[ACA-4229] [ADW-AGS] Move Governance plugin check script to ADF CLI (#6523)

* [ACA-4229] [ADW-AGS] Move Governance plugin check script to ADF CLI

* * Added description
This commit is contained in:
siva kumar 2021-01-22 14:58:18 +05:30 committed by GitHub
parent 5712b50d62
commit cf1bb700ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 106 additions and 14 deletions

View File

@ -44,6 +44,7 @@ In develop mode, the CLI takes the prebuilt scripts from the dist folder.
|--- |--- | |--- |--- |
|check-cs-env |Check cs env is up | |check-cs-env |Check cs env is up |
|check-ps-env |Check ps env is up | |check-ps-env |Check ps env is up |
|check-plugin-env |Check plugin status |
|artifact-from-s3 |Get artifact from S3 | |artifact-from-s3 |Get artifact from S3 |
|artifact-to-s3 |Get artifact to S3 | |artifact-to-s3 |Get artifact to S3 |
|docker-publish |publish docker image| |docker-publish |publish docker image|
@ -183,3 +184,12 @@ TEST_APP: {
        }]         }]
    },     },
``` ```
### Checks plugin status
The following command is in charge of checking plugin status by given plugin name:
```bash
adf-cli check-plugin-env --host "gateway_env" --pluginName "Name of the plugin" --appName "appName" -u "username" -p "password"
--ui "uiName"
```

View File

@ -3,6 +3,7 @@ import { CheckEnv } from './plugins/check-env';
import program = require('commander'); import program = require('commander');
import { ProcessServiceCheckPlugin } from './plugins/process-service-check-plugin'; import { ProcessServiceCheckPlugin } from './plugins/process-service-check-plugin';
import { ProcessAutomationCheckPlugin } from './plugins/process-automation-check-plugin'; import { ProcessAutomationCheckPlugin } from './plugins/process-automation-check-plugin';
import { GovernanceCheckPlugin } from './plugins/governance-check-plugin';
let pluginEnv; let pluginEnv;
@ -10,11 +11,11 @@ export default async function main(_args: string[]) {
program program
.version('0.1.0') .version('0.1.0')
.option('--host [type]', 'Remote environment host') .option('--host [type]', 'Remote environment host')
.option('--pluginName [type]', 'pluginName ') .option('--pluginName [type]', 'pluginName')
.option('--appName [type]', 'appName ') .option('--appName [type]', 'appName ', 'Deployed appName on activiti-cloud')
.option('-p, --password [type]', 'password ') .option('-p, --password [type]', 'password ')
.option('-u, --username [type]', 'username ') .option('-u, --username [type]', 'username ')
.option('--ui, --uiName [type]', 'uiName') .option('--ui, --uiName [type]', 'uiName', 'Deployed app UI type on activiti-cloud')
.parse(process.argv); .parse(process.argv);
pluginEnv = new CheckEnv(program.host, program.username, program.password); pluginEnv = new CheckEnv(program.host, program.username, program.password);
@ -27,15 +28,17 @@ export default async function main(_args: string[]) {
if (program.pluginName === PluginTarget.processAutomation) { if (program.pluginName === PluginTarget.processAutomation) {
await checkProcessAutomationPlugin(); await checkProcessAutomationPlugin();
} }
if (program.pluginName === PluginTarget.governance) {
await checkGovernancePlugin();
}
} }
async function checkProcessServicesPlugin() { async function checkProcessServicesPlugin() {
const processServiceCheckPlugin = new ProcessServiceCheckPlugin( const processServiceCheckPlugin = new ProcessServiceCheckPlugin(
{ {
host: program.host, host: program.host,
name: PluginTarget.processService, name: PluginTarget.processService
appName: null,
uiName: null
}, },
pluginEnv.alfrescoJsApi pluginEnv.alfrescoJsApi
); );
@ -54,3 +57,15 @@ async function checkProcessAutomationPlugin() {
); );
await processAutomationCheckPlugin.checkProcessAutomationPlugin(); await processAutomationCheckPlugin.checkProcessAutomationPlugin();
} }
async function checkGovernancePlugin() {
const governancePluginCheck = new GovernanceCheckPlugin(
{
host: program.host,
name: PluginTarget.governance
},
pluginEnv.alfrescoJsApi
);
await governancePluginCheck.checkRecordManagement();
}

View File

@ -0,0 +1,26 @@
import { PluginInterface } from './plugin-model';
import { GovernanceHealth } from './governance-health';
export class GovernanceCheckPlugin {
governanceHealth: GovernanceHealth;
constructor(
private pluginInfo: PluginInterface,
private alfrescoJsApi: any
) {
this.governanceHealth = new GovernanceHealth(this.alfrescoJsApi);
}
async checkRecordManagement() {
let pluginStatus;
const isAvailable = await this.governanceHealth.isRecordManagementAvailable();
if (!isAvailable) {
await this.governanceHealth.createRecordManagementSite();
pluginStatus = [{ PluginName: this.pluginInfo.name, Status: 'Active', RecordManagement: 'Created'}];
console.table(pluginStatus);
} else {
pluginStatus = [{ PluginName: this.pluginInfo.name, Status: 'Active', RecordManagement: 'Available' }];
console.table(pluginStatus);
}
}
}

View File

@ -0,0 +1,41 @@
import { logger } from '../logger';
export class GovernanceHealth {
constructor(private alfrescoJsApi: any) {}
async isRecordManagementAvailable() {
try {
const site = await this.alfrescoJsApi.gsCore.gsSitesApi.getRMSite();
logger.info(
`Record Management site is present: ${site.entry.title}`
);
return true;
} catch (error) {
logger.error(
`Record Management site get failed: ${
JSON.parse(error.message).error.errorKey
}`
);
return false;
}
}
async createRecordManagementSite() {
const body = { title: 'Records Management' };
const opts = { skipAddToFavorites: false }; // | Flag to indicate whether the RM site should not be added to the user's site favorites.
try {
const site = await this.alfrescoJsApi.gsCore.gsSitesApi.createRMSite(
body,
opts
);
logger.info('Record Management site: created' + site);
} catch (error) {
logger.error(
`Record Management site creation failed: ${
JSON.parse(error.message).error.errorKey
}`
);
}
}
}

View File

@ -7,6 +7,6 @@ export enum PluginTarget {
export interface PluginInterface { export interface PluginInterface {
name: string; name: string;
host: string; host: string;
appName: string; appName?: string;
uiName: string; uiName?: string;
} }

View File

@ -28,17 +28,17 @@ export class ProcessAutomationCheckPlugin {
} has been correctly configured` } has been correctly configured`
); );
pluginStatus = [{ PluginName: this.plugInInfo.name, Status: 'Active', BE: 'Enabled', FE: 'Enabled' }]; pluginStatus = [{ PluginName: this.plugInInfo.name, Status: 'Active', BE: 'UP', FE: 'Enabled' }];
console.table(pluginStatus); console.table(pluginStatus);
} else { } else {
this.logConfigurationError(); this.logConfigurationError();
pluginStatus = [{ PluginName: this.plugInInfo.name, Status: 'Inactive', BE: isBackendActive ? 'Enabled' : 'Disabled', FE: isPluginEnabled ? 'Enabled' : 'Disabled' }]; pluginStatus = [{ PluginName: this.plugInInfo.name, Status: 'Inactive', BE: isBackendActive ? 'UP' : 'DOWN', FE: isPluginEnabled ? 'Enabled' : 'Disabled' }];
console.table(pluginStatus); console.table(pluginStatus);
process.exit(1); process.exit(1);
} }
} catch (e) { } catch (e) {
this.logConfigurationError(e); this.logConfigurationError(e);
pluginStatus = [{ PluginName: this.plugInInfo.name, Status: 'Inactive', BE: 'Disabled', FE: 'Disabled' }]; pluginStatus = [{ PluginName: this.plugInInfo.name, Status: 'Inactive', BE: 'DOWN', FE: 'Disabled' }];
console.table(pluginStatus); console.table(pluginStatus);
process.exit(1); process.exit(1);
} }

View File

@ -27,17 +27,17 @@ export class ProcessServiceCheckPlugin {
this.plugInInfo.name this.plugInInfo.name
} has been correctly configured` } has been correctly configured`
); );
pluginStatus = [{ PluginName: this.plugInInfo.name, Status: `${'Active'}`, BE: 'Enabled', FE: 'Enabled' }]; pluginStatus = [{ PluginName: this.plugInInfo.name, Status: `${'Active'}`, BE: 'UP', FE: 'Enabled' }];
console.table(pluginStatus); console.table(pluginStatus);
} else { } else {
this.logConfigurationError(); this.logConfigurationError();
pluginStatus = [{ PluginName: this.plugInInfo.name, Status: 'Inactive', BE: isBackendActive ? 'Enabled' : 'Disabled', FE: isPluginEnabled ? 'Enabled' : 'Disabled' }]; pluginStatus = [{ PluginName: this.plugInInfo.name, Status: 'Inactive', BE: isBackendActive ? 'UP' : 'DOWN', FE: isPluginEnabled ? 'Enabled' : 'Disabled' }];
console.table(pluginStatus); console.table(pluginStatus);
process.exit(1); process.exit(1);
} }
} catch (e) { } catch (e) {
this.logConfigurationError(e); this.logConfigurationError(e);
pluginStatus = [{ PluginName: this.plugInInfo.name, Status: 'Inactive', BE: 'Disabled', FE: 'Disabled' }]; pluginStatus = [{ PluginName: this.plugInInfo.name, Status: 'Inactive', BE: 'DOWN', FE: 'Disabled' }];
console.table(pluginStatus); console.table(pluginStatus);
process.exit(1); process.exit(1);
} }