@@ -93,6 +93,7 @@ public class VMInstanceDaoImpl extends GenericDaoBase<VMInstanceVO, Long> implem
9393 protected GenericSearchBuilder <VMInstanceVO , String > DistinctHostNameSearch ;
9494 protected SearchBuilder <VMInstanceVO > HostAndStateSearch ;
9595 protected SearchBuilder <VMInstanceVO > StartingWithNoHostSearch ;
96+ protected SearchBuilder <VMInstanceVO > NotMigratingSearch ;
9697
9798 @ Inject
9899 ResourceTagDao _tagsDao ;
@@ -280,6 +281,11 @@ protected void init() {
280281 DistinctHostNameSearch .join ("nicSearch" , nicSearch , DistinctHostNameSearch .entity ().getId (), nicSearch .entity ().getInstanceId (), JoinBuilder .JoinType .INNER );
281282 DistinctHostNameSearch .done ();
282283
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 ();
283289 }
284290
285291 @ Override
@@ -305,11 +311,11 @@ public List<VMInstanceVO> listByHostId(long hostid) {
305311 }
306312
307313 @ 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 ();
310316 sc .setParameters ("host" , hostId );
311317 sc .setParameters ("lastHost" , hostId );
312- sc .setParameters ("state" , State .Running );
318+ sc .setParameters ("state" , State .Migrating );
313319 return listBy (sc );
314320 }
315321
0 commit comments