Exemplo n.º 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);
    }
  }
Exemplo n.º 2
0
  protected void checkManagement(RequestedHost requestedHost) {
    try {
      if (requestedHost.getStatus() == ResourceHostRegistrationStatus.REQUESTED
          && containsManagementContainer(requestedHost.getHostInfos())) {
        boolean managementAlreadyApproved = false;

        for (RequestedHostImpl requestedHostImpl : requestDataService.getAll()) {
          if (requestedHostImpl.getStatus() == ResourceHostRegistrationStatus.APPROVED
              && containsManagementContainer(requestedHostImpl.getHostInfos())) {
            managementAlreadyApproved = true;
            break;
          }
        }

        if (!managementAlreadyApproved) {
          approveRequest(requestedHost.getId());
        }
      }
    } catch (Exception e) {
      // ignore
    }
  }