/** * Get the version string from a glassfish installation on the node. * @param node * @return version string */ String getGlassFishVersionOnNode(Node node) throws CommandValidationException { if (node == null) return ""; List<String> command = new ArrayList<String>(); command.add("version"); command.add("--local"); command.add("--terse"); NodeRunner nr = new NodeRunner(habitat, logger); StringBuilder output = new StringBuilder(); try { int commandStatus = nr.runAdminCommandOnNode(node, output, command); if (commandStatus != 0) { return "unknown version: " + output.toString(); } } catch (Exception e) { throw new CommandValidationException( Strings.get("failed.to.run", command.toString(), node.getNodeHost()), e); } return output.toString().trim(); }
/** * Get the version string from a glassfish installation on the node. * @param node * @return version string */ String getGlassFishVersionOnNode(Node node, AdminCommandContext context) throws CommandValidationException { if (node == null) return ""; List<String> command = new ArrayList<String>(); command.add("version"); command.add("--local"); command.add("--terse"); NodeRunner nr = new NodeRunner(habitat, logger); StringBuilder output = new StringBuilder(); try { int commandStatus = nr.runAdminCommandOnNode(node, output, command, context); if (commandStatus != 0) { return "unknown version: " + output.toString(); } } catch (Exception e) { throw new CommandValidationException( Strings.get("failed.to.run", command.toString(), node.getNodeHost()), e); } return output.toString().trim(); }
String host = n.getNodeHost(); String installDir = n.getInstallDir();
instanceName, noderef, theNode.getNodeHost() ); instanceName, theNode.getNodeHost()); if (!terse) { msg = StringUtils.cat(NL,
public static boolean isLocal(Node node) { // Short circuit common case for efficiency Dom serverDom = Dom.unwrap(node); Domain domain = serverDom.getHabitat().getService(Domain.class); if (node.getName().equals("localhost-" + domain.getName())) { return true; } String nodeHost = node.getNodeHost(); if (nodeHost == null || nodeHost.length() == 0) { return false; } return NetUtils.isThisHostLocal(nodeHost); }
public static boolean isLocal(Node node) { // Short circuit common case for efficiency Dom serverDom = Dom.unwrap(node); Domain domain = serverDom.getHabitat().getComponent(Domain.class); if (node.getName().equals("localhost-" + domain.getName())) { return true; } String nodeHost = node.getNodeHost(); if (nodeHost == null || nodeHost.length() == 0) { return false; } return NetUtils.isThisHostLocal(nodeHost); }
/** * 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)); } }
/** * Make sure we can make an SSH connection using an existing node. * * @param node Node to connect to * @throws CommandValidationException */ private void pingSSHConnection(Node node) throws CommandValidationException { 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(), "SSH"); logger.warning(StringUtils.cat(": ", msg, m1, m2, sshL.toString())); throw new CommandValidationException(StringUtils.cat(NL, msg, m1, m2)); } }
if (targetServer != null && ! targetServer.isDas()) { port = JmsRaUtil.getJMSPropertyValue(targetServer); host = domain.getNodeNamed(targetServer.getNodeRef()).getNodeHost(); } else{ Cluster cluster = domain.getClusterNamed(target); targetServer = cluster.getInstances().get(0); port = JmsRaUtil.getJMSPropertyValue(targetServer); host = domain.getNodeNamed(targetServer.getNodeRef()).getNodeHost();
/** * 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 setupSupplemental(AdminCommandContext context, final Server instance) { if (clusterName != null) { InstanceRegisterInstanceCommandParameters cp = new InstanceRegisterInstanceCommandParameters(); context.getActionReport(). setResultType(InstanceRegisterInstanceCommandParameters.class, cp); Node instNode = domain.getNodeNamed(node); cp.config = instance.getConfigRef(); cp.nodehost = instNode.getNodeHost(); cp.nodedir = instNode.getNodeDir(); cp.installdir = instNode.getInstallDir(); List<SystemProperty> spList = instance.getSystemProperty(); if (spList != null) { Properties p = new Properties(); for (SystemProperty sp : spList) { p.put(sp.getName(), sp.getValue()); } cp.systemProperties = p; } } }
private void setupSupplemental(AdminCommandContext context, final Server instance) { if (clusterName != null) { InstanceRegisterInstanceCommandParameters cp = new InstanceRegisterInstanceCommandParameters(); context.getActionReport(). setResultType(InstanceRegisterInstanceCommandParameters.class, cp); Node instNode = domain.getNodeNamed(node); cp.config = instance.getConfigRef(); cp.nodehost = instNode.getNodeHost(); cp.nodedir = instNode.getNodeDir(); cp.installdir = instNode.getInstallDir(); List<SystemProperty> spList = instance.getSystemProperty(); if (spList != null) { Properties p = new Properties(); for (SystemProperty sp : spList) { p.put(sp.getName(), sp.getValue()); } cp.systemProperties = p; } } }
this.host = host; } else { this.host = node.getNodeHost();
private void checkAdminPort(final Server instance, final Config config, LocalStringManagerImpl localStrings) throws TransactionFailure { if (node != null) { Node n = domain.getNodeNamed(node); if (n != null) { String nodeHost = n.getNodeHost(); if (NetUtils.isThisHostLocal(nodeHost)) { // instance on same host as DAS int dasAdminPort = domain.getServerNamed("server").getAdminPort(); // Don't use the getAdminPort duck type method directly on the instance being created int instanceAdminPort = new ServerHelper(instance, config).getAdminPort(); if (instanceAdminPort != -1 && dasAdminPort != -1) { if (instanceAdminPort == dasAdminPort) { throw new TransactionFailure(localStrings.getLocalString( "Server.cannotHaveSameAdminPortAsDAS", "Cannot create an instance on the same host as DAS with the same admin port as DAS: {0}.", instanceAdminPort + "")); } } } } } }
private void checkAdminPort(final Server instance, final Config config, LocalStringManagerImpl localStrings) throws TransactionFailure { if (node != null) { Node n = domain.getNodeNamed(node); if (n != null) { String nodeHost = n.getNodeHost(); if (NetUtils.isThisHostLocal(nodeHost)) { // instance on same host as DAS int dasAdminPort = domain.getServerNamed("server").getAdminPort(); // Don't use the getAdminPort duck type method directly on the instance being created int instanceAdminPort = new ServerHelper(instance, config).getAdminPort(); if (instanceAdminPort != -1 && dasAdminPort != -1) { if (instanceAdminPort == dasAdminPort) { throw new TransactionFailure(localStrings.getLocalString( "Server.cannotHaveSameAdminPortAsDAS", "Cannot create an instance on the same host as DAS with the same admin port as DAS: {0}.", instanceAdminPort + "")); } } } } } }
nodehost = node.getNodeHost();
value = node.getNodeHost(); validateHostname("nodehost", nodehost, value);
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; }
value = node.getNodeHost(); validateHostname("nodehost", nodehost, value);
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_REMOTEPORT, sshc.getSshPort()); SshAuth ssha = sshc.getSshAuth(); map.add(NodeUtils.PARAM_REMOTEUSER, ssha.getUserName()); map.add(NodeUtils.PARAM_SSHKEYFILE, ssha.getKeyfile()); map.add(NodeUtils.PARAM_REMOTEPASSWORD, ssha.getPassword()); map.add(NodeUtils.PARAM_SSHKEYPASSPHRASE, ssha.getKeyPassphrase()); map.add(NodeUtils.PARAM_TYPE, node.getType()); } validate(map); return; }