From 21da2d66085210186a9c7a272a5320db59ba8293 Mon Sep 17 00:00:00 2001 From: anthony Date: Wed, 20 Oct 2010 11:21:51 -0700 Subject: [PATCH] There are subdomain concept, so this patch doesn't fix the issue, Kris is on this Revert "for domain admin, only list snapshot inside this domain" This reverts commit f314c59ba8ca5377bfcf22387c040019f868bff4. --- .../cloud/api/commands/ListSnapshotsCmd.java | 23 ++++--------------- 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/server/src/com/cloud/api/commands/ListSnapshotsCmd.java b/server/src/com/cloud/api/commands/ListSnapshotsCmd.java index 44be1219b60..c3b5b2a21e4 100644 --- a/server/src/com/cloud/api/commands/ListSnapshotsCmd.java +++ b/server/src/com/cloud/api/commands/ListSnapshotsCmd.java @@ -90,19 +90,12 @@ public class ListSnapshotsCmd extends BaseCmd { if (account == null) { if (domainId != null && accountName != null) { account = getManagementServer().findAccountByName(accountName, domainId); - if( account == null ) { - throw new ServerApiException (BaseCmd.SNAPSHOT_INVALID_PARAM_ERROR, "can not find Account by accountName " + accountName + " domainId " + domainId); - } } } - if( !isAdmin(account.getType())) { + if( account != null && !isAdmin(account.getType())) { accountId = account.getId(); } - - if( domainId == null ) { - domainId = account.getDomainId(); - } Long startIndex = Long.valueOf(0); int pageSizeNum = 50; @@ -143,19 +136,13 @@ public class ListSnapshotsCmd extends BaseCmd { snapshotData.add(new Pair(BaseCmd.Properties.ID.getName(), snapshot.getId().toString())); Account acct = getManagementServer().findAccountById(Long.valueOf(snapshot.getAccountId())); - if (acct == null || acct.getDomainId() != domainId ){ - continue; + if (acct != null) { + snapshotData.add(new Pair(BaseCmd.Properties.ACCOUNT.getName(), acct.getAccountName())); + snapshotData.add(new Pair(BaseCmd.Properties.DOMAIN_ID.getName(), acct.getDomainId().toString())); + snapshotData.add(new Pair(BaseCmd.Properties.DOMAIN.getName(), getManagementServer().findDomainIdById(acct.getDomainId()).getName())); } volumeId = snapshot.getVolumeId(); VolumeVO volume = getManagementServer().findAnyVolumeById(volumeId); - if ( volume == null ){ - continue; - } - snapshotData.add(new Pair(BaseCmd.Properties.ACCOUNT.getName(), acct.getAccountName())); - snapshotData.add(new Pair(BaseCmd.Properties.DOMAIN_ID.getName(), acct.getDomainId().toString())); - snapshotData.add(new Pair(BaseCmd.Properties.DOMAIN.getName(), getManagementServer() - .findDomainIdById(acct.getDomainId()).getName())); - String snapshotTypeStr = SnapshotType.values()[snapshot.getSnapshotType()].name(); snapshotData.add(new Pair(BaseCmd.Properties.SNAPSHOT_TYPE.getName(), snapshotTypeStr)); snapshotData.add(new Pair(BaseCmd.Properties.VOLUME_ID.getName(), volumeId));