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; }
@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 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); }
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; }
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 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; } } } } }