api_refactor: move template api preparetemplate to admin pkg Signed-off-by: Rohit Yadav <[email protected]>
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/55f2bd81 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/55f2bd81 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/55f2bd81 Branch: refs/heads/api_refactoring Commit: 55f2bd810a17633b262b2d679553ce201f128139 Parents: ceddaf1 Author: Rohit Yadav <[email protected]> Authored: Wed Dec 5 15:15:26 2012 -0800 Committer: Rohit Yadav <[email protected]> Committed: Wed Dec 5 15:15:26 2012 -0800 ---------------------------------------------------------------------- .../com/cloud/api/commands/PrepareTemplateCmd.java | 89 --------------- .../admin/template/command/PrepareTemplateCmd.java | 89 +++++++++++++++ client/tomcatconf/commands.properties.in | 2 +- 3 files changed, 90 insertions(+), 90 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/55f2bd81/api/src/com/cloud/api/commands/PrepareTemplateCmd.java ---------------------------------------------------------------------- diff --git a/api/src/com/cloud/api/commands/PrepareTemplateCmd.java b/api/src/com/cloud/api/commands/PrepareTemplateCmd.java deleted file mode 100644 index 97686a8..0000000 --- a/api/src/com/cloud/api/commands/PrepareTemplateCmd.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 com.cloud.api.commands; - -import java.util.List; - -import org.apache.log4j.Logger; - -import org.apache.cloudstack.api.ApiConstants; -import org.apache.cloudstack.api.BaseCmd; -import org.apache.cloudstack.api.IdentityMapper; -import org.apache.cloudstack.api.Implementation; -import org.apache.cloudstack.api.Parameter; -import com.cloud.api.response.ListResponse; -import com.cloud.api.response.TemplateResponse; -import com.cloud.template.VirtualMachineTemplate; -import com.cloud.user.Account; - -@Implementation(responseObject=TemplateResponse.class, description="load template into primary storage") -public class PrepareTemplateCmd extends BaseCmd { - public static final Logger s_logger = Logger.getLogger(PrepareTemplateCmd.class.getName()); - - private static final String s_name = "preparetemplateresponse"; - - ///////////////////////////////////////////////////// - //////////////// API parameters ///////////////////// - ///////////////////////////////////////////////////// - - @IdentityMapper(entityTableName="data_center") - @Parameter(name=ApiConstants.ZONE_ID, required=true, type=CommandType.LONG, description="zone ID of the template to be prepared in primary storage(s).") - private Long zoneId; - - @IdentityMapper(entityTableName="vm_template") - @Parameter(name=ApiConstants.TEMPLATE_ID, required=true, type=CommandType.LONG, description="template ID of the template to be prepared in primary storage(s).") - private Long templateId; - - - ///////////////////////////////////////////////////// - /////////////////// Accessors /////////////////////// - ///////////////////////////////////////////////////// - - public Long getZoneId() { - return zoneId; - } - - public Long getTemplateId() { - return templateId; - } - - ///////////////////////////////////////////////////// - /////////////// API Implementation/////////////////// - ///////////////////////////////////////////////////// - - @Override - public String getCommandName() { - return s_name; - } - - @Override - public long getEntityOwnerId() { - return Account.ACCOUNT_ID_SYSTEM; - } - - @Override - public void execute() { - ListResponse<TemplateResponse> response = new ListResponse<TemplateResponse>(); - - VirtualMachineTemplate vmTemplate = _templateService.prepareTemplate(templateId, zoneId); - List<TemplateResponse> templateResponses = _responseGenerator.createTemplateResponses(vmTemplate.getId(), zoneId, true); - response.setResponses(templateResponses); - response.setResponseName(getCommandName()); - this.setResponseObject(response); - } -} - http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/55f2bd81/api/src/org/apache/cloudstack/api/admin/template/command/PrepareTemplateCmd.java ---------------------------------------------------------------------- diff --git a/api/src/org/apache/cloudstack/api/admin/template/command/PrepareTemplateCmd.java b/api/src/org/apache/cloudstack/api/admin/template/command/PrepareTemplateCmd.java new file mode 100644 index 0000000..910169b --- /dev/null +++ b/api/src/org/apache/cloudstack/api/admin/template/command/PrepareTemplateCmd.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.admin.template.command; + +import java.util.List; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.api.ApiConstants; +import org.apache.cloudstack.api.BaseCmd; +import org.apache.cloudstack.api.IdentityMapper; +import org.apache.cloudstack.api.Implementation; +import org.apache.cloudstack.api.Parameter; +import com.cloud.api.response.ListResponse; +import com.cloud.api.response.TemplateResponse; +import com.cloud.template.VirtualMachineTemplate; +import com.cloud.user.Account; + +@Implementation(responseObject=TemplateResponse.class, description="load template into primary storage") +public class PrepareTemplateCmd extends BaseCmd { + public static final Logger s_logger = Logger.getLogger(PrepareTemplateCmd.class.getName()); + + private static final String s_name = "preparetemplateresponse"; + + ///////////////////////////////////////////////////// + //////////////// API parameters ///////////////////// + ///////////////////////////////////////////////////// + + @IdentityMapper(entityTableName="data_center") + @Parameter(name=ApiConstants.ZONE_ID, required=true, type=CommandType.LONG, description="zone ID of the template to be prepared in primary storage(s).") + private Long zoneId; + + @IdentityMapper(entityTableName="vm_template") + @Parameter(name=ApiConstants.TEMPLATE_ID, required=true, type=CommandType.LONG, description="template ID of the template to be prepared in primary storage(s).") + private Long templateId; + + + ///////////////////////////////////////////////////// + /////////////////// Accessors /////////////////////// + ///////////////////////////////////////////////////// + + public Long getZoneId() { + return zoneId; + } + + public Long getTemplateId() { + return templateId; + } + + ///////////////////////////////////////////////////// + /////////////// API Implementation/////////////////// + ///////////////////////////////////////////////////// + + @Override + public String getCommandName() { + return s_name; + } + + @Override + public long getEntityOwnerId() { + return Account.ACCOUNT_ID_SYSTEM; + } + + @Override + public void execute() { + ListResponse<TemplateResponse> response = new ListResponse<TemplateResponse>(); + + VirtualMachineTemplate vmTemplate = _templateService.prepareTemplate(templateId, zoneId); + List<TemplateResponse> templateResponses = _responseGenerator.createTemplateResponses(vmTemplate.getId(), zoneId, true); + response.setResponses(templateResponses); + response.setResponseName(getCommandName()); + this.setResponseObject(response); + } +} + http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/55f2bd81/client/tomcatconf/commands.properties.in ---------------------------------------------------------------------- diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in index 9868710..ca7321c 100755 --- a/client/tomcatconf/commands.properties.in +++ b/client/tomcatconf/commands.properties.in @@ -88,7 +88,7 @@ listTemplates=org.apache.cloudstack.api.user.template.command.ListTemplatesCmd;1 updateTemplatePermissions=org.apache.cloudstack.api.user.template.command.UpdateTemplatePermissionsCmd;15 listTemplatePermissions=org.apache.cloudstack.api.user.template.command.ListTemplatePermissionsCmd;15 extractTemplate=org.apache.cloudstack.api.user.template.command.ExtractTemplateCmd;15 -prepareTemplate=com.cloud.api.commands.PrepareTemplateCmd;1 +prepareTemplate=org.apache.cloudstack.api.admin.template.command.PrepareTemplateCmd;1 #### iso commands attachIso=org.apache.cloudstack.api.user.iso.command.AttachIsoCmd;15
