@Override public void execute(AdminCommandContext context) { ActionReport report = context.getActionReport(); Logger logger = context.getLogger(); Node node = nodes.getNode(name); if (node == null) { //no node to delete nothing to do here String msg = Strings.get("noSuchNode", name); logger.warning(msg); report.setActionExitCode(ActionReport.ExitCode.FAILURE); report.setMessage(msg); return; } if (!(node.getType().equals("CONFIG") )){ //no node to delete nothing to do here String msg = Strings.get("notConfigNodeType", name); logger.warning(msg); report.setActionExitCode(ActionReport.ExitCode.FAILURE); report.setMessage(msg); return; } CommandInvocation ci = cr.getCommandInvocation("_delete-node", report, context.getSubject()); ParameterMap map = new ParameterMap(); map.add("DEFAULT", name); ci.parameters(map); ci.execute(); }
ParameterMap p = new ParameterMap(); for (Map.Entry<Object,Object> entry : props.entrySet()) p.set((String)entry.getKey(), (String)entry.getValue()); ActionReport report = commandRunner.getActionReport("hk2-agent"); CommandRunner.CommandInvocation inv = commandRunner.getCommandInvocation(commandName, report, internalSystemAdministrator.getSubject()); inv.parameters(p).execute(command); AutodeploymentStatus ds = AutodeploymentStatus.forExitCode(report.getActionExitCode()); if (ds.status) { deplLogger.log(Level.INFO, getMessageString(ds, file)); } else { if(report.getMessage() != null){ deplLogger.log(Level.WARNING, WARNING_MSG, report.getMessage());
final ActionReport report = context.getActionReport(); String actual = e.getMessage(); String def = "JDBC connection pool: {0} could not be created, reason: {1}"; report.setMessage(localStrings.getLocalString("create.jdbc.connection.pool.fail", def, jdbc_connection_pool_id, actual)); report.setActionExitCode(ActionReport.ExitCode.FAILURE); report.setFailureCause(e); return; ec = ActionReport.ExitCode.FAILURE; if (rs.getMessage() == null) { report.setMessage(localStrings.getLocalString("create.jdbc.connection.pool.fail", "JDBC connection pool {0} creation failed", jdbc_connection_pool_id, "")); ActionReport subReport = report.addSubActionsReport(); ParameterMap parameters = new ParameterMap(); parameters.set("pool_name", jdbc_connection_pool_id); commandRunner.getCommandInvocation("ping-connection-pool", subReport, context.getSubject()).parameters(parameters).execute(); if (ActionReport.ExitCode.FAILURE.equals(subReport.getActionExitCode())) { subReport.setMessage(localStrings.getLocalString("ping.create.jdbc.connection.pool.fail", "\nAttempting to ping during JDBC Connection Pool " + "Creation : {0} - Failed.", jdbc_connection_pool_id));
LocalStringManagerImpl localStrings = new LocalStringManagerImpl(Cluster.class); final ActionReport report = context.getActionReport(); AdminCommand command = runner.getCommand("copy-config", report, context.getLogger()); if (command == null) { String msg = localStrings.getLocalString("cannot.execute.command", "Cluster software is not installed"); throw new TransactionFailure(msg); final String msg = localStrings.getLocalString( "Cluster.hasInstances", "Cluster {0} contains server instances {1} and must not contain any instances" : localStrings.getLocalString("deleteConfigFailed", "Unable to remove config {0}", instanceConfig); report.setMessage(msg); report.setActionExitCode(ActionReport.ExitCode.FAILURE); report.setFailureCause(ex); throw ex;
Logger logger = context.getLogger(); ActionReport report = context.getActionReport(); report.setActionExitCode(ExitCode.SUCCESS); report.setMessage(Strings.get("cluster.command.noInstances", clusterName)); return report; map = new ParameterMap(); waitingForServerNames.add(iname); ParameterMap instanceParameterMap = new ParameterMap(map); instanceParameterMap.set("DEFAULT", iname); ActionReport instanceReport = runner.getActionReport("plain"); instanceReport.setActionExitCode(ExitCode.SUCCESS); CommandInvocation invocation = runner.getCommandInvocation( command, instanceReport); invocation.parameters(instanceParameterMap);
public void execute(AdminCommandContext context) { final ActionReport report = context.getActionReport(); ActionReport.MessagePart part = report.getTopMessagePart(); VersioningUtils.checkIdentifier(applicationName); } catch (VersioningSyntaxException ex) { report.setMessage(ex.getLocalizedMessage()); report.setActionExitCode(ActionReport.ExitCode.FAILURE); return; report.setMessage(localStrings.getLocalString("application.notreg","Application {0} not registered", applicationName)); report.setActionExitCode(ActionReport.ExitCode.FAILURE); return; part.setMessage(localStrings.getLocalString("listsubcomponents.no.elements.to.list", "Nothing to List.")); report.setMessage(localStrings.getLocalString("application.not.enabled","Application {0} is not in an enabled state", applicationName)); return; if (module != null) { ActionReport subReport = report.addSubActionsReport(); CommandRunner.CommandInvocation inv = commandRunner.getCommandInvocation("_list-resources", subReport, context.getSubject()); final ParameterMap parameters = new ParameterMap(); parameters.add("appname", application.getName()); parameters.add("modulename", module.getName()); inv.parameters(parameters).execute();
@Override public void execute(AdminCommandContext context) { ActionReport report = context.getActionReport(); if (name == null) name = nodehost.toString(); if (nodes.getNode(name) != null) { //already created nothing to do here return; } CommandInvocation ci = cr.getCommandInvocation("_create-node", report); ParameterMap map = new ParameterMap(); map.add("DEFAULT", name); map.add(NodeUtils.PARAM_NODEDIR, nodedir); map.add(NodeUtils.PARAM_INSTALLDIR, installdir); map.add(NodeUtils.PARAM_NODEHOST, nodehost); map.add(NodeUtils.PARAM_TYPE,"CONFIG"); ci.parameters(map); ci.execute(); }
public void execute(AdminCommandContext context) { ActionReport report = context.getActionReport(); final Logger logger = context.getLogger(); report.setMessage(localStrings.getLocalString("ref.not.referenced.target","Application {0} is not referenced by target {1}", name, target)); report.setActionExitCode(ActionReport.ExitCode.FAILURE); } else { logger.fine(localStrings.getLocalString("ref.not.referenced.target","Application {0} is not referenced by target {1}", name, target)); report.setMessage(localStrings.getLocalString("application.notreg","Application {0} not registered", appName)); report.setActionExitCode(ActionReport.ExitCode.FAILURE); return; CommandRunner.CommandInvocation inv = commandRunner.getCommandInvocation("disable", report); parameters.set("DEFAULT", appName); parameters.add(DeploymentProperties.IS_UNDEPLOY, Boolean.TRUE.toString()); inv.parameters(parameters).execute(); List<String> targets = domain.getAllReferencedTargetsForApplication(appName); parameters.remove("isUndeploy"); ClusterOperationUtil.replicateCommand("undeploy", FailurePolicy.Error, FailurePolicy.Warn, targets, context, parameters, habitat);
public void execute(AdminCommandContext context) { final ActionReport report = context.getActionReport(); if (error != null) { _logger.log(Level.WARNING, localStrings.getString("recover.transactions.failed") + " " + error); report.setMessage(error); report.setActionExitCode(ActionReport.ExitCode.FAILURE); return; CommandRunner.CommandInvocation inv = runner.getCommandInvocation( "_recover-transactions-internal", report, context.getSubject()); final ParameterMap parameters = new ParameterMap(); parameters.add("target", destinationServer); parameters.add("DEFAULT", serverToRecover); parameters.add("transactionlogdir", transactionLogDir); _logger.info("==> _recover-transactions-internal returned with: " + report.getActionExitCode());
CommandRunner.CommandInvocation commandInvocation = commandRunner.getCommandInvocation("create-cluster", actionReport); ParameterMap parameterMap = new ParameterMap(); parameterMap.add("DEFAULT", virtualClusterName); commandInvocation.parameters(parameterMap).execute(); Object args[] = new Object[]{virtualClusterName, actionReport.getMessage()}; logger.log(Level.INFO, "create.cluster.exec.output", args); if (actionReport.getActionExitCode().equals(ActionReport.ExitCode.FAILURE)) { if (actionReport.getFailureCause() != null) { report.setFailureCause(actionReport.getFailureCause());
/** * Disable the enabled version of the application if it exists. This method * is used in versioning context. * * @param appName application's name * @param target an option supply from admin command, it's retained for * compatibility with other releases * @param report ActionReport, report object to send back to client. */ public void handleDisable(final String appName, final String target, final ActionReport report) throws VersioningDeploymentSyntaxException { // retrieve the currently enabled version of the application String enabledVersion = getEnabledVersion(appName, target); // invoke disable if the currently enabled version is not itself if (enabledVersion != null && !enabledVersion.equals(appName)) { final ParameterMap parameters = new ParameterMap(); parameters.add("DEFAULT", enabledVersion); parameters.add("target", target); ActionReport subReport = report.addSubActionsReport(); CommandRunner.CommandInvocation inv = commandRunner.getCommandInvocation("disable", subReport); inv.parameters(parameters).execute(); } }
private void validateInstanceDirUnique(ActionReport report, AdminCommandContext context) { CommandInvocation listInstances = cr.getCommandInvocation("list-instances", report, context.getSubject()); ParameterMap map = new ParameterMap(); map.add("whichTarget", theNode.getName()); listInstances.parameters(map); listInstances.execute(); Properties pro = listInstances.report().getExtraProperties(); if (pro != null){ List<HashMap> instanceList = (List<HashMap>) pro.get("instanceList"); if (instanceList == null) return; for (HashMap instanceMap : instanceList) { final File nodeDirFile = (nodeDir != null ? new File(nodeDir) : defaultLocalNodeDirFile()); File instanceDir = new File(new File(nodeDirFile.toString(), theNode.getName()), instance); String instanceName = (String)instanceMap.get("name"); File instanceListDir = new File(new File(nodeDirFile.toString(), theNode.getName()), instance); if (instance.equalsIgnoreCase(instanceName) && instanceDir.equals(instanceListDir)) { String msg = Strings.get("Instance.duplicateInstanceDir", instance, instanceName); logger.warning(msg); report.setActionExitCode(ActionReport.ExitCode.FAILURE); report.setMessage(msg); return; } } } }
throw new IllegalArgumentException(localStrings.getLocalString("lifecyclemodule_withsamename_exists", "Lifecycle module with same name {0} already exists, please pick a different name for the application. ", name)); final ParameterMap parameters = new ParameterMap(); parameters.add("DEFAULT", name); parameters.add(DeploymentProperties.TARGET, target); parameters.add(DeploymentProperties.KEEP_REPOSITORY_DIRECTORY, keepreposdir.toString()); parameters.add(DeploymentProperties.IS_REDEPLOY, isredeploy.toString()); ActionReport subReport = report.addSubActionsReport(); subReport.setExtraProperties(new Properties()); populatePropertiesToParameterMap(parameters, propertyNames); CommandRunner.CommandInvocation inv = commandRunner.getCommandInvocation("undeploy", subReport, context.getSubject()); return subReport.getExtraProperties();
@Override public void execute(final AdminCommandContext context) { final ActionReport result = context.getActionReport(); .getCommand("copy-config", context.getActionReport(), context.getLogger()); if (command == null ) { String msg = localStrings.getLocalString("cannot.execute.command", "Cluster software is not installed"); result.failure(logger,msg) ; return; String msg = localStrings.getLocalString(GenericCrudCommand.class, "GenericDeleteCommand.target_object_not_found", "The CrudResolver {0} could not find the configuration object of type {1} where instances of {2} should be removed", resolver.getClass().toString(), parentType, targetType); result.failure(logger, msg); return; String msg = localStrings.getLocalString(GenericCrudCommand.class, "GenericDeleteCommand.transaction_exception", "Exception while deleting the configuration {0} :{1}", child.typeName(), e.getMessage()); result.failure(logger, msg);
final ParameterMap parameters = new ParameterMap(); parameters.add("DEFAULT", name); parameters.add(DeploymentProperties.TARGET, target); parameters.add(DeploymentProperties.KEEP_REPOSITORY_DIRECTORY, keepreposdir.toString()); parameters.add(DeploymentProperties.IS_REDEPLOY, isredeploy.toString()); ActionReport subReport = report.addSubActionsReport(); subReport.setExtraProperties(new Properties()); populatePropertiesToParameterMap(parameters, propertyNames); CommandRunner.CommandInvocation inv = commandRunner.getCommandInvocation("undeploy", subReport); return subReport.getExtraProperties();
public boolean executeAdminCommand(ActionReport report, String commandName, String operand, String... parameters) { ParameterMap params = new ParameterMap(); if (operand!=null) { params.add("DEFAULT", operand); } for (int i=0;i<parameters.length;) { String key = parameters[i++]; String value=null; if (i<parameters.length) { value = parameters[i++]; } params.add(key, value); } CommandRunner.CommandInvocation inv = commandRunner.getCommandInvocation(commandName, report); inv.parameters(params); inv.execute(); return (report.getActionExitCode()==ActionReport.ExitCode.SUCCESS); }
void deleteJMSResource(ActionReport subReport, String tmpJMSResource, final Subject subject) { ParameterMap aoAttrList = new ParameterMap(); aoAttrList.set("DEFAULT", tmpJMSResource); //aoAttrList.set("target", target); commandRunner.getCommandInvocation("delete-jms-resource", subReport, subject).parameters(aoAttrList).execute(); } }
/** * Executes the command. * * @param context information */ public void execute(AdminCommandContext context) { final ActionReport report = context.getActionReport(); if (!validateParameters(name, report)) { return; } final ParameterMap paramMap; final ParameterMapExtractor extractor = new ParameterMapExtractor(this); try { paramMap = extractor.extract(excludedDeployCommandParamNames); } catch (IllegalArgumentException ex) { throw new RuntimeException(ex); } catch (IllegalAccessException ex) { throw new RuntimeException(ex); } paramMap.set("force", String.valueOf(true)); CommandRunner.CommandInvocation inv = commandRunner.getCommandInvocation("deploy", report); inv.parameters(paramMap).inbound(context.getInboundPayload()).outbound(context.getOutboundPayload()).execute(); }
logger.debug("Configure port for SSL"); String command = "create-http-listener"; ParameterMap params = new ParameterMap(); params.add("listeneraddress", "0.0.0.0"); params.add("listenerport", "443"); params.add("defaultvs", "server"); params.add("securityenabled", "true"); params.add("enabled", "true"); params.add("DEFAULT", "http-listener2"); CommandRunner runner = server.getHabitat().getComponent(CommandRunner.class); ActionReport report = server.getHabitat().getComponent(ActionReport.class); runner.getCommandInvocation(command, report).parameters(params).execute();
ParameterMap parameterMap = new ParameterMap(); parameterMap.add("DEFAULT", appName); parameterMap.add("properties", ServiceOrchestratorImpl.ORCHESTRATOR_UNDEPLOY_CALL + "=true"); ActionReport report = habitat.getComponent(ActionReport.class); CommandRunner.CommandInvocation invocation = commandRunner.getCommandInvocation("undeploy", report); invocation.parameters(parameterMap).execute(); Object args[] = new Object[]{appName, report.getMessage()}; logger.log(Level.FINEST, "undeploying.app", args);