From 9f68870a779d0b969e4fb8f766846537a456e2ad Mon Sep 17 00:00:00 2001 From: Prachi Damle Date: Wed, 2 Jul 2014 16:32:13 -0700 Subject: [PATCH] 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. --- .../deploy/DeploymentPlanningManagerImpl.java | 10 +++++----- server/src/com/cloud/deploy/FirstFitPlanner.java | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java b/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java index db6fa5fee83..d6f87b92599 100644 --- a/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java +++ b/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java @@ -1233,7 +1233,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"); @@ -1361,10 +1361,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; } diff --git a/server/src/com/cloud/deploy/FirstFitPlanner.java b/server/src/com/cloud/deploy/FirstFitPlanner.java index 6ffe31f99a2..859245644e7 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 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 disabledClusters = new ArrayList(); if (isZone) { disabledClusters = listDisabledClusters(plan.getDataCenterId(), null); @@ -465,11 +465,11 @@ 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()); - }else{ + private boolean isRootAdmin(VirtualMachineProfile vmProfile) { + if (vmProfile != null) { + if (vmProfile.getOwner() != null) { + return _accountMgr.isRootAdmin(vmProfile.getOwner().getId()); + } else { return false; } }