From 5129df106bda169feec6bbce0ea764a60a6e6446 Mon Sep 17 00:00:00 2001 From: alena Date: Wed, 9 Mar 2011 10:19:12 -0800 Subject: [PATCH] bug 8847: createUser api - "account" parameter is required now status 8847: resolved fixed --- api/src/com/cloud/api/commands/CreateUserCmd.java | 2 +- server/src/com/cloud/user/AccountManagerImpl.java | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/api/src/com/cloud/api/commands/CreateUserCmd.java b/api/src/com/cloud/api/commands/CreateUserCmd.java index 660ed62bdf4..b73decb6d20 100644 --- a/api/src/com/cloud/api/commands/CreateUserCmd.java +++ b/api/src/com/cloud/api/commands/CreateUserCmd.java @@ -40,7 +40,7 @@ public class CreateUserCmd extends BaseCmd { //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - @Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="Creates the user under the specified account. If no account is specified, the username will be used as the account name.") + @Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, required=true, description="Creates the user under the specified account. If no account is specified, the username will be used as the account name.") private String accountName; @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="Creates the user under the specified domain. Has to be accompanied with the account parameter") diff --git a/server/src/com/cloud/user/AccountManagerImpl.java b/server/src/com/cloud/user/AccountManagerImpl.java index 50ca54ab3b6..1e1cf946558 100755 --- a/server/src/com/cloud/user/AccountManagerImpl.java +++ b/server/src/com/cloud/user/AccountManagerImpl.java @@ -1101,10 +1101,15 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag String timeZone = cmd.getTimezone(); Long accountId = null; + //default domain to ROOT if not specified + if (domainId == null) { + domainId = Domain.ROOT_DOMAIN; + } + Account account = _accountDao.findActiveAccount(accountName, domainId); - if( account == null){ - throw new InvalidParameterValueException("Unable to find account to create user"); + if(account == null){ + throw new InvalidParameterValueException("Unable to find account " + accountName + " in domain id=" + domainId + " to create user"); }else{ accountId = account.getAccountId(); }