Package com.sun.enterprise.ee.admin.servermgmt

Examples of com.sun.enterprise.ee.admin.servermgmt.AgentManager


                //END WARNING!!!
            } else {
                agentName = getAgentName();           
                AgentConfig config = new AgentConfig(agentName,
                    getAgentPath());          
                AgentManager manager = getAgentManager(config);
                //Ensure that the node agent exists
                manager.validateNodeAgent(config, true);
                masterPassword = getMasterPassword(manager, config);

                config.put(AgentConfig.K_MASTER_PASSWORD, masterPassword);
                manager.validateMasterPassword(config, true);

                //getPassword(optionName, allowedOnCommandLine, readPrefsFile, readPasswordOptionFromPrefs,
                //readMasterPasswordFile, mgr, config,
                //promptUser, confirm, validate)
                newMasterPassword = getNewMasterPassword();
                Boolean saveMasterPassword = getSaveMasterPassword(null);               
                config.put(AgentConfig.K_NEW_MASTER_PASSWORD, newMasterPassword);
                config.put(AgentConfig.K_SAVE_MASTER_PASSWORD, saveMasterPassword);
                manager.changeMasterPassword(config);    
                CLILogger.getInstance().printDetailMessage(_strMgr.getString("NodeAgentPasswordChanged",
                    new Object[] {agentName}));
            }
        } catch (Exception e) {
            displayExceptionMessage(e);           
View Full Code Here


        try {
            final String agentName = (String)operands.firstElement();                      

            AgentConfig agentConfig = new AgentConfig(agentName, getAgentPath());
            AgentManager manager = getAgentManager(agentConfig);
            manager.deleteNodeAgent();
          
            CLILogger.getInstance().printDetailMessage(getLocalizedString(
                                                       "CommandSuccessful",
                                                       new Object[] {name}));
        } catch (Exception e) {           
View Full Code Here

 
    protected String[] getAgents() throws CommandException
    {
       try {                           
            AgentConfig agentConfig = new AgentConfig(null, getAgentPath());
            AgentManager manager = getAgentManager(agentConfig);
            return manager.listNodeAgents();
       } catch (Exception ex) {
           throw new CommandException(ex);
       }
    }
View Full Code Here

            // log agentname for debug
            CLILogger.getInstance().printDebugMessage("agentName = " + agentName);
           
            AgentConfig agentConfig = new AgentConfig(agentName,
                getAgentPath());
            AgentManager manager = getAgentManager(agentConfig);             
            manager.validateNodeAgent(agentConfig, false);
        } catch (Exception e) {
            if (e.getLocalizedMessage() != null)
                CLILogger.getInstance().printDetailMessage(e.getLocalizedMessage());

            throw new CommandException(getLocalizedString(
                "CommandUnSuccessful", new Object[] {name} ), e);
        }
       
        try {                      
            Properties agentProperties = getAgentProperties(getOption(AGENT_PROPERTIES));
            final String adminUser = getUser();
            final String adminPassword = getPassword();
           
                //need to call setOption before calling getMasterPassword() since
                //getMasterPassword() needs to get ADMIN_PASSWORD first.
            setOption(ADMIN_PASSWORD, adminPassword);
           
            boolean saveMasterPasswordSpecified = getBooleanOption(SAVE_MASTER_PASSWORD);
            String masterPassword = null;
            if (saveMasterPasswordSpecified)
            {
               masterPassword = getMasterPasswordWithDefaultPrompt(null, null);
            }
           
            final String adminPort = String.valueOf(getPort());
            final String adminHost = getHost();
           
            Boolean saveMasterPassword = getSaveMasterPassword(masterPassword)
           
            //The --secure option is a synonymn for --agentproperties agent.das.isSecure=false           
            if (!getBooleanOption(SECURE)) {               
                agentProperties.setProperty(AgentConfig.AGENT_DAS_IS_SECURE, "false");
            }                      

            //System.out.println("adminPassword=" + adminPassword + " masterPassword=" + masterPassword +
            //    " saveMasterPassword=" + saveMasterPassword);           
           
            if (adminHost == null || adminPort == null || adminUser == null || adminPassword == null) {
                throw new CommandValidationException(_strMgr.getString("InvalidDASConfiguration"));
            }
       
            // defaulted protocol and clientHostName until moved to cli if deemed appropriate ???
            // temporary fix to remove agent user & password, for now map them to das user & password???
            AgentConfig agentConfig = new AgentConfig(agentName, getAgentPath(), adminUser,
                adminPassword, new Integer(getAdminPort()),
                adminHost, adminPort, adminUser, adminPassword,
                masterPassword,
                saveMasterPassword, agentProperties);                                               
           
            AgentManager manager = getAgentManager(agentConfig);                       
           
            //Create the node agent
            manager.createNodeAgent();                                              
           
            try {
                //If the DAS and Node Agent were created together on the same machine (i.e. by the
                //installer), the we attempt to pre-register the new node agent's config directly
                //in the domain.xml of the domain.
                rendezvousWithDAS(agentConfig, agentProperties);
            } catch (Exception ex) {
                try {
                    //if we could not register, then  cleanup
                    manager.deleteNodeAgent();
                } catch (Exception ex2) {
                    //eat any exceptions occuring during cleanup time.                   
                }
                throw ex;
            }
View Full Code Here

    {
        String nodeAgentName = typeDir.getName();
        String nodeAgentRoot = typeDir.getParent();
        try {
            AgentConfig ac = new AgentConfig(nodeAgentName, nodeAgentRoot);
            AgentManager agentManager = new AgentManager(ac);
            agentManager.validateNodeAgent(ac, true);
        }catch (AgentException ae){
            throw new CommandException(ae);
        }
    }
View Full Code Here

        try {
            final String agentName = getAgentName();
            String stopInstancesOverride=getOption(STOP_INSTANCES_OVERRIDE);
            AgentConfig agentConfig = new AgentConfig(agentName,
                getAgentPath());
            AgentManager manager = getAgentManager(agentConfig);
                //validate node-agent to make sure it exists
            manager.validateNodeAgent(agentConfig, true);
            if (isNotRunning(manager,agentConfig)) {
                CLILogger.getInstance().printDetailMessage(_strMgr.getString("TargetAlreadyStopped",
                                                                             new Object[] {agentName}));
                return;
            }
View Full Code Here

        try {
            final String agentName = getAgentName();
            AgentConfig agentConfig = new AgentConfig(agentName,
                getAgentPath());
            AgentManager manager = getAgentManager(agentConfig);   
           
            //validate node agent before prompting
            manager.validateNodeAgent(agentConfig, true);

            if (!isNotRunning(manager,agentConfig)) {
                CLILogger.getInstance().printDetailMessage(_strMgr.getString("TargetAlreadyRunning",
                                                                             new Object[] {agentName}));
                return;
            }
                //call getPortAndHost before getPassword()
            getPortAndHost(agentConfig);
            agentConfig.put(AgentConfig.K_DAS_USER, getUser());           
            agentConfig.put(AgentConfig.K_DAS_PASSWORD, getPassword());
            agentConfig.put(AgentConfig.K_MASTER_PASSWORD,
                            getMasterPasswordWithDefaultPrompt(manager, agentConfig));

      //Validation of admin password can only be done after synchronization, see 6304850
            manager.validateMasterPassword(agentConfig, false);
            if (getOption(S1ASCommand.PASSWORDFILE) != null ) {
                 final String adminPwdAlias =
                        RelativePathResolver.getAlias( (String)agentConfig.get(AgentConfig.K_DAS_PASSWORD));
                
                 if (adminPwdAlias!=null) {
                     final String masterPwd= (String)agentConfig.get(AgentConfig.K_MASTER_PASSWORD);
                     final String clearPwd = manager.getClearPasswordForAlias(agentConfig,masterPwd,adminPwdAlias);
                     agentConfig.put(AgentConfig.K_DAS_PASSWORD, clearPwd);
                 }
            }

            String[] extraPasswordOptions = manager.getExtraPasswordOptions(agentConfig);
            if (extraPasswordOptions != null) {
                java.util.HashMap extrapasswords = getExtraPasswords(extraPasswordOptions);
                if (getOption(S1ASCommand.PASSWORDFILE) != null && extrapasswords.size()>0) {
                    final String masterPwd = (String)agentConfig.get( AgentConfig.K_MASTER_PASSWORD);
                    for (java.util.Iterator it = extrapasswords.entrySet().iterator(); it.hasNext(); ) {
                         java.util.Map.Entry entry = (java.util.Map.Entry)it.next();
                         String optionname = (String) entry.getKey();
                         String password = (String) entry.getValue();
                         String aliasname = RelativePathResolver.getAlias(password);
                         if (aliasname != null) {
                             final String clearpwd = manager.getClearPasswordForAlias(agentConfig, masterPwd, aliasname);
                             if (clearpwd != null)
                                 entry.setValue(clearpwd);
                         }
                    }
                }
                agentConfig.put(AgentConfig.K_EXTRA_PASSWORDS, extrapasswords);
            }
           
            //System.out.println("adminUser=" + agentConfig.get(AgentConfig.K_DAS_USER) + " adminPassword=" +
            //    agentConfig.get(AgentConfig.K_DAS_PASSWORD) + " masterPassword=" +
            //    agentConfig.get(AgentConfig.K_MASTER_PASSWORD));                 

            // get override for start managed start instances
            String startInstancesOverride=getOption(START_INSTANCES_OVERRIDE);
            String syncInstancesOverride = getOption(SYNC_INSTANCES_OVERRIDE);
            String monitorInterval = getOption(MONITOR_INTERVAL_OVERRIDE);
            String restartInstancesOverride = getOption(RESTART_INSTANCES_OVERRIDE);
            CLILogger.getInstance().printDebugMessage("startInstanceOverride = "
                + startInstancesOverride);
            CLILogger.getInstance().printDebugMessage("syncInstanceOverride = "
                + syncInstancesOverride);
            CLILogger.getInstance().printDebugMessage("monitorIntervalOverride = "
                + monitorInterval);
      // add map entries for --verbose start-node-agent
      if ( getBooleanOption("verbose") ) {
                // use domain constant, because that is where PEInstancesManager looks, for now
            agentConfig.put("domain.verbose", Boolean.TRUE);
      }           
                      
            manager.startNodeAgent(startInstancesOverride, syncInstancesOverride, monitorInterval, restartInstancesOverride);
           
            CLILogger.getInstance().printDetailMessage(getLocalizedString(
                                                       "CommandSuccessful",
                                                       new Object[] {name}));
        } catch (Exception e) {           
View Full Code Here

        RuntimeStatus.clearRuntimeStatus();
    }
           
    public RuntimeStatus getRuntimeStatus() throws AgentException {       
        try {           
            final AgentManager manager = new AgentManager(getNodeAgentConfig());
            return RuntimeStatus.getRuntimeStatus(getNodeAgentName(),
                manager);
        } catch (Exception ex) {
            StringManagerBase sm = StringManagerBase.getStringManager(
                getLogger().getResourceBundleName())
View Full Code Here

    }   
   
    protected void validateAdminUserAndPassword() throws AgentException {
        final AgentConfig ac = getAgentConfig();
        setPasswords(ac);
        final AgentManager am = getAgentManager(ac);
        am.validateAdminUserAndPassword(ac);
    }
View Full Code Here

TOP

Related Classes of com.sun.enterprise.ee.admin.servermgmt.AgentManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.