sureshanaparti commented on a change in pull request #6104: URL: https://github.com/apache/cloudstack/pull/6104#discussion_r829052612
########## File path: api/src/main/java/org/apache/cloudstack/api/command/admin/direct/download/ListTemplateDirectDownloadCertificatesCmd.java ########## @@ -0,0 +1,110 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +package org.apache.cloudstack.api.command.admin.direct.download; + +import com.cloud.exception.ConcurrentOperationException; +import com.cloud.exception.InsufficientCapacityException; +import com.cloud.exception.NetworkRuleConflictException; +import com.cloud.exception.ResourceAllocationException; +import com.cloud.exception.ResourceUnavailableException; +import org.apache.cloudstack.acl.RoleType; +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiConstants; +import org.apache.cloudstack.api.BaseCmd; +import org.apache.cloudstack.api.BaseListCmd; +import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.response.DirectDownloadCertificateHostMapResponse; +import org.apache.cloudstack.api.response.ListResponse; +import org.apache.cloudstack.api.response.DirectDownloadCertificateResponse; +import org.apache.cloudstack.api.response.ZoneResponse; +import org.apache.cloudstack.context.CallContext; +import org.apache.cloudstack.direct.download.DirectDownloadCertificate; +import org.apache.cloudstack.direct.download.DirectDownloadCertificateHostMap; +import org.apache.cloudstack.direct.download.DirectDownloadManager; +import org.apache.log4j.Logger; + +import javax.inject.Inject; +import java.util.ArrayList; +import java.util.List; + +@APICommand(name = ListTemplateDirectDownloadCertificatesCmd.APINAME, + description = "List the uploaded direct download certificates", Review comment: ```suggestion description = "List the uploaded certificates for direct download templates", ``` ########## File path: api/src/main/java/org/apache/cloudstack/api/command/admin/direct/download/ListTemplateDirectDownloadCertificatesCmd.java ########## @@ -0,0 +1,110 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +package org.apache.cloudstack.api.command.admin.direct.download; + +import com.cloud.exception.ConcurrentOperationException; +import com.cloud.exception.InsufficientCapacityException; +import com.cloud.exception.NetworkRuleConflictException; +import com.cloud.exception.ResourceAllocationException; +import com.cloud.exception.ResourceUnavailableException; +import org.apache.cloudstack.acl.RoleType; +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiConstants; +import org.apache.cloudstack.api.BaseCmd; +import org.apache.cloudstack.api.BaseListCmd; +import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.response.DirectDownloadCertificateHostMapResponse; +import org.apache.cloudstack.api.response.ListResponse; +import org.apache.cloudstack.api.response.DirectDownloadCertificateResponse; +import org.apache.cloudstack.api.response.ZoneResponse; +import org.apache.cloudstack.context.CallContext; +import org.apache.cloudstack.direct.download.DirectDownloadCertificate; +import org.apache.cloudstack.direct.download.DirectDownloadCertificateHostMap; +import org.apache.cloudstack.direct.download.DirectDownloadManager; +import org.apache.log4j.Logger; + +import javax.inject.Inject; +import java.util.ArrayList; +import java.util.List; + +@APICommand(name = ListTemplateDirectDownloadCertificatesCmd.APINAME, + description = "List the uploaded direct download certificates", Review comment: whatever applicable. ```suggestion description = "List the uploaded certificates for direct download templates", ``` (or) ```suggestion description = "List the uploaded direct download certificates of templates", ``` ########## File path: api/src/main/java/org/apache/cloudstack/api/command/admin/direct/download/RevokeTemplateDirectDownloadCertificateCmd.java ########## @@ -28,39 +28,40 @@ import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; import org.apache.cloudstack.api.BaseCmd; +import org.apache.cloudstack.api.BaseListCmd; import org.apache.cloudstack.api.Parameter; import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.response.DirectDownloadCertificateResponse; import org.apache.cloudstack.api.response.HostResponse; -import org.apache.cloudstack.api.response.SuccessResponse; +import org.apache.cloudstack.api.response.ListResponse; +import org.apache.cloudstack.api.response.DirectDownloadCertificateHostStatusResponse; import org.apache.cloudstack.api.response.ZoneResponse; import org.apache.cloudstack.context.CallContext; import org.apache.cloudstack.direct.download.DirectDownloadManager; +import org.apache.cloudstack.direct.download.DirectDownloadManager.HostCertificateStatus; import org.apache.log4j.Logger; import javax.inject.Inject; +import java.util.ArrayList; +import java.util.List; @APICommand(name = RevokeTemplateDirectDownloadCertificateCmd.APINAME, - description = "Revoke a certificate alias from a KVM host", - responseObject = SuccessResponse.class, - requestHasSensitiveInfo = true, - responseHasSensitiveInfo = true, + description = "Revoke a certificate from hosts in a zone", Review comment: ```suggestion description = "Revoke a direct download certificate from hosts in a zone", ``` ########## File path: engine/schema/src/main/java/org/apache/cloudstack/direct/download/DirectDownloadCertificateHostMapVO.java ########## @@ -25,12 +25,12 @@ @Entity @Table(name = "direct_download_certificate_host_map") -public class DirectDownloadCertificateHostMapVO { +public class DirectDownloadCertificateHostMapVO implements DirectDownloadCertificateHostMap{ Review comment: ```suggestion public class DirectDownloadCertificateHostMapVO implements DirectDownloadCertificateHostMap { ``` ########## File path: server/src/main/java/org/apache/cloudstack/direct/download/DirectDownloadManagerImpl.java ########## @@ -19,6 +19,10 @@ package org.apache.cloudstack.direct.download; import static com.cloud.storage.Storage.ImageFormat; +import static org.apache.cloudstack.direct.download.DirectDownloadManager.HostCertificateStatus.CertificateStatus.FAILED; +import static org.apache.cloudstack.direct.download.DirectDownloadManager.HostCertificateStatus.CertificateStatus.REVOKED; +import static org.apache.cloudstack.direct.download.DirectDownloadManager.HostCertificateStatus.CertificateStatus.SKIPPED; +import static org.apache.cloudstack.direct.download.DirectDownloadManager.HostCertificateStatus.CertificateStatus.UPLOADED; Review comment: possible to import _org.apache.cloudstack.direct.download.DirectDownloadManager.HostCertificateStatus.CertificateStatus_ , and use the status enums ? ########## File path: server/src/main/java/org/apache/cloudstack/direct/download/DirectDownloadManagerImpl.java ########## @@ -475,48 +486,55 @@ public boolean uploadCertificateToHosts(String certificateCer, String alias, Str certificateVO = directDownloadCertificateDao.findByAlias(alias, hypervisorType, zoneId); if (certificateVO == null) { s_logger.info("Certificate must be uploaded on zone " + zoneId); - return false; + return new ArrayList<>(); } } s_logger.info("Attempting to upload certificate: " + alias + " to " + hosts.size() + " hosts on zone " + zoneId); - int hostCount = 0; + int success = 0; + int failed = 0; + List<HostCertificateStatus> results = new ArrayList<>(); if (CollectionUtils.isNotEmpty(hosts)) { for (HostVO host : hosts) { - if (!uploadCertificate(certificateVO.getId(), host.getId())) { - String msg = "Could not upload certificate " + alias + " on host: " + host.getName() + " (" + host.getUuid() + ")"; + if (host == null) { + continue; + } + HostCertificateStatus hostStatus; + Pair<Boolean, String> result = provisionCertificate(certificateVO.getId(), host.getId()); + if (!result.first()) { + String msg = "Could not upload certificate " + alias + " on host: " + host.getName() + " (" + host.getUuid() + "): " + result.second(); s_logger.error(msg); - throw new CloudRuntimeException(msg); + failed++; Review comment: failed ones can be re-provisioned later ? any retry attempt here ? -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
