Пример #1
0
 private static void markSlaveForDeletion(AzureSlave slave, String message) {
   slave.setTemplateStatus(Constants.TEMPLATE_STATUS_DISBALED, message);
   if (slave.toComputer() != null) {
     slave
         .toComputer()
         .setTemporarilyOffline(true, OfflineCause.create(Messages._Slave_Failed_To_Connect()));
   }
   slave.setDeleteSlave(true);
 }
Пример #2
0
 public HttpResponse doChangeOfflineCause(@QueryParameter String offlineMessage)
     throws IOException, ServletException {
   checkPermission(DISCONNECT);
   offlineMessage = Util.fixEmptyAndTrim(offlineMessage);
   setTemporarilyOffline(
       true,
       OfflineCause.create(
           hudson.slaves.Messages._SlaveComputer_DisconnectedBy(
               Jenkins.getAuthentication().getName(),
               offlineMessage != null ? " : " + offlineMessage : "")));
   return HttpResponses.redirectToDot();
 }
Пример #3
0
  /**
   * If the computer was offline (either temporarily or not), this method will return the cause as a
   * string (without user info).
   *
   * @return empty string if the system was put offline without given a cause.
   */
  @Exported
  public String getOfflineCauseReason() {
    if (offlineCause == null) {
      return "";
    }
    // fetch the localized string for "Disconnected By"
    String gsub_base = hudson.slaves.Messages.SlaveComputer_DisconnectedBy("", "");
    // regex to remove commented reason base string
    String gsub1 = "^" + gsub_base + "[\\w\\W]* \\: ";
    // regex to remove non-commented reason base string
    String gsub2 = "^" + gsub_base + "[\\w\\W]*";

    String newString = offlineCause.toString().replaceAll(gsub1, "");
    return newString.replaceAll(gsub2, "");
  }
 @Override
 public synchronized long check(JCloudsComputer c) {
   if (c.isIdle() && !c.getNode().isPendingDelete() && !disabled) {
     // Get the retention time, in minutes, from the JCloudsCloud this JCloudsComputer belongs to.
     final int retentionTime = JCloudsCloud.getByName(c.getCloudName()).getRetentionTime();
     if (retentionTime > -1) {
       final long idleMilliseconds = System.currentTimeMillis() - c.getIdleStartMilliseconds();
       if (idleMilliseconds > TimeUnit2.MINUTES.toMillis(retentionTime)) {
         LOGGER.info("Setting " + c.getName() + " to be deleted.");
         if (!c.isOffline()) {
           c.setTemporarilyOffline(true, OfflineCause.create(Messages._DeletedCause()));
         }
         c.getNode().setPendingDelete(true);
       }
     }
   }
   return 1;
 }