Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright [2017-2022] [Payara Foundation and/or its affiliates]
// Portions Copyright [2017-2026] [Payara Foundation and/or its affiliates]

/**
* @author anilam
Expand Down Expand Up @@ -466,11 +466,6 @@ public static void nodeAction(HandlerContext handlerCtx) {
payload = new HashMap<>();
payload.put("id", nodeName);
payload.put("uninstall", "true");
} else if ("DCOM".equals(type)) {
endpoint = prefix + "delete-node-dcom";
payload = new HashMap<>();
payload.put("id", nodeName);
payload.put("uninstall", "true");
}
GuiUtil.getLogger().info(endpoint);
RestUtil.restRequest(endpoint, payload, "DELETE", null, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright [2018-2019] Payara Foundation and/or affiliates
// Portions Copyright [2018-2026] Payara Foundation and/or affiliates

package com.sun.enterprise.v3.admin.cluster;

Expand Down Expand Up @@ -134,8 +134,7 @@ protected final RemoteType getType() {
}

/**
* We can't put these values into the base class simply to get the names that the user sees correct. I.e. "ssh" versus
* "dcom" versus future types...
* We can't put these values into the base class simply to get the names that the user sees correct. I.e. "ssh"
*
*/
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
# only if the new code is made subject to such option by the copyright
# holder.
#
## Portions Copyright [2018-2022] [Payara Foundation and/or its affiliates]
## Portions Copyright [2018-2026] [Payara Foundation and/or its affiliates]

#####restart-instance
restart.instance.notInstance=-_restart-instance only works on instances. This is a {0}
Expand Down Expand Up @@ -290,36 +290,5 @@ get.health.instance.state.since={0} {1} since {2}

secure.admin.boot.errCreDir=Could not create directories for {0}. No further information is available.
secure.admin.boot.errSetLastMod=Could not set the lastModified date for {0}. No further information is available.
bad.dcom.ping=Error connecting to remote with DCOM: {0}
dcom.no.remote.install=Could not find a remote Payara installation on host: {0} at {1}
dcom.no.connection=Couldn''t connect via DCOM to remote host: {0}
internal.error=Internal Error: {0}
no.mkdir=Could not create the directory on the remote host: {0}
dcom.connect.ok=Successfully connected to {0} via DCOM. Also successfully \n\ran the version command on the remote Payara installation.
dcom.no.remote.access=Could not access the files, {0} on host {1} via DCOM.
dcom.no.remote.file=The remote file, {0} doesn''t exist on {1}
dcom.no.remote.file.access=Can not access the remote file system. Is UAC on?
dcom.access.ok=Successfully accessed {0} on {1} using DCOM.
dcom.no.write=Could not write {0} to {1} on {2} using DCOM.
dcom.write.ok=Successfully wrote {0} to {1} on {2} using DCOM.
dcom.run.ok=Successfully ran the test script on {0} using DCOM.\n\
The script simply ran the DIR command. Here are the first few \
lines from the output of the dir command on the remote machine:\n\{1}
dcom.no.run=Could not run the test script on {0} using DCOM.
validate.dcom.getbyname=\nSuccessfully resolved host name to: {0}
validate.dcom.connect=Successfully connected to {0} at port {1} on host {2}.
validate.dcom.no.connect=Can''t connect to {0} at port {1} on host {2}.\n\
This is usually caused by a firewall blocking the port or the Server Service being stopped.
dcom.no.wmi=Could not connect to WMI (Windows Management Interface) on {0}.
dcom.wmi.ok=Successfully accessed WMI (Windows Management Interface) on {0}. There are {1} processes running on {0}.
dcom.wmi.procinfolegend=Below are the command lines for all the remote processes that have one: \n
dcom.nopassword=Missing Windows password. If you are using asadmin, \
specify the remote Windows password in a file as follows:\n\
AS_ADMIN_WINDOWSPASSWORD=windows-password\n\
Specify the path of the password file to asadmin with the --passwordfile (or -W) option.
dcom.no.installdir=The configuration for the node is invalid. There is no value for the installdir. \
Try running update-node-dcom and specify the install directory for Payara.
dcom.no.jdk=Could not find javac in the path on {0]. A JDK is required to be configured in the Path.
dcom.yes.jdk=Verified that a JDK is installed and available in the Path on {0}. javac -version returned this: {1}
dcom.no.local=Successfully verified that the host, {0}, is not the local machine as required.
dcom.yes.local=The host, {0}, is the local machine. DCOM is only for use on distributed systems.
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,13 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright [2018-2020] Payara Foundation and/or affiliates
// Portions Copyright [2018-2026] Payara Foundation and/or affiliates

package com.sun.enterprise.v3.admin.cluster;

import com.sun.enterprise.util.cluster.RemoteType;
import com.sun.enterprise.util.cluster.SshAuthType;

import org.glassfish.cluster.ssh.util.DcomUtils;
import org.glassfish.hk2.api.ServiceLocator;
import org.glassfish.internal.api.RelativePathResolver;
import com.sun.enterprise.universal.process.ProcessManagerException;
Expand All @@ -57,10 +56,6 @@
import org.glassfish.api.ActionReport;
import org.glassfish.api.admin.*;
import com.sun.enterprise.universal.glassfish.TokenResolver;
import com.sun.enterprise.util.cluster.windows.process.WindowsCredentials;
import com.sun.enterprise.util.cluster.windows.process.WindowsRemotePinger;
import com.sun.enterprise.util.cluster.windows.io.WindowsRemoteFile;
import com.sun.enterprise.util.cluster.windows.io.WindowsRemoteFileSystem;
import org.glassfish.cluster.ssh.launcher.SSHLauncher;
import java.util.logging.Logger;
import java.io.File;
Expand Down Expand Up @@ -124,13 +119,6 @@ static boolean isSSHNode(Node node) {
return node.getType().equals("SSH");
}

public static boolean isDcomNode(Node node) {
if (node == null) {
return false;
}
return node.getType().equals("DCOM");
}

/**
* Get the version string from a glassfish installation on the node.
* @param node
Expand Down Expand Up @@ -319,19 +307,8 @@ private void validatePassword(String p) throws CommandValidationException {
* @throws CommandValidationException
*/
void pingRemoteConnection(Node node) throws CommandValidationException {
RemoteType type = RemoteType.valueOf(node.getType());
validateHostName(node.getNodeHost());

switch (type) {
case SSH:
pingSSHConnection(node);
break;
case DCOM:
pingDcomConnection(node);
break;
default:
throw new CommandValidationException("Internal Error: unknown type");
}
pingSSHConnection(node);
}

/**
Expand Down Expand Up @@ -361,124 +338,8 @@ private void pingSSHConnection(Node node) throws
}
}

/**
* Make sure we can make a DCOM connection using an existing node.
* Exception...
* @param node Node to connect to
* @throws CommandValidationException
*/
private void pingDcomConnection(Node node) throws CommandValidationException {
try {
SshConnector connector = node.getSshConnector();
SshAuth auth = connector.getSshAuth();
String host = connector.getSshHost();

if (!StringUtils.ok(host)) {
host = node.getNodeHost();
}

String username = auth.getUserName();
String password = resolvePassword(auth.getPassword());
String installdir = node.getInstallDirUnixStyle();
String domain = node.getWindowsDomain();

if (!StringUtils.ok(domain)) {
domain = host;
}

if (!StringUtils.ok(installdir)) {
throw new CommandValidationException(Strings.get("dcom.no.installdir"));
}

pingDcomConnection(host, domain, username, password, getInstallRoot(installdir));
}
// very complicated catch copied from pingssh above...
catch (CommandValidationException cve) {
throw cve;
}
catch (Exception e) {
String m1 = e.getMessage();
String m2 = "";
Throwable e2 = e.getCause();
if (e2 != null) {
m2 = e2.getMessage();
}
String msg = Strings.get("ssh.bad.connect", node.getNodeHost(), "DCOM");
logger.warning(StringUtils.cat(": ", msg, m1, m2));
throw new CommandValidationException(StringUtils.cat(NL, msg, m1, m2));
}
}

/**
* Make sure GF is installed and available.
*
* @throws CommandValidationException
*/
void pingDcomConnection(String host, String domain, String username,
String password, String installRoot) throws CommandValidationException {
// don't bother trying to connect if we have no password!

if (!StringUtils.ok(password)) {
throw new CommandValidationException(Strings.get("dcom.nopassword"));
}

// resolve password aliases
password = DcomUtils.resolvePassword(resolver.resolve(password));

if (NetUtils.isThisHostLocal(host)) {
throw new CommandValidationException(Strings.get("dcom.yes.local", host));
}

try {
installRoot = installRoot.replace('/', '\\');
WindowsRemoteFileSystem wrfs = new WindowsRemoteFileSystem(host, username, password);
WindowsRemoteFile wrf = new WindowsRemoteFile(wrfs, installRoot);
WindowsCredentials creds = new WindowsCredentials(host, domain, username, password);

// also looking for side-effect of Exception getting thrown...
if (!wrf.exists()) {
throw new CommandValidationException(Strings.get("dcom.no.remote.install",
host, installRoot));
}

if (!WindowsRemotePinger.ping(installRoot, creds)) {
throw new CommandValidationException(Strings.get("dcom.no.connection", host));
}
}
catch (CommandValidationException cve) {
throw cve;
}
catch (Exception ex) {
throw new CommandValidationException(ex);
}
}

private void validateRemoteConnection(ParameterMap map) throws
CommandValidationException {
// guaranteed to either get a valid type -- or a CommandValidationException
RemoteType type = parseType(map);

// just too difficult to refactor now...
if (type == RemoteType.SSH) {
validateSSHConnection(map);
} else if (type == RemoteType.DCOM) {
validateDcomConnection(map);
}
}

private void validateDcomConnection(ParameterMap map) throws CommandValidationException {
if (Boolean.parseBoolean(map.getOne(PARAM_INSTALL))) {
// we don't want to insist that there is an installation - there isn't one probably!!
return;
}

String nodehost = resolver.resolve(map.getOne(PARAM_NODEHOST));
String installdir = resolver.resolve(map.getOne(PARAM_INSTALLDIR));
String user = resolver.resolve(map.getOne(PARAM_REMOTEUSER));
String password = map.getOne(PARAM_SSHPASSWORD);
String domain = nodehost;

pingDcomConnection(nodehost, domain, user, password, getInstallRoot(installdir));
private void validateRemoteConnection(ParameterMap map) throws CommandValidationException {
validateSSHConnection(map);
}

private void validateSSHConnection(ParameterMap map) throws
Expand Down
Loading