You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by we...@apache.org on 2013/10/21 14:07:42 UTC
[1/2] git commit: updated refs/heads/master to cd72e2a
Updated Branches:
refs/heads/master 7623c4527 -> cd72e2afe
fix a bug in findAllChildren of domains
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/db890bc7
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/db890bc7
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/db890bc7
Branch: refs/heads/master
Commit: db890bc71e10855285c64f006a0153a21834182a
Parents: 7623c45
Author: Wei Zhou <w....@leaseweb.com>
Authored: Mon Oct 21 14:02:53 2013 +0200
Committer: Wei Zhou <w....@leaseweb.com>
Committed: Mon Oct 21 14:02:53 2013 +0200
----------------------------------------------------------------------
engine/schema/src/com/cloud/domain/dao/DomainDaoImpl.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/db890bc7/engine/schema/src/com/cloud/domain/dao/DomainDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/domain/dao/DomainDaoImpl.java b/engine/schema/src/com/cloud/domain/dao/DomainDaoImpl.java
index 3d0588e..2a3642e 100644
--- a/engine/schema/src/com/cloud/domain/dao/DomainDaoImpl.java
+++ b/engine/schema/src/com/cloud/domain/dao/DomainDaoImpl.java
@@ -224,7 +224,7 @@ public class DomainDaoImpl extends GenericDaoBase<DomainVO, Long> implements Dom
@Override
public List<DomainVO> findAllChildren(String path, Long parentId){
SearchCriteria<DomainVO> sc = FindAllChildrenSearch.create();
- sc.setParameters("path", "%"+path+"%");
+ sc.setParameters("path", path+"%");
sc.setParameters("id", parentId);
return listBy(sc);
}
[2/2] git commit: updated refs/heads/master to cd72e2a
Posted by we...@apache.org.
fix a bug in listServiceOffering with vmId
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/cd72e2af
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/cd72e2af
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/cd72e2af
Branch: refs/heads/master
Commit: cd72e2afeef0e74db499963971720ff4a8dbd3af
Parents: db890bc
Author: Wei Zhou <w....@leaseweb.com>
Authored: Mon Oct 21 14:05:53 2013 +0200
Committer: Wei Zhou <w....@leaseweb.com>
Committed: Mon Oct 21 14:05:53 2013 +0200
----------------------------------------------------------------------
.../com/cloud/api/query/QueryManagerImpl.java | 59 ++++++++++++--------
1 file changed, 35 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cd72e2af/server/src/com/cloud/api/query/QueryManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/QueryManagerImpl.java b/server/src/com/cloud/api/query/QueryManagerImpl.java
index 8edc2eb..cbe5e24 100644
--- a/server/src/com/cloud/api/query/QueryManagerImpl.java
+++ b/server/src/com/cloud/api/query/QueryManagerImpl.java
@@ -2423,6 +2423,27 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
}
}
+ if (vmId != null) {
+ UserVmVO vmInstance = _userVmDao.findById(vmId);
+ if ((vmInstance == null) || (vmInstance.getRemoved() != null)) {
+ InvalidParameterValueException ex = new InvalidParameterValueException(
+ "unable to find a virtual machine with specified id");
+ ex.addProxyObject(vmId.toString(), "vmId");
+ throw ex;
+ }
+
+ _accountMgr.checkAccess(caller, null, true, vmInstance);
+
+ ServiceOfferingVO offering = _srvOfferingDao.findByIdIncludingRemoved(vmInstance.getServiceOfferingId());
+ sc.addAnd("id", SearchCriteria.Op.NEQ, offering.getId());
+
+ // Only return offerings with the same Guest IP type and storage
+ // pool preference
+ // sc.addAnd("guestIpType", SearchCriteria.Op.EQ,
+ // offering.getGuestIpType());
+ sc.addAnd("useLocalStorage", SearchCriteria.Op.EQ, offering.getUseLocalStorage());
+ }
+
// boolean includePublicOfferings = false;
if ((caller.getType() == Account.ACCOUNT_TYPE_NORMAL || caller.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN)
|| caller.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) {
@@ -2432,11 +2453,20 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
}
// find all domain Id up to root domain for this account
List<Long> domainIds = new ArrayList<Long>();
- DomainVO domainRecord = _domainDao.findById(caller.getDomainId());
- if (domainRecord == null) {
- s_logger.error("Could not find the domainId for account:" + caller.getAccountName());
- throw new CloudAuthenticationException("Could not find the domainId for account:"
- + caller.getAccountName());
+ DomainVO domainRecord;
+ if (vmId != null) {
+ UserVmVO vmInstance = _userVmDao.findById(vmId);
+ domainRecord = _domainDao.findById(vmInstance.getDomainId());
+ if ( domainRecord == null ){
+ s_logger.error("Could not find the domainId for vmId:" + vmId);
+ throw new CloudAuthenticationException("Could not find the domainId for vmId:" + vmId);
+ }
+ } else {
+ domainRecord = _domainDao.findById(caller.getDomainId());
+ if ( domainRecord == null ){
+ s_logger.error("Could not find the domainId for account:" + caller.getAccountName());
+ throw new CloudAuthenticationException("Could not find the domainId for account:" + caller.getAccountName());
+ }
}
domainIds.add(domainRecord.getId());
while (domainRecord.getParent() != null) {
@@ -2466,25 +2496,6 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
sc.addAnd("name", SearchCriteria.Op.SC, ssc);
- } else if (vmId != null) {
- UserVmVO vmInstance = _userVmDao.findById(vmId);
- if ((vmInstance == null) || (vmInstance.getRemoved() != null)) {
- InvalidParameterValueException ex = new InvalidParameterValueException(
- "unable to find a virtual machine with specified id");
- ex.addProxyObject(vmId.toString(), "vmId");
- throw ex;
- }
-
- _accountMgr.checkAccess(caller, null, true, vmInstance);
-
- ServiceOfferingVO offering = _srvOfferingDao.findByIdIncludingRemoved(vmInstance.getServiceOfferingId());
- sc.addAnd("id", SearchCriteria.Op.NEQ, offering.getId());
-
- // Only return offerings with the same Guest IP type and storage
- // pool preference
- // sc.addAnd("guestIpType", SearchCriteria.Op.EQ,
- // offering.getGuestIpType());
- sc.addAnd("useLocalStorage", SearchCriteria.Op.EQ, offering.getUseLocalStorage());
}
if (id != null) {