Repository: cloudstack Updated Branches: refs/heads/volume-upload 7e030ee72 -> f70a2a148
volume upload: renamed command classes to follow the naming convention Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/f70a2a14 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/f70a2a14 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/f70a2a14 Branch: refs/heads/volume-upload Commit: f70a2a1486e63e8860c163e569a524dd249dc048 Parents: 7e030ee Author: Rajani Karuturi <rajanikarut...@gmail.com> Authored: Tue Dec 16 12:48:37 2014 +0530 Committer: Rajani Karuturi <rajanikarut...@gmail.com> Committed: Tue Dec 16 12:48:37 2014 +0530 ---------------------------------------------------------------------- .../com/cloud/template/TemplateApiService.java | 4 +- .../api/AbstractGetUploadParamsCmd.java | 89 ++++++++++ .../api/AbstractGetUploadParamsCommand.java | 89 ---------- .../template/GetUploadParamsForTemplate.java | 172 ------------------- .../template/GetUploadParamsForTemplateCmd.java | 172 +++++++++++++++++++ .../user/volume/GetUploadParamsForVolume.java | 88 ---------- .../volume/GetUploadParamsForVolumeCmd.java | 88 ++++++++++ .../com/cloud/server/ManagementServerImpl.java | 8 +- .../template/HypervisorTemplateAdapter.java | 4 +- .../src/com/cloud/template/TemplateAdapter.java | 4 +- .../com/cloud/template/TemplateAdapterBase.java | 4 +- .../com/cloud/template/TemplateManagerImpl.java | 4 +- 12 files changed, 363 insertions(+), 363 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f70a2a14/api/src/com/cloud/template/TemplateApiService.java ---------------------------------------------------------------------- diff --git a/api/src/com/cloud/template/TemplateApiService.java b/api/src/com/cloud/template/TemplateApiService.java index ea8eaf8..43177fc 100755 --- a/api/src/com/cloud/template/TemplateApiService.java +++ b/api/src/com/cloud/template/TemplateApiService.java @@ -30,7 +30,7 @@ import org.apache.cloudstack.api.command.user.template.CopyTemplateCmd; import org.apache.cloudstack.api.command.user.template.CreateTemplateCmd; import org.apache.cloudstack.api.command.user.template.DeleteTemplateCmd; import org.apache.cloudstack.api.command.user.template.ExtractTemplateCmd; -import org.apache.cloudstack.api.command.user.template.GetUploadParamsForTemplate; +import org.apache.cloudstack.api.command.user.template.GetUploadParamsForTemplateCmd; import org.apache.cloudstack.api.command.user.template.RegisterTemplateCmd; import org.apache.cloudstack.api.command.user.template.UpdateTemplateCmd; @@ -45,7 +45,7 @@ public interface TemplateApiService { VirtualMachineTemplate registerTemplate(RegisterTemplateCmd cmd) throws URISyntaxException, ResourceAllocationException; - public GetUploadParamsResponse registerTemplateForPostUpload(GetUploadParamsForTemplate cmd) throws ResourceAllocationException, MalformedURLException; + public GetUploadParamsResponse registerTemplateForPostUpload(GetUploadParamsForTemplateCmd cmd) throws ResourceAllocationException, MalformedURLException; VirtualMachineTemplate registerIso(RegisterIsoCmd cmd) throws IllegalArgumentException, ResourceAllocationException; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f70a2a14/api/src/org/apache/cloudstack/api/AbstractGetUploadParamsCmd.java ---------------------------------------------------------------------- diff --git a/api/src/org/apache/cloudstack/api/AbstractGetUploadParamsCmd.java b/api/src/org/apache/cloudstack/api/AbstractGetUploadParamsCmd.java new file mode 100644 index 0000000..df63d74 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/AbstractGetUploadParamsCmd.java @@ -0,0 +1,89 @@ +/* + * 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; + +import org.apache.cloudstack.api.response.DomainResponse; +import org.apache.cloudstack.api.response.GetUploadParamsResponse; +import org.apache.cloudstack.api.response.ProjectResponse; +import org.apache.cloudstack.api.response.ZoneResponse; +import org.apache.log4j.Logger; + +import java.net.URL; +import java.util.UUID; + +public abstract class AbstractGetUploadParamsCmd extends BaseCmd { + + public static final Logger s_logger = Logger.getLogger(AbstractGetUploadParamsCmd.class.getName()); + + @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = true, description = "the name of the volume/template") + private String name; + + @Parameter(name = ApiConstants.FORMAT, type = CommandType.STRING, required = true, description = "the format for the volume/template. Possible values include QCOW2, OVA, " + + "and VHD.") + private String format; + + @Parameter(name = ApiConstants.ZONE_ID, type = CommandType.UUID, entityType = ZoneResponse.class, required = true, description = "the ID of the zone the volume/template is " + + "to be hosted on") + private Long zoneId; + + @Parameter(name = ApiConstants.CHECKSUM, type = CommandType.STRING, description = "the MD5 checksum value of this volume/template") + private String checksum; + + @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "an optional accountName. Must be used with domainId.") + private String accountName; + + @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, entityType = DomainResponse.class, description = "an optional domainId. If the account parameter is used, " + + "domainId must also be used.") + private Long domainId; + + @Parameter(name = ApiConstants.PROJECT_ID, type = CommandType.UUID, entityType = ProjectResponse.class, description = "Upload volume/template for the project") + private Long projectId; + + public String getName() { + return name; + } + + public String getFormat() { + return format; + } + + public Long getZoneId() { + return zoneId; + } + + public String getChecksum() { + return checksum; + } + + public String getAccountName() { + return accountName; + } + + public Long getDomainId() { + return domainId; + } + + public Long getProjectId() { + return projectId; + } + + public GetUploadParamsResponse createGetUploadParamsResponse(UUID id, URL postURL, String metadata, String timeout, String signature) { + return new GetUploadParamsResponse(id, postURL, metadata, timeout, signature); + } +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f70a2a14/api/src/org/apache/cloudstack/api/AbstractGetUploadParamsCommand.java ---------------------------------------------------------------------- diff --git a/api/src/org/apache/cloudstack/api/AbstractGetUploadParamsCommand.java b/api/src/org/apache/cloudstack/api/AbstractGetUploadParamsCommand.java deleted file mode 100644 index cd5fb14..0000000 --- a/api/src/org/apache/cloudstack/api/AbstractGetUploadParamsCommand.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * 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; - -import org.apache.cloudstack.api.response.DomainResponse; -import org.apache.cloudstack.api.response.GetUploadParamsResponse; -import org.apache.cloudstack.api.response.ProjectResponse; -import org.apache.cloudstack.api.response.ZoneResponse; -import org.apache.log4j.Logger; - -import java.net.URL; -import java.util.UUID; - -public abstract class AbstractGetUploadParamsCommand extends BaseCmd { - - public static final Logger s_logger = Logger.getLogger(AbstractGetUploadParamsCommand.class.getName()); - - @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = true, description = "the name of the volume/template") - private String name; - - @Parameter(name = ApiConstants.FORMAT, type = CommandType.STRING, required = true, description = "the format for the volume/template. Possible values include QCOW2, OVA, " - + "and VHD.") - private String format; - - @Parameter(name = ApiConstants.ZONE_ID, type = CommandType.UUID, entityType = ZoneResponse.class, required = true, description = "the ID of the zone the volume/template is " - + "to be hosted on") - private Long zoneId; - - @Parameter(name = ApiConstants.CHECKSUM, type = CommandType.STRING, description = "the MD5 checksum value of this volume/template") - private String checksum; - - @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "an optional accountName. Must be used with domainId.") - private String accountName; - - @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, entityType = DomainResponse.class, description = "an optional domainId. If the account parameter is used, " - + "domainId must also be used.") - private Long domainId; - - @Parameter(name = ApiConstants.PROJECT_ID, type = CommandType.UUID, entityType = ProjectResponse.class, description = "Upload volume/template for the project") - private Long projectId; - - public String getName() { - return name; - } - - public String getFormat() { - return format; - } - - public Long getZoneId() { - return zoneId; - } - - public String getChecksum() { - return checksum; - } - - public String getAccountName() { - return accountName; - } - - public Long getDomainId() { - return domainId; - } - - public Long getProjectId() { - return projectId; - } - - public GetUploadParamsResponse createGetUploadParamsResponse(UUID id, URL postURL, String metadata, String timeout, String signature) { - return new GetUploadParamsResponse(id, postURL, metadata, timeout, signature); - } -} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f70a2a14/api/src/org/apache/cloudstack/api/command/user/template/GetUploadParamsForTemplate.java ---------------------------------------------------------------------- diff --git a/api/src/org/apache/cloudstack/api/command/user/template/GetUploadParamsForTemplate.java b/api/src/org/apache/cloudstack/api/command/user/template/GetUploadParamsForTemplate.java deleted file mode 100644 index bb3b958..0000000 --- a/api/src/org/apache/cloudstack/api/command/user/template/GetUploadParamsForTemplate.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * 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.user.template; - -import java.net.MalformedURLException; -import java.util.Collection; -import java.util.Map; - -import com.cloud.exception.ResourceAllocationException; -import org.apache.cloudstack.api.APICommand; -import org.apache.cloudstack.api.AbstractGetUploadParamsCommand; -import org.apache.cloudstack.api.ApiConstants; -import org.apache.cloudstack.api.ApiErrorCode; -import org.apache.cloudstack.api.Parameter; -import org.apache.cloudstack.api.ServerApiException; -import org.apache.cloudstack.api.response.GetUploadParamsResponse; -import org.apache.cloudstack.api.response.GuestOSResponse; -import org.apache.cloudstack.context.CallContext; -import org.apache.log4j.Logger; - -@APICommand(name = "getUploadParamsForTemplate", description = "upload an existing template into the CloudStack cloud. ", responseObject = GetUploadParamsResponse.class, since = - "4.6.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) -public class GetUploadParamsForTemplate extends AbstractGetUploadParamsCommand { - public static final Logger s_logger = Logger.getLogger(GetUploadParamsForTemplate.class.getName()); - - private static final String s_name = "postuploadtemplateresponse"; - - @Parameter(name = ApiConstants.DISPLAY_TEXT, type = CommandType.STRING, required = true, description = "the display text of the template. This is usually used for display purposes.", length = 4096) - private String displayText; - - @Parameter(name = ApiConstants.HYPERVISOR, type = CommandType.STRING, required = true, description = "the target hypervisor for the template") - private String hypervisor; - - @Parameter(name = ApiConstants.OS_TYPE_ID, type = CommandType.UUID, entityType = GuestOSResponse.class, required = true, description = "the ID of the OS Type that best represents the OS of this template.") - private Long osTypeId; - - @Parameter(name = ApiConstants.BITS, type = CommandType.INTEGER, description = "32 or 64 bits support. 64 by default") - private Integer bits; - - @Parameter(name = ApiConstants.DETAILS, type = CommandType.MAP, description = "Template details in key/value pairs.") - private Map details; - - @Parameter(name = ApiConstants.IS_DYNAMICALLY_SCALABLE, type = CommandType.BOOLEAN, description = "true if template contains XS/VMWare tools inorder to support dynamic scaling of VM cpu/memory") - private Boolean isDynamicallyScalable; - - @Parameter(name = ApiConstants.IS_EXTRACTABLE, type = CommandType.BOOLEAN, description = "true if the template or its derivatives are extractable; default is false") - private Boolean extractable; - - @Parameter(name = ApiConstants.IS_FEATURED, type = CommandType.BOOLEAN, description = "true if this template is a featured template, false otherwise") - private Boolean featured; - - @Parameter(name = ApiConstants.IS_PUBLIC, type = CommandType.BOOLEAN, description = "true if the template is available to all accounts; default is true") - private Boolean publicTemplate; - - @Parameter(name = ApiConstants.ROUTING, type = CommandType.BOOLEAN, description = "true if the template type is routing i.e., if template is used to deploy router") - private Boolean isRoutingType; - - @Parameter(name = ApiConstants.PASSWORD_ENABLED, type = CommandType.BOOLEAN, description = "true if the template supports the password reset feature; default is false") - private Boolean passwordEnabled; - - @Parameter(name = ApiConstants.REQUIRES_HVM, type = CommandType.BOOLEAN, description = "true if this template requires HVM") - private Boolean requiresHvm; - - @Parameter(name = ApiConstants.SSHKEY_ENABLED, type = CommandType.BOOLEAN, description = "true if the template supports the sshkey upload feature; default is false") - private Boolean sshKeyEnabled; - - @Parameter(name = ApiConstants.TEMPLATE_TAG, type = CommandType.STRING, description = "the tag for this template.") - private String templateTag; - - public String getDisplayText() { - return displayText; - } - - public String getHypervisor() { - return hypervisor; - } - - public Long getOsTypeId() { - return osTypeId; - } - - public Integer getBits() { - return bits; - } - - public Map getDetails() { - if (details == null || details.isEmpty()) { - return null; - } - Collection paramsCollection = details.values(); - Map params = (Map)(paramsCollection.toArray())[0]; - return params; - } - - public Boolean isDynamicallyScalable() { - return isDynamicallyScalable; - } - - public Boolean isExtractable() { - return extractable; - } - - public Boolean isFeatured() { - return featured; - } - - public Boolean isPublic() { - return publicTemplate; - } - - public Boolean isRoutingType() { - return isRoutingType; - } - - public Boolean isPasswordEnabled() { - return passwordEnabled; - } - - public Boolean getRequiresHvm() { - return requiresHvm; - } - - public Boolean isSshKeyEnabled() { - return sshKeyEnabled; - } - - public String getTemplateTag() { - return templateTag; - } - - @Override - public void execute() throws ServerApiException { - try { - GetUploadParamsResponse response = _templateService.registerTemplateForPostUpload(this); - response.setResponseName(getCommandName()); - setResponseObject(response); - } catch (ResourceAllocationException | MalformedURLException e) { - s_logger.error("exception while registering template", e); - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "exception while registering template: " + e.getMessage()); - } - } - - @Override - public String getCommandName() { - return s_name; - } - - @Override - public long getEntityOwnerId() { - Long accountId = _accountService.finalyzeAccountId(getAccountName(), getDomainId(), getProjectId(), true); - if (accountId == null) { - return CallContext.current().getCallingAccount().getId(); - } - return accountId; - } -} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f70a2a14/api/src/org/apache/cloudstack/api/command/user/template/GetUploadParamsForTemplateCmd.java ---------------------------------------------------------------------- diff --git a/api/src/org/apache/cloudstack/api/command/user/template/GetUploadParamsForTemplateCmd.java b/api/src/org/apache/cloudstack/api/command/user/template/GetUploadParamsForTemplateCmd.java new file mode 100644 index 0000000..79f920f --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/user/template/GetUploadParamsForTemplateCmd.java @@ -0,0 +1,172 @@ +/* + * 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.user.template; + +import java.net.MalformedURLException; +import java.util.Collection; +import java.util.Map; + +import com.cloud.exception.ResourceAllocationException; +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.AbstractGetUploadParamsCmd; +import org.apache.cloudstack.api.ApiConstants; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.response.GetUploadParamsResponse; +import org.apache.cloudstack.api.response.GuestOSResponse; +import org.apache.cloudstack.context.CallContext; +import org.apache.log4j.Logger; + +@APICommand(name = "getUploadParamsForTemplate", description = "upload an existing template into the CloudStack cloud. ", responseObject = GetUploadParamsResponse.class, since = + "4.6.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class GetUploadParamsForTemplateCmd extends AbstractGetUploadParamsCmd { + public static final Logger s_logger = Logger.getLogger(GetUploadParamsForTemplateCmd.class.getName()); + + private static final String s_name = "postuploadtemplateresponse"; + + @Parameter(name = ApiConstants.DISPLAY_TEXT, type = CommandType.STRING, required = true, description = "the display text of the template. This is usually used for display purposes.", length = 4096) + private String displayText; + + @Parameter(name = ApiConstants.HYPERVISOR, type = CommandType.STRING, required = true, description = "the target hypervisor for the template") + private String hypervisor; + + @Parameter(name = ApiConstants.OS_TYPE_ID, type = CommandType.UUID, entityType = GuestOSResponse.class, required = true, description = "the ID of the OS Type that best represents the OS of this template.") + private Long osTypeId; + + @Parameter(name = ApiConstants.BITS, type = CommandType.INTEGER, description = "32 or 64 bits support. 64 by default") + private Integer bits; + + @Parameter(name = ApiConstants.DETAILS, type = CommandType.MAP, description = "Template details in key/value pairs.") + private Map details; + + @Parameter(name = ApiConstants.IS_DYNAMICALLY_SCALABLE, type = CommandType.BOOLEAN, description = "true if template contains XS/VMWare tools inorder to support dynamic scaling of VM cpu/memory") + private Boolean isDynamicallyScalable; + + @Parameter(name = ApiConstants.IS_EXTRACTABLE, type = CommandType.BOOLEAN, description = "true if the template or its derivatives are extractable; default is false") + private Boolean extractable; + + @Parameter(name = ApiConstants.IS_FEATURED, type = CommandType.BOOLEAN, description = "true if this template is a featured template, false otherwise") + private Boolean featured; + + @Parameter(name = ApiConstants.IS_PUBLIC, type = CommandType.BOOLEAN, description = "true if the template is available to all accounts; default is true") + private Boolean publicTemplate; + + @Parameter(name = ApiConstants.ROUTING, type = CommandType.BOOLEAN, description = "true if the template type is routing i.e., if template is used to deploy router") + private Boolean isRoutingType; + + @Parameter(name = ApiConstants.PASSWORD_ENABLED, type = CommandType.BOOLEAN, description = "true if the template supports the password reset feature; default is false") + private Boolean passwordEnabled; + + @Parameter(name = ApiConstants.REQUIRES_HVM, type = CommandType.BOOLEAN, description = "true if this template requires HVM") + private Boolean requiresHvm; + + @Parameter(name = ApiConstants.SSHKEY_ENABLED, type = CommandType.BOOLEAN, description = "true if the template supports the sshkey upload feature; default is false") + private Boolean sshKeyEnabled; + + @Parameter(name = ApiConstants.TEMPLATE_TAG, type = CommandType.STRING, description = "the tag for this template.") + private String templateTag; + + public String getDisplayText() { + return displayText; + } + + public String getHypervisor() { + return hypervisor; + } + + public Long getOsTypeId() { + return osTypeId; + } + + public Integer getBits() { + return bits; + } + + public Map getDetails() { + if (details == null || details.isEmpty()) { + return null; + } + Collection paramsCollection = details.values(); + Map params = (Map)(paramsCollection.toArray())[0]; + return params; + } + + public Boolean isDynamicallyScalable() { + return isDynamicallyScalable; + } + + public Boolean isExtractable() { + return extractable; + } + + public Boolean isFeatured() { + return featured; + } + + public Boolean isPublic() { + return publicTemplate; + } + + public Boolean isRoutingType() { + return isRoutingType; + } + + public Boolean isPasswordEnabled() { + return passwordEnabled; + } + + public Boolean getRequiresHvm() { + return requiresHvm; + } + + public Boolean isSshKeyEnabled() { + return sshKeyEnabled; + } + + public String getTemplateTag() { + return templateTag; + } + + @Override + public void execute() throws ServerApiException { + try { + GetUploadParamsResponse response = _templateService.registerTemplateForPostUpload(this); + response.setResponseName(getCommandName()); + setResponseObject(response); + } catch (ResourceAllocationException | MalformedURLException e) { + s_logger.error("exception while registering template", e); + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "exception while registering template: " + e.getMessage()); + } + } + + @Override + public String getCommandName() { + return s_name; + } + + @Override + public long getEntityOwnerId() { + Long accountId = _accountService.finalyzeAccountId(getAccountName(), getDomainId(), getProjectId(), true); + if (accountId == null) { + return CallContext.current().getCallingAccount().getId(); + } + return accountId; + } +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f70a2a14/api/src/org/apache/cloudstack/api/command/user/volume/GetUploadParamsForVolume.java ---------------------------------------------------------------------- diff --git a/api/src/org/apache/cloudstack/api/command/user/volume/GetUploadParamsForVolume.java b/api/src/org/apache/cloudstack/api/command/user/volume/GetUploadParamsForVolume.java deleted file mode 100644 index 062c008..0000000 --- a/api/src/org/apache/cloudstack/api/command/user/volume/GetUploadParamsForVolume.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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.user.volume; - -import java.net.MalformedURLException; -import java.net.URL; -import java.util.UUID; - -import org.apache.cloudstack.api.APICommand; -import org.apache.cloudstack.api.AbstractGetUploadParamsCommand; -import org.apache.cloudstack.api.ApiConstants; -import org.apache.cloudstack.api.ApiErrorCode; -import org.apache.cloudstack.api.Parameter; -import org.apache.cloudstack.api.ServerApiException; -import org.apache.cloudstack.api.response.DiskOfferingResponse; -import org.apache.cloudstack.api.response.GetUploadParamsResponse; -import org.apache.cloudstack.context.CallContext; -import org.apache.log4j.Logger; - -@APICommand(name = "getUploadParamsForVolume", description = "Upload a data disk to the cloudstack cloud.", responseObject = GetUploadParamsResponse.class, since = "4.6.0", - requestHasSensitiveInfo= false, responseHasSensitiveInfo = false) -public class GetUploadParamsForVolume extends AbstractGetUploadParamsCommand { - public static final Logger s_logger = Logger.getLogger(GetUploadParamsForVolume.class.getName()); - - private static final String s_name = "postuploadvolumeresponse"; - - @Parameter(name = ApiConstants.IMAGE_STORE_UUID, type = CommandType.STRING, description = "Image store uuid") - private String imageStoreUuid; - - @Parameter(name = ApiConstants.DISK_OFFERING_ID, required = false, type = CommandType.UUID, entityType = DiskOfferingResponse.class, description = "the ID of the disk " - + "offering. This must be a custom sized offering since during upload of volume/template size is unknown.") - private Long diskOfferingId; - - public String getImageStoreUuid() { - return imageStoreUuid; - } - - public Long getDiskOfferingId() { - return diskOfferingId; - } - - @Override - public void execute() throws ServerApiException { - // TODO Auto-generated method stub - try { - GetUploadParamsResponse response = createGetUploadParamsResponse( - UUID.fromString("C7D351D2-F167-4CC8-A9FF-3BECB0A625C4"), - new URL("https://1-2-3-4.xyz.com/upload/C7D351D2-F167-4CC8-A9FF-3BECB0A625C4"), - "TKPFeuz2nHmE/kcREEu24mnj1MrLdzOeJIHXR9HLIGgk56bkRJHaD0RRL2lds1rKKhrro4/PuleEh4YhRinhxaAmPpU4e55eprG8gTCX0ItyFAtlZViVdKXMew5Dfp4Qg8W9I1/IsDJd2Kas9/ftDQLiemAlPt0uS7Ou6asOCpifnBaKvhM4UGEjHSnni1KhBzjgEyDW3Y42HKJSSv58Sgmxl9LCewBX8vtn9tXKr+j4afj7Jlh7DFhyo9HOPC5ogR4hPBKqP7xF9tHxAyq6YqfBzsng3Xwe+Pb8TU1kFHg1l2DM4tY6ooW2h8lOhWUkrJu4hOAOeTeRtCjW3H452NKoeA1M8pKWuqMo5zRMti2u2hNZs0YY2yOy8oWMMG+lG0hvIlajqEU=", - "2014-10-17T12:00:00+0530", "de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9"); - response.setResponseName(getCommandName()); - setResponseObject(response); - - } catch (MalformedURLException e) { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "malformedurl exception: " + e.getMessage()); - } - } - - @Override - public String getCommandName() { - return s_name; - } - - @Override - public long getEntityOwnerId() { - Long accountId = _accountService.finalyzeAccountId(getAccountName(), getDomainId(), getProjectId(), true); - if (accountId == null) { - return CallContext.current().getCallingAccount().getId(); - } - return accountId; - } -} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f70a2a14/api/src/org/apache/cloudstack/api/command/user/volume/GetUploadParamsForVolumeCmd.java ---------------------------------------------------------------------- diff --git a/api/src/org/apache/cloudstack/api/command/user/volume/GetUploadParamsForVolumeCmd.java b/api/src/org/apache/cloudstack/api/command/user/volume/GetUploadParamsForVolumeCmd.java new file mode 100644 index 0000000..d6f5c7d --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/user/volume/GetUploadParamsForVolumeCmd.java @@ -0,0 +1,88 @@ +/* + * 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.user.volume; + +import java.net.MalformedURLException; +import java.net.URL; +import java.util.UUID; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.AbstractGetUploadParamsCmd; +import org.apache.cloudstack.api.ApiConstants; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.response.DiskOfferingResponse; +import org.apache.cloudstack.api.response.GetUploadParamsResponse; +import org.apache.cloudstack.context.CallContext; +import org.apache.log4j.Logger; + +@APICommand(name = "getUploadParamsForVolume", description = "Upload a data disk to the cloudstack cloud.", responseObject = GetUploadParamsResponse.class, since = "4.6.0", + requestHasSensitiveInfo= false, responseHasSensitiveInfo = false) +public class GetUploadParamsForVolumeCmd extends AbstractGetUploadParamsCmd { + public static final Logger s_logger = Logger.getLogger(GetUploadParamsForVolumeCmd.class.getName()); + + private static final String s_name = "postuploadvolumeresponse"; + + @Parameter(name = ApiConstants.IMAGE_STORE_UUID, type = CommandType.STRING, description = "Image store uuid") + private String imageStoreUuid; + + @Parameter(name = ApiConstants.DISK_OFFERING_ID, required = false, type = CommandType.UUID, entityType = DiskOfferingResponse.class, description = "the ID of the disk " + + "offering. This must be a custom sized offering since during upload of volume/template size is unknown.") + private Long diskOfferingId; + + public String getImageStoreUuid() { + return imageStoreUuid; + } + + public Long getDiskOfferingId() { + return diskOfferingId; + } + + @Override + public void execute() throws ServerApiException { + // TODO Auto-generated method stub + try { + GetUploadParamsResponse response = createGetUploadParamsResponse( + UUID.fromString("C7D351D2-F167-4CC8-A9FF-3BECB0A625C4"), + new URL("https://1-2-3-4.xyz.com/upload/C7D351D2-F167-4CC8-A9FF-3BECB0A625C4"), + "TKPFeuz2nHmE/kcREEu24mnj1MrLdzOeJIHXR9HLIGgk56bkRJHaD0RRL2lds1rKKhrro4/PuleEh4YhRinhxaAmPpU4e55eprG8gTCX0ItyFAtlZViVdKXMew5Dfp4Qg8W9I1/IsDJd2Kas9/ftDQLiemAlPt0uS7Ou6asOCpifnBaKvhM4UGEjHSnni1KhBzjgEyDW3Y42HKJSSv58Sgmxl9LCewBX8vtn9tXKr+j4afj7Jlh7DFhyo9HOPC5ogR4hPBKqP7xF9tHxAyq6YqfBzsng3Xwe+Pb8TU1kFHg1l2DM4tY6ooW2h8lOhWUkrJu4hOAOeTeRtCjW3H452NKoeA1M8pKWuqMo5zRMti2u2hNZs0YY2yOy8oWMMG+lG0hvIlajqEU=", + "2014-10-17T12:00:00+0530", "de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9"); + response.setResponseName(getCommandName()); + setResponseObject(response); + + } catch (MalformedURLException e) { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "malformedurl exception: " + e.getMessage()); + } + } + + @Override + public String getCommandName() { + return s_name; + } + + @Override + public long getEntityOwnerId() { + Long accountId = _accountService.finalyzeAccountId(getAccountName(), getDomainId(), getProjectId(), true); + if (accountId == null) { + return CallContext.current().getCallingAccount().getId(); + } + return accountId; + } +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f70a2a14/server/src/com/cloud/server/ManagementServerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index 4bbee0f..66fa52a 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -38,8 +38,8 @@ import javax.inject.Inject; import javax.naming.ConfigurationException; import org.apache.cloudstack.api.command.user.snapshot.UpdateSnapshotPolicyCmd; -import org.apache.cloudstack.api.command.user.template.GetUploadParamsForTemplate; -import org.apache.cloudstack.api.command.user.volume.GetUploadParamsForVolume; +import org.apache.cloudstack.api.command.user.template.GetUploadParamsForTemplateCmd; +import org.apache.cloudstack.api.command.user.volume.GetUploadParamsForVolumeCmd; import org.apache.commons.codec.binary.Base64; import org.apache.log4j.Logger; import org.apache.cloudstack.acl.ControlledEntity; @@ -2996,8 +2996,8 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe cmdList.add(UpdateVPCCmdByAdmin.class); cmdList.add(UpdateLBStickinessPolicyCmd.class); cmdList.add(UpdateLBHealthCheckPolicyCmd.class); - cmdList.add(GetUploadParamsForTemplate.class); - cmdList.add(GetUploadParamsForVolume.class); + cmdList.add(GetUploadParamsForTemplateCmd.class); + cmdList.add(GetUploadParamsForVolumeCmd.class); return cmdList; } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f70a2a14/server/src/com/cloud/template/HypervisorTemplateAdapter.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/template/HypervisorTemplateAdapter.java b/server/src/com/cloud/template/HypervisorTemplateAdapter.java index 8a90915..eecd84b 100755 --- a/server/src/com/cloud/template/HypervisorTemplateAdapter.java +++ b/server/src/com/cloud/template/HypervisorTemplateAdapter.java @@ -26,7 +26,7 @@ import java.util.concurrent.ExecutionException; import javax.ejb.Local; import javax.inject.Inject; -import org.apache.cloudstack.api.command.user.template.GetUploadParamsForTemplate; +import org.apache.cloudstack.api.command.user.template.GetUploadParamsForTemplateCmd; import org.apache.cloudstack.engine.subsystem.api.storage.DataObject; import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint; import org.apache.cloudstack.storage.command.TemplateOrVolumePostUploadCommand; @@ -137,7 +137,7 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase { } @Override - public TemplateProfile prepare(GetUploadParamsForTemplate cmd) throws ResourceAllocationException { + public TemplateProfile prepare(GetUploadParamsForTemplateCmd cmd) throws ResourceAllocationException { TemplateProfile profile = super.prepare(cmd); // Check that the resource limit for secondary storage won't be exceeded http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f70a2a14/server/src/com/cloud/template/TemplateAdapter.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/template/TemplateAdapter.java b/server/src/com/cloud/template/TemplateAdapter.java index fb1e841..4ed0a81 100755 --- a/server/src/com/cloud/template/TemplateAdapter.java +++ b/server/src/com/cloud/template/TemplateAdapter.java @@ -23,7 +23,7 @@ import org.apache.cloudstack.api.command.user.iso.DeleteIsoCmd; import org.apache.cloudstack.api.command.user.iso.RegisterIsoCmd; import org.apache.cloudstack.api.command.user.template.DeleteTemplateCmd; import org.apache.cloudstack.api.command.user.template.ExtractTemplateCmd; -import org.apache.cloudstack.api.command.user.template.GetUploadParamsForTemplate; +import org.apache.cloudstack.api.command.user.template.GetUploadParamsForTemplateCmd; import org.apache.cloudstack.api.command.user.template.RegisterTemplateCmd; import com.cloud.exception.ResourceAllocationException; @@ -53,7 +53,7 @@ public interface TemplateAdapter extends Adapter { public TemplateProfile prepare(RegisterTemplateCmd cmd) throws ResourceAllocationException; - public TemplateProfile prepare(GetUploadParamsForTemplate cmd) throws ResourceAllocationException; + public TemplateProfile prepare(GetUploadParamsForTemplateCmd cmd) throws ResourceAllocationException; public TemplateProfile prepare(RegisterIsoCmd cmd) throws ResourceAllocationException; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f70a2a14/server/src/com/cloud/template/TemplateAdapterBase.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/template/TemplateAdapterBase.java b/server/src/com/cloud/template/TemplateAdapterBase.java index a313bdd..960f193 100755 --- a/server/src/com/cloud/template/TemplateAdapterBase.java +++ b/server/src/com/cloud/template/TemplateAdapterBase.java @@ -22,7 +22,7 @@ import java.util.Map; import javax.inject.Inject; -import org.apache.cloudstack.api.command.user.template.GetUploadParamsForTemplate; +import org.apache.cloudstack.api.command.user.template.GetUploadParamsForTemplateCmd; import org.apache.log4j.Logger; import org.apache.cloudstack.api.ApiConstants; @@ -275,7 +275,7 @@ public abstract class TemplateAdapterBase extends AdapterBase implements Templat } @Override - public TemplateProfile prepare(GetUploadParamsForTemplate cmd) throws ResourceAllocationException { + public TemplateProfile prepare(GetUploadParamsForTemplateCmd cmd) throws ResourceAllocationException { //check if the caller can operate with the template owner Account caller = CallContext.current().getCallingAccount(); Account owner = _accountMgr.getAccount(cmd.getEntityOwnerId()); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f70a2a14/server/src/com/cloud/template/TemplateManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/template/TemplateManagerImpl.java b/server/src/com/cloud/template/TemplateManagerImpl.java index 18fe28b..2185986 100755 --- a/server/src/com/cloud/template/TemplateManagerImpl.java +++ b/server/src/com/cloud/template/TemplateManagerImpl.java @@ -38,7 +38,7 @@ import javax.inject.Inject; import javax.naming.ConfigurationException; import com.google.gson.Gson; -import org.apache.cloudstack.api.command.user.template.GetUploadParamsForTemplate; +import org.apache.cloudstack.api.command.user.template.GetUploadParamsForTemplateCmd; import org.apache.cloudstack.api.response.GetUploadParamsResponse; import org.apache.cloudstack.storage.command.TemplateOrVolumePostUploadCommand; import org.apache.commons.codec.binary.Base64; @@ -336,7 +336,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager, @Override @ActionEvent(eventType = EventTypes.EVENT_TEMPLATE_CREATE, eventDescription = "creating post upload template") - public GetUploadParamsResponse registerTemplateForPostUpload(GetUploadParamsForTemplate cmd) throws ResourceAllocationException, MalformedURLException { + public GetUploadParamsResponse registerTemplateForPostUpload(GetUploadParamsForTemplateCmd cmd) throws ResourceAllocationException, MalformedURLException { TemplateAdapter adapter = getAdapter(HypervisorType.getType(cmd.getHypervisor())); TemplateProfile profile = adapter.prepare(cmd); List<TemplateOrVolumePostUploadCommand> payload = adapter.createTemplateForPostUpload(profile);