/** * Fluent API for adding parameters to the map. * @param k * @param v * @return ParameterMap */ public ParameterMap insert(String k, String v) { add(k, v); return this; } }
/** * Fluent API for adding parameters to the map. * @param k * @param v * @return ParameterMap */ public ParameterMap insert(String k, String v) { add(k, v); return this; } }
protected void fillParameterMap(ParameterMap parameterMap) { if (isTerse) parameterMap.add("terse", ""+isTerse); if (outputHeaderList != null) parameterMap.add("output", outputHeaderList); if (header) parameterMap.add("header", ""+header); if (useLongFormat) parameterMap.add("long", ""+useLongFormat); }
/** * Adds a command option as the user would specify it using the * CLI command for instance * * @param optionName option name (without leading -- chars) * @param optionValue option value */ public void addOption(String optionName, String optionValue) { params.add(optionName, optionValue); }
/** * Adds a command option as the user would specify it using the * CLI command for instance * * @param optionName option name (without leading -- chars) * @param optionValue option value */ public void addOption(String optionName, String optionValue) { params.add(optionName, optionValue); }
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();
private void populateParametersInternal(ParameterMap map) { map.add("DEFAULT", name); map.add(NodeUtils.PARAM_INSTALLDIR, installdir); map.add(NodeUtils.PARAM_NODEHOST, nodehost); map.add(NodeUtils.PARAM_NODEDIR, nodedir); map.add(NodeUtils.PARAM_REMOTEPORT, remotePort); map.add(NodeUtils.PARAM_REMOTEUSER, remoteUser); map.add(NodeUtils.PARAM_REMOTEPASSWORD, remotePassword); map.add(NodeUtils.PARAM_TYPE, getType().toString()); map.add(NodeUtils.PARAM_INSTALL, Boolean.toString(install)); // let subclasses overwrite our values if they like. populateParameters(map); }
private void populatePropertiesToParameterMap(ParameterMap parameters, List<String> propertyNamesList) { Properties props = new Properties(); if (properties != null) { for (String propertyName : propertyNamesList) { if (properties.containsKey(propertyName)) { props.put(propertyName, properties.getProperty(propertyName)); } } } parameters.add("properties", DeploymentUtils.propertiesValue(props, ':')); }
protected void fillParameterMap(ParameterMap parameterMap) { super.fillParameterMap(parameterMap); if (jobName != null) parameterMap.add("DEFAULT", jobName); }
protected void fillParameterMap(ParameterMap parameterMap) { super.fillParameterMap(parameterMap); if (executionId != null) parameterMap.add("DEFAULT", ""+executionId); }
private void populatePropertiesToParameterMap(ParameterMap parameters, List<String> propertyNamesList) { Properties props = new Properties(); if (properties != null) { for (String propertyName : propertyNamesList) { if (properties.containsKey(propertyName)) { props.put(propertyName, properties.getProperty(propertyName)); } } } parameters.add("properties", DeploymentUtils.propertiesValue(props, ':')); }
@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 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); }
private void downloadPayloadFromManaged(String jobId) { if (jobId == null) { return; } try { RemoteRestAdminCommand command = new RemoteRestAdminCommand("_get-payload", this.host, this.port, this.secure, this.user, this.password, this.logger, this.scope, this.authToken, this.prohibitDirectoryUploads,notify); ParameterMap params = new ParameterMap(); params.add("DEFAULT", jobId); command.executeCommand(params); } catch (CommandException ex) { logger.log(Level.WARNING, strings.getString("remote.sse.canNotGetPayload", "Cannot retrieve payload. {0}"), ex.getMessage()); } }
/** * return null if all went OK... * */ private void callInstance() throws CommandException { if (isError()) return; String cmdName = "_restart-instance"; RemoteRestAdminCommand rac = createRac(cmdName); // notice how we do NOT send in the instance's name as an operand!! ParameterMap map = new ParameterMap(); if (debug != null) map.add("debug", debug); rac.executeCommand(map); }
/** * return null if all went OK... * */ private void callInstance() throws CommandException { if (isError()) return; String cmdName = "_restart-instance"; RemoteAdminCommand rac = createRac(cmdName); // notice how we do NOT send in the instance's name as an operand!! ParameterMap map = new ParameterMap(); if (debug != null) map.add("debug", debug); rac.executeCommand(map); }
private void displaySubComponents(String appName, ActionReport report, ActionReport.MessagePart part) { ActionReport subReport = report.addSubActionsReport(); CommandRunner.CommandInvocation inv = commandRunner.getCommandInvocation("list-sub-components", subReport); final ParameterMap parameters = new ParameterMap(); parameters.add("DEFAULT", appName); parameters.add("terse", "true"); parameters.add("resources", resources.toString()); inv.parameters(parameters).execute(); ActionReport.MessagePart subPart = subReport.getTopMessagePart(); for (ActionReport.MessagePart childPart: subPart.getChildren()) { ActionReport.MessagePart actualChildPart = part.addChild(); actualChildPart.setMessage(" " + childPart.getMessage()); for(ActionReport.MessagePart grandChildPart : childPart.getChildren()){ actualChildPart.addChild().setMessage(grandChildPart.getMessage()); } } }
private ActionReport executeInternalCommand(AdminCommandContext context, String targetInstanceName) { String commandName = getCommandName(); ParameterMap params = new ParameterMap(); params.add("target", targetInstanceName); fillParameterMap(params); CommandRunner runner = serviceLocator.getService(CommandRunner.class); ActionReport subReport = context.getActionReport().addSubActionsReport(); CommandRunner.CommandInvocation inv = runner.getCommandInvocation(commandName, subReport, context.getSubject()); inv.parameters(params); inv.execute(); return subReport; }