1616// under the License.
1717package org .apache .cloudstack .api .command .admin .direct .download ;
1818
19- import com .cloud .exception .ConcurrentOperationException ;
20- import com .cloud .exception .InsufficientCapacityException ;
21- import com .cloud .exception .ResourceAllocationException ;
22- import com .cloud .exception .ResourceUnavailableException ;
23- import com .cloud .exception .NetworkRuleConflictException ;
2419import org .apache .cloudstack .acl .RoleType ;
2520import org .apache .cloudstack .api .APICommand ;
2621import org .apache .cloudstack .api .ApiConstants ;
2924import org .apache .cloudstack .api .ServerApiException ;
3025import org .apache .cloudstack .api .ApiErrorCode ;
3126import org .apache .cloudstack .api .response .SuccessResponse ;
27+ import org .apache .cloudstack .api .response .ZoneResponse ;
3228import org .apache .cloudstack .context .CallContext ;
3329import org .apache .cloudstack .direct .download .DirectDownloadManager ;
3430import org .apache .log4j .Logger ;
3935 description = "Upload a certificate for HTTPS direct template download on KVM hosts" ,
4036 responseObject = SuccessResponse .class ,
4137 requestHasSensitiveInfo = true ,
42- responseHasSensitiveInfo = true ,
38+ responseHasSensitiveInfo = false ,
4339 since = "4.11.0" ,
4440 authorized = {RoleType .Admin })
4541public class UploadTemplateDirectDownloadCertificateCmd extends BaseCmd {
@@ -61,16 +57,24 @@ public class UploadTemplateDirectDownloadCertificateCmd extends BaseCmd {
6157 @ Parameter (name = ApiConstants .HYPERVISOR , type = BaseCmd .CommandType .STRING , required = true , description = "Hypervisor type" )
6258 private String hypervisor ;
6359
60+ @ Parameter (name = ApiConstants .ZONE_ID , type = CommandType .UUID , entityType = ZoneResponse .class ,
61+ description = "Zone to upload certificate" , required = true )
62+ private Long zoneId ;
63+
6464 @ Override
65- public void execute () throws ResourceUnavailableException , InsufficientCapacityException , ServerApiException , ConcurrentOperationException , ResourceAllocationException , NetworkRuleConflictException {
65+ public void execute () {
6666 if (!hypervisor .equalsIgnoreCase ("kvm" )) {
6767 throw new ServerApiException (ApiErrorCode .PARAM_ERROR , "Currently supporting KVM hosts only" );
6868 }
6969
70- SuccessResponse response = new SuccessResponse (getCommandName ());
70+ if (name .equalsIgnoreCase ("cloud" )) {
71+ throw new ServerApiException (ApiErrorCode .PARAM_ERROR , "Please provide a different alias name for the certificate" );
72+ }
73+
7174 try {
7275 LOG .debug ("Uploading certificate " + name + " to agents for Direct Download" );
73- boolean result = directDownloadManager .uploadCertificateToHosts (certificate , name , hypervisor );
76+ boolean result = directDownloadManager .uploadCertificateToHosts (certificate , name , hypervisor , zoneId );
77+ SuccessResponse response = new SuccessResponse (getCommandName ());
7478 response .setSuccess (result );
7579 setResponseObject (response );
7680 } catch (Exception e ) {
0 commit comments