From 3d40c1032b0201a40aa77524ce740875e9275188 Mon Sep 17 00:00:00 2001 From: kishan Date: Thu, 8 Dec 2011 19:50:21 +0530 Subject: [PATCH] Skip userdispersing allocator when account is not available --- .../storage/allocator/FirstFitStoragePoolAllocator.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/src/com/cloud/storage/allocator/FirstFitStoragePoolAllocator.java b/server/src/com/cloud/storage/allocator/FirstFitStoragePoolAllocator.java index b34d7a9c893..7765cca6775 100644 --- a/server/src/com/cloud/storage/allocator/FirstFitStoragePoolAllocator.java +++ b/server/src/com/cloud/storage/allocator/FirstFitStoragePoolAllocator.java @@ -56,7 +56,10 @@ public class FirstFitStoragePoolAllocator extends AbstractStoragePoolAllocator { VMTemplateVO template = (VMTemplateVO)vmProfile.getTemplate(); - Account account = vmProfile.getOwner(); + Account account = null; + if(vmProfile.getVirtualMachine() != null){ + account = vmProfile.getOwner(); + } List suitablePools = new ArrayList(); @@ -84,7 +87,8 @@ public class FirstFitStoragePoolAllocator extends AbstractStoragePoolAllocator { StatsCollector sc = StatsCollector.getInstance(); - if(_allocationAlgorithm.equals("random")) { + //FixMe: We are ignoring userdispersing algorithm when account is null. Find a way to get account ID when VMprofile is null + if(_allocationAlgorithm.equals("random") || (account == null)) { // Shuffle this so that we don't check the pools in the same order. Collections.shuffle(pools); }else if(_allocationAlgorithm.equals("userdispersing")){