/** * Get list of password file entries * @return List */ @Override protected List<String> getPasswords() { List list = new ArrayList<String>(); NodeUtils nUtils = new NodeUtils(habitat, logger); list.add("AS_ADMIN_SSHPASSWORD=" + nUtils.sshL.expandPasswordAlias(remotePassword)); if (sshkeypassphrase != null) { list.add("AS_ADMIN_SSHKEYPASSPHRASE=" + nUtils.sshL.expandPasswordAlias(sshkeypassphrase)); } return list; }
/** * * @param node the node of interest * @return null if all-OK, otherwise return an error message */ @Override protected String validateSubType(Node node) { if (!NodeUtils.isSSHNode(node)) { return Strings.get("notSshNode", name); } return null; } }
/** * Make sure we can make an SSH connection using an existing node. * * @param node Node to connect to * @throws CommandValidationException */ void pingRemoteConnection(Node node) throws CommandValidationException { RemoteType type = RemoteType.valueOf(node.getType()); validateHostName(node.getNodeHost()); switch (type) { case SSH: pingSSHConnection(node); break; default: throw new CommandValidationException("Internal Error: unknown type"); } }
private void validateRemoteConnection(ParameterMap map) throws CommandValidationException { // guaranteed to either get a valid type -- or a CommandValidationException RemoteType type = parseType(map); // just too difficult to refactor now... if (type == RemoteType.SSH) validateSSHConnection(map); }
/** * Validate all the parameters used to create a remote node * @param map Map with all parameters used to create a remote node. * The map values can contain system property tokens. * @throws CommandValidationException */ void validate(ParameterMap map) throws CommandValidationException { validatePassword(map.getOne(PARAM_REMOTEPASSWORD)); String nodehost = map.getOne(PARAM_NODEHOST); validateHostName(nodehost); validateRemote(map, nodehost); }
private void startInstance(AdminCommandContext ctx) { NodeUtils nodeUtils = new NodeUtils(habitat, logger); ArrayList<String> command = new ArrayList<String>(); String humanCommand = null; nodeUtils.runAdminCommandOnNode(node, command, ctx, firstErrorMessage, humanCommand, output, waitForReaderThreads);
NodeUtils nodeUtils = new NodeUtils(habitat, logger); if (! NodeUtils.isSSHNode(theNode)) { String m = Strings.get("notSshNode", name); logger.warning(m); if (validate) { nodeUtils.validate(theNode); version = Strings.get("ping.glassfish.version", theNode.getInstallDir(), nodeUtils.getGlassFishVersionOnNode(theNode)); } else { nodeUtils.pingSSHConnection(theNode);
NodeUtils nodeUtils = new NodeUtils(habitat, logger); nodeUtils.validate(map); if (install) { boolean s = installNode(context, nodeUtils.sshL); ci.execute(); NodeUtils.sanitizeReport(report);
NodeUtils nodeUtils = new NodeUtils(habitat, logger); if (validate) { nodeUtils.validate(theNode); version = Strings.get("ping.glassfish.version", theNode.getInstallDir(), nodeUtils.getGlassFishVersionOnNode(theNode, context)); nodeUtils.pingRemoteConnection(theNode);
validatePassword(map.getOne(PARAM_SSHPASSWORD)); validatePassword(map.getOne(PARAM_SSHKEYPASSPHRASE)); validateHostName(nodehost); validateSSHConnection(map);
final Session session = workflowSession.getSession(); final WorkflowData data = workItem.getWorkflowData(); String path = null; String type = data.getPayloadType(); try { if (type.equals(TYPE_JCR_PATH) && data.getPayload() != null) { String payloadData = (String) data.getPayload(); if (session.itemExists(payloadData)) { path = payloadData; } } NodeUtils nodeUtils = new NodeUtils(); if (path != null) { final Node payloadNode = (Node) session.getItem(path); final Node node = nodeUtils.getMainAsset(payloadNode, ASSET_NODE_TYPE, ROOT_NODE_TYPE); ...
void runAdminCommandOnNode(Node node, List<String> command, AdminCommandContext context, String firstErrorMessage, String humanCommand, StringBuilder output) { runAdminCommandOnNode(node, command, context, firstErrorMessage, humanCommand, output, true); }
void validate(Node node) throws CommandValidationException { // Put node values into parameter map and validate ParameterMap map = new ParameterMap(); map.add("DEFAULT", node.getName()); map.add(NodeUtils.PARAM_INSTALLDIR, node.getInstallDir()); map.add(NodeUtils.PARAM_NODEHOST, node.getNodeHost()); map.add(NodeUtils.PARAM_NODEDIR, node.getNodeDirAbsolute()); SshConnector sshc = node.getSshConnector(); if (sshc != null) { map.add(NodeUtils.PARAM_SSHPORT, sshc.getSshPort()); SshAuth ssha = sshc.getSshAuth(); map.add(NodeUtils.PARAM_SSHUSER, ssha.getUserName()); map.add(NodeUtils.PARAM_SSHKEYFILE, ssha.getKeyfile()); map.add(NodeUtils.PARAM_SSHPASSWORD, ssha.getPassword()); map.add(NodeUtils.PARAM_SSHKEYPASSPHRASE, ssha.getKeyPassphrase()); map.add(NodeUtils.PARAM_TYPE,"SSH"); } validate(map); return; }
ci.execute(); NodeUtils.sanitizeReport(report);
/** * Make sure we can make an SSH connection using an existing node. * * @param node Node to connect to * @throws CommandValidationException */ void pingSSHConnection(Node node) throws CommandValidationException { validateHostName(node.getNodeHost()); try { sshL.init(node, logger); sshL.pingConnection(); } catch (Exception e) { String m1 = e.getMessage(); String m2 = ""; Throwable e2 = e.getCause(); if (e2 != null) { m2 = e2.getMessage(); } String msg = Strings.get("ssh.bad.connect", node.getNodeHost()); logger.warning(StringUtils.cat(": ", msg, m1, m2, sshL.toString())); throw new CommandValidationException(StringUtils.cat(NL, msg, m1, m2)); } }
report.setActionExitCode(ActionReport.ExitCode.SUCCESS); NodeUtils nodeUtils = new NodeUtils(habitat, logger); Server dasServer = servers.getServer(SystemPropertyConstants.DAS_SERVER_NAME); nodeUtils.runAdminCommandOnNode(theNode, command, ctx, "", null, null);
nodeUtils = new NodeUtils(habitat, logger); nodeUtils.validate(map); if (install) { boolean s = installNode(context); ci.execute(); NodeUtils.sanitizeReport(report);
void runAdminCommandOnNode(Node node, List<String> command, AdminCommandContext context, String firstErrorMessage, String humanCommand, StringBuilder output) { runAdminCommandOnNode(node, command, context, firstErrorMessage, humanCommand, output, true); } }