public static PortByBaseEndpoint createPortByBaseEndpoint(UniqueId portId, AddressEndpointKey addrEpKey) { return new PortByBaseEndpointBuilder().setPortId(portId) .setAddressType(addrEpKey.getAddressType()) .setAddress(addrEpKey.getAddress()) .setContextType(addrEpKey.getContextType()) .setContextId(addrEpKey.getContextId()) .build(); }
private boolean isSameEpg(RegisterEndpointInput epInput, AddressEndpoint input) { if (epInput == null || epInput.getAddressEndpointReg() == null || epInput.getAddressEndpointReg().isEmpty()) { return true; } final AddressEndpointReg epInputAddressEndpoint = epInput.getAddressEndpointReg().get(0); if (epInputAddressEndpoint.getEndpointGroup() == null || epInputAddressEndpoint.getEndpointGroup().isEmpty()) { return true; } if (input == null || input.getEndpointGroup() == null || input.getEndpointGroup().isEmpty()) { return true; } final EndpointGroupId addressEndpointGroupId = epInputAddressEndpoint.getEndpointGroup().get(0); final EndpointGroupId existingEndpointGroupId = input.getEndpointGroup().get(0); return addressEndpointGroupId.equals(existingEndpointGroupId); }
public static AddressEndpointKey addressEndpointKey(RendererEndpointKey fromKey) { return new AddressEndpointKey(fromKey.getAddress(), fromKey.getAddressType(), fromKey.getContextId(), fromKey.getContextType()); }
private void processDeletedEN(EndpointNetwork en, WriteTransaction wtx) { for (AddressEndpoint endpoint : endpoints) { if (endpoint.getContextType().isAssignableFrom(L3Context.class) && endpoint.getContextId().equals(en.getL3ContextId()) && endpoint.getAddressType().isAssignableFrom(IpPrefixType.class) && NetUtils.samePrefix(new IpPrefix(endpoint.getAddress().toCharArray()), en.getIpPrefix())) { InstanceIdentifier<AbsoluteLocation> iid = IidFactory .providerAddressEndpointLocationIid(NE_LOCATION_PROVIDER_NAME, IpPrefixType.class, endpoint.getAddress(), endpoint.getContextType(), endpoint.getContextId()) .child(AbsoluteLocation.class); wtx.delete(LogicalDatastoreType.CONFIGURATION, iid); LOG.debug("Location deleted for endpoint {}", endpoint); } } return; }
@Override public Entry<Class<? extends Augmentation<AddressEndpointWithLocation>>, Augmentation<AddressEndpointWithLocation>> buildAddressEndpointWithLocationAugmentation( AddressEndpoint input) { final EpPolicyTemplateValueKey templateValueKey = epPolicyTemplateKeyFactory.createKey( input.getTenant(), input.getEndpointGroup(), input.getCondition()); final Collection<EndpointPolicyTemplateBySgt> epPolicyTemplates = epPolicyTemplateDao.readBy(templateValueKey); final Entry<Class<? extends Augmentation<AddressEndpointWithLocation>>, Augmentation<AddressEndpointWithLocation>> entry; if (epPolicyTemplates.isEmpty()) { entry = null; } else { //TODO: cover case when multiple templates found final Augmentation<AddressEndpointWithLocation> addressEndpointWithLocationAug = new AddressEndpointWithLocationAugBuilder() .setSgt(Iterables.getFirst(epPolicyTemplates, null).getSgt()) .build(); entry = new AbstractMap.SimpleEntry<>(AddressEndpointWithLocationAug.class, addressEndpointWithLocationAug); } return entry; }
private void processCreatedEN(EndpointNetwork en, InstanceIdentifier<?> nodeIID, String connectorIID, WriteTransaction wtx) { for (AddressEndpoint endpoint : endpoints) { if (endpoint.getContextType().isAssignableFrom(L3Context.class) && endpoint.getContextId().equals(en.getL3ContextId()) && endpoint.getAddressType().isAssignableFrom(IpPrefixType.class) && NetUtils.samePrefix(new IpPrefix(endpoint.getAddress().toCharArray()), en.getIpPrefix())) { InstanceIdentifier<AbsoluteLocation> iid = IidFactory .providerAddressEndpointLocationIid(NE_LOCATION_PROVIDER_NAME, IpPrefixType.class, endpoint.getAddress(), endpoint.getContextType(), endpoint.getContextId()) .child(AbsoluteLocation.class); wtx.put(LogicalDatastoreType.CONFIGURATION, iid, createRealLocation(nodeIID, connectorIID), true); LOG.debug("New location created for endpoint {}", endpoint); } } return; }
private CheckedFuture<Optional<AddressEndpoint>, ReadFailedException> findExistingEndPoint(final ContextId containment, final String address) { KeyedInstanceIdentifier<AddressEndpoint, AddressEndpointKey> addressEndpointPath = InstanceIdentifier.create(Endpoints.class).child(AddressEndpoints.class).child(AddressEndpoint.class, new AddressEndpointKey(address, IpPrefixType.class, containment, L3Context.class)); final ReadOnlyTransaction rTx = dataBroker.newReadOnlyTransaction(); final CheckedFuture<Optional<AddressEndpoint>, ReadFailedException> read = rTx.read( LogicalDatastoreType.OPERATIONAL, addressEndpointPath); Futures.addCallback(read, SxpListenerUtil.createTxCloseCallback(rTx)); return read; }
public static BaseEndpointByPort createBaseEndpointByPort(AddressEndpointKey addrEpKey, UniqueId portId) { return new BaseEndpointByPortBuilder().setPortId(portId) .setAddressType(addrEpKey.getAddressType()) .setAddress(addrEpKey.getAddress()) .setContextType(addrEpKey.getContextType()) .setContextId(addrEpKey.getContextId()) .build(); }
private void removeLocationForEndpoint(AddressEndpoint endpoint, WriteTransaction wtx) { for (NetworkElement ne : nullToEmpty(networkElements.getNetworkElement())) { for (Interface iface : nullToEmpty(ne.getInterface())) { for (EndpointNetwork en : nullToEmpty(iface.getEndpointNetwork())) { if (endpoint.getContextType().isAssignableFrom(L3Context.class) && endpoint.getContextId().equals(en.getL3ContextId()) && endpoint.getAddressType().isAssignableFrom(IpPrefixType.class) && NetUtils .samePrefix(new IpPrefix(endpoint.getAddress().toCharArray()), en.getIpPrefix())) { InstanceIdentifier<AbsoluteLocation> iid = IidFactory .providerAddressEndpointLocationIid(NE_LOCATION_PROVIDER_NAME, IpPrefixType.class, endpoint.getAddress(), endpoint.getContextType(), endpoint.getContextId()) .child(AbsoluteLocation.class); wtx.delete(LogicalDatastoreType.CONFIGURATION, iid); LOG.debug("Location deleted for endpoint {}", endpoint); return; } } } } }
private void registerBaseEndpointAndStoreMapping(List<AddressEndpointReg> addrEpRegs, Port port, WriteTransaction wTx) { RegisterEndpointInput regBaseEpInput = new RegisterEndpointInputBuilder().setAddressEndpointReg(addrEpRegs) .build(); boolean isRegisteredBaseEndpoint = epRegistrator.registerEndpoint(regBaseEpInput); if (!isRegisteredBaseEndpoint) { LOG.error("Failed to register an address endpoint: {}", addrEpRegs); return; } for (AddressEndpointReg addrEpReg : addrEpRegs) { if (MappingUtils.L2_BRDIGE_DOMAIN.equals(addrEpReg.getContextType())) { UniqueId portId = new UniqueId(port.getUuid().getValue()); LOG.trace("Adding Port-BaseEndpoint mapping for port {} (device owner {}) and endpoint {}", port.getUuid()); AddressEndpointKey addrEpKey = new AddressEndpointKey(addrEpReg.getAddress(), addrEpReg.getAddressType(), addrEpReg.getContextId(), addrEpReg.getContextType()); addBaseEndpointMappings(addrEpKey, portId, wTx); } } }
private void createLocationForEndpoint(AddressEndpoint endpoint, WriteTransaction wtx) { for (NetworkElement ne : nullToEmpty(networkElements.getNetworkElement())) { for (Interface iface : nullToEmpty(ne.getInterface())) { for (EndpointNetwork en : nullToEmpty(iface.getEndpointNetwork())) { if (endpoint.getContextType().isAssignableFrom(L3Context.class) && endpoint.getContextId().equals(en.getL3ContextId()) && endpoint.getAddressType().isAssignableFrom(IpPrefixType.class) && NetUtils .samePrefix(new IpPrefix(endpoint.getAddress().toCharArray()), en.getIpPrefix())) { InstanceIdentifier<AbsoluteLocation> iid = IidFactory .providerAddressEndpointLocationIid(NE_LOCATION_PROVIDER_NAME, IpPrefixType.class, endpoint.getAddress(), endpoint.getContextType(), endpoint.getContextId()) .child(AbsoluteLocation.class); wtx.put(LogicalDatastoreType.CONFIGURATION, iid, createRealLocation(ne.getIid(), iface.getIid()), true); LOG.debug("New location created for endpoint {}", endpoint); return; } } } } }
rwTx.merge(LogicalDatastoreType.CONFIGURATION, L2L3IidFactory.subnetIid(tenantId, subnetDomain.getNetworkDomainId()), subnetDomain); AddressEndpointKey addrEpKey = new AddressEndpointKey(port.getMacAddress().getValue(), MacAddressType.class, new ContextId(port.getNetworkId().getValue()), MappingUtils.L2_BRDIGE_DOMAIN); UniqueId portId = new UniqueId(port.getUuid().getValue());