@Override public boolean isValid(NetworkAttachment value, ConstraintValidatorContext context) { boolean networkIdNotSet = value.getNetworkId() == null; boolean networkNameNotSet = value.getNetworkName() == null; return !(networkIdNotSet && networkNameNotSet); } }
private Map<String, Set<LogicalNetworkModel>> createNicNameToNetworkModels() { Map<String, Set<LogicalNetworkModel>> nicToNetworks = new HashMap<>(); for (NetworkAttachment networkAttachment : hostSetupNetworksParametersData.getNetworkAttachments()) { String nicName = networkAttachment.getNicName(); if (!nicToNetworks.containsKey(nicName)) { nicToNetworks.put(nicName, new HashSet<LogicalNetworkModel>()); } LogicalNetworkModel networkModel = networkModelByName.get(networkAttachment.getNetworkName()); assert networkModel != null : "network on an attachment should have a logical model"; //$NON-NLS-1$ setVlanDeviceOnNetworkModelIfNeeded(nicName, networkModel); nicToNetworks.get(nicName).add(networkModel); } createModelsForUnamangedNetworks(nicToNetworks); return nicToNetworks; }
public NetworkAttachment mapNetworkAttachment(Map<Guid, NetworkAttachment> attachmentsById, org.ovirt.engine.api.model.NetworkAttachment model) { Mapper<org.ovirt.engine.api.model.NetworkAttachment, NetworkAttachment> networkAttachmentMapper = getMapper(org.ovirt.engine.api.model.NetworkAttachment.class, NetworkAttachment.class); NetworkAttachment attachment = null; if (model.isSetId()) { attachment = attachmentsById.get(asGuid(model.getId())); } else if (model.isSetNetwork() && (model.getNetwork().isSetName() || model.getNetwork().isSetId())) { for (Map.Entry<Guid, NetworkAttachment> backendNetworkAttachmentMapEntry : attachmentsById.entrySet()) { NetworkAttachment backendNetworkAttachment = backendNetworkAttachmentMapEntry.getValue(); String backendNetworkName = backendNetworkAttachment.getNetworkName(); String backendNetworkId = backendNetworkAttachment.getNetworkId().toString(); if (backendNetworkName.equals(model.getNetwork().getName()) || backendNetworkId.equals(model.getNetwork().getId())) { attachment = backendNetworkAttachment; break; } } } return networkAttachmentMapper.map(model, attachment); }
public NetworkAttachment(NetworkAttachment networkAttachment) { id = networkAttachment.getId(); nicId = networkAttachment.getNicId(); nicName = networkAttachment.getNicName(); networkId = networkAttachment.getNetworkId(); networkName = networkAttachment.getNetworkName(); ipConfiguration = networkAttachment.getIpConfiguration(); properties = networkAttachment.getProperties(); overrideConfiguration = networkAttachment.isOverrideConfiguration(); reportedConfigurations = networkAttachment.getReportedConfigurations(); }
public HostSetupNetworksParameters createHostSetupNetworksParameters() { HostSetupNetworksParameters result = new HostSetupNetworksParameters(getEntity().getId()); for (NetworkAttachment attachment : hostSetupNetworksParametersData.getNetworkAttachments()) { attachment.setOverrideConfiguration(shouldSyncNetwork(attachment.getNetworkName())); } result.setNetworkAttachments( new ArrayList<NetworkAttachment>(hostSetupNetworksParametersData.getNetworkAttachments())); result.setRemovedNetworkAttachments(hostSetupNetworksParametersData.getRemovedNetworkAttachments()); result.setCreateOrUpdateBonds(new ArrayList<CreateOrUpdateBond>(hostSetupNetworksParametersData.getBonds())); result.setRemovedBonds(new HashSet<>(hostSetupNetworksParametersData.getRemovedBonds())); result.setRemovedUnmanagedNetworks(hostSetupNetworksParametersData.getRemovedUnmanagedNetworks()); result.setLabels(hostSetupNetworksParametersData.getLabels()); result.setRemovedLabels(hostSetupNetworksParametersData.getRemovedLabels()); result.setCommitOnSuccess(commitChanges.getEntity()); return result; }
@Override public String toString() { return ToStringBuilder.forInstance(this) .append("id", getId()) .append("networkId", getNetworkId()) .append("networkName", getNetworkName()) .append("nicId", getNicId()) .append("nicName", getNicName()) .append("ipConfiguration", getIpConfiguration()) .append("dnsResolverConfiguration", getDnsResolverConfiguration()) .append("properties", getProperties()) .append("overrideConfiguration", isOverrideConfiguration()) .build(); } }