Liron Ar has posted comments on this change. Change subject: engine: Introduce commands to manage iscsi bonds entities ......................................................................
Patch Set 11: (11 comments) http://gerrit.ovirt.org/#/c/22952/11/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/AddIscsiBondCommand.java File backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/AddIscsiBondCommand.java: Line 44: @Override Line 45: public Void runInTransaction() { Line 46: getDbFacade().getIscsiBondDao().save(iscsiBond); Line 47: Line 48: for (Guid networkId : iscsiBond.getNetworkIds()) { getNetworkIds can return nulll Line 49: getDbFacade().getIscsiBondDao().addNetworkToIscsiBond(iscsiBond.getId(), networkId); Line 50: } Line 51: Line 52: for (String connectionId : iscsiBond.getStorageConnectionIds()) { Line 45: public Void runInTransaction() { Line 46: getDbFacade().getIscsiBondDao().save(iscsiBond); Line 47: Line 48: for (Guid networkId : iscsiBond.getNetworkIds()) { Line 49: getDbFacade().getIscsiBondDao().addNetworkToIscsiBond(iscsiBond.getId(), networkId); please add getIscsiBondDao method and export to it getDbFacade().getIscsiBondDao() Line 50: } Line 51: Line 52: for (String connectionId : iscsiBond.getStorageConnectionIds()) { Line 53: getDbFacade().getIscsiBondDao().addStorageConnectionToIscsiBond(iscsiBond.getId(), connectionId); Line 52: for (String connectionId : iscsiBond.getStorageConnectionIds()) { Line 53: getDbFacade().getIscsiBondDao().addStorageConnectionToIscsiBond(iscsiBond.getId(), connectionId); Line 54: } Line 55: Line 56: getCompensationContext().stateChanged(); there's no compensation here. Line 57: return null; Line 58: } Line 59: }); Line 60: http://gerrit.ovirt.org/#/c/22952/11/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/EditIscsiBondCommand.java File backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/EditIscsiBondCommand.java: Line 16: import org.ovirt.engine.core.compat.Guid; Line 17: import org.ovirt.engine.core.utils.transaction.TransactionMethod; Line 18: import org.ovirt.engine.core.utils.transaction.TransactionSupport; Line 19: Line 20: @LockIdNameAttribute locks? Line 21: @NonTransactiveCommandAttribute Line 22: public class EditIscsiBondCommand <T extends EditIscsiBondParameters> extends BaseIscsiBondCommand<T> { Line 23: Line 24: private IscsiBond existingIscsiBond; Line 24: private IscsiBond existingIscsiBond; Line 25: Line 26: public EditIscsiBondCommand(T parameters) { Line 27: super(parameters); Line 28: setStoragePoolId(parameters.getIscsiBond().getStoragePoolId()); possible npe Line 29: } Line 30: Line 31: public EditIscsiBondCommand(Guid commandId) { Line 32: super(commandId); Line 60: Line 61: updateNetworksIds(); Line 62: updateConnectionsIds(); Line 63: Line 64: getCompensationContext().stateChanged(); no compensation here Line 65: return null; Line 66: } Line 67: }); Line 68: Line 73: Set<Guid> beforeChangeNetworkIds = new HashSet<>(getExistingIscsiBond().getNetworkIds()); Line 74: Line 75: for (Guid networkId : getIscsiBond().getNetworkIds()) { Line 76: if (!beforeChangeNetworkIds.remove(networkId)) { Line 77: getDbFacade().getIscsiBondDao().addNetworkToIscsiBond(getExistingIscsiBond().getId(), networkId); i suggest to have this dao method to accept multiple networks at once. Line 78: } Line 79: } Line 80: Line 81: for (Guid networkId : beforeChangeNetworkIds) { Line 78: } Line 79: } Line 80: Line 81: for (Guid networkId : beforeChangeNetworkIds) { Line 82: getDbFacade().getIscsiBondDao().removeNetworkFromIscsiBond(getExistingIscsiBond().getId(), networkId); same Line 83: } Line 84: } Line 85: Line 86: private void updateConnectionsIds() { Line 87: Set<String> beforeChangeConnectionIds = new HashSet<>(getExistingIscsiBond().getStorageConnectionIds()); Line 88: Line 89: for (String connectionId : getIscsiBond().getStorageConnectionIds()) { Line 90: if (!beforeChangeConnectionIds.remove(connectionId)) { Line 91: getDbFacade().getIscsiBondDao().addStorageConnectionToIscsiBond(getExistingIscsiBond().getId(), connectionId); same Line 92: } Line 93: } Line 94: Line 95: for (String connectionId : beforeChangeConnectionIds) { Line 92: } Line 93: } Line 94: Line 95: for (String connectionId : beforeChangeConnectionIds) { Line 96: getDbFacade().getIscsiBondDao().removeStorageConnectionFromIscsiBond(getExistingIscsiBond().getId(), connectionId); same Line 97: } Line 98: } Line 99: Line 100: private IscsiBond getExistingIscsiBond() { http://gerrit.ovirt.org/#/c/22952/11/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/RemoveIscsiBondCommand.java File backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/RemoveIscsiBondCommand.java: Line 13: import org.ovirt.engine.core.common.businessentities.IscsiBond; Line 14: import org.ovirt.engine.core.common.errors.VdcBllMessages; Line 15: import org.ovirt.engine.core.compat.Guid; Line 16: Line 17: @LockIdNameAttribute locks? Line 18: public class RemoveIscsiBondCommand<T extends RemoveIscsiBondParameters> extends BaseIscsiBondCommand<T> { Line 19: Line 20: private IscsiBond iscsiBond; Line 21: -- To view, visit http://gerrit.ovirt.org/22952 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I06890ea40d22b86d9421cb1b0c68ea28bc430b0a Gerrit-PatchSet: 11 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Sergey Gotliv <[email protected]> Gerrit-Reviewer: Allon Mureinik <[email protected]> Gerrit-Reviewer: Amador Pahim <[email protected]> Gerrit-Reviewer: Daniel Erez <[email protected]> Gerrit-Reviewer: Liron Ar <[email protected]> Gerrit-Reviewer: Maor Lipchuk <[email protected]> Gerrit-Reviewer: Sergey Gotliv <[email protected]> Gerrit-Reviewer: Tal Nisan <[email protected]> Gerrit-Reviewer: Vered Volansky <[email protected]> Gerrit-Reviewer: oVirt Jenkins CI Server Gerrit-HasComments: Yes _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
