rafaelweingartner commented on a change in pull request #2995: KVM: Improvements on upload direct download certificates URL: https://github.com/apache/cloudstack/pull/2995#discussion_r289654752
########## File path: server/src/org/apache/cloudstack/direct/download/DirectDownloadManagerImpl.java ########## @@ -331,14 +390,44 @@ public boolean uploadCertificateToHosts(String certificateCer, String certificat * Upload and import certificate to hostId on keystore */ protected boolean uploadCertificate(String certificate, String certificateName, long hostId) { - String cert = certificate.replaceAll("(.{64})", "$1\n"); - final String prettified_cert = BEGIN_CERT + LINE_SEPARATOR + cert + LINE_SEPARATOR + END_CERT; - SetupDirectDownloadCertificate cmd = new SetupDirectDownloadCertificate(prettified_cert, certificateName); + SetupDirectDownloadCertificateCommand cmd = new SetupDirectDownloadCertificateCommand(certificate, certificateName); Answer answer = agentManager.easySend(hostId, cmd); if (answer == null || !answer.getResult()) { + String msg = "Certificate " + certificateName + " could not be added to host " + hostId; + if (answer != null) { + msg += " due to: " + answer.getDetails(); + } + s_logger.info(msg); return false; } s_logger.info("Certificate " + certificateName + " successfully uploaded to host: " + hostId); return true; } + + @Override + public boolean revokeCertificateAlias(String certificateAlias, String hypervisor) { + HypervisorType hypervisorType = HypervisorType.getType(hypervisor); + List<HostVO> hosts = getRunningHostsToUploadCertificate(hypervisorType); + s_logger.info("Attempting to revoke certificate alias: " + certificateAlias + " from " + hosts.size() + " hosts"); + if (CollectionUtils.isNotEmpty(hosts)) { + for (HostVO host : hosts) { + if (!revokeCertificateAliasFromHost(certificateAlias, host.getId())) { + s_logger.error("Could not revoke certificate from host: " + host.getName() + " (" + host.getUuid() + ")"); Review comment: You can re-use the same message for both exception and log error message ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services