@Override public PersistentHostSetupNetworksParameters buildParameters( Guid vdsId, List<Network> labeledNetworksToBeAdded, List<Network> labeledNetworksToBeRemoved, Map<String, VdsNetworkInterface> nicsByLabel) { final PersistentHostSetupNetworksParameters addSetupNetworksParameters = addNetworksByLabelParametersBuilder.buildParameters( vdsId, labeledNetworksToBeAdded, nicsByLabel); final PersistentHostSetupNetworksParameters removeSetupNetworksParameters = removeNetworksByLabelParametersBuilder.buildParameters(vdsId, labeledNetworksToBeRemoved); final PersistentHostSetupNetworksParameters combinedParams = combine(addSetupNetworksParameters, removeSetupNetworksParameters); final Collection<Network> affectedNetworks = concat(labeledNetworksToBeAdded, labeledNetworksToBeRemoved); combinedParams.setNetworkNames(StringUtils.join(Entities.objectNames(affectedNetworks), ", ")); return combinedParams; }
private PersistentHostSetupNetworksParameters combine( PersistentHostSetupNetworksParameters addSetupNetworksParameters, PersistentHostSetupNetworksParameters removeSetupNetworksParameters) { Guid hostId = addSetupNetworksParameters.getVdsId(); final PersistentHostSetupNetworksParameters resultParam = createHostSetupNetworksParameters(hostId); extendParameters(resultParam, addSetupNetworksParameters); extendParameters(resultParam, removeSetupNetworksParameters); return resultParam; }
private void extendParameters( PersistentHostSetupNetworksParameters resultParam, PersistentHostSetupNetworksParameters setupNetworksParameters) { resultParam.getNetworkAttachments().addAll(setupNetworksParameters.getNetworkAttachments()); resultParam .getRemovedNetworkAttachments() .addAll(setupNetworksParameters.getRemovedNetworkAttachments()); resultParam .getRemovedUnmanagedNetworks() .addAll(setupNetworksParameters.getRemovedUnmanagedNetworks()); }