use of com.sun.enterprise.util.cluster.windows.io.WindowsRemoteFileSystem in project Payara by payara.
the class ValidateDcom method init.
private boolean init(AdminCommandContext context) {
report = context.getActionReport();
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
user = resolver.resolve(user);
password = DcomUtils.resolvePassword(resolver.resolve(password));
if (!ok(password)) {
setError(Strings.get("dcom.nopassword"));
return false;
}
// backslash does not actually matter but it's neater
testdir = resolver.resolve(testdir).replace('/', '\\');
if (testdir.endsWith("\\"))
testdir = testdir.substring(0, testdir.length() - 1);
if (!ok(windowsdomain))
windowsdomain = host;
creds = new WindowsCredentials(host, windowsdomain, user, password);
try {
wrfs = new WindowsRemoteFileSystem(creds);
} catch (WindowsException ex) {
// probably the j-interop-repackagted.jar is missing
setError(ex.getMessage());
return false;
}
scriptFullPath = testdir + "\\" + SCRIPT_NAME;
return true;
}
use of com.sun.enterprise.util.cluster.windows.io.WindowsRemoteFileSystem in project Payara by payara.
the class InstallNodeDcomCommand method precopy.
/**
* bnevins: This is exclusively a "user-performance" enhancement.
* We are forcing the failure
* to happen before the very very slow zipfile creation.
* FAIL FAST principle
* This adds a bit of extra overhead to the command...
* Note that allowing multiple hosts makes things MUCH more complicated.
* @throws WindowsException
*/
@Override
final void precopy() throws CommandException {
remoteInstallDirString = getInstallDir().replace('/', '\\');
try {
for (String host : hosts) {
String remotePassword = getWindowsPassword(host);
passwords.add(new HostAndPassword(host, remotePassword));
if (!getForce()) {
WindowsRemoteFileSystem wrfs = new WindowsRemoteFileSystem(host, getRemoteUser(), remotePassword);
WindowsRemoteFile remoteInstallDir = new WindowsRemoteFile(wrfs, remoteInstallDirString);
if (remoteInstallDir.exists())
throw new CommandException(Strings.get("install.dir.exists", remoteInstallDir));
}
}
} catch (WindowsException ex) {
throw new CommandException(ex);
}
}
use of com.sun.enterprise.util.cluster.windows.io.WindowsRemoteFileSystem in project Payara by payara.
the class InstallNodeDcomCommand method copyToHostsInternal.
private void copyToHostsInternal(File zipFile, ArrayList<String> binDirFiles) throws CommandException, WindowsException {
final String zipFileName = "glassfish_install.zip";
final String unpackScriptName = "unpack.bat";
for (String host : hosts) {
String remotePassword = getPassword(host);
WindowsRemoteFileSystem wrfs = new WindowsRemoteFileSystem(host, getRemoteUser(), remotePassword);
WindowsRemoteFile remoteInstallDir = new WindowsRemoteFile(wrfs, remoteInstallDirString);
remoteInstallDir.mkdirs(getForce());
WindowsRemoteFile remoteZip = new WindowsRemoteFile(remoteInstallDir, zipFileName);
WindowsRemoteFile unpackScript = new WindowsRemoteFile(remoteInstallDir, unpackScriptName);
// createUnpackScript
System.out.printf("Copying %d bytes", zipFile.length());
remoteZip.copyFrom(zipFile, new RemoteFileCopyProgress() {
@Override
public void callback(long numcopied, long numtotal) {
// final int percent = (int)((double)numcopied / (double)numtotal * 100.0);
System.out.print(".");
}
@Override
public int getChunkSize() {
return 1048576;
}
});
System.out.println("");
String fullZipFileName = remoteInstallDirString + "\\" + zipFileName;
String fullUnpackScriptPath = remoteInstallDirString + "\\" + unpackScriptName;
unpackScript.copyFrom(makeScriptString(remoteInstallDirString, zipFileName));
if (logger.isLoggable(Level.FINE))
logger.fine("WROTE FILE TO REMOTE SYSTEM: " + fullZipFileName + " and " + fullUnpackScriptPath);
unpackOnHosts(host, remotePassword, fullUnpackScriptPath.replace('/', '\\'));
}
}
use of com.sun.enterprise.util.cluster.windows.io.WindowsRemoteFileSystem in project Payara by payara.
the class UninstallNodeDcomCommand method deleteFromHosts.
@Override
final void deleteFromHosts() throws CommandException {
for (String host : hosts) {
try {
String pw = getWindowsPassword(host);
WindowsRemoteFileSystem wrfs = new WindowsRemoteFileSystem(host, getRemoteUser(), pw);
WindowsRemoteFile remoteInstallDir = new WindowsRemoteFile(wrfs, getInstallDir());
if (!remoteInstallDir.exists()) {
throw new CommandException(Strings.get("remote.install.dir.already.gone", getInstallDir()));
}
remoteInstallDir.delete();
// make sure it's gone now...
if (remoteInstallDir.exists()) {
throw new CommandException(Strings.get("remote.install.dir.cant.delete", getInstallDir()));
}
} catch (CommandException ce) {
throw ce;
} catch (Exception e) {
throw new CommandException(e);
}
}
}
Aggregations