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
This commit is contained in:
Kishan Kavala 2013-12-12 12:08:21 +05:30
parent e08f64e6ae
commit fa38a7a409
2 changed files with 18 additions and 15 deletions

View File

@ -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") @Parameter(name = ApiConstants.ZONE_ID, type = CommandType.UUID, entityType = ZoneResponse.class, description = "upgrades all routers within the specified zone")
private Long zoneId; private Long zoneId;
@Parameter(name = ApiConstants.ACCOUNT_ID, @Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING,
type = CommandType.UUID, description="upgrades all routers owned by the specified account")
entityType = AccountResponse.class, private String account;
description = "upgrades all routers owned by the specified account")
private Long accountId;
@Parameter(name = ApiConstants.DOMAIN_ID, @Parameter(name = ApiConstants.DOMAIN_ID,
type = CommandType.UUID, type = CommandType.UUID,
@ -97,8 +95,8 @@ public class UpgradeRouterTemplateCmd extends org.apache.cloudstack.api.BaseCmd
return zoneId; return zoneId;
} }
public Long getAccountId() { public String getAccount() {
return accountId; return account;
} }
public Long getDomainId() { public Long getDomainId() {

View File

@ -4088,17 +4088,22 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
} }
} }
Long accountId = cmd.getAccountId();
if (accountId != null) {
params++;
routers = _routerDao.listBy(accountId);
}
Long domainId = cmd.getDomainId(); Long domainId = cmd.getDomainId();
if (domainId != null) { if(domainId != null){
params++; 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); routers = _routerDao.listByDomain(domainId);
} }
params++;
}
Long clusterId = cmd.getClusterId(); Long clusterId = cmd.getClusterId();
if (clusterId != null) { if (clusterId != null) {