Skip to content

Add option to discover remote domain without creating archive #141

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

Merged
merged 8 commits into from
Jun 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 29 additions & 6 deletions electron/app/js/wdtDiscovery.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @license
* Copyright (c) 2021, Oracle and/or its affiliates.
* Copyright (c) 2021, 2022, Oracle and/or its affiliates.
* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
*/
const path = require('path');
Expand All @@ -13,6 +13,8 @@ const { getAbsolutePath, makeDirectoryIfNotExists } = require('./fsUtils');
const { getDiscoverDomainShellScript } = require('./wktTools');
const { getLogger } = require('./wktLogging');
const { sendToWindow } = require('./windowUtils');
const { readFile } = require('fs/promises');
const fsUtils = require('./fsUtils');

/* global process */

Expand Down Expand Up @@ -77,16 +79,31 @@ async function _runDiscover(targetWindow, discoverConfig, online) {
argList.push(discoverConfig['adminPass']);
}

argList.push('-archive_file');
argList.push(archiveFile);
const isRemote = discoverConfig['isRemote'];
if (!isRemote) {
argList.push('-archive_file');
argList.push(archiveFile);
}

argList.push('-model_file');
argList.push(modelFile);
argList.push('-variable_file');
argList.push(propertiesFile);

const env = {};
if (!process.env.JAVA_HOME) {
env['JAVA_HOME'] = discoverConfig['javaHome'];
if (isRemote) {
argList.push('-remote');
}

const env = {
JAVA_HOME: process.env.JAVA_HOME || discoverConfig['javaHome']
};

let resultsDirectory = null;
let resultsFile = null;
if (isRemote) {
resultsDirectory = await fsUtils.createTemporaryDirectory(projectDir, 'discoverModel');
resultsFile = path.join(resultsDirectory, 'result.json');
env['__WLSDEPLOY_STORE_RESULT__'] = resultsFile;
}

let stdoutEventName = 'show-console-out-line';
Expand Down Expand Up @@ -114,6 +131,12 @@ async function _runDiscover(targetWindow, discoverConfig, online) {

results.modelFileContent = await project.getModelFileContent(targetWindow, [relativeModelFile], [relativePropertiesFile],
[relativeArchiveFile]);

if(isRemote) {
const resultsText = await readFile(resultsFile, {encoding: 'utf8'});
results.resultData = JSON.parse(resultsText);
await fsUtils.removeDirectoryRecursively(resultsDirectory);
}
} catch (err) {
results.isSuccess = false;
results.reason = i18n.t('wdt-discovery-failed-error-message', { script: getDiscoverDomainShellScript(), error: errorUtils.getErrorMessage(err)});
Expand Down
29 changes: 28 additions & 1 deletion electron/app/locales/en/webui.json
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,16 @@
"discover-dialog-admin-user-help": "The login user name for the Administration Server.",
"discover-dialog-admin-password-label": "Administration Server Password",
"discover-dialog-admin-password-help": "The login password for the Administration Server.",
"discover-dialog-remote-discovery-label": "Remote Discovery",
"discover-dialog-remote-discovery-help": "Discover without collecting archive artifacts",
"discover-dialog-domain-home-remote-help": "The directory of the domain to be discovered on the remote system",
"discover-dialog-domain-home-remote-label": "Remote Domain Home",

"discover-result-dialog-title": "Discover Domain Result",
"discover-result-dialog-archive-message": "The following files need to be collected from the remote system and placed in the archive file at the specified paths",
"discover-result-dialog-file-location-header": "File Location",
"discover-result-dialog-archive-path-header": "Archive Path",
"discover-result-dialog-archive-table-aria-label": "Archive Entries Table",

"wdt-discoverer-replace-title": "Replace Existing Model Content",
"wdt-discoverer-replace-message": "This will replace the project's existing model content, continue?",
Expand Down Expand Up @@ -1448,5 +1458,22 @@
"quickstart-page9-list4-item-2": "Code view provides a shell script that shows how you can automate the installation as well as the YAML resource definitions.",
"quickstart-page9-list4-item-3": "The Install Ingress Controller and Update Ingress Routing buttons (and Go menu items) perform the necessary actions to install the ingress controller and update routes on an existing ingress controller.",

"quickstart-page10-title": "Verrazzano-Specific Sections"
"quickstart-page10-title": "Verrazzano-Specific Sections",

"archive-type-APPLICATION_PLAN": "Application Plans",
"archive-type-APPLICATIONS": "Applications",
"archive-type-CLASSPATH_LIB": "Classpath Libraries",
"archive-type-COHERENCE": "Coherence Files",
"archive-type-COHERENCE_CONFIG": "Coherence Configurations",
"archive-type-COHERENCE_PERSISTENCE_DIR": "Coherence Persistence Directories",
"archive-type-DOMAIN_BIN": "Domain Binaries",
"archive-type-DOMAIN_LIB": "Domain Libraries",
"archive-type-FILE_STORE": "File Stores",
"archive-type-JMS_FOREIGN_SERVER": "JMS Foreign Servers",
"archive-type-MIME_MAPPING": "MIME Mappings",
"archive-type-NODE_MANAGER_KEY_STORE": "Node Manager Key Stores",
"archive-type-SCRIPTS": "Scripts",
"archive-type-SERVER_KEYSTORE": "Server Key Stores",
"archive-type-SHARED_LIBRARIES": "Shared Libraries",
"archive-type-SHLIB_PLAN": "Shared Library Plans"
}
11 changes: 11 additions & 0 deletions webui/src/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,12 @@ h6:first-child {
height: auto;
}

.wkt-discover-result-dialog {
max-width: 1000px;
height: 85vh;
width: 85%;
}

.wkt-add-to-archive-dialog {
width: 600px;
height: auto;
Expand Down Expand Up @@ -506,6 +512,11 @@ h6:first-child {
height: 100%;
}

.wkt-stacked-dialog-body {
display: flex;
flex-direction: column;
}

/* the oj-switcher in the code view should use the remaining height */
.wkt-code-view-switcher {
min-height: 1px;
Expand Down
32 changes: 21 additions & 11 deletions webui/src/js/utils/wdt-discoverer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @license
* Copyright (c) 2021, Oracle and/or its affiliates.
* Copyright (c) 2021, 2022, Oracle and/or its affiliates.
* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
*/
'use strict';
Expand Down Expand Up @@ -65,16 +65,21 @@ function (WdtActionsBase, ko, project, wktConsole, dialogHelper, projectIO, i18n
return Promise.resolve(false);
}

busyDialogMessage = i18n.t('flow-validate-domain-home-in-progress');
dialogHelper.updateBusyDialog(busyDialogMessage, 2/totalSteps);
const errContext = i18n.t('wdt-discoverer-invalid-domain-home-error-prefix');
const domainHomeValidationResult =
await window.api.ipc.invoke('validate-domain-home', domainHomeDirectory, errContext);
if (!domainHomeValidationResult.isValid) {
const errMessage = domainHomeValidationResult.reason;
dialogHelper.closeBusyDialog();
await window.api.ipc.invoke('show-error-message', errTitle, errMessage);
return Promise.resolve(false);
// for remote discovery, domain home is on the remote machine,
// so don't validate the directory
const isRemote = discoverConfig.isRemote;
if (!isRemote) {
busyDialogMessage = i18n.t('flow-validate-domain-home-in-progress');
dialogHelper.updateBusyDialog(busyDialogMessage, 2/totalSteps);
const errContext = i18n.t('wdt-discoverer-invalid-domain-home-error-prefix');
const domainHomeValidationResult =
await window.api.ipc.invoke('validate-domain-home', domainHomeDirectory, errContext);
if (!domainHomeValidationResult.isValid) {
const errMessage = domainHomeValidationResult.reason;
dialogHelper.closeBusyDialog();
await window.api.ipc.invoke('show-error-message', errTitle, errMessage);
return Promise.resolve(false);
}
}

busyDialogMessage = i18n.t('flow-save-project-in-progress');
Expand Down Expand Up @@ -105,6 +110,11 @@ function (WdtActionsBase, ko, project, wktConsole, dialogHelper, projectIO, i18n
if (discoverResults.isSuccess) {
wktLogger.debug('discover complete: %s', discoverResults.modelFileContent);
project.wdtModel.setModelFiles(discoverResults.modelFileContent);

if (isRemote) {
const options = { resultData: discoverResults.resultData };
dialogHelper.openDialog('discover-result-dialog', options);
}
return Promise.resolve(true);
} else {
let errMessage;
Expand Down
33 changes: 23 additions & 10 deletions webui/src/js/viewModels/discover-dialog.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
/**
* @license
* Copyright (c) 2021, Oracle and/or its affiliates.
* Copyright (c) 2021, 2022, Oracle and/or its affiliates.
* Licensed under The Universal Permissive License (UPL), Version 1.0 as shown at https://oss.oracle.com/licenses/upl/
*/
'use strict';

define(['accUtils', 'knockout', 'utils/i18n', 'ojs/ojarraydataprovider', 'models/wkt-project',
define(['accUtils', 'knockout', 'utils/i18n', 'utils/view-helper', 'ojs/ojarraydataprovider', 'models/wkt-project',
'utils/wdt-discoverer', 'ojs/ojknockout', 'ojs/ojinputtext', 'ojs/ojlabel', 'ojs/ojbutton',
'ojs/ojdialog', 'ojs/ojformlayout', 'ojs/ojselectsingle', 'ojs/ojvalidationgroup'],
function(accUtils, ko, i18n, ArrayDataProvider, project, wdtDiscoverer) {
'ojs/ojdialog', 'ojs/ojformlayout', 'ojs/ojselectsingle', 'ojs/ojvalidationgroup', 'ojs/ojswitch'],
function(accUtils, ko, i18n, viewHelper, ArrayDataProvider, project, wdtDiscoverer) {
function DiscoverDialogModel(config) {
const DIALOG_SELECTOR = '#discoverDialog';

this.connected = () => {
if(config['hide']) {
Expand All @@ -18,11 +19,13 @@ function(accUtils, ko, i18n, ArrayDataProvider, project, wdtDiscoverer) {

accUtils.announce('Discover dialog loaded.', 'assertive');

// open the dialog after the current thread, which is loading this view model.
this.dialogContainer = $(DIALOG_SELECTOR)[0];

// open the dialog when the container is ready.
// using oj-dialog initial-visibility="show" causes vertical centering issues.
setTimeout(function() {
$('#discoverDialog')[0].open();
}, 1);
viewHelper.componentReady(this.dialogContainer).then(() => {
this.dialogContainer.open();
});
};

this.labelMapper = (labelId, arg) => {
Expand All @@ -49,6 +52,15 @@ function(accUtils, ko, i18n, ArrayDataProvider, project, wdtDiscoverer) {
this.adminUrl = ko.observable();
this.adminUser = ko.observable();
this.adminPassword = ko.observable();
this.isRemote = ko.observable();

this.domainHomeHelp = ko.computed(() => {
return this.labelMapper(this.isRemote() ? 'domain-home-remote-help' : 'domain-home-help');
}, this);

this.domainHomeLabel = ko.computed(() => {
return this.labelMapper(this.isRemote() ? 'domain-home-remote-label' : 'domain-home-label');
}, this);

this.wdtDomainTypes = [
{ key: 'WLS', label: this.labelMapper('wls-domain-type-label') },
Expand Down Expand Up @@ -80,9 +92,10 @@ function(accUtils, ko, i18n, ArrayDataProvider, project, wdtDiscoverer) {
discoverConfig['adminUrl'] = this.adminUrl();
discoverConfig['adminUser'] = this.adminUser();
discoverConfig['adminPass'] = this.adminPassword();
discoverConfig['isRemote'] = this.isRemote();
}

$('#discoverDialog')[0].close();
this.dialogContainer.close();
wdtDiscoverer.executeDiscover(discoverConfig, this.online).then();
} else {
// show messages on all the components that have messages hidden.
Expand All @@ -92,7 +105,7 @@ function(accUtils, ko, i18n, ArrayDataProvider, project, wdtDiscoverer) {
};

this.cancelDiscover = () => {
$('#discoverDialog')[0].close();
this.dialogContainer.close();
};

this.chooseDomainHome = () => {
Expand Down
83 changes: 83 additions & 0 deletions webui/src/js/viewModels/discover-result-dialog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/**
* @license
* Copyright (c) 2022, Oracle and/or its affiliates.
* Licensed under The Universal Permissive License (UPL), Version 1.0 as shown at https://oss.oracle.com/licenses/upl/
*/
'use strict';

define(['accUtils', 'knockout', 'utils/i18n', 'utils/view-helper', 'ojs/ojarraydataprovider',
'ojs/ojknockout', 'ojs/ojbutton', 'ojs/ojdialog', 'ojs/ojtable'],
function(accUtils, ko, i18n, viewHelper, ArrayDataProvider) {
function DiscoverResultDialogModel(config) {
const DIALOG_SELECTOR = '#discoverResultDialog';

this.connected = () => {
accUtils.announce('Discover result dialog loaded.', 'assertive');

this.dialogContainer = $(DIALOG_SELECTOR)[0];

// open the dialog when the container is ready.
// using oj-dialog initial-visibility="show" causes vertical centering issues.
viewHelper.componentReady(this.dialogContainer).then(() => {
this.dialogContainer.open();
});
};

this.labelMapper = (labelId, arg) => {
if (arg) {
return i18n.t(`discover-result-dialog-${labelId}`, arg);
}
return i18n.t(`discover-result-dialog-${labelId}`);
};

this.anyLabelMapper = (labelId, arg) => {
if (arg) {
return i18n.t(labelId, arg);
}
return i18n.t(labelId);
};

// organize the archive entries by type
const resultData = config.resultData;
const missingArchiveEntries = resultData.missingArchiveEntries;
const archiveTypeMap = {};
for(const entry of missingArchiveEntries) {
const archiveType = entry.type;
archiveTypeMap[archiveType] = archiveTypeMap[archiveType] || [];
archiveTypeMap[archiveType].push({ file: entry.sourceFile, path: entry.path });
}

// assemble the types into a list
this.archiveTypes = [];
for(const typeKey in archiveTypeMap) {
const labelKey = 'archive-type-' + typeKey;
const typeLabel = i18n.t(labelKey, typeKey);
this.archiveTypes.push({ type: typeLabel, entries: new ArrayDataProvider(archiveTypeMap[typeKey]) });
}

// sort archive types by resolved type name
this.archiveTypes.sort((a, b) => {
return a.type.localeCompare(b.type);
});

this.typesColumnData = [
{
'headerText': this.labelMapper('file-location-header'),
'sortProperty': 'file'
},
{
'headerText': this.labelMapper('archive-path-header'),
'sortable': 'disable'
}
];

this.closeDialog = () => {
this.dialogContainer.close();
};
}

/*
* Returns a constructor for the ViewModel.
*/
return DiscoverResultDialogModel;
});
Loading