From fa38a7a409720a8c639b17f4f3a44e1fb0c45f08 Mon Sep 17 00:00:00 2001 From: Kishan Kavala Date: Thu, 12 Dec 2013 12:08:21 +0530 Subject: [PATCH] Upgrade router template by accountName and domainId instead of accountId Conflicts: api/src/org/apache/cloudstack/api/command/admin/router/UpgradeRouterTemplateCmd.java server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java --- .../router/UpgradeRouterTemplateCmd.java | 12 +++++------ .../VirtualNetworkApplianceManagerImpl.java | 21 ++++++++++++------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/api/src/org/apache/cloudstack/api/command/admin/router/UpgradeRouterTemplateCmd.java b/api/src/org/apache/cloudstack/api/command/admin/router/UpgradeRouterTemplateCmd.java index 3a20a515b8c..27fffc9a033 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/router/UpgradeRouterTemplateCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/router/UpgradeRouterTemplateCmd.java @@ -65,11 +65,9 @@ public class UpgradeRouterTemplateCmd extends org.apache.cloudstack.api.BaseCmd @Parameter(name = ApiConstants.ZONE_ID, type = CommandType.UUID, entityType = ZoneResponse.class, description = "upgrades all routers within the specified zone") private Long zoneId; - @Parameter(name = ApiConstants.ACCOUNT_ID, - type = CommandType.UUID, - entityType = AccountResponse.class, - description = "upgrades all routers owned by the specified account") - private Long accountId; + @Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, + description="upgrades all routers owned by the specified account") + private String account; @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, @@ -97,8 +95,8 @@ public class UpgradeRouterTemplateCmd extends org.apache.cloudstack.api.BaseCmd return zoneId; } - public Long getAccountId() { - return accountId; + public String getAccount() { + return account; } public Long getDomainId() { diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java index 2e8cde3bad7..9ea36386bf5 100755 --- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java +++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java @@ -4088,16 +4088,21 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V } } - Long accountId = cmd.getAccountId(); - if (accountId != null) { - params++; - routers = _routerDao.listBy(accountId); - } - Long domainId = cmd.getDomainId(); - if (domainId != null) { + if(domainId != null){ + String accountName = cmd.getAccount(); + //List by account, if account Name is specified along with domainId + if(accountName != null){ + Account account = _accountMgr.getActiveAccountByName(accountName, domainId); + if(account == null){ + throw new InvalidParameterValueException("Account :"+accountName+" does not exist in domain: "+domainId); + } + routers = _routerDao.listBy(account.getId()); + } else { + //List by domainId, account name not specified + routers = _routerDao.listByDomain(domainId); + } params++; - routers = _routerDao.listByDomain(domainId); } Long clusterId = cmd.getClusterId();