3131import javax .inject .Inject ;
3232import javax .naming .ConfigurationException ;
3333
34+ import org .apache .log4j .Logger ;
35+
3436import org .apache .cloudstack .affinity .AffinityGroupProcessor ;
3537import org .apache .cloudstack .affinity .AffinityGroupService ;
3638import org .apache .cloudstack .affinity .AffinityGroupVMMapVO ;
4951import org .apache .cloudstack .storage .datastore .db .PrimaryDataStoreDao ;
5052import org .apache .cloudstack .storage .datastore .db .StoragePoolVO ;
5153import org .apache .cloudstack .utils .identity .ManagementServerNode ;
52- import org .apache .log4j .Logger ;
5354
55+ import com .cloud .agent .AgentManager ;
56+ import com .cloud .agent .Listener ;
57+ import com .cloud .agent .api .AgentControlAnswer ;
58+ import com .cloud .agent .api .AgentControlCommand ;
59+ import com .cloud .agent .api .Answer ;
60+ import com .cloud .agent .api .Command ;
61+ import com .cloud .agent .api .StartupCommand ;
62+ import com .cloud .agent .api .StartupRoutingCommand ;
63+ import com .cloud .agent .manager .allocator .HostAllocator ;
5464import com .cloud .capacity .CapacityManager ;
5565import com .cloud .capacity .dao .CapacityDao ;
5666import com .cloud .configuration .Config ;
7181import com .cloud .exception .AffinityConflictException ;
7282import com .cloud .exception .ConnectionException ;
7383import com .cloud .exception .InsufficientServerCapacityException ;
74- import com .cloud .exception .PermissionDeniedException ;
7584import com .cloud .host .Host ;
7685import com .cloud .host .HostVO ;
7786import com .cloud .host .Status ;
104113import com .cloud .utils .db .SearchCriteria ;
105114import com .cloud .utils .db .Transaction ;
106115import com .cloud .utils .db .TransactionCallback ;
107- import com .cloud .utils .db .TransactionCallbackNoReturn ;
108116import com .cloud .utils .db .TransactionStatus ;
109117import com .cloud .utils .exception .CloudRuntimeException ;
110118import com .cloud .utils .fsm .StateListener ;
113121import com .cloud .vm .VMInstanceVO ;
114122import com .cloud .vm .VirtualMachine ;
115123import com .cloud .vm .VirtualMachine .Event ;
116- import com .cloud .vm .VirtualMachineProfile ;
117124import com .cloud .vm .VirtualMachine .State ;
125+ import com .cloud .vm .VirtualMachineProfile ;
118126import com .cloud .vm .dao .UserVmDao ;
119127import com .cloud .vm .dao .VMInstanceDao ;
120- import com .cloud .agent .AgentManager ;
121- import com .cloud .agent .Listener ;
122- import com .cloud .agent .api .AgentControlAnswer ;
123- import com .cloud .agent .api .AgentControlCommand ;
124- import com .cloud .agent .api .Answer ;
125- import com .cloud .agent .api .Command ;
126- import com .cloud .agent .api .StartupCommand ;
127- import com .cloud .agent .api .StartupRoutingCommand ;
128- import com .cloud .agent .manager .allocator .HostAllocator ;
129128
130129
131130@ Local (value = { DeploymentPlanningManager .class })
@@ -209,7 +208,7 @@ public List<AffinityGroupProcessor> getAffinityGroupProcessors() {
209208 return _affinityProcessors ;
210209 }
211210 public void setAffinityGroupProcessors (List <AffinityGroupProcessor > affinityProcessors ) {
212- this . _affinityProcessors = affinityProcessors ;
211+ _affinityProcessors = affinityProcessors ;
213212 }
214213
215214 @ Override
@@ -953,7 +952,7 @@ private boolean canAvoidCluster(Cluster clusterVO, ExcludeList avoids, ExcludeLi
953952 }
954953
955954 // Cluster can be put in avoid set in following scenarios:
956- // 1. If storage allocators haven't put any pools in avoid set means either no pools in cluster
955+ // 1. If storage allocators haven't put any pools in avoid set means either no pools in cluster
957956 // or pools not suitable for the allocators to handle or there is no
958957 // linkage of any suitable host to any of the pools in cluster
959958 // 2. If all 'shared' or 'local' pools are in avoid set
@@ -1154,9 +1153,9 @@ protected Pair<Map<Volume, List<StoragePool>>, List<Volume>> findSuitablePoolsFo
11541153 List <StoragePool > suitablePools = new ArrayList <StoragePool >();
11551154 StoragePool pool = null ;
11561155 if (toBeCreated .getPoolId () != null ) {
1157- pool = (StoragePool ) this . dataStoreMgr .getPrimaryDataStore (toBeCreated .getPoolId ());
1156+ pool = (StoragePool ) dataStoreMgr .getPrimaryDataStore (toBeCreated .getPoolId ());
11581157 } else {
1159- pool = (StoragePool ) this . dataStoreMgr .getPrimaryDataStore (plan .getPoolId ());
1158+ pool = (StoragePool ) dataStoreMgr .getPrimaryDataStore (plan .getPoolId ());
11601159 }
11611160
11621161 if (!pool .isInMaintenance ()) {
@@ -1169,7 +1168,7 @@ protected Pair<Map<Volume, List<StoragePool>>, List<Volume>> findSuitablePoolsFo
11691168 && plan .getClusterId () == exstPoolClusterId ) {
11701169 canReusePool = true ;
11711170 } else if (plan .getDataCenterId () == exstPoolDcId ) {
1172- DataStore dataStore = this . dataStoreMgr .getPrimaryDataStore (pool .getId ());
1171+ DataStore dataStore = dataStoreMgr .getPrimaryDataStore (pool .getId ());
11731172 if (dataStore != null && dataStore .getScope () != null
11741173 && dataStore .getScope ().getScopeType () == ScopeType .ZONE ) {
11751174 canReusePool = true ;
@@ -1274,7 +1273,13 @@ protected Pair<Map<Volume, List<StoragePool>>, List<Volume>> findSuitablePoolsFo
12741273 }
12751274 }
12761275 if (suitableVolumeStoragePools .values () != null ) {
1277- poolsToAvoidOutput .removeAll (suitableVolumeStoragePools .values ());
1276+ HashSet <Long > toRemove = new HashSet <Long >();
1277+ for (List <StoragePool > lsp : suitableVolumeStoragePools .values ()) {
1278+ for (StoragePool sp : lsp ) {
1279+ toRemove .add (sp .getId ());
1280+ }
1281+ }
1282+ poolsToAvoidOutput .removeAll (toRemove );
12781283 }
12791284 if (avoid .getPoolsToAvoid () != null ) {
12801285 avoid .getPoolsToAvoid ().addAll (poolsToAvoidOutput );
0 commit comments