Repository: cloudstack Updated Branches: refs/heads/4.4 332836746 -> 29b09b1e2
CLOUDSTACK-7047: DeploymentPlanner should include disabled resources only when the VM owner is Admin account Changes: -DeploymentPlanner should include disabled resources only when the VM owner is Admin account. The disabled resources should be ignored when VM is owned by any other user. (cherry picked from commit 40e28de7275804f4483868ba8a737878ff54fba8) Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/b70bd23b Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/b70bd23b Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/b70bd23b Branch: refs/heads/4.4 Commit: b70bd23be37bb7d8fa581b26a0bb6d8c657c9098 Parents: 3328367 Author: Prachi Damle <prachi.da...@citrix.com> Authored: Wed Jul 2 18:02:40 2014 -0700 Committer: Daan Hoogland <d...@onecht.net> Committed: Thu Jul 3 16:13:05 2014 +0200 ---------------------------------------------------------------------- .../com/cloud/deploy/DeploymentPlanningManagerImpl.java | 10 +++++----- server/src/com/cloud/deploy/FirstFitPlanner.java | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b70bd23b/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java b/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java index f954615..c61e507 100644 --- a/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java +++ b/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java @@ -1243,7 +1243,7 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy if (s_logger.isDebugEnabled()) { s_logger.debug("We need to allocate new storagepool for this volume"); } - if (!isRootAdmin(plan.getReservationContext())) { + if (!isRootAdmin(vmProfile)) { if (!isEnabledForAllocation(plan.getDataCenterId(), plan.getPodId(), plan.getClusterId())) { if (s_logger.isDebugEnabled()) { s_logger.debug("Cannot allocate new storagepool for this volume in this cluster, allocation state is disabled"); @@ -1359,10 +1359,10 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy return true; } - private boolean isRootAdmin(ReservationContext reservationContext) { - if (reservationContext != null) { - if (reservationContext.getAccount() != null) { - return _accountMgr.isRootAdmin(reservationContext.getAccount().getId()); + private boolean isRootAdmin(VirtualMachineProfile vmProfile) { + if (vmProfile != null) { + if (vmProfile.getOwner() != null) { + return _accountMgr.isRootAdmin(vmProfile.getOwner().getId()); } else { return false; } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b70bd23b/server/src/com/cloud/deploy/FirstFitPlanner.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/deploy/FirstFitPlanner.java b/server/src/com/cloud/deploy/FirstFitPlanner.java index 6ffe31f..cd093f3 100755 --- a/server/src/com/cloud/deploy/FirstFitPlanner.java +++ b/server/src/com/cloud/deploy/FirstFitPlanner.java @@ -191,7 +191,7 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentClusterPla } podsWithCapacity.removeAll(avoid.getPodsToAvoid()); } - if (!isRootAdmin(plan.getReservationContext())) { + if (!isRootAdmin(vmProfile)) { List<Long> disabledPods = listDisabledPods(plan.getDataCenterId()); if (!disabledPods.isEmpty()) { if (s_logger.isDebugEnabled()) { @@ -322,7 +322,7 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentClusterPla prioritizedClusterIds.removeAll(avoid.getClustersToAvoid()); } - if (!isRootAdmin(plan.getReservationContext())) { + if (!isRootAdmin(vmProfile)) { List<Long> disabledClusters = new ArrayList<Long>(); if (isZone) { disabledClusters = listDisabledClusters(plan.getDataCenterId(), null); @@ -465,10 +465,10 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentClusterPla } - private boolean isRootAdmin(ReservationContext reservationContext) { - if(reservationContext != null){ - if(reservationContext.getAccount() != null){ - return _accountMgr.isRootAdmin(reservationContext.getAccount().getId()); + private boolean isRootAdmin(VirtualMachineProfile vmProfile) { + if (vmProfile != null) { + if (vmProfile.getOwner() != null) { + return _accountMgr.isRootAdmin(vmProfile.getOwner().getId()); }else{ return false; }