Mike Kolesnik has uploaded a new change for review. Change subject: engine: Block hot updating external networks ......................................................................
engine: Block hot updating external networks Hot update of external network on a vNIC is not supported, so blocking it. Change-Id: I597531ca417b8e5649c44e4da28f32bd660e1c11 Signed-off-by: Mike Kolesnik <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/vm/AbstractVmInterfaceCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/vm/AddVmInterfaceCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/vm/UpdateVmInterfaceCommand.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java M backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties M frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java M frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties M frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties 8 files changed, 36 insertions(+), 4 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/38/14138/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/vm/AbstractVmInterfaceCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/vm/AbstractVmInterfaceCommand.java index 713af99..971f98d 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/vm/AbstractVmInterfaceCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/vm/AbstractVmInterfaceCommand.java @@ -103,9 +103,13 @@ : ValidationResult.VALID; } - protected Network getNetworkFromDb(Guid vdsGroupId) { + protected Network getNetworkFromDb(Guid vdsGroupId, String networkName) { + if (networkName == null) { + return null; + } + for (Network network : getNetworkDAO().getAllForCluster(vdsGroupId)) { - if (network.getName().equals(getNetworkName())) { + if (network.getName().equals(networkName)) { return network; } } diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/vm/AddVmInterfaceCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/vm/AddVmInterfaceCommand.java index b7b7087..b441c30 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/vm/AddVmInterfaceCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/vm/AddVmInterfaceCommand.java @@ -141,7 +141,7 @@ if (getNetworkName() != null) { // check that the network exists in current cluster - Network interfaceNetwork = getNetworkFromDb(vm.getVdsGroupId()); + Network interfaceNetwork = getNetworkFromDb(vm.getVdsGroupId(), getNetworkName()); if (interfaceNetwork == null) { addCanDoActionMessage(VdcBllMessages.NETWORK_NOT_EXISTS_IN_CURRENT_CLUSTER); diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/vm/UpdateVmInterfaceCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/vm/UpdateVmInterfaceCommand.java index 1e6054e..2eacc9c 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/vm/UpdateVmInterfaceCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/vm/UpdateVmInterfaceCommand.java @@ -183,14 +183,21 @@ return false; } + Network network = getNetworkFromDb(vm.getVdsGroupId(), getNetworkName()); if (getNetworkName() != null) { - Network network = getNetworkFromDb(vm.getVdsGroupId()); // check that the network exists in current cluster if (network == null) { addCanDoActionMessage(VdcBllMessages.NETWORK_NOT_EXISTS_IN_CURRENT_CLUSTER); return false; } else if (!validate(nicValidator.portMirroringNotSetIfExternalNetwork(network))) { + return false; + } + } + + if (getRequiredAction() == RequiredAction.UPDATE_VM_DEVICE) { + Network oldNetwork = getNetworkFromDb(vm.getVdsGroupId(), oldIface.getNetworkName()); + if (!validate(nicValidator.hotUpdateDoneWithInternalNetwork(oldNetwork, network))) { return false; } } @@ -317,5 +324,19 @@ || (!oldIface.getMacAddress().equals(getMacAddress())) || (oldIface.isPortMirroring() != getInterface().isPortMirroring()); } + + /** + * @param oldNetwork + * The old network (can be <code>null</code>). + * @param newNetwork + * The new network (can be <code>null</code>). + * @return An error if either the old or new network is an external network, otherwise hot update is allowed. + */ + public ValidationResult hotUpdateDoneWithInternalNetwork(Network oldNetwork, Network newNetwork) { + return (oldNetwork == null || oldNetwork.getProvidedBy() == null) + && (newNetwork == null || newNetwork.getProvidedBy() == null) + ? ValidationResult.VALID + : new ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_BE_REWIRED); + } } } diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java index 0152211..9cab968 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java @@ -447,6 +447,7 @@ ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_BE_DISPLAY, ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_BE_REQUIRED, ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_BE_PORT_MIRRORED, + ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_BE_REWIRED, ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_HAVE_MTU, ACTION_TYPE_FAILED_MANAGEMENT_NETWORK_REQUIRED, ACTION_TYPE_FAILED_MANAGEMENT_NETWORK_ADDRESS_CANNOT_BE_CHANGED, diff --git a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties index 2d740d6..edb7bf5 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties @@ -469,6 +469,7 @@ ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_BE_DISPLAY=Cannot ${action} ${type}. External network cannot be used as a display network. ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_BE_REQUIRED=Cannot ${action} ${type}. External network cannot be set as required in the cluster. ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_BE_PORT_MIRRORED=Cannot ${action} ${type}. External network cannot be used when port mirroring is set. +ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_BE_REWIRED=Cannot ${action} ${type}. External network cannot be changed while the virtual machine is running. ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_HAVE_MTU=Cannot ${action} ${type}. External network cannot have MTU set. ACTION_TYPE_FAILED_MANAGEMENT_NETWORK_REQUIRED=Cannot ${action} ${type}. The management network '${NetworkName}' must be required, please change the network to be required and try again. ACTION_TYPE_FAILED_MANAGEMENT_NETWORK_ADDRESS_CANNOT_BE_CHANGED=Cannot ${action} ${type}. The management network address cannot be modified without reinstalling the host, since this address was used to create the host's certification. diff --git a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java index e306c29..86a599d 100644 --- a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java +++ b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java @@ -1261,6 +1261,9 @@ @DefaultStringValue("Cannot ${action} ${type}. External network cannot be used when port mirroring is set.") String ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_BE_PORT_MIRRORED(); + @DefaultStringValue("Cannot ${action} ${type}. External network cannot be changed while the virtual machine is running") + String ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_BE_REWIRED(); + @DefaultStringValue("Cannot ${action} ${type}. External network cannot have MTU set.") String ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_HAVE_MTU(); diff --git a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties index bde5058..df79049 100644 --- a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties +++ b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties @@ -466,6 +466,7 @@ ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_BE_DISPLAY=Cannot ${action} ${type}. External network cannot be used as a display network. ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_BE_REQUIRED=Cannot ${action} ${type}. External network cannot be set as required in the cluster. ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_BE_PORT_MIRRORED=Cannot ${action} ${type}. External network cannot be used when port mirroring is set. +ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_BE_REWIRED=Cannot ${action} ${type}. External network cannot be changed while the virtual machine is running. ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_HAVE_MTU=Cannot ${action} ${type}. External network cannot have MTU set. ACTION_TYPE_FAILED_MANAGEMENT_NETWORK_REQUIRED=Cannot ${action} ${type}. The management network '${NetworkName}' must be required, please change the network to be required and try again. ACTION_TYPE_FAILED_MANAGEMENT_NETWORK_ADDRESS_CANNOT_BE_CHANGED=Cannot ${action} ${type}. The management network address cannot be modified without reinstalling the host, since this address was used to create the host's certification. diff --git a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties index 1101fa6..a4fae9a 100644 --- a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties +++ b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties @@ -462,6 +462,7 @@ ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_BE_DISPLAY=Cannot ${action} ${type}. External network cannot be used as a display network. ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_BE_REQUIRED=Cannot ${action} ${type}. External network cannot be set as required in the cluster. ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_BE_PORT_MIRRORED=Cannot ${action} ${type}. External network cannot be used when port mirroring is set. +ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_BE_REWIRED=Cannot ${action} ${type}. External network cannot be changed while the virtual machine is running. ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_HAVE_MTU=Cannot ${action} ${type}. External network cannot have MTU set. ACTION_TYPE_FAILED_MANAGEMENT_NETWORK_REQUIRED=Cannot ${action} ${type}. The management network '${NetworkName}' must be required, please change the network to be required and try again. ACTION_TYPE_FAILED_MANAGEMENT_NETWORK_ADDRESS_CANNOT_BE_CHANGED=Cannot ${action} ${type}. The management network address cannot be modified without reinstalling the host, since this address was used to create the host's certification. -- To view, visit http://gerrit.ovirt.org/14138 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I597531ca417b8e5649c44e4da28f32bd660e1c11 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Mike Kolesnik <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
