Martin Mucha has uploaded a new change for review. Change subject: core: removed procedural parameter passing ......................................................................
core: removed procedural parameter passing Change-Id: I6804d28a14d2fb7a3cc414a0627f7ca055cd0a9a Signed-off-by: Martin Mucha <mmu...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/host/HostSetupNetworksValidator.java 1 file changed, 20 insertions(+), 22 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/79/35979/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/host/HostSetupNetworksValidator.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/host/HostSetupNetworksValidator.java index 9b24576..4833eff 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/host/HostSetupNetworksValidator.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/host/HostSetupNetworksValidator.java @@ -48,6 +48,8 @@ private List<NetworkAttachment> existingAttachments; private boolean networkCustomPropertiesSupported; private Map<Guid, Network> clusterNetworks; + private final Map<Guid, NetworkAttachment> attachmentsById; + private final BusinessEntityMap<Bond> removedBonds; public HostSetupNetworksValidator(VDS host, HostSetupNetworksParameters params, @@ -61,6 +63,9 @@ this.clusterNetworks = clusterNetworks; setSupportedFeatures(); + + attachmentsById = Entities.businessEntitiesById(existingAttachments); + removedBonds = new BusinessEntityMap<>(params.getRemovedBonds()); } private void setSupportedFeatures() { @@ -73,18 +78,13 @@ } public List<String> validate() { - //TODO MM: this should be instance parameter - Map<Guid, NetworkAttachment> attachmentsById = Entities.businessEntitiesById(existingAttachments); - //TODO MM: this should be instance parameter - BusinessEntityMap<Bond> removedBonds = new BusinessEntityMap<>(params.getRemovedBonds()); - - if (validModifiedNetworkAttachments(attachmentsById) - && validRemovedNetworkAttachments(attachmentsById, removedBonds) - && validModifiedBonds(removedBonds) - && validRemovedBonds(removedBonds) + if (validModifiedNetworkAttachments() + && validRemovedNetworkAttachments() + && validModifiedBonds() + && validRemovedBonds() && validateNotRemovingUsedNetworkByVms()) { - Collection<NetworkAttachment> attachmentsToConfigure = getAttachmentsToConfigure(removedBonds); + Collection<NetworkAttachment> attachmentsToConfigure = getAttachmentsToConfigure(); if (networksUniquelyConfiguredOnHost(attachmentsToConfigure) && validate(validateNetworkExclusiveOnNics(attachmentsToConfigure)) && validateMtu(attachmentsToConfigure) @@ -139,8 +139,8 @@ return passed; } - private boolean validRemovedBonds(BusinessEntityMap<Bond> removedBonds) { - Set<String> requiredNicsNames = getRemovedBondsUsedByNetworks(removedBonds); + private boolean validRemovedBonds() { + Set<String> requiredNicsNames = getRemovedBondsUsedByNetworks(); boolean passed = true; for (Bond removedBond : params.getRemovedBonds()) { @@ -166,8 +166,8 @@ return passed; } - private Set<String> getRemovedBondsUsedByNetworks(BusinessEntityMap<Bond> removedBonds) { - Collection<NetworkAttachment> attachmentsToConfigure = getAttachmentsToConfigure(removedBonds); + private Set<String> getRemovedBondsUsedByNetworks() { + Collection<NetworkAttachment> attachmentsToConfigure = getAttachmentsToConfigure(); Set<String> requiredNicsNames = new HashSet<>(); for (NetworkAttachment attachment : attachmentsToConfigure) { requiredNicsNames.add(attachment.getNicName()); @@ -176,7 +176,7 @@ return requiredNicsNames; } - private Collection<NetworkAttachment> getAttachmentsToConfigure(BusinessEntityMap<Bond> removedBonds) { + private Collection<NetworkAttachment> getAttachmentsToConfigure() { Map<Guid, NetworkAttachment> attachmentsToConfigure = new HashMap<>(Entities.businessEntitiesById(existingAttachments)); // ignore removed attachments for (NetworkAttachment removedAttachment : params.getRemovedNetworkAttachments()) { @@ -206,7 +206,7 @@ return candidateAttachments; } - private boolean validModifiedBonds(BusinessEntityMap<Bond> removedBonds) { + private boolean validModifiedBonds() { boolean passed = true; for (Bond modifiedOrNewBond : params.getBonds()) { String bondName = modifiedOrNewBond.getName(); @@ -288,7 +288,7 @@ return false; } - private boolean validModifiedNetworkAttachments(Map<Guid, NetworkAttachment> attachmentsById) { + private boolean validModifiedNetworkAttachments() { boolean passed = true; for (NetworkAttachment attachment : params.getNetworkAttachments()) { NetworkAttachmentValidator validator = new NetworkAttachmentValidator(attachment, host); @@ -310,8 +310,7 @@ return passed; } - private boolean validRemovedNetworkAttachments(Map<Guid, NetworkAttachment> attachmentsById, - BusinessEntityMap<Bond> removedBonds) { + private boolean validRemovedNetworkAttachments() { boolean passed = true; for (NetworkAttachment attachment : params.getRemovedNetworkAttachments()) { NetworkAttachment attachmentToValidate = attachmentsById.get(attachment.getId()); @@ -319,7 +318,7 @@ if (!(validate(validator.networkAttachmentIsSet()) && validate(validator.notExternalNetwork()) && validate(validator.notManagementNetwork()) - && notRemovingLabeledNetworks(attachment, getExistingIfaces(), removedBonds))) { + && notRemovingLabeledNetworks(attachment, getExistingIfaces()))) { passed = false; } } @@ -328,8 +327,7 @@ } private boolean notRemovingLabeledNetworks(NetworkAttachment attachment, - Map<String, VdsNetworkInterface> existingNics, - BusinessEntityMap<Bond> removedBonds) { + Map<String, VdsNetworkInterface> existingNics) { Network removedNetwork = clusterNetworks.get(attachment.getNetworkId()); if (!NetworkUtils.isLabeled(removedNetwork)) { return true; -- To view, visit http://gerrit.ovirt.org/35979 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6804d28a14d2fb7a3cc414a0627f7ca055cd0a9a Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Martin Mucha <mmu...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches