Alona Kaplan has uploaded a new change for review. Change subject: core: add NetworkLinking to ChangeVMClusterCommand ......................................................................
core: add NetworkLinking to ChangeVMClusterCommand When chaning the VM Cluster- if the new Cluster doesn't support NetworkLinking and the VM has Vnics with 1. No network (null)- it is allowed. CanDoAction will be thrown when the user will try to run the vm. 2. Unlinked Network- canDoAction is thrown. Change-Id: Icc3dd865ccd99f23862db4f4a37aa5e816db3214 Signed-off-by: Alona Kaplan <alkap...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ChangeVMClusterCommand.java 1 file changed, 28 insertions(+), 15 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/76/9576/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ChangeVMClusterCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ChangeVMClusterCommand.java index 79de676..680dd7d 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ChangeVMClusterCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ChangeVMClusterCommand.java @@ -1,19 +1,17 @@ package org.ovirt.engine.core.bll; -import static org.apache.commons.lang.StringUtils.isNotEmpty; - import java.util.ArrayList; import java.util.List; -import org.ovirt.engine.core.common.AuditLogType; import org.ovirt.engine.core.bll.utils.PermissionSubject; +import org.ovirt.engine.core.common.AuditLogType; import org.ovirt.engine.core.common.VdcObjectType; import org.ovirt.engine.core.common.action.ChangeVMClusterParameters; import org.ovirt.engine.core.common.businessentities.ActionGroup; +import org.ovirt.engine.core.common.businessentities.Network; import org.ovirt.engine.core.common.businessentities.VDSGroup; import org.ovirt.engine.core.common.businessentities.VM; import org.ovirt.engine.core.common.businessentities.VmNetworkInterface; -import org.ovirt.engine.core.common.businessentities.Network; import org.ovirt.engine.core.common.config.Config; import org.ovirt.engine.core.common.config.ConfigValues; import org.ovirt.engine.core.dal.VdcBllMessages; @@ -79,11 +77,24 @@ } // Check the destination cluster have all the networks that the VM use + // Checks that if the destination Cluster doesn't support Network linking the VM doesn't have Nics with + // unlinked Network ("no network" is allowed here, will be blocked in RunVm) List<Network> networks = DbFacade.getInstance().getNetworkDao().getAllForCluster(getParameters().getClusterId()); StringBuilder missingNets = new StringBuilder(); + boolean unlinkingSupportedOnTargetCluster = + Config.<Boolean> GetValue(ConfigValues.NetworkLinkingSupported, + targetCluster.getcompatibility_version().getValue()); for (VmNetworkInterface iface: interfaces) { + if (!unlinkingSupportedOnTargetCluster && !iface.isLinked()) { + addCanDoActionMessage(VdcBllMessages.MOVE_VM_CLUSTER_UNLINKING_IS_NOT_SUPPORTED); + addCanDoActionMessage(String.format("$clusterVersion %1$s", + targetCluster.getcompatibility_version(). + getValue())); + return false; + } + String netName = iface.getNetworkName(); - if (isNotEmpty(netName)) { + if (netName != null) { boolean exists = false; for (Network net: networks) { if (net.getname().equals(netName)) { @@ -144,17 +155,19 @@ .getAllForVm(getParameters().getVmId()); for (final VmNetworkInterface iface : interfaces) { - Network net = LinqUtils.firstOrNull(networks, new Predicate<Network>() { - @Override - public boolean eval(Network n) { - return iface.getNetworkName().equals(n.getname()); + if (iface.getNetworkName() != null) { + Network net = LinqUtils.firstOrNull(networks, new Predicate<Network>() { + @Override + public boolean eval(Network n) { + return iface.getNetworkName().equals(n.getname()); + } + }); + // if network not exists in cluster we remove the network to + // interface connection + if (net == null) { + iface.setNetworkName(null); + DbFacade.getInstance().getVmNetworkInterfaceDao().update(iface); } - }); - // if network not exists in cluster we remove the network to - // interface connection - if (net == null) { - iface.setNetworkName(null); - DbFacade.getInstance().getVmNetworkInterfaceDao().update(iface); } } -- To view, visit http://gerrit.ovirt.org/9576 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Icc3dd865ccd99f23862db4f4a37aa5e816db3214 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Alona Kaplan <alkap...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches