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 ;
3531
3632import javax .inject .Inject ;
3733
38- @ APICommand (name = UploadTemplateDirectDownloadCertificate .APINAME ,
34+ @ APICommand (name = UploadTemplateDirectDownloadCertificateCmd .APINAME ,
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 })
45- public class UploadTemplateDirectDownloadCertificate extends BaseCmd {
41+ public class UploadTemplateDirectDownloadCertificateCmd extends BaseCmd {
4642
4743 @ Inject
4844 DirectDownloadManager directDownloadManager ;
4945
50- private static final Logger LOG = Logger .getLogger (UploadTemplateDirectDownloadCertificate .class );
46+ private static final Logger LOG = Logger .getLogger (UploadTemplateDirectDownloadCertificateCmd .class );
5147 public static final String APINAME = "uploadTemplateDirectDownloadCertificate" ;
5248
5349 @ Parameter (name = ApiConstants .CERTIFICATE , type = BaseCmd .CommandType .STRING , required = true , length = 65535 ,
@@ -61,16 +57,24 @@ public class UploadTemplateDirectDownloadCertificate 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