@@ -93,6 +93,7 @@ public class VMInstanceDaoImpl extends GenericDaoBase<VMInstanceVO, Long> implem
93
93
protected GenericSearchBuilder <VMInstanceVO , String > DistinctHostNameSearch ;
94
94
protected SearchBuilder <VMInstanceVO > HostAndStateSearch ;
95
95
protected SearchBuilder <VMInstanceVO > StartingWithNoHostSearch ;
96
+ protected SearchBuilder <VMInstanceVO > NotMigratingSearch ;
96
97
97
98
@ Inject
98
99
ResourceTagDao _tagsDao ;
@@ -280,6 +281,11 @@ protected void init() {
280
281
DistinctHostNameSearch .join ("nicSearch" , nicSearch , DistinctHostNameSearch .entity ().getId (), nicSearch .entity ().getInstanceId (), JoinBuilder .JoinType .INNER );
281
282
DistinctHostNameSearch .done ();
282
283
284
+ NotMigratingSearch = createSearchBuilder ();
285
+ NotMigratingSearch .and ("host" , NotMigratingSearch .entity ().getHostId (), Op .EQ );
286
+ NotMigratingSearch .and ("lastHost" , NotMigratingSearch .entity ().getLastHostId (), Op .EQ );
287
+ NotMigratingSearch .and ("state" , NotMigratingSearch .entity ().getState (), Op .NEQ );
288
+ NotMigratingSearch .done ();
283
289
}
284
290
285
291
@ Override
@@ -305,11 +311,11 @@ public List<VMInstanceVO> listByHostId(long hostid) {
305
311
}
306
312
307
313
@ Override
308
- public List <VMInstanceVO > listRunningVmsByHostAndLastHostSameId (long hostId ) {
309
- SearchCriteria <VMInstanceVO > sc = AllFieldsSearch .create ();
314
+ public List <VMInstanceVO > listNonMigratingVmsByHostEqualsLastHost (long hostId ) {
315
+ SearchCriteria <VMInstanceVO > sc = NotMigratingSearch .create ();
310
316
sc .setParameters ("host" , hostId );
311
317
sc .setParameters ("lastHost" , hostId );
312
- sc .setParameters ("state" , State .Running );
318
+ sc .setParameters ("state" , State .Migrating );
313
319
return listBy (sc );
314
320
}
315
321
0 commit comments