Пример #1
0
  @Override
  public void approveRequest(final String requestId) throws HostRegistrationException {
    try {
      RequestedHostImpl registrationRequest = requestDataService.find(requestId);

      if (registrationRequest == null
          || !ResourceHostRegistrationStatus.REQUESTED.equals(registrationRequest.getStatus())) {
        return;
      }

      registrationRequest.setStatus(ResourceHostRegistrationStatus.APPROVED);

      requestDataService.update(registrationRequest);

      importHostPublicKey(registrationRequest.getId(), registrationRequest.getPublicKey(), true);

      importHostSslCert(registrationRequest.getId(), registrationRequest.getCert());

      for (final ContainerInfo containerInfo : registrationRequest.getHostInfos()) {
        importHostPublicKey(containerInfo.getId(), containerInfo.getPublicKey(), false);
      }
    } catch (Exception e) {
      LOG.error("Error approving agent registration request", e);

      throw new HostRegistrationException(e);
    }
  }
Пример #2
0
  @Override
  public void rejectRequest(final String requestId) throws HostRegistrationException {
    try {
      RequestedHostImpl registrationRequest = requestDataService.find(requestId);
      registrationRequest.setStatus(ResourceHostRegistrationStatus.REJECTED);
      requestDataService.update(registrationRequest);
    } catch (Exception e) {
      LOG.error("Error rejecting agent registration request", e);

      throw new HostRegistrationException(e);
    }
  }
Пример #3
0
  @RolesAllowed("Resource-Management|Write")
  @Override
  public synchronized void queueRequest(final RequestedHost requestedHost)
      throws HostRegistrationException {
    Preconditions.checkNotNull(requestedHost, "'Invalid registration request");
    Preconditions.checkArgument(
        PGPKeyUtil.isValidPublicKeyring(requestedHost.getPublicKey()), "Invalid public key");

    try {
      RequestedHostImpl requestedHostImpl = requestDataService.find(requestedHost.getId());

      if (requestedHostImpl != null) {
        LOG.info("Already requested registration");

        // update hostname

        if (!Strings.isNullOrEmpty(requestedHost.getHostname())
            && !requestedHostImpl.getHostname().equalsIgnoreCase(requestedHost.getHostname())) {
          requestedHostImpl.setHostname(requestedHost.getHostname());

          requestDataService.update(requestedHostImpl);
        }
      } else {
        RequestedHostImpl registrationRequest = new RequestedHostImpl(requestedHost);

        registrationRequest.setStatus(ResourceHostRegistrationStatus.REQUESTED);

        requestDataService.update(registrationRequest);

        checkManagement(registrationRequest);
      }
    } catch (Exception e) {
      LOG.error("Error queueing agent registration request", e);

      throw new HostRegistrationException(e);
    }
  }