You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2012/12/04 11:02:55 UTC
[10/55] [abbrv] git commit: api_refactor: refactor register apis
api_refactor: refactor register apis
- Split register apis across template, iso and ssh pkgs
- Fix refactored apis, mappings in commands*.in
- Fix comments etc.
Signed-off-by: Rohit Yadav <bh...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/add1b9b0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/add1b9b0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/add1b9b0
Branch: refs/heads/api_refactoring
Commit: add1b9b05541564d24efaf5a0ddad5673edc7aa1
Parents: 316e7f2
Author: Rohit Yadav <bh...@apache.org>
Authored: Mon Dec 3 23:54:19 2012 -0800
Committer: Rohit Yadav <bh...@apache.org>
Committed: Mon Dec 3 23:54:19 2012 -0800
----------------------------------------------------------------------
api/src/com/cloud/api/commands/RegisterIsoCmd.java | 173 -----------
.../cloud/api/commands/RegisterSSHKeyPairCmd.java | 110 -------
.../cloud/api/commands/RegisterTemplateCmd.java | 240 ---------------
api/src/com/cloud/server/ManagementService.java | 2 +-
api/src/com/cloud/template/TemplateService.java | 4 +-
.../api/user/iso/command/RegisterIsoCmd.java | 173 +++++++++++
.../user/ssh/command/RegisterSSHKeyPairCmd.java | 110 +++++++
.../user/template/command/RegisterTemplateCmd.java | 240 +++++++++++++++
client/tomcatconf/commands.properties.in | 6 +-
.../cloud/baremetal/BareMetalTemplateAdapter.java | 4 +-
.../src/com/cloud/server/ManagementServerImpl.java | 2 +-
.../cloud/template/HyervisorTemplateAdapter.java | 4 +-
server/src/com/cloud/template/TemplateAdapter.java | 4 +-
.../com/cloud/template/TemplateAdapterBase.java | 4 +-
.../com/cloud/template/TemplateManagerImpl.java | 10 +-
15 files changed, 541 insertions(+), 545 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/add1b9b0/api/src/com/cloud/api/commands/RegisterIsoCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/RegisterIsoCmd.java b/api/src/com/cloud/api/commands/RegisterIsoCmd.java
deleted file mode 100755
index ff7aa33..0000000
--- a/api/src/com/cloud/api/commands/RegisterIsoCmd.java
+++ /dev/null
@@ -1,173 +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 org.apache.cloudstack.api.ServerApiException;
-import com.cloud.api.response.ListResponse;
-import com.cloud.api.response.TemplateResponse;
-import com.cloud.exception.ResourceAllocationException;
-import com.cloud.template.VirtualMachineTemplate;
-import com.cloud.user.UserContext;
-
-@Implementation(responseObject=TemplateResponse.class, description="Registers an existing ISO into the CloudStack Cloud.")
-public class RegisterIsoCmd extends BaseCmd {
- public static final Logger s_logger = Logger.getLogger(RegisterIsoCmd.class.getName());
-
- private static final String s_name = "registerisoresponse";
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @Parameter(name=ApiConstants.BOOTABLE, type=CommandType.BOOLEAN, description="true if this ISO is bootable. If not passed explicitly its assumed to be true")
- private Boolean bootable;
-
- @Parameter(name=ApiConstants.DISPLAY_TEXT, type=CommandType.STRING, required=true, description="the display text of the ISO. This is usually used for display purposes.", length=4096)
- private String displayText;
-
- @Parameter(name=ApiConstants.IS_FEATURED, type=CommandType.BOOLEAN, description="true if you want this ISO to be featured")
- private Boolean featured;
-
- @Parameter(name=ApiConstants.IS_PUBLIC, type=CommandType.BOOLEAN, description="true if you want to register the ISO to be publicly available to all users, false otherwise.")
- private Boolean publicIso;
-
- @Parameter(name=ApiConstants.IS_EXTRACTABLE, type=CommandType.BOOLEAN, description="true if the iso or its derivatives are extractable; default is false")
- private Boolean extractable;
-
- @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="the name of the ISO")
- private String isoName;
-
- @IdentityMapper(entityTableName="guest_os")
- @Parameter(name=ApiConstants.OS_TYPE_ID, type=CommandType.LONG, description="the ID of the OS Type that best represents the OS of this ISO. If the iso is bootable this parameter needs to be passed")
- private Long osTypeId;
-
- @Parameter(name=ApiConstants.URL, type=CommandType.STRING, required=true, description="the URL to where the ISO is currently being hosted")
- private String url;
-
- @IdentityMapper(entityTableName="data_center")
- @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, required=true, description="the ID of the zone you wish to register the ISO to.")
- private Long zoneId;
-
- @IdentityMapper(entityTableName="domain")
- @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="an optional domainId. If the account parameter is used, domainId must also be used.")
- private Long domainId;
-
- @Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="an optional account name. Must be used with domainId.")
- private String accountName;
-
- @Parameter(name=ApiConstants.CHECKSUM, type=CommandType.STRING, description="the MD5 checksum value of this ISO")
- private String checksum;
-
- @IdentityMapper(entityTableName="projects")
- @Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="Register iso for the project")
- private Long projectId;
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public Boolean isBootable() {
- return bootable;
- }
-
- public String getDisplayText() {
- return displayText;
- }
-
- public Boolean isFeatured() {
- return featured;
- }
-
- public Boolean isPublic() {
- return publicIso;
- }
-
- public Boolean isExtractable() {
- return extractable;
- }
-
- public String getIsoName() {
- return isoName;
- }
-
- public Long getOsTypeId() {
- return osTypeId;
- }
-
- public String getUrl() {
- return url;
- }
-
- public Long getZoneId() {
- return zoneId;
- }
-
- public Long getDomainId() {
- return domainId;
- }
-
- public String getAccountName() {
- return accountName;
- }
-
- public String getChecksum() {
- return checksum;
- }
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- @Override
- public long getEntityOwnerId() {
- Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
- if (accountId == null) {
- return UserContext.current().getCaller().getId();
- }
-
- return accountId;
- }
-
- @Override
- public void execute() throws ResourceAllocationException{
- VirtualMachineTemplate template = _templateService.registerIso(this);
- if (template != null) {
- ListResponse<TemplateResponse> response = new ListResponse<TemplateResponse>();
- List<TemplateResponse> templateResponses = _responseGenerator.createIsoResponses(template.getId(), zoneId, false);
- response.setResponses(templateResponses);
- response.setResponseName(getCommandName());
- this.setResponseObject(response);
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to register iso");
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/add1b9b0/api/src/com/cloud/api/commands/RegisterSSHKeyPairCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/RegisterSSHKeyPairCmd.java b/api/src/com/cloud/api/commands/RegisterSSHKeyPairCmd.java
deleted file mode 100644
index ae62e34..0000000
--- a/api/src/com/cloud/api/commands/RegisterSSHKeyPairCmd.java
+++ /dev/null
@@ -1,110 +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 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.SSHKeyPairResponse;
-import com.cloud.user.SSHKeyPair;
-import com.cloud.user.UserContext;
-
-@Implementation(description="Register a public key in a keypair under a certain name", responseObject=SSHKeyPairResponse.class)
-public class RegisterSSHKeyPairCmd extends BaseCmd {
- public static final Logger s_logger = Logger.getLogger(RegisterSSHKeyPairCmd.class.getName());
- private static final String s_name = "registersshkeypairresponse";
-
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="Name of the keypair")
- private String name;
-
- @Parameter(name="publickey", type=CommandType.STRING, required=true, description="Public key material of the keypair", length=5120)
- private String publicKey;
-
- //Owner information
- @Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="an optional account for the ssh key. Must be used with domainId.")
- private String accountName;
-
- @IdentityMapper(entityTableName="domain")
- @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="an optional domainId for the ssh key. If the account parameter is used, domainId must also be used.")
- private Long domainId;
-
- @IdentityMapper(entityTableName="projects")
- @Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="an optional project for the ssh key")
- private Long projectId;
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public String getName() {
- return name;
- }
-
- public String getPublicKey() {
- return publicKey;
- }
-
- public String getAccountName() {
- return accountName;
- }
-
- public Long getDomainId() {
- return domainId;
- }
-
- public Long getProjectId() {
- return projectId;
- }
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
-
- @Override
- public long getEntityOwnerId() {
- Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
- if (accountId == null) {
- return UserContext.current().getCaller().getId();
- }
-
- return accountId;
- }
-
- @Override
- public void execute() {
- SSHKeyPair result = _mgr.registerSSHKeyPair(this);
- SSHKeyPairResponse response = new SSHKeyPairResponse(result.getName(), result.getFingerprint());
- response.setResponseName(getCommandName());
- response.setObjectName("keypair");
- this.setResponseObject(response);
- }
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/add1b9b0/api/src/com/cloud/api/commands/RegisterTemplateCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/RegisterTemplateCmd.java b/api/src/com/cloud/api/commands/RegisterTemplateCmd.java
deleted file mode 100755
index c479001..0000000
--- a/api/src/com/cloud/api/commands/RegisterTemplateCmd.java
+++ /dev/null
@@ -1,240 +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.net.URISyntaxException;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-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 org.apache.cloudstack.api.ServerApiException;
-import com.cloud.api.response.ListResponse;
-import com.cloud.api.response.TemplateResponse;
-import com.cloud.async.AsyncJob;
-import com.cloud.exception.ResourceAllocationException;
-import com.cloud.template.VirtualMachineTemplate;
-import com.cloud.user.UserContext;
-
-@Implementation(description="Registers an existing template into the CloudStack cloud. ", responseObject=TemplateResponse.class)
-public class RegisterTemplateCmd extends BaseCmd {
- public static final Logger s_logger = Logger.getLogger(RegisterTemplateCmd.class.getName());
-
- private static final String s_name = "registertemplateresponse";
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @Parameter(name=ApiConstants.BITS, type=CommandType.INTEGER, description="32 or 64 bits support. 64 by default")
- private Integer bits;
-
- @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.FORMAT, type=CommandType.STRING, required=true, description="the format for the template. Possible values include QCOW2, RAW, and VHD.")
- private String format;
-
- @Parameter(name=ApiConstants.HYPERVISOR, type=CommandType.STRING, required=true, description="the target hypervisor for the template")
- private String hypervisor;
-
- @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.NAME, type=CommandType.STRING, required=true, description="the name of the template")
- private String templateName;
-
- @Parameter(name=ApiConstants.OS_TYPE_ID, type=CommandType.LONG, required=true, description="the ID of the OS Type that best represents the OS of this template.")
- @IdentityMapper(entityTableName="guest_os")
- private Long osTypeId;
-
- @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.SSHKEY_ENABLED, type=CommandType.BOOLEAN, description="true if the template supports the sshkey upload feature; default is false")
- private Boolean sshKeyEnabled;
-
- @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.REQUIRES_HVM, type=CommandType.BOOLEAN, description="true if this template requires HVM")
- private Boolean requiresHvm;
-
- @Parameter(name=ApiConstants.URL, type=CommandType.STRING, required=true, description="the URL of where the template is hosted. Possible URL include http:// and https://")
- private String url;
-
- @IdentityMapper(entityTableName="data_center")
- @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, required=true, description="the ID of the zone the template is to be hosted on")
- private Long zoneId;
-
- @IdentityMapper(entityTableName="domain")
- @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="an optional domainId. If the account parameter is used, domainId must also be used.")
- private Long domainId;
-
- @Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="an optional accountName. Must be used with domainId.")
- private String accountName;
-
- @Parameter(name=ApiConstants.CHECKSUM, type=CommandType.STRING, description="the MD5 checksum value of this template")
- private String checksum;
-
- @Parameter(name=ApiConstants.TEMPLATE_TAG, type=CommandType.STRING, description="the tag for this template.")
- private String templateTag;
-
- @IdentityMapper(entityTableName="projects")
- @Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="Register template for the project")
- private Long projectId;
-
- @Parameter(name=ApiConstants.DETAILS, type=CommandType.MAP, description="Template details in key/value pairs.")
- protected Map details;
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public Integer getBits() {
- return bits;
- }
-
- public String getDisplayText() {
- return displayText;
- }
-
- public String getFormat() {
- return format;
- }
-
- public String getHypervisor() {
- return hypervisor;
- }
-
- public Boolean isFeatured() {
- return featured;
- }
-
- public Boolean isPublic() {
- return publicTemplate;
- }
-
- public String getTemplateName() {
- return templateName;
- }
-
- public Long getOsTypeId() {
- return osTypeId;
- }
-
- public Boolean isPasswordEnabled() {
- return passwordEnabled;
- }
-
- public Boolean isSshKeyEnabled() {
- return sshKeyEnabled;
- }
-
- public Boolean isExtractable() {
- return extractable;
- }
-
- public Boolean getRequiresHvm() {
- return requiresHvm;
- }
-
- public String getUrl() {
- return url;
- }
-
- public Long getZoneId() {
- return zoneId;
- }
-
- public Long getDomainId() {
- return domainId;
- }
-
- public String getAccountName() {
- return accountName;
- }
-
- public String getChecksum() {
- return checksum;
- }
-
- public String getTemplateTag() {
- return templateTag;
- }
-
- public Map getDetails() {
- if (details == null || details.isEmpty()) {
- return null;
- }
-
- Collection paramsCollection = details.values();
- Map params = (Map) (paramsCollection.toArray())[0];
- return params;
- }
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- public AsyncJob.Type getInstanceType() {
- return AsyncJob.Type.Template;
- }
-
- @Override
- public long getEntityOwnerId() {
- Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
- if (accountId == null) {
- return UserContext.current().getCaller().getId();
- }
-
- return accountId;
- }
-
- @Override
- public void execute() throws ResourceAllocationException{
- try {
- VirtualMachineTemplate template = _templateService.registerTemplate(this);
- if (template != null){
- ListResponse<TemplateResponse> response = new ListResponse<TemplateResponse>();
- List<TemplateResponse> templateResponses = _responseGenerator.createTemplateResponses(template.getId(), zoneId, false);
- response.setResponses(templateResponses);
- response.setResponseName(getCommandName());
- this.setResponseObject(response);
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to register template");
- }
- } catch (URISyntaxException ex1) {
- s_logger.info(ex1);
- throw new ServerApiException(BaseCmd.PARAM_ERROR, ex1.getMessage());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/add1b9b0/api/src/com/cloud/server/ManagementService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/server/ManagementService.java b/api/src/com/cloud/server/ManagementService.java
index 331b276..ccb1efa 100755
--- a/api/src/com/cloud/server/ManagementService.java
+++ b/api/src/com/cloud/server/ManagementService.java
@@ -54,7 +54,7 @@ import org.apache.cloudstack.api.user.vmgroup.command.ListVMGroupsCmd;
import com.cloud.api.commands.ListVlanIpRangesCmd;
import com.cloud.api.commands.ListZonesByCmd;
import com.cloud.api.commands.RebootSystemVmCmd;
-import com.cloud.api.commands.RegisterSSHKeyPairCmd;
+import org.apache.cloudstack.api.user.ssh.command.RegisterSSHKeyPairCmd;
import com.cloud.api.commands.StopSystemVmCmd;
import com.cloud.api.commands.UpdateDomainCmd;
import com.cloud.api.commands.UpdateHostPasswordCmd;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/add1b9b0/api/src/com/cloud/template/TemplateService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/template/TemplateService.java b/api/src/com/cloud/template/TemplateService.java
index 9d63b25..1b41c33 100755
--- a/api/src/com/cloud/template/TemplateService.java
+++ b/api/src/com/cloud/template/TemplateService.java
@@ -19,14 +19,14 @@ package com.cloud.template;
import java.net.URISyntaxException;
import java.util.List;
+import org.apache.cloudstack.api.user.iso.command.RegisterIsoCmd;
import org.apache.cloudstack.api.user.template.command.CopyTemplateCmd;
import org.apache.cloudstack.api.user.iso.command.DeleteIsoCmd;
import org.apache.cloudstack.api.user.template.command.DeleteTemplateCmd;
import org.apache.cloudstack.api.user.iso.command.ExtractIsoCmd;
import org.apache.cloudstack.api.user.template.command.ExtractTemplateCmd;
import com.cloud.api.commands.ListTemplateOrIsoPermissionsCmd;
-import com.cloud.api.commands.RegisterIsoCmd;
-import com.cloud.api.commands.RegisterTemplateCmd;
+import org.apache.cloudstack.api.user.template.command.RegisterTemplateCmd;
import com.cloud.api.commands.UpdateTemplateOrIsoPermissionsCmd;
import com.cloud.exception.InternalErrorException;
import com.cloud.exception.ResourceAllocationException;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/add1b9b0/api/src/org/apache/cloudstack/api/user/iso/command/RegisterIsoCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/user/iso/command/RegisterIsoCmd.java b/api/src/org/apache/cloudstack/api/user/iso/command/RegisterIsoCmd.java
new file mode 100755
index 0000000..cedaa86
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/user/iso/command/RegisterIsoCmd.java
@@ -0,0 +1,173 @@
+// 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.user.iso.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 org.apache.cloudstack.api.ServerApiException;
+import com.cloud.api.response.ListResponse;
+import com.cloud.api.response.TemplateResponse;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.template.VirtualMachineTemplate;
+import com.cloud.user.UserContext;
+
+@Implementation(responseObject=TemplateResponse.class, description="Registers an existing ISO into the CloudStack Cloud.")
+public class RegisterIsoCmd extends BaseCmd {
+ public static final Logger s_logger = Logger.getLogger(RegisterIsoCmd.class.getName());
+
+ private static final String s_name = "registerisoresponse";
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+
+ @Parameter(name=ApiConstants.BOOTABLE, type=CommandType.BOOLEAN, description="true if this ISO is bootable. If not passed explicitly its assumed to be true")
+ private Boolean bootable;
+
+ @Parameter(name=ApiConstants.DISPLAY_TEXT, type=CommandType.STRING, required=true, description="the display text of the ISO. This is usually used for display purposes.", length=4096)
+ private String displayText;
+
+ @Parameter(name=ApiConstants.IS_FEATURED, type=CommandType.BOOLEAN, description="true if you want this ISO to be featured")
+ private Boolean featured;
+
+ @Parameter(name=ApiConstants.IS_PUBLIC, type=CommandType.BOOLEAN, description="true if you want to register the ISO to be publicly available to all users, false otherwise.")
+ private Boolean publicIso;
+
+ @Parameter(name=ApiConstants.IS_EXTRACTABLE, type=CommandType.BOOLEAN, description="true if the iso or its derivatives are extractable; default is false")
+ private Boolean extractable;
+
+ @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="the name of the ISO")
+ private String isoName;
+
+ @IdentityMapper(entityTableName="guest_os")
+ @Parameter(name=ApiConstants.OS_TYPE_ID, type=CommandType.LONG, description="the ID of the OS Type that best represents the OS of this ISO. If the iso is bootable this parameter needs to be passed")
+ private Long osTypeId;
+
+ @Parameter(name=ApiConstants.URL, type=CommandType.STRING, required=true, description="the URL to where the ISO is currently being hosted")
+ private String url;
+
+ @IdentityMapper(entityTableName="data_center")
+ @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, required=true, description="the ID of the zone you wish to register the ISO to.")
+ private Long zoneId;
+
+ @IdentityMapper(entityTableName="domain")
+ @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="an optional domainId. If the account parameter is used, domainId must also be used.")
+ private Long domainId;
+
+ @Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="an optional account name. Must be used with domainId.")
+ private String accountName;
+
+ @Parameter(name=ApiConstants.CHECKSUM, type=CommandType.STRING, description="the MD5 checksum value of this ISO")
+ private String checksum;
+
+ @IdentityMapper(entityTableName="projects")
+ @Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="Register iso for the project")
+ private Long projectId;
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public Boolean isBootable() {
+ return bootable;
+ }
+
+ public String getDisplayText() {
+ return displayText;
+ }
+
+ public Boolean isFeatured() {
+ return featured;
+ }
+
+ public Boolean isPublic() {
+ return publicIso;
+ }
+
+ public Boolean isExtractable() {
+ return extractable;
+ }
+
+ public String getIsoName() {
+ return isoName;
+ }
+
+ public Long getOsTypeId() {
+ return osTypeId;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public Long getZoneId() {
+ return zoneId;
+ }
+
+ public Long getDomainId() {
+ return domainId;
+ }
+
+ public String getAccountName() {
+ return accountName;
+ }
+
+ public String getChecksum() {
+ return checksum;
+ }
+
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
+ if (accountId == null) {
+ return UserContext.current().getCaller().getId();
+ }
+
+ return accountId;
+ }
+
+ @Override
+ public void execute() throws ResourceAllocationException{
+ VirtualMachineTemplate template = _templateService.registerIso(this);
+ if (template != null) {
+ ListResponse<TemplateResponse> response = new ListResponse<TemplateResponse>();
+ List<TemplateResponse> templateResponses = _responseGenerator.createIsoResponses(template.getId(), zoneId, false);
+ response.setResponses(templateResponses);
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ } else {
+ throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to register iso");
+ }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/add1b9b0/api/src/org/apache/cloudstack/api/user/ssh/command/RegisterSSHKeyPairCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/user/ssh/command/RegisterSSHKeyPairCmd.java b/api/src/org/apache/cloudstack/api/user/ssh/command/RegisterSSHKeyPairCmd.java
new file mode 100644
index 0000000..9c4eb8cd
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/user/ssh/command/RegisterSSHKeyPairCmd.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.user.ssh.command;
+
+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.SSHKeyPairResponse;
+import com.cloud.user.SSHKeyPair;
+import com.cloud.user.UserContext;
+
+@Implementation(description="Register a public key in a keypair under a certain name", responseObject=SSHKeyPairResponse.class)
+public class RegisterSSHKeyPairCmd extends BaseCmd {
+ public static final Logger s_logger = Logger.getLogger(RegisterSSHKeyPairCmd.class.getName());
+ private static final String s_name = "registersshkeypairresponse";
+
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+
+ @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="Name of the keypair")
+ private String name;
+
+ @Parameter(name="publickey", type=CommandType.STRING, required=true, description="Public key material of the keypair", length=5120)
+ private String publicKey;
+
+ //Owner information
+ @Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="an optional account for the ssh key. Must be used with domainId.")
+ private String accountName;
+
+ @IdentityMapper(entityTableName="domain")
+ @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="an optional domainId for the ssh key. If the account parameter is used, domainId must also be used.")
+ private Long domainId;
+
+ @IdentityMapper(entityTableName="projects")
+ @Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="an optional project for the ssh key")
+ private Long projectId;
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public String getName() {
+ return name;
+ }
+
+ public String getPublicKey() {
+ return publicKey;
+ }
+
+ public String getAccountName() {
+ return accountName;
+ }
+
+ public Long getDomainId() {
+ return domainId;
+ }
+
+ public Long getProjectId() {
+ return projectId;
+ }
+
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+
+ @Override
+ public long getEntityOwnerId() {
+ Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
+ if (accountId == null) {
+ return UserContext.current().getCaller().getId();
+ }
+
+ return accountId;
+ }
+
+ @Override
+ public void execute() {
+ SSHKeyPair result = _mgr.registerSSHKeyPair(this);
+ SSHKeyPairResponse response = new SSHKeyPairResponse(result.getName(), result.getFingerprint());
+ response.setResponseName(getCommandName());
+ response.setObjectName("keypair");
+ this.setResponseObject(response);
+ }
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/add1b9b0/api/src/org/apache/cloudstack/api/user/template/command/RegisterTemplateCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/user/template/command/RegisterTemplateCmd.java b/api/src/org/apache/cloudstack/api/user/template/command/RegisterTemplateCmd.java
new file mode 100755
index 0000000..5ad284c
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/user/template/command/RegisterTemplateCmd.java
@@ -0,0 +1,240 @@
+// 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.user.template.command;
+
+import java.net.URISyntaxException;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+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 org.apache.cloudstack.api.ServerApiException;
+import com.cloud.api.response.ListResponse;
+import com.cloud.api.response.TemplateResponse;
+import com.cloud.async.AsyncJob;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.template.VirtualMachineTemplate;
+import com.cloud.user.UserContext;
+
+@Implementation(description="Registers an existing template into the CloudStack cloud. ", responseObject=TemplateResponse.class)
+public class RegisterTemplateCmd extends BaseCmd {
+ public static final Logger s_logger = Logger.getLogger(RegisterTemplateCmd.class.getName());
+
+ private static final String s_name = "registertemplateresponse";
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+
+ @Parameter(name=ApiConstants.BITS, type=CommandType.INTEGER, description="32 or 64 bits support. 64 by default")
+ private Integer bits;
+
+ @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.FORMAT, type=CommandType.STRING, required=true, description="the format for the template. Possible values include QCOW2, RAW, and VHD.")
+ private String format;
+
+ @Parameter(name=ApiConstants.HYPERVISOR, type=CommandType.STRING, required=true, description="the target hypervisor for the template")
+ private String hypervisor;
+
+ @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.NAME, type=CommandType.STRING, required=true, description="the name of the template")
+ private String templateName;
+
+ @Parameter(name=ApiConstants.OS_TYPE_ID, type=CommandType.LONG, required=true, description="the ID of the OS Type that best represents the OS of this template.")
+ @IdentityMapper(entityTableName="guest_os")
+ private Long osTypeId;
+
+ @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.SSHKEY_ENABLED, type=CommandType.BOOLEAN, description="true if the template supports the sshkey upload feature; default is false")
+ private Boolean sshKeyEnabled;
+
+ @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.REQUIRES_HVM, type=CommandType.BOOLEAN, description="true if this template requires HVM")
+ private Boolean requiresHvm;
+
+ @Parameter(name=ApiConstants.URL, type=CommandType.STRING, required=true, description="the URL of where the template is hosted. Possible URL include http:// and https://")
+ private String url;
+
+ @IdentityMapper(entityTableName="data_center")
+ @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, required=true, description="the ID of the zone the template is to be hosted on")
+ private Long zoneId;
+
+ @IdentityMapper(entityTableName="domain")
+ @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="an optional domainId. If the account parameter is used, domainId must also be used.")
+ private Long domainId;
+
+ @Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="an optional accountName. Must be used with domainId.")
+ private String accountName;
+
+ @Parameter(name=ApiConstants.CHECKSUM, type=CommandType.STRING, description="the MD5 checksum value of this template")
+ private String checksum;
+
+ @Parameter(name=ApiConstants.TEMPLATE_TAG, type=CommandType.STRING, description="the tag for this template.")
+ private String templateTag;
+
+ @IdentityMapper(entityTableName="projects")
+ @Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="Register template for the project")
+ private Long projectId;
+
+ @Parameter(name=ApiConstants.DETAILS, type=CommandType.MAP, description="Template details in key/value pairs.")
+ protected Map details;
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public Integer getBits() {
+ return bits;
+ }
+
+ public String getDisplayText() {
+ return displayText;
+ }
+
+ public String getFormat() {
+ return format;
+ }
+
+ public String getHypervisor() {
+ return hypervisor;
+ }
+
+ public Boolean isFeatured() {
+ return featured;
+ }
+
+ public Boolean isPublic() {
+ return publicTemplate;
+ }
+
+ public String getTemplateName() {
+ return templateName;
+ }
+
+ public Long getOsTypeId() {
+ return osTypeId;
+ }
+
+ public Boolean isPasswordEnabled() {
+ return passwordEnabled;
+ }
+
+ public Boolean isSshKeyEnabled() {
+ return sshKeyEnabled;
+ }
+
+ public Boolean isExtractable() {
+ return extractable;
+ }
+
+ public Boolean getRequiresHvm() {
+ return requiresHvm;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public Long getZoneId() {
+ return zoneId;
+ }
+
+ public Long getDomainId() {
+ return domainId;
+ }
+
+ public String getAccountName() {
+ return accountName;
+ }
+
+ public String getChecksum() {
+ return checksum;
+ }
+
+ public String getTemplateTag() {
+ return templateTag;
+ }
+
+ public Map getDetails() {
+ if (details == null || details.isEmpty()) {
+ return null;
+ }
+
+ Collection paramsCollection = details.values();
+ Map params = (Map) (paramsCollection.toArray())[0];
+ return params;
+ }
+
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ public AsyncJob.Type getInstanceType() {
+ return AsyncJob.Type.Template;
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
+ if (accountId == null) {
+ return UserContext.current().getCaller().getId();
+ }
+
+ return accountId;
+ }
+
+ @Override
+ public void execute() throws ResourceAllocationException{
+ try {
+ VirtualMachineTemplate template = _templateService.registerTemplate(this);
+ if (template != null){
+ ListResponse<TemplateResponse> response = new ListResponse<TemplateResponse>();
+ List<TemplateResponse> templateResponses = _responseGenerator.createTemplateResponses(template.getId(), zoneId, false);
+ response.setResponses(templateResponses);
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ } else {
+ throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to register template");
+ }
+ } catch (URISyntaxException ex1) {
+ s_logger.info(ex1);
+ throw new ServerApiException(BaseCmd.PARAM_ERROR, ex1.getMessage());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/add1b9b0/client/tomcatconf/commands.properties.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in
index 83d56da..05f949e 100755
--- a/client/tomcatconf/commands.properties.in
+++ b/client/tomcatconf/commands.properties.in
@@ -80,7 +80,7 @@ listSnapshotPolicies=org.apache.cloudstack.api.user.snapshot.command.ListSnapsho
#### template commands
createTemplate=org.apache.cloudstack.api.user.template.command.CreateTemplateCmd;15
-registerTemplate=com.cloud.api.commands.RegisterTemplateCmd;15
+registerTemplate=org.apache.cloudstack.api.user.template.command.RegisterTemplateCmd;15
updateTemplate=org.apache.cloudstack.api.user.template.command.UpdateTemplateCmd;15
copyTemplate=org.apache.cloudstack.api.user.template.command.CopyTemplateCmd;15
deleteTemplate=org.apache.cloudstack.api.user.template.command.DeleteTemplateCmd;15
@@ -94,7 +94,7 @@ prepareTemplate=com.cloud.api.commands.PrepareTemplateCmd;1
attachIso=org.apache.cloudstack.api.user.iso.command.AttachIsoCmd;15
detachIso=org.apache.cloudstack.api.user.iso.command.DetachIsoCmd;15
listIsos=org.apache.cloudstack.api.user.iso.command.ListIsosCmd;15
-registerIso=com.cloud.api.commands.RegisterIsoCmd;15
+registerIso=org.apache.cloudstack.api.user.iso.command.RegisterIsoCmd;15
updateIso=org.apache.cloudstack.api.user.iso.command.UpdateIsoCmd;15
deleteIso=org.apache.cloudstack.api.user.iso.command.DeleteIsoCmd;15
copyIso=org.apache.cloudstack.api.user.template.command.CopyTemplateCmd;15
@@ -316,7 +316,7 @@ restartNetwork=org.apache.cloudstack.api.user.network.command.RestartNetworkCmd;
updateNetwork=org.apache.cloudstack.api.user.network.command.UpdateNetworkCmd;15
#### SSH key pair commands
-registerSSHKeyPair=com.cloud.api.commands.RegisterSSHKeyPairCmd;15
+registerSSHKeyPair=org.apache.cloudstack.api.user.ssh.command.RegisterSSHKeyPairCmd;15
createSSHKeyPair=org.apache.cloudstack.api.user.ssh.command.CreateSSHKeyPairCmd;15
deleteSSHKeyPair=org.apache.cloudstack.api.user.ssh.command.DeleteSSHKeyPairCmd;15
listSSHKeyPairs=org.apache.cloudstack.api.user.ssh.command.ListSSHKeyPairsCmd;15
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/add1b9b0/server/src/com/cloud/baremetal/BareMetalTemplateAdapter.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/baremetal/BareMetalTemplateAdapter.java b/server/src/com/cloud/baremetal/BareMetalTemplateAdapter.java
index 75e401d..c609e83 100755
--- a/server/src/com/cloud/baremetal/BareMetalTemplateAdapter.java
+++ b/server/src/com/cloud/baremetal/BareMetalTemplateAdapter.java
@@ -22,10 +22,10 @@ import java.util.List;
import javax.ejb.Local;
import org.apache.cloudstack.api.user.iso.command.DeleteIsoCmd;
+import org.apache.cloudstack.api.user.iso.command.RegisterIsoCmd;
import org.apache.log4j.Logger;
-import com.cloud.api.commands.RegisterIsoCmd;
-import com.cloud.api.commands.RegisterTemplateCmd;
+import org.apache.cloudstack.api.user.template.command.RegisterTemplateCmd;
import com.cloud.configuration.Resource.ResourceType;
import com.cloud.dc.DataCenterVO;
import com.cloud.event.EventTypes;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/add1b9b0/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 4116d4c..92a4fbc 100755
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@ -44,6 +44,7 @@ import javax.crypto.spec.SecretKeySpec;
import org.apache.cloudstack.api.user.iso.command.ListIsosCmd;
import org.apache.cloudstack.api.user.ssh.command.DeleteSSHKeyPairCmd;
+import org.apache.cloudstack.api.user.ssh.command.RegisterSSHKeyPairCmd;
import org.apache.cloudstack.api.user.template.command.ListTemplatesCmd;
import org.apache.cloudstack.api.user.template.command.UpdateTemplateCmd;
import org.apache.cloudstack.api.user.vmgroup.command.ListVMGroupsCmd;
@@ -88,7 +89,6 @@ import com.cloud.api.commands.ListSystemVMsCmd;
import com.cloud.api.commands.ListVlanIpRangesCmd;
import com.cloud.api.commands.ListZonesByCmd;
import com.cloud.api.commands.RebootSystemVmCmd;
-import com.cloud.api.commands.RegisterSSHKeyPairCmd;
import com.cloud.api.commands.StopSystemVmCmd;
import com.cloud.api.commands.UpdateDomainCmd;
import com.cloud.api.commands.UpdateHostPasswordCmd;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/add1b9b0/server/src/com/cloud/template/HyervisorTemplateAdapter.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/template/HyervisorTemplateAdapter.java b/server/src/com/cloud/template/HyervisorTemplateAdapter.java
index f4348fd..4d5ee65 100755
--- a/server/src/com/cloud/template/HyervisorTemplateAdapter.java
+++ b/server/src/com/cloud/template/HyervisorTemplateAdapter.java
@@ -26,14 +26,14 @@ import java.util.List;
import javax.ejb.Local;
import org.apache.cloudstack.api.user.iso.command.DeleteIsoCmd;
+import org.apache.cloudstack.api.user.iso.command.RegisterIsoCmd;
import org.apache.log4j.Logger;
import com.cloud.agent.AgentManager;
import com.cloud.agent.api.Answer;
import com.cloud.agent.api.storage.DeleteTemplateCommand;
import org.apache.cloudstack.api.user.template.command.DeleteTemplateCmd;
-import com.cloud.api.commands.RegisterIsoCmd;
-import com.cloud.api.commands.RegisterTemplateCmd;
+import org.apache.cloudstack.api.user.template.command.RegisterTemplateCmd;
import com.cloud.configuration.Resource.ResourceType;
import com.cloud.dc.DataCenterVO;
import com.cloud.event.EventTypes;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/add1b9b0/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 0c6f329..ec6ed46 100755
--- a/server/src/com/cloud/template/TemplateAdapter.java
+++ b/server/src/com/cloud/template/TemplateAdapter.java
@@ -19,9 +19,9 @@ package com.cloud.template;
import java.util.Map;
import org.apache.cloudstack.api.user.iso.command.DeleteIsoCmd;
+import org.apache.cloudstack.api.user.iso.command.RegisterIsoCmd;
import org.apache.cloudstack.api.user.template.command.DeleteTemplateCmd;
-import com.cloud.api.commands.RegisterIsoCmd;
-import com.cloud.api.commands.RegisterTemplateCmd;
+import org.apache.cloudstack.api.user.template.command.RegisterTemplateCmd;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.storage.VMTemplateVO;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/add1b9b0/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 916540f..6ac1197 100755
--- a/server/src/com/cloud/template/TemplateAdapterBase.java
+++ b/server/src/com/cloud/template/TemplateAdapterBase.java
@@ -21,14 +21,14 @@ import java.util.Map;
import javax.naming.ConfigurationException;
+import org.apache.cloudstack.api.user.iso.command.RegisterIsoCmd;
+import org.apache.cloudstack.api.user.template.command.RegisterTemplateCmd;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import com.cloud.api.ApiDBUtils;
import org.apache.cloudstack.api.user.iso.command.DeleteIsoCmd;
import org.apache.cloudstack.api.user.template.command.DeleteTemplateCmd;
-import com.cloud.api.commands.RegisterIsoCmd;
-import com.cloud.api.commands.RegisterTemplateCmd;
import com.cloud.configuration.Resource.ResourceType;
import com.cloud.configuration.dao.ConfigurationDao;
import com.cloud.dc.DataCenterVO;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/add1b9b0/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 ffe7d17..f789e46 100755
--- a/server/src/com/cloud/template/TemplateManagerImpl.java
+++ b/server/src/com/cloud/template/TemplateManagerImpl.java
@@ -35,10 +35,7 @@ import javax.ejb.Local;
import javax.naming.ConfigurationException;
import org.apache.cloudstack.api.user.iso.command.*;
-import org.apache.cloudstack.api.user.template.command.CopyTemplateCmd;
-import org.apache.cloudstack.api.user.template.command.ExtractTemplateCmd;
-import org.apache.cloudstack.api.user.template.command.ListTemplatePermissionsCmd;
-import org.apache.cloudstack.api.user.template.command.UpdateTemplatePermissionsCmd;
+import org.apache.cloudstack.api.user.template.command.*;
import org.apache.log4j.Logger;
import com.cloud.acl.SecurityChecker.AccessType;
@@ -50,10 +47,9 @@ import com.cloud.agent.api.storage.DestroyCommand;
import com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer;
import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand;
import com.cloud.agent.api.to.SwiftTO;
-import org.apache.cloudstack.api.user.template.command.DeleteTemplateCmd;
import com.cloud.api.commands.ListTemplateOrIsoPermissionsCmd;
-import com.cloud.api.commands.RegisterIsoCmd;
-import com.cloud.api.commands.RegisterTemplateCmd;
+import org.apache.cloudstack.api.user.iso.command.RegisterIsoCmd;
+import org.apache.cloudstack.api.user.template.command.RegisterTemplateCmd;
import com.cloud.api.commands.UpdateTemplateOrIsoPermissionsCmd;
import com.cloud.async.AsyncJobManager;
import com.cloud.async.AsyncJobVO;