Skip to content

Commit b70bd23

Browse files
Prachi DamleDaanHoogland
authored andcommitted
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 40e28de)
1 parent 3328367 commit b70bd23

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

‎server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,7 +1243,7 @@ protected Pair<Map<Volume, List<StoragePool>>, List<Volume>> findSuitablePoolsFo
12431243
if (s_logger.isDebugEnabled()) {
12441244
s_logger.debug("We need to allocate new storagepool for this volume");
12451245
}
1246-
if (!isRootAdmin(plan.getReservationContext())) {
1246+
if (!isRootAdmin(vmProfile)) {
12471247
if (!isEnabledForAllocation(plan.getDataCenterId(), plan.getPodId(), plan.getClusterId())) {
12481248
if (s_logger.isDebugEnabled()) {
12491249
s_logger.debug("Cannot allocate new storagepool for this volume in this cluster, allocation state is disabled");
@@ -1359,10 +1359,10 @@ private boolean isEnabledForAllocation(long zoneId, Long podId, Long clusterId)
13591359
return true;
13601360
}
13611361

1362-
private boolean isRootAdmin(ReservationContext reservationContext) {
1363-
if (reservationContext != null) {
1364-
if (reservationContext.getAccount() != null) {
1365-
return _accountMgr.isRootAdmin(reservationContext.getAccount().getId());
1362+
private boolean isRootAdmin(VirtualMachineProfile vmProfile) {
1363+
if (vmProfile != null) {
1364+
if (vmProfile.getOwner() != null) {
1365+
return _accountMgr.isRootAdmin(vmProfile.getOwner().getId());
13661366
} else {
13671367
return false;
13681368
}

‎server/src/com/cloud/deploy/FirstFitPlanner.java‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ private List<Long> scanPodsForDestination(VirtualMachineProfile vmProfile, Deplo
191191
}
192192
podsWithCapacity.removeAll(avoid.getPodsToAvoid());
193193
}
194-
if (!isRootAdmin(plan.getReservationContext())) {
194+
if (!isRootAdmin(vmProfile)) {
195195
List<Long> disabledPods = listDisabledPods(plan.getDataCenterId());
196196
if (!disabledPods.isEmpty()) {
197197
if (s_logger.isDebugEnabled()) {
@@ -322,7 +322,7 @@ private List<Long> scanClustersForDestinationInZoneOrPod(long id, boolean isZone
322322
prioritizedClusterIds.removeAll(avoid.getClustersToAvoid());
323323
}
324324

325-
if (!isRootAdmin(plan.getReservationContext())) {
325+
if (!isRootAdmin(vmProfile)) {
326326
List<Long> disabledClusters = new ArrayList<Long>();
327327
if (isZone) {
328328
disabledClusters = listDisabledClusters(plan.getDataCenterId(), null);
@@ -465,10 +465,10 @@ protected Pair<List<Long>, Map<Long, Double>> listPodsByCapacity(long zoneId, in
465465

466466
}
467467

468-
private boolean isRootAdmin(ReservationContext reservationContext) {
469-
if(reservationContext != null){
470-
if(reservationContext.getAccount() != null){
471-
return _accountMgr.isRootAdmin(reservationContext.getAccount().getId());
468+
private boolean isRootAdmin(VirtualMachineProfile vmProfile) {
469+
if (vmProfile != null) {
470+
if (vmProfile.getOwner() != null) {
471+
return _accountMgr.isRootAdmin(vmProfile.getOwner().getId());
472472
}else{
473473
return false;
474474
}

0 commit comments

Comments
 (0)