Search in sources :

Example 6 with WindowsRemoteFileSystem

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;
}
Also used : WindowsRemoteFileSystem(com.sun.enterprise.util.cluster.windows.io.WindowsRemoteFileSystem) WindowsCredentials(com.sun.enterprise.util.cluster.windows.process.WindowsCredentials) WindowsException(com.sun.enterprise.util.cluster.windows.process.WindowsException)

Example 7 with WindowsRemoteFileSystem

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);
    }
}
Also used : WindowsRemoteFile(com.sun.enterprise.util.cluster.windows.io.WindowsRemoteFile) WindowsRemoteFileSystem(com.sun.enterprise.util.cluster.windows.io.WindowsRemoteFileSystem) CommandException(org.glassfish.api.admin.CommandException) WindowsException(com.sun.enterprise.util.cluster.windows.process.WindowsException)

Example 8 with WindowsRemoteFileSystem

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('/', '\\'));
    }
}
Also used : WindowsRemoteFile(com.sun.enterprise.util.cluster.windows.io.WindowsRemoteFile) WindowsRemoteFileSystem(com.sun.enterprise.util.cluster.windows.io.WindowsRemoteFileSystem) RemoteFileCopyProgress(com.sun.enterprise.util.cluster.windows.io.RemoteFileCopyProgress)

Example 9 with WindowsRemoteFileSystem

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);
        }
    }
}
Also used : WindowsRemoteFile(com.sun.enterprise.util.cluster.windows.io.WindowsRemoteFile) WindowsRemoteFileSystem(com.sun.enterprise.util.cluster.windows.io.WindowsRemoteFileSystem) CommandException(org.glassfish.api.admin.CommandException) CommandException(org.glassfish.api.admin.CommandException)

Aggregations

WindowsRemoteFileSystem (com.sun.enterprise.util.cluster.windows.io.WindowsRemoteFileSystem)9 WindowsRemoteFile (com.sun.enterprise.util.cluster.windows.io.WindowsRemoteFile)8 WindowsException (com.sun.enterprise.util.cluster.windows.process.WindowsException)6 Node (com.sun.enterprise.config.serverbeans.Node)3 SFTPv3DirectoryEntry (com.trilead.ssh2.SFTPv3DirectoryEntry)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 SSHLauncher (org.glassfish.cluster.ssh.launcher.SSHLauncher)3 SFTPClient (org.glassfish.cluster.ssh.sftp.SFTPClient)3 DcomInfo (org.glassfish.cluster.ssh.util.DcomInfo)3 Nodes (com.sun.enterprise.config.serverbeans.Nodes)2 WindowsCredentials (com.sun.enterprise.util.cluster.windows.process.WindowsCredentials)2 CommandException (org.glassfish.api.admin.CommandException)2 ProcessManagerException (com.sun.enterprise.universal.process.ProcessManagerException)1 RemoteFileCopyProgress (com.sun.enterprise.util.cluster.windows.io.RemoteFileCopyProgress)1 SCPClient (com.trilead.ssh2.SCPClient)1 SFTPv3FileAttributes (com.trilead.ssh2.SFTPv3FileAttributes)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 UnknownHostException (java.net.UnknownHostException)1