DeployVMCmd: Add userid param to deployVM API Signed-off-by: Rohit Yadav <[email protected]>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/eb8fba3e Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/eb8fba3e Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/eb8fba3e Branch: refs/heads/useraccount-refactoring Commit: eb8fba3e06fd7c0e7ef32ea2e73a5c251565462b Parents: cb018b8 Author: Rohit Yadav <[email protected]> Authored: Fri Nov 14 13:58:17 2014 +0530 Committer: Rohit Yadav <[email protected]> Committed: Fri Nov 14 13:58:17 2014 +0530 ---------------------------------------------------------------------- .../cloudstack/api/command/user/vm/DeployVMCmd.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/eb8fba3e/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java ---------------------------------------------------------------------- diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java index bb7b13c..31ab27e 100755 --- a/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java @@ -54,6 +54,7 @@ import org.apache.cloudstack.api.response.ProjectResponse; import org.apache.cloudstack.api.response.SecurityGroupResponse; import org.apache.cloudstack.api.response.ServiceOfferingResponse; import org.apache.cloudstack.api.response.TemplateResponse; +import org.apache.cloudstack.api.response.UserResponse; import org.apache.cloudstack.api.response.UserVmResponse; import org.apache.cloudstack.api.response.ZoneResponse; import org.apache.cloudstack.context.CallContext; @@ -95,10 +96,14 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd { @Parameter(name = ApiConstants.DISPLAY_NAME, type = CommandType.STRING, description = "an optional user generated name for the virtual machine") private String displayName; - //Owner information + //Owner account information @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "an optional account for the virtual machine. Must be used with domainId.") private String accountName; + //Owner userId + @Parameter(name = ApiConstants.USER_ID, type = CommandType.UUID, entityType = UserResponse.class, required = true, description = "the user ID of the owner, optional to use with account and domainId. If not provided logged in user's ID is used.") + private Long userId; + @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, entityType = DomainResponse.class, description = "an optional domainId for the virtual machine. If the account parameter is used, domainId must also be used.") private Long domainId; @@ -200,6 +205,13 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd { return accountName; } + public Long getUserId() { + if (this.userId == null) { + return CallContext.current().getCallingUserId(); + } + return userId; + } + public Long getDiskOfferingId() { return diskOfferingId; }
