@Override public long getEntityOwnerId() { Account activeAccountByName = _accountService.getActiveAccountByName(accountName, domainId); if (activeAccountByName != null) { return activeAccountByName.getAccountId(); } return Account.ACCOUNT_ID_SYSTEM; }
@Override public long getEntityOwnerId() { return _accountService.getActiveAccountByName(accountName, domainId).getAccountId(); }
@Override public long getEntityOwnerId() { final Account account = _accountService.getActiveAccountByName(getAccountName(), getDomainId()); if (account != null) { return account.getAccountId(); } return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked }
private DomainRouterVO deployLoadBalancerVM(final Long networkId, final IPAddressVO ipAddr) { final NetworkVO network = _networkDao.findById(networkId); final DataCenter dc = _dcDao.findById(network.getDataCenterId()); final Long podId = getPodIdForDirectIp(ipAddr); final Pod pod = podId == null ? null : _podDao.findById(podId); final Map<VirtualMachineProfile.Param, Object> params = new HashMap<VirtualMachineProfile.Param, Object>(1); params.put(VirtualMachineProfile.Param.ReProgramGuestNetworks, true); final Account owner = _accountService.getActiveAccountByName("system", new Long(1)); final DeployDestination dest = new DeployDestination(dc, pod, null, null); s_logger.debug("About to deploy ELB vm "); try { final DomainRouterVO elbVm = deployELBVm(network, dest, owner, params); if (elbVm == null) { throw new InvalidParameterValueException("Could not deploy or find existing ELB VM"); } s_logger.debug("Deployed ELB vm = " + elbVm); return elbVm; } catch (final Throwable t) { s_logger.warn("Error while deploying ELB VM: ", t); return null; } }
@Override public long getEntityOwnerId() { Account account = _entityMgr.findById(Account.class, getId()); if (account != null) { return account.getAccountId(); } account = _accountService.getActiveAccountByName(getAccountName(), getDomainId()); if (account != null) { return account.getAccountId(); } return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked }
@Override public long getEntityOwnerId() { Account account = _entityMgr.findById(Account.class, getId()); if (account != null) { return account.getAccountId(); } account = _accountService.getActiveAccountByName(getAccountName(), getDomainId()); if (account != null) { return account.getAccountId(); } return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked }
@Override public long getEntityOwnerId() { Account account = _entityMgr.findById(Account.class, getId()); if (account != null) { return account.getAccountId(); } account = _accountService.getActiveAccountByName(getAccountName(), getDomainId()); if (account != null) { return account.getAccountId(); } return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked }
Account account = _accountService.getActiveAccountByName(admin, domainId); if (account == null) { try {
Account account = _accountService.getActiveAccountByName(admin, domainId); if (account == null) { try {
private void createCloudstackUserAccount(LdapUser user, String accountName, Domain domain) { Account account = _accountService.getActiveAccountByName(accountName, domain.getId()); if (account == null) { s_logger.debug("No account exists with name: " + accountName + " creating the account and an user with name: " + user.getUsername() + " in the account"); _accountService.createUserAccount(user.getUsername(), generatePassword(), user.getFirstname(), user.getLastname(), user.getEmail(), timezone, accountName, getAccountType(), getRoleId(), domain.getId(), domain.getNetworkDomain(), details, UUID.randomUUID().toString(), UUID.randomUUID().toString(), User.Source.LDAP); } else { // check if the user exists. if yes, call update UserAccount csuser = _accountService.getActiveUserAccount(user.getUsername(), domain.getId()); if (csuser == null) { s_logger.debug("No user exists with name: " + user.getUsername() + " creating a user in the account: " + accountName); _accountService.createUser(user.getUsername(), generatePassword(), user.getFirstname(), user.getLastname(), user.getEmail(), timezone, accountName, domain.getId(), UUID.randomUUID().toString(), User.Source.LDAP); } else { s_logger.debug("Account [name=%s] and user [name=%s] already exist in CloudStack. Executing the user update."); UpdateUserCmd updateUserCmd = new UpdateUserCmd(); updateUserCmd.setId(csuser.getId()); updateUserCmd.setFirstname(user.getFirstname()); updateUserCmd.setLastname(user.getLastname()); updateUserCmd.setEmail(user.getEmail()); _accountService.updateUser(updateUserCmd); } } }
UserAccount createCloudstackUserAccount(final LdapUser user, String accountName, Long domainId) { Account account = _accountService.getActiveAccountByName(accountName, domainId); if (account == null) { return _accountService.createUserAccount(username, generatePassword(), user.getFirstname(), user.getLastname(), user.getEmail(), timezone, accountName, getAccountType(), getRoleId(), domainId, networkDomain, details, accountUUID, userUUID, User.Source.LDAP); } else { User newUser = _accountService.createUser(username, generatePassword(), user.getFirstname(), user.getLastname(), user.getEmail(), timezone, accountName, domainId, userUUID, User.Source.LDAP); return _accountService.getUserAccountById(newUser.getId()); } }
@Override public void execute() { Long accountId = null; Account account = _accountService.getActiveAccountByName(accountName, domainId); if (account != null) { accountId = account.getAccountId(); } if (accountId == null) { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "The account does not exists or has been removed/disabled"); } if (getValue() == null) { throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Please send a valid non-empty quota value"); } if (getQuotaEnforce() != null) { _quotaService.setLockAccount(accountId, getQuotaEnforce()); } if (getMinBalance() != null) { _quotaService.setMinBalance(accountId, getMinBalance()); } else { throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Please set a value for min balance"); } final QuotaCreditsResponse response = _responseBuilder.addQuotaCredits(accountId, getDomainId(), getValue(), CallContext.current().getCallingUserId(), getQuotaEnforce()); response.setResponseName(getCommandName()); response.setObjectName("quotacredits"); setResponseObject(response); }
@Override public long getEntityOwnerId() { final Account account = _accountService.getActiveAccountByName(getAccountName(), getDomainId()); if (account != null) { return account.getAccountId(); } return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked }
@Override public long getEntityOwnerId() { Account account = _entityMgr.findById(Account.class, getId()); if (account != null) { return account.getAccountId(); } account = _accountService.getActiveAccountByName(getAccountName(), getDomainId()); if (account != null) { return account.getAccountId(); } return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked }
@Override public long getEntityOwnerId() { Account account = _entityMgr.findById(Account.class, getId()); if (account != null) { return account.getAccountId(); } account = _accountService.getActiveAccountByName(getAccountName(), getDomainId()); if (account != null) { return account.getAccountId(); } return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked }
@Override public long getEntityOwnerId() { Account account = _entityMgr.findById(Account.class, getId()); if (account != null) { return account.getAccountId(); } account = _accountService.getActiveAccountByName(getAccountName(), getDomainId()); if (account != null) { return account.getAccountId(); } return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked }