Moti Asayag has posted comments on this change.
Change subject: engine: Improved error message when unassigning network used by
VMs
......................................................................
Patch Set 1: (3 inline comments)
....................................................
File
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/cluster/DetachNetworkToVdsGroupCommand.java
Line 60:
addCanDoActionMessage(VdcBllMessages.NETWORK_CANNOT_REMOVE_NETWORK_IN_USE_BY_VM);
Line 61:
getReturnValue().getCanDoActionMessages().add(String.format("$NetworkName %1$s",
Line 62: getParameters().getNetwork().getName()));
Line 63:
Line 64: // list all the VMs using the network
you can replace the entire loop and further string manipulation by letting
VmStatic implements the Nameable interface and use:
StringUtils.join(Entities.objectNames(vms), '\n')
for creating the replacement value.
But rethinking it, this suffers from the same problem of the proposed solution:
what if there are too many vms using the network then we wish/can present in
the error message?
Here comes the recently added ReplacementUtils which does both: creates a
replacement properly and limits the number of shown entities.
Using it yet requires implementing the Nameable by VmStatic
Line 65: String vmList = "";
Line 66: for (VmStatic vm : vms)
Line 67: vmList += vm.getvm_name() + '\n';
Line 68: vmList = vmList.substring(0, vmList.length() - 1); // drop
last newline
Line 64: // list all the VMs using the network
Line 65: String vmList = "";
Line 66: for (VmStatic vm : vms)
Line 67: vmList += vm.getvm_name() + '\n';
Line 68: vmList = vmList.substring(0, vmList.length() - 1); // drop
last newline
I've already suggested an alternative for it, just for the sake of discussion,
you could chomp the last new line by:
StringUtils.chomp(vmList)
Line 69:
getReturnValue().getCanDoActionMessages().add(String.format("$VmList %s",
vmList));
Line 70:
Line 71: return false;
Line 72: }
....................................................
File backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
Line 490: NETWORK_ADDR_MANDATORY_IN_STATIC_IP=Netwrok address must be specify
when using static ip
Line 491: ACTION_TYPE_FAILED_OBJECT_LOCKED=Cannot ${action} ${type}. Related
operation is currently in progress. Please try again later.
Line 492: NETWORK_BOND_HAVE_ATTACHED_VLANS=Bond attached to vlan, remove bonds
vlan first
Line 493: NETWORK_INTERFACE_CONNECT_TO_VLAN=Cannot attach non vlan network to
vlan interface
Line 494: NETWORK_CANNOT_REMOVE_NETWORK_IN_USE_BY_VM=Cannot remove network
'${NetworkName}', it's in use by the following virtual machines:\n\n${VmList}
please use ReplacementUtils items counter property to show the total number of
vms using the network.
Line 495: ACTION_TYPE_FAILED_DISK_MAX_SIZE_EXCEEDED=Cannot create disk more
than ${max}_disk_size GB
Line 496: NETWORK_HOST_IS_BUSY=Cannot edit Network while Host is Active, change
the Host to Maintenance mode and try again.
Line 497: VMT_CANNOT_CHANGE_IMAGES_TEMPLATE=Cannot change Template images format
Line 498: VMT_CANNOT_IMPORT_RAW_IMAGE_WITH_SNAPSHOTS=Cannot change image format
to raw when image have Snapshots.
--
To view, visit http://gerrit.ovirt.org/10683
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I127615d9144084ad093ac1d20841979be8163a12
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Lior Vernia <[email protected]>
Gerrit-Reviewer: Lior Vernia <[email protected]>
Gerrit-Reviewer: Liron Aravot <[email protected]>
Gerrit-Reviewer: Livnat Peer <[email protected]>
Gerrit-Reviewer: Mike Kolesnik <[email protected]>
Gerrit-Reviewer: Moti Asayag <[email protected]>
Gerrit-Reviewer: Muli Salem <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches