コード例 #1
0
ファイル: Computer.java プロジェクト: recampbell/jenkins
    public List<String> call() throws IOException {
      List<String> names = new ArrayList<String>();

      Enumeration<NetworkInterface> nis = NetworkInterface.getNetworkInterfaces();
      while (nis.hasMoreElements()) {
        NetworkInterface ni = nis.nextElement();
        LOGGER.fine("Listing up IP addresses for " + ni.getDisplayName());
        Enumeration<InetAddress> e = ni.getInetAddresses();
        while (e.hasMoreElements()) {
          InetAddress ia = e.nextElement();
          if (ia.isLoopbackAddress()) {
            LOGGER.fine(ia + " is a loopback address");
            continue;
          }

          if (!(ia instanceof Inet4Address)) {
            LOGGER.fine(ia + " is not an IPv4 address");
            continue;
          }

          LOGGER.fine(ia + " is a viable candidate");
          names.add(ia.getHostAddress());
        }
      }
      return names;
    }
コード例 #2
0
ファイル: Computer.java プロジェクト: recampbell/jenkins
 /** Returns the transient {@link Action}s associated with the computer. */
 public List<Action> getActions() {
   List<Action> result = new ArrayList<Action>();
   result.addAll(super.getActions());
   synchronized (this) {
     if (transientActions == null) {
       transientActions = TransientComputerActionFactory.createAllFor(this);
     }
     result.addAll(transientActions);
   }
   return result;
 }
コード例 #3
0
ファイル: Computer.java プロジェクト: recampbell/jenkins
 /** Used for CLI binding. */
 @CLIResolver
 public static Computer resolveForCLI(
     @Argument(required = true, metaVar = "NAME", usage = "Slave name, or empty string for master")
         String name)
     throws CmdLineException {
   Jenkins h = Jenkins.getInstance();
   Computer item = h.getComputer(name);
   if (item == null) {
     List<String> names = new ArrayList<String>();
     for (Computer c : h.getComputers()) if (c.getName().length() > 0) names.add(c.getName());
     throw new CmdLineException(
         null, Messages.Computer_NoSuchSlaveExists(name, EditDistance.findNearest(name, names)));
   }
   return item;
 }
コード例 #4
0
ファイル: Computer.java プロジェクト: recampbell/jenkins
  /** Replaces the current {@link Node} by another one. */
  private void replaceBy(Node newNode) throws ServletException, IOException {
    final Jenkins app = Jenkins.getInstance();

    // replace the old Node object by the new one
    synchronized (app) {
      List<Node> nodes = new ArrayList<Node>(app.getNodes());
      int i = nodes.indexOf(getNode());
      if (i < 0) {
        throw new IOException(
            "This slave appears to be removed while you were editing the configuration");
      }

      nodes.set(i, newNode);
      app.setNodes(nodes);
    }
  }