Esempio n. 1
0
 /**
  * Update the nodes resources file from a specific URL, with BASIC authentication as provided or
  * as defined in the URL's userInfo section.
  *
  * @param providerURL URL to retrieve resources file definition
  * @param username username or null
  * @param password or null
  * @throws com.dtolabs.rundeck.core.common.UpdateUtils.UpdateException if an error occurs during
  *     the update process
  */
 public void updateNodesResourceFileFromUrl(
     final String providerURL, final String username, final String password)
     throws UpdateUtils.UpdateException {
   if (!validateResourceProviderURL(providerURL)) {
     throw new UpdateUtils.UpdateException("providerURL is not allowed: " + providerURL);
   }
   UpdateUtils.updateFileFromUrl(providerURL, getNodesResourceFilePath(), username, password);
   logger.debug("Updated nodes resources file: " + getNodesResourceFilePath());
 }
Esempio n. 2
0
 private void cleanupStagingArea() {
   // ensure last DL was sound
   Revision latestStaged = getLatestStaged();
   File zip = latestStaged.getLocalPath().toFile();
   if (zip.exists()) {
     if (!UpdateUtils.isZipValid(zip)) {
       // TODO(pquitslund): sysout for debugging
       System.out.println("deleting invalid zip: " + zip.getName());
       zip.delete();
     }
   }
 }
Esempio n. 3
0
  /**
   * Update the nodes resources file from a specific URL, with BASIC authentication as provided or
   * as defined in the URL's userInfo section.
   *
   * @param providerURL URL to retrieve resources file definition
   * @param username username or null
   * @param password or null
   * @param nodesResourceFilePath path of the destination file
   * @throws com.dtolabs.rundeck.core.common.UpdateUtils.UpdateException if an error occurs during
   *     the update process
   */
  @Override
  public void updateNodesResourceFileFromUrl(
      final String providerURL,
      final String username,
      final String password,
      final String nodesResourceFilePath)
      throws UpdateUtils.UpdateException {
    if (!validateResourceProviderURL(providerURL)) {
      throw new UpdateUtils.UpdateException("providerURL is not allowed: " + providerURL);
    }

    UpdateUtils.updateFileFromUrl(
        providerURL, nodesResourceFilePath, username, password, URLFileUpdater.factory());
    logger.debug("Updated nodes resources file: " + nodesResourceFilePath);
  }
  public boolean execute(IProgressMonitor pm, IOperationListener listener) throws CoreException {

    IStatus status = OperationsManager.getValidator().validatePendingConfig(feature);
    if (status != null && status.getCode() == IStatus.ERROR) {
      throw new CoreException(status);
    }
    try {
      targetSite.configure(feature);
      // ensureUnique();

      // Restart not needed
      boolean restartNeeded = false;

      // Check if this operation is cancelling one that's already pending
      IOperation pendingOperation = OperationsManager.findPendingOperation(feature);

      if (pendingOperation instanceof IUnconfigFeatureOperation) {
        // no need to do either pending change
        OperationsManager.removePendingOperation(pendingOperation);
      } else {
        OperationsManager.addPendingOperation(this);
      }

      markProcessed();
      if (listener != null) listener.afterExecute(this, null);

      restartNeeded = SiteManager.getLocalSite().save() && restartNeeded;

      // notify the model
      OperationsManager.fireObjectChanged(feature, null);

      return restartNeeded;
    } catch (CoreException e) {
      undo();
      UpdateUtils.logException(e);
      throw e;
    }
  }
Esempio n. 5
0
 /**
  * Update the resources file from a source file
  *
  * @param source the source file
  * @throws UpdateUtils.UpdateException if an error occurs while trying to update the resources
  *     file
  */
 public void updateNodesResourceFile(final File source) throws UpdateUtils.UpdateException {
   UpdateUtils.updateFileFromFile(source, getNodesResourceFilePath());
   logger.debug("Updated nodes resources file: " + getNodesResourceFilePath());
 }
Esempio n. 6
0
 /**
  * Update the resources file from a source file
  *
  * @param source the source file
  * @throws UpdateUtils.UpdateException if an error occurs while trying to update the resources
  *     file
  */
 public void updateNodesResourceFile(final File source, final String nodesResourceFilePath)
     throws UpdateUtils.UpdateException {
   UpdateUtils.updateFileFromFile(source, nodesResourceFilePath);
   logger.debug("Updated nodes resources file: " + nodesResourceFilePath);
 }
Esempio n. 7
0
 /**
  * Get the latest revision number for update testing.
  *
  * @return the latest revision
  * @throws IOException if an error occurs accessing revision info
  */
 public Revision getLatestRevision() throws IOException {
   return UpdateUtils.getLatestRevision(UpdateCore.getUpdateUrl());
 }