Arik Hadas has uploaded a new change for review. Change subject: core: common scheduling with migration ......................................................................
core: common scheduling with migration Change-Id: I84c213d29b5f2193b7bc3eb31b52cfd021e1362c Signed-off-by: Arik Hadas <aha...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommandBase.java 3 files changed, 45 insertions(+), 40 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/02/22102/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java index 4ffb3f4..bd14a52 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java @@ -100,25 +100,13 @@ protected void initVdss() { setVdsIdRef(getVm().getRunOnVds()); - VDS destVds = getDestinationVds(); - Guid vdsToRunOn = - SchedulingManager.getInstance().schedule(getVdsGroup(), - getVm(), - getVdsBlackList(), - getVdsWhiteList(), - destVds == null ? null : destVds.getId(), - new ArrayList<String>(), - new VdsFreeMemoryChecker(this), - getCorrelationId()); - setVdsDestinationId(vdsToRunOn); - if (vdsToRunOn != null && !Guid.Empty.equals(vdsToRunOn)) { - getRunVdssList().add(vdsToRunOn); - } - VmHandler.updateVmGuestAgentVersion(getVm()); - // make _destinationVds null in order to refresh it from db in case it - // changed. + // make _destinationVds null in order to refresh it from + // db in case it changed. _destinationVds = null; - if (vdsDestinationId != null && vdsDestinationId.equals(Guid.Empty)) { + + setVdsDestinationId(schedule()); + + if (Guid.isNullOrEmpty(vdsDestinationId)) { throw new VdcBLLException(VdcBllErrors.RESOURCE_MANAGER_CANT_ALLOC_VDS_MIGRATION); } @@ -129,6 +117,7 @@ @Override protected void executeVmCommand() { + VmHandler.updateVmGuestAgentVersion(getVm()); initVdss(); perform(); processVm(); @@ -427,8 +416,11 @@ return builder.toString(); } - // hosts that cannot be selected for scheduling (failed hosts + VM source host) - private List<Guid> getVdsBlackList() { + /** + * hosts that cannot be selected for scheduling (failed hosts + VM source host) + */ + @Override + protected List<Guid> getVdsBlackList() { List<Guid> blackList = new ArrayList<Guid>(getRunVdssList()); if (getVdsId() != null) { blackList.add(getVdsId()); @@ -436,8 +428,11 @@ return blackList; } - // initial hosts list picked for scheduling, currently - // passed by load balancing process. + /** + * initial hosts list picked for scheduling, currently + * passed by load balancing process. + */ + @Override protected List<Guid> getVdsWhiteList() { return getParameters().getInitialHosts(); } diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java index d131445..d76ef2b 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java @@ -624,22 +624,6 @@ return true; } - protected Guid schedule() { - Guid vdsId = SchedulingManager.getInstance().schedule( - getVdsGroup(), - getVm(), - getRunVdssList(), - getVdsWhiteList(), - getDestinationVds() != null ? getDestinationVds().getId() : null, - new ArrayList<String>(), - new VdsFreeMemoryChecker(this), - getCorrelationId()); - if (!Guid.isNullOrEmpty(vdsId)) { - getRunVdssList().add(vdsId); - } - return vdsId; - } - /** * If vds version greater then vm's and vm not running with cd and there is appropriate RhevAgentTools image - * add it to vm as cd. @@ -736,7 +720,7 @@ if (!runVmValidator.canRunVm( getReturnValue().getCanDoActionMessages(), getStoragePool(), - getRunVdssList(), + getVdsBlackList(), getVdsWhiteList(), getDestinationVds() != null ? getDestinationVds().getId() : null, getVdsGroup())) { @@ -946,8 +930,16 @@ } } - // initial white list (null == all hosts) + /** + * initial white list (null == all hosts) + */ + @Override protected List<Guid> getVdsWhiteList() { return null; } + + @Override + protected List<Guid> getVdsBlackList() { + return getRunVdssList(); + } } diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommandBase.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommandBase.java index 32836a5..d7a1443 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommandBase.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommandBase.java @@ -71,6 +71,8 @@ } protected abstract VDS getDestinationVds(); + protected abstract List<Guid> getVdsWhiteList(); + protected abstract List<Guid> getVdsBlackList(); public SnapshotsValidator getSnapshotsValidator() { return snapshotsValidator; @@ -83,6 +85,22 @@ return runVdsList; } + protected Guid schedule() { + Guid vdsId = SchedulingManager.getInstance().schedule( + getVdsGroup(), + getVm(), + getVdsBlackList(), + getVdsWhiteList(), + getDestinationVds() != null ? getDestinationVds().getId() : null, + new ArrayList<String>(), + new VdsFreeMemoryChecker(this), + getCorrelationId()); + if (!Guid.isNullOrEmpty(vdsId)) { + getRunVdssList().add(vdsId); + } + return vdsId; + } + @Override public void rerun() { Guid vdsId = getDestinationVds() != null ? getDestinationVds().getId() : getCurrentVdsId(); -- To view, visit http://gerrit.ovirt.org/22102 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I84c213d29b5f2193b7bc3eb31b52cfd021e1362c Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Arik Hadas <aha...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches