Search in sources :

Example 46 with CommandException

use of org.glassfish.api.admin.CommandException in project Payara by payara.

the class StartDeploymentGroupCommand method execute.

@Override
public void execute(AdminCommandContext context) {
    ActionReport report = context.getActionReport();
    Logger logger = context.getLogger();
    logger.info(Strings.get("start.dg", deploymentGroup));
    // Require that we be a DAS
    if (!env.isDas()) {
        String msg = Strings.get("cluster.command.notDas");
        logger.warning(msg);
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        report.setMessage(msg);
        return;
    }
    ClusterCommandHelper clusterHelper = new ClusterCommandHelper(domain, runner);
    try {
        // Run start-instance against each instance in the cluster
        String commandName = "start-instance";
        clusterHelper.runCommand(commandName, null, deploymentGroup, context, verbose);
    } catch (CommandException e) {
        String msg = e.getLocalizedMessage();
        logger.warning(msg);
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        report.setMessage(msg);
        return;
    }
}
Also used : ClusterCommandHelper(com.sun.enterprise.v3.admin.cluster.ClusterCommandHelper) CommandException(org.glassfish.api.admin.CommandException) ActionReport(org.glassfish.api.ActionReport) Logger(java.util.logging.Logger)

Example 47 with CommandException

use of org.glassfish.api.admin.CommandException in project Payara by payara.

the class ChangeNodeMasterPasswordCommand method getInstanceDirs.

/**
 * This will get all the instances for a given node
 * @param parent  node
 * @return   The list of instances for a node
 * @throws CommandException
 */
private ArrayList<String> getInstanceDirs(File parent) throws CommandException {
    ArrayList<String> instancesList = new ArrayList<String>();
    File[] files = parent.listFiles(new FileFilter() {

        public boolean accept(File f) {
            return f.isDirectory();
        }
    });
    if (files == null || files.length == 0) {
        throw new CommandException(strings.get("Instance.noInstanceDirs", parent));
    }
    for (File f : files) {
        if (!f.getName().equals("agent"))
            instancesList.add(f.getName());
    }
    return instancesList;
}
Also used : ArrayList(java.util.ArrayList) CommandException(org.glassfish.api.admin.CommandException) FileFilter(java.io.FileFilter) File(java.io.File)

Example 48 with CommandException

use of org.glassfish.api.admin.CommandException in project Payara by payara.

the class ChangeNodeMasterPasswordCommand method createMasterPasswordFile.

/**
 * Create the master password keystore. This routine can also modify the master password
 * if the keystore already exists
 *
 * @throws CommandException
 */
protected void createMasterPasswordFile() throws CommandException {
    final File pwdFile = new File(this.getServerDirs().getAgentDir(), MASTER_PASSWORD_ALIAS);
    try {
        PasswordAdapter p = new PasswordAdapter(pwdFile.getAbsolutePath(), MASTER_PASSWORD_ALIAS.toCharArray());
        p.setPasswordForAlias(MASTER_PASSWORD_ALIAS, newPassword.getBytes());
        FileProtectionUtility.chmod0600(pwdFile);
    } catch (Exception ex) {
        throw new CommandException(strings.get("masterPasswordFileNotCreated", pwdFile), ex);
    }
}
Also used : PasswordAdapter(com.sun.enterprise.security.store.PasswordAdapter) CommandException(org.glassfish.api.admin.CommandException) File(java.io.File) MiniXmlParserException(com.sun.enterprise.universal.xml.MiniXmlParserException) CommandException(org.glassfish.api.admin.CommandException)

Example 49 with CommandException

use of org.glassfish.api.admin.CommandException in project Payara by payara.

the class CreateLocalInstanceCommand method rendezvousOccurred.

private boolean rendezvousOccurred() {
    boolean rendezvousOccurred = false;
    RemoteCLICommand rc = null;
    try {
        rc = new RemoteCLICommand("get", this.programOpts, this.env);
        String s = rc.executeAndReturnOutput("get", RENDEZVOUS_DOTTED_NAME);
        String val = s.substring(s.indexOf("=") + 1);
        rendezvousOccurred = Boolean.parseBoolean(val);
        logger.log(Level.FINER, "rendezvousOccurred = {0} for instance {1}", new Object[] { val, instanceName });
    } catch (CommandException ce) {
        logger.log(Level.FINER, RENDEZVOUS_PROPERTY_NAME + " property may not be set yet on {0}", instanceName);
    }
    return rendezvousOccurred;
}
Also used : CommandException(org.glassfish.api.admin.CommandException) RemoteCLICommand(com.sun.enterprise.admin.cli.remote.RemoteCLICommand)

Example 50 with CommandException

use of org.glassfish.api.admin.CommandException in project Payara by payara.

the class CreateLocalInstanceCommand method createMasterPasswordFile.

/**
 * Create the master password keystore. This routine can also modify the master password
 * if the keystore already exists
 * @param masterPassword
 * @throws CommandException
 */
protected void createMasterPasswordFile(String masterPassword) throws CommandException {
    final File pwdFile = new File(this.getServerDirs().getAgentDir(), MASTER_PASSWORD_ALIAS);
    try {
        PasswordAdapter p = new PasswordAdapter(pwdFile.getAbsolutePath(), MASTER_PASSWORD_ALIAS.toCharArray());
        p.setPasswordForAlias(MASTER_PASSWORD_ALIAS, masterPassword.getBytes());
        FileProtectionUtility.chmod0600(pwdFile);
    } catch (Exception ex) {
        throw new CommandException(Strings.get("masterPasswordFileNotCreated", pwdFile), ex);
    }
}
Also used : PasswordAdapter(com.sun.enterprise.security.store.PasswordAdapter) CommandException(org.glassfish.api.admin.CommandException) File(java.io.File) UnknownHostException(java.net.UnknownHostException) CommandValidationException(org.glassfish.api.admin.CommandValidationException) CommandException(org.glassfish.api.admin.CommandException)

Aggregations

CommandException (org.glassfish.api.admin.CommandException)61 File (java.io.File)20 CommandValidationException (org.glassfish.api.admin.CommandValidationException)16 IOException (java.io.IOException)13 ParameterMap (org.glassfish.api.admin.ParameterMap)11 InvalidCommandException (org.glassfish.api.admin.InvalidCommandException)10 ActionReport (org.glassfish.api.ActionReport)9 ArrayList (java.util.ArrayList)6 RemoteCLICommand (com.sun.enterprise.admin.cli.remote.RemoteCLICommand)5 MiniXmlParserException (com.sun.enterprise.universal.xml.MiniXmlParserException)5 HostAndPort (com.sun.enterprise.util.HostAndPort)4 BackupException (com.sun.enterprise.backup.BackupException)3 BackupWarningException (com.sun.enterprise.backup.BackupWarningException)3 SmartFile (com.sun.enterprise.universal.io.SmartFile)3 FileNotFoundException (java.io.FileNotFoundException)3 UnknownHostException (java.net.UnknownHostException)3 Logger (java.util.logging.Logger)3 SFTPClient (org.glassfish.cluster.ssh.sftp.SFTPClient)3 CLIProcessExecutor (com.sun.enterprise.admin.cli.CLIProcessExecutor)2 PEDomainsManager (com.sun.enterprise.admin.servermgmt.pe.PEDomainsManager)2