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 40e28de727)
This commit is contained in:
Prachi Damle 2014-07-02 18:02:40 -07:00 committed by Daan Hoogland
parent 332836746d
commit b70bd23be3
2 changed files with 11 additions and 11 deletions

View File

@ -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;
}

View File

@ -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;
}