import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ScheduledExecutorService;
+import javax.annotation.Nullable;
+
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.NotificationService;
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-import org.opendaylight.groupbasedpolicy.endpoint.EpKey;
+import org.opendaylight.groupbasedpolicy.dto.EgKey;
+import org.opendaylight.groupbasedpolicy.dto.EpKey;
+import org.opendaylight.groupbasedpolicy.dto.IndexedTenant;
import org.opendaylight.groupbasedpolicy.renderer.ofoverlay.EndpointListener;
import org.opendaylight.groupbasedpolicy.renderer.ofoverlay.arp.ArpTasker;
import org.opendaylight.groupbasedpolicy.renderer.ofoverlay.node.SwitchManager;
-import org.opendaylight.groupbasedpolicy.resolver.EgKey;
-import org.opendaylight.groupbasedpolicy.resolver.IndexedTenant;
import org.opendaylight.groupbasedpolicy.util.DataStoreHelper;
import org.opendaylight.groupbasedpolicy.util.IidFactory;
import org.opendaylight.groupbasedpolicy.util.SetUtils;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ConditionName;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.EndpointGroupId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.TenantId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.EndpointFields;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.Endpoints;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoint.fields.L3Address;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoint.fields.L3AddressBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3Prefix;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.ofoverlay.rev140528.EndpointLocation;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.ofoverlay.rev140528.EndpointLocation.LocationType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.l3endpoint.rev151217.NatAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.ofoverlay.rev140528.OfOverlayConfig;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.ofoverlay.rev140528.OfOverlayContext;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.ofoverlay.rev140528.OfOverlayContextBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.ofoverlay.rev140528.OfOverlayL3Context;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.ofoverlay.rev140528.OfOverlayL3Nat;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.ofoverlay.rev140528.napt.translations.fields.napt.translations.NaptTranslation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.Tenant;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.L2BridgeDomain;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.L3Context;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.forwarding.context.L2BridgeDomain;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.forwarding.context.L3Context;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.ExternalImplicitGroup;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.slf4j.Logger;
private final EndpointManagerListener endpointListener;
private final ConcurrentHashMap<EpKey, Endpoint> endpoints = new ConcurrentHashMap<>();
private final ConcurrentHashMap<EpKey, Endpoint> externalEndpointsWithoutLocation = new ConcurrentHashMap<>();
- private final ConcurrentHashMap<NodeId, ConcurrentMap<EgKey, Set<EpKey>>> endpointsByGroupByNode = new ConcurrentHashMap<>();
+ private final ConcurrentHashMap<NodeId, ConcurrentMap<EgKey, Set<EpKey>>> endpointsByGroupByNode =
+ new ConcurrentHashMap<>();
private final ConcurrentHashMap<NodeId, Set<EpKey>> endpointsByNode = new ConcurrentHashMap<>();
private final ConcurrentHashMap<EgKey, Set<EpKey>> endpointsByGroup = new ConcurrentHashMap<>();
private final ScheduledExecutorService executor;
}
};
- public EndpointManager(DataBroker dataProvider, RpcProviderRegistry rpcRegistry, NotificationService notificationService, ScheduledExecutorService executor,
- SwitchManager switchManager) {
+ public EndpointManager(DataBroker dataProvider, RpcProviderRegistry rpcRegistry,
+ NotificationService notificationService, ScheduledExecutorService executor, SwitchManager switchManager) {
this.executor = executor;
this.dataProvider = dataProvider;
if (rpcRegistry != null) {
* Get the endpoints in a particular group on a particular node
*
* @param nodeId - the node ID to look up
- * @param eg - the group to look up
+ * @param eg - the group to look up
* @return the endpoints
*/
public synchronized Collection<Endpoint> getEndpointsForNode(NodeId nodeId, EgKey eg) {
*/
public synchronized Collection<Endpoint> getExtEpsNoLocForGroup(final EgKey eg) {
- return ImmutableSet.copyOf(Collections2.filter(externalEndpointsWithoutLocation.values(),
- new Predicate<Endpoint>() {
-
- @Override
- public boolean apply(Endpoint input) {
- Set<EndpointGroupId> epgIds = new HashSet<>();
- if (input.getEndpointGroup() != null) {
- epgIds.add(input.getEndpointGroup());
- }
- if (input.getEndpointGroups() != null) {
- epgIds.addAll(input.getEndpointGroups());
- }
- if (epgIds.isEmpty()) {
- LOG.error("No EPGs for {}. This is not a valid Endpoint.", input.getKey());
- return false;
- }
- return (epgIds.contains(eg.getEgId()));
+ return ImmutableSet
+ .copyOf(Collections2.filter(externalEndpointsWithoutLocation.values(), new Predicate<Endpoint>() {
+
+ @Override
+ public boolean apply(Endpoint input) {
+ Set<EndpointGroupId> epgIds = new HashSet<>();
+ if (input.getEndpointGroup() != null) {
+ epgIds.add(input.getEndpointGroup());
+ }
+ if (input.getEndpointGroups() != null) {
+ epgIds.addAll(input.getEndpointGroups());
+ }
+ if (epgIds.isEmpty()) {
+ LOG.error("No EPGs for {}. This is not a valid Endpoint.", input.getKey());
+ return false;
}
+ return (epgIds.contains(eg.getEgId()));
+ }
- }));
+ }));
}
/**
*/
protected synchronized void processL3Endpoint(EndpointL3 oldL3Ep, EndpointL3 newL3Ep) {
// TODO Bug 3543
- //create L3 endpoint
+ // create L3 endpoint
if (oldL3Ep == null && newL3Ep != null) {
createL3Endpoint(newL3Ep);
}
- //update L3 endpoint
+ // update L3 endpoint
if (oldL3Ep != null && newL3Ep != null) {
updateL3Endpoint(newL3Ep);
}
- //remove L3 endpoint
+ // remove L3 endpoint
if (oldL3Ep != null && newL3Ep == null) {
removeL3Endpoint(oldL3Ep);
}
boolean notifyOldEg = false;
boolean notifyNewEg = false;
- //maintain external endpoints map
- if (newLoc == null && oldLoc == null) {
- if (newEp != null && newEpKey != null) {
+ // create endpoint
+ if (oldEp == null && newEp != null) {
+ if (newLoc != null) {
+ createEndpoint(newLoc, newEpKey, newEpgIds, tenantId);
+ endpoints.put(newEpKey, newEp);
+ notifyEndpointUpdated(newEpKey);
+ notifyNewLoc = true;
+ notifyNewEg = true;
+ } else {
externalEndpointsWithoutLocation.put(newEpKey, newEp);
}
- if (oldEp != null && oldEpKey != null) {
- externalEndpointsWithoutLocation.remove(oldEpKey);
- }
- return;
- }
-
- //maintain endpoint maps
- //new endpoint
- if (newEp != null && newEpKey != null) {
- endpoints.put(newEpKey, newEp);
- notifyEndpointUpdated(newEpKey);
- }
- //odl endpoint
- else if (oldEpKey != null) {
- endpoints.remove(oldEpKey);
- notifyEndpointUpdated(oldEpKey);
- }
-
- //create endpoint
- if (oldEp == null && newEp != null && newLoc != null) {
- createEndpoint(newLoc, newEpKey, newEpgIds, tenantId);
- notifyNewLoc = true;
- notifyNewEg = true;
}
- //update endpoint
- if (oldEp != null && newEp != null && oldEpKey != null && newEpKey != null &&
- newLoc != null && (oldEpKey.toString().equals(newEpKey.toString()))) {
-
- //endpoint was moved, new location exists but is different from old one
- if (oldLoc != null && !(oldLoc.getValue().equals(newLoc.getValue()))) {
- //remove old endpoint
+ // update endpoint
+ else if (oldEp != null && newEp != null && oldEpKey != null && newEpKey != null) {
+ // endpoint is not external anymore
+ if (newLoc != null && oldLoc == null) {
+ createEndpoint(newLoc, newEpKey, newEpgIds, tenantId);
+ externalEndpointsWithoutLocation.remove(oldEpKey);
+ endpoints.put(newEpKey, newEp);
+ notifyEndpointUpdated(newEpKey);
+ notifyNewLoc = true;
+ notifyNewEg = true;
+ }
+ // endpoint changed to external
+ else if (newLoc == null && oldLoc != null) {
removeEndpoint(oldEp, oldLoc, oldEpKey, oldEpgIds);
+ externalEndpointsWithoutLocation.put(newEpKey, newEp);
+ endpoints.remove(oldEpKey);
+ notifyEndpointUpdated(oldEpKey);
notifyOldLoc = true;
notifyOldEg = true;
+ // endpoint might have changed location, EPGs or it's properties
+ } else if (newLoc != null && oldLoc != null) {
+ // endpoit changed location
+ if (!(oldLoc.getValue().equals(newLoc.getValue()))) {
+ notifyOldLoc = true;
+ notifyNewLoc = true;
+ }
+ // endpoint changed EPGs
+ if (!oldEpgIds.equals(newEpgIds)) {
+ notifyOldEg = true;
+ notifyNewEg = true;
+ }
+ removeEndpoint(oldEp, oldLoc, oldEpKey, oldEpgIds);
+ createEndpoint(newLoc, newEpKey, newEpgIds, tenantId);
+ notifyEndpointUpdated(newEpKey);
}
- //add moved endpoint
- createEndpoint(newLoc, newEpKey, newEpgIds, tenantId);
- notifyNewLoc = true;
- notifyNewEg = true;
}
- //remove endpoint
- if (oldEp != null && newEp == null) {
- removeEndpoint(oldEp, oldLoc, oldEpKey, oldEpgIds);
- notifyOldLoc = true;
- notifyOldEg = true;
+ // remove endpoint
+ else if (oldEp != null && newEp == null) {
+ if (oldLoc != null) {
+ removeEndpoint(oldEp, oldLoc, oldEpKey, oldEpgIds);
+ endpoints.remove(oldEpKey);
+ notifyEndpointUpdated(oldEpKey);
+ notifyOldLoc = true;
+ notifyOldEg = true;
+ } else {
+ externalEndpointsWithoutLocation.remove(oldEpKey);
+ }
}
- //notifications
+ // notifications
if (notifyOldLoc)
notifyNodeEndpointUpdated(oldLoc, oldEpKey);
if (notifyNewLoc)
}
}
- // Update endpointsByGroupByNode and endpointsByGroup, get map of EPGs and their Endpoints for Node
+ // Update endpointsByGroupByNode and endpointsByGroup, get map of EPGs and their Endpoints
+ // for Node
ConcurrentMap<EgKey, Set<EpKey>> map = endpointsByGroupByNode.get(oldLoc);
for (EndpointGroupId oldEpgId : oldEpgIds) {
// endpointsByGroupByNode
private void createL3Endpoint(EndpointL3 newL3Ep) {
LOG.trace("Processing L3Endpoint {}", newL3Ep.getKey());
if (isValidL3Ep(newL3Ep)) {
- if (newL3Ep.getMacAddress() == null && getLocationType(newL3Ep) != null
- && getLocationType(newL3Ep).equals(LocationType.External)) {
+ if (newL3Ep.getMacAddress() == null) {
if (newL3Ep.getNetworkContainment() != null) {
arpTasker.addMacForL3EpAndCreateEp(newL3Ep);
} else {
}
- //auto closeable
+ // auto closeable
@Override
public void close() throws Exception {
if (endpointListener != null)
return SetUtils.getNestedSet(eg, map);
}
- protected boolean isInternal(Endpoint ep) {
+ /**
+ * An endpoint is external if its endpoint-group is external implicit group.
+ *
+ * @param ep an endpoint
+ * @param eigs external implicit groups
+ * @return {@code true} if the given endpoint has EPG representing external implicit group;
+ * {@code false} otherwise
+ * @throws NullPointerException if the given endpoint is {@code null}
+ * @throws IllegalArgumentException if the given endpoint does not contain any endpoint-group
+ */
+ public static boolean isExternal(Endpoint ep, @Nullable Collection<ExternalImplicitGroup> eigs) {
+ return !isInternal(ep, eigs);
+ }
+
+ /**
+ * An endpoint is internal if none of its endpoint-groups is external implicit group.
+ *
+ * @param ep an endpoint
+ * @param eigs external implicit groups
+ * @return {@code true} if the given endpoint does not have EPG representing external implicit
+ * group;
+ * {@code false} otherwise
+ * @throws NullPointerException if the given endpoint is {@code null}
+ * @throws IllegalArgumentException if the given endpoint does not contain any endpoint-group
+ */
+ public static boolean isInternal(Endpoint ep, @Nullable Collection<ExternalImplicitGroup> eigs) {
Preconditions.checkNotNull(ep);
- OfOverlayContext ofc = ep.getAugmentation(OfOverlayContext.class);
- return ofc == null || ofc.getLocationType() == null || ofc.getLocationType().equals(EndpointLocation.LocationType.Internal);
+ if (eigs == null || eigs.isEmpty()) {
+ return true;
+ }
+ Set<EndpointGroupId> epgs = getEpgs(ep);
+ Preconditions.checkArgument(!epgs.isEmpty());
+ for (EndpointGroupId epg : epgs) {
+ for (ExternalImplicitGroup eig : eigs) {
+ if (epg.equals(eig.getId())) {
+ return false;
+ }
+ }
+ }
+ return true;
}
- public boolean isExternal(Endpoint ep) {
- return !isInternal(ep);
+ private static Set<EndpointGroupId> getEpgs(EndpointFields ep) {
+ EndpointGroupId epgId = ep.getEndpointGroup();
+ List<EndpointGroupId> epgsId = ep.getEndpointGroups();
+ Set<EndpointGroupId> result = new HashSet<>();
+ if (epgId != null) {
+ result.add(epgId);
+ }
+ if (epgsId != null) {
+ result.addAll(epgsId);
+ }
+ return result;
}
/**
* Get the endpoints container from data store.
* Note: There are maps maintained by listener when higher performance is required.
*
- * @return the {@link org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.Endpoints}
+ * @return the
+ * {@link org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.Endpoints}
*/
protected Endpoints getEndpointsFromDataStore() {
/*
return null;
}
ReadOnlyTransaction rTx = dataProvider.newReadOnlyTransaction();
- Optional<Endpoints> endpoints = DataStoreHelper.readFromDs(LogicalDatastoreType.OPERATIONAL,
- IidFactory.endpointsIidWildcard(), rTx);
+ Optional<Endpoints> endpoints =
+ DataStoreHelper.readFromDs(LogicalDatastoreType.OPERATIONAL, IidFactory.endpointsIidWildcard(), rTx);
if (!endpoints.isPresent()) {
LOG.warn("No Endpoints present in data store.");
return null;
/**
* Return all L3Endpoints from data store.
*
- * @return the {@link org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3}
+ * @return the
+ * {@link org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3}
*/
protected Collection<EndpointL3> getL3Endpoints() {
Endpoints endpoints = getEndpointsFromDataStore();
/**
* Return all L3Prefix Endpoints from data store.
*
- * @return the {@link org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3Prefix}
+ * @return the
+ * {@link org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3Prefix}
*/
private Collection<EndpointL3Prefix> getEndpointsL3Prefix() {
Endpoints endpoints = getEndpointsFromDataStore();
/**
* Return all L3Prefix Endpoints which come under particular tenant
*
- * @param tenantId - the {@link org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.TenantId} to resolve
- * @return the {@link org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3Prefix}
+ * @param tenantId - the
+ * {@link org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.TenantId}
+ * to resolve
+ * @return the
+ * {@link org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3Prefix}
*/
public Collection<EndpointL3Prefix> getEndpointsL3PrefixForTenant(final TenantId tenantId) {
Collection<EndpointL3Prefix> l3PrefixEndpoints = getEndpointsL3Prefix();
/**
* Return all L3Endpoints containing network and port address translation in augmentation
*
- * @return the {@link org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3}
+ * @return the
+ * {@link org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3}
*/
public Collection<EndpointL3> getL3EndpointsWithNat() {
Collection<EndpointL3> l3Endpoints = getL3Endpoints();
@Override
public boolean apply(EndpointL3 input) {
- return !((input.getAugmentation(OfOverlayL3Nat.class) == null)
- || (input.getAugmentation(OfOverlayL3Nat.class).getNaptTranslations() == null)
- || (input.getAugmentation(OfOverlayL3Nat.class).getNaptTranslations().getNaptTranslation() == null));
+ return !((input.getAugmentation(NatAddress.class) == null)
+ || (input.getAugmentation(NatAddress.class).getNatAddress() == null));
}
});
if (l3Endpoints == null) {
return ImmutableSet.copyOf(l3Endpoints);
}
- /**
- * Return NAPT of concrete endpoint
- *
- * @param endpointL3 - the {@link org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3} to resolve
- * @return the {@link org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.Endpoint}
- */
- public List<NaptTranslation> getNaptAugL3Endpoint(EndpointL3 endpointL3) {
- if ((endpointL3.getAugmentation(OfOverlayL3Nat.class) == null)
- || (endpointL3.getAugmentation(OfOverlayL3Nat.class).getNaptTranslations() == null)
- || (endpointL3.getAugmentation(OfOverlayL3Nat.class).getNaptTranslations().getNaptTranslation() == null)) {
- return null;
- }
- return endpointL3.getAugmentation(OfOverlayL3Nat.class).getNaptTranslations().getNaptTranslation();
- }
-
/**
* Set the learning mode to the specified value
*
* directly represented in the endpoint object
* set
*
- * @param endpoint - the {@link org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.Endpoint} to resolve
- * @return the list of {@link org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ConditionName}
+ * @param endpoint - the
+ * {@link org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.Endpoint}
+ * to resolve
+ * @return the list of
+ * {@link org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ConditionName}
*/
public List<ConditionName> getConditionsForEndpoint(Endpoint endpoint) {
// TODO Be alagalah From Helium: consider group conditions as well. Also
return egKeys;
}
- private EndpointLocation.LocationType getLocationType(EndpointL3 epL3) {
- if (epL3 == null || epL3.getAugmentation(OfOverlayL3Context.class) == null
- || epL3.getAugmentation(OfOverlayL3Context.class).getLocationType() == null) {
- return null;
- }
- return epL3.getAugmentation(OfOverlayL3Context.class).getLocationType();
- }
-
@SuppressWarnings("unused")
private Endpoint addEndpointFromL3Endpoint(EndpointL3 l3Ep, ReadWriteTransaction rwTx) {
// Make an indexed tenant and resolveL2BridgeDomain from L3EP containment if not L3
// (instanceof)
OfOverlayL3Context ofL3Ctx = l3Ep.getAugmentation(OfOverlayL3Context.class);
- OfOverlayContext ofCtx = getOfOverlayContextFromL3Endpoint(ofL3Ctx);
+ OfOverlayContext ofCtx = new OfOverlayContextBuilder(ofL3Ctx).build();
if (l3Ep.getNetworkContainment() instanceof L3Context) {
LOG.error("Cannot generate Endpoint from EndpointL3, network containment is L3Context.");
rwTx.cancel();
}
IndexedTenant indexedTenant;
- Optional<Tenant> tenant = readFromDs(LogicalDatastoreType.CONFIGURATION,
- IidFactory.tenantIid(l3Ep.getTenant()), rwTx);
+ Optional<Tenant> tenant =
+ readFromDs(LogicalDatastoreType.CONFIGURATION, IidFactory.tenantIid(l3Ep.getTenant()), rwTx);
if (tenant.isPresent()) {
indexedTenant = new IndexedTenant(tenant.get());
} else {
}
List<L3Address> l3Address = new ArrayList<>();
l3Address.add(new L3AddressBuilder().setIpAddress(l3Ep.getIpAddress())
- .setL3Context(l3Ep.getL3Context())
- .setKey(new L3AddressKey(l3Ep.getIpAddress(), l3Ep.getL3Context()))
- .build());
+ .setL3Context(l3Ep.getL3Context())
+ .setKey(new L3AddressKey(l3Ep.getIpAddress(), l3Ep.getL3Context()))
+ .build());
L2BridgeDomain l2Bd = indexedTenant.resolveL2BridgeDomain(l3Ep.getNetworkContainment());
Endpoint ep = new EndpointBuilder().setKey(new EndpointKey(l2Bd.getId(), l3Ep.getMacAddress()))
- .setMacAddress(l3Ep.getMacAddress())
- .setL2Context(l2Bd.getId())
- .setEndpointGroups(l3Ep.getEndpointGroups())
- .setTenant(l3Ep.getTenant())
- .setL3Address(l3Address)
- .setCondition(l3Ep.getCondition())
- .setNetworkContainment(l3Ep.getNetworkContainment())
- .addAugmentation(OfOverlayContext.class, ofCtx)
- .build();
+ .setMacAddress(l3Ep.getMacAddress())
+ .setL2Context(l2Bd.getId())
+ .setEndpointGroups(l3Ep.getEndpointGroups())
+ .setTenant(l3Ep.getTenant())
+ .setL3Address(l3Address)
+ .setCondition(l3Ep.getCondition())
+ .setNetworkContainment(l3Ep.getNetworkContainment())
+ .addAugmentation(OfOverlayContext.class, ofCtx)
+ .build();
rwTx.put(LogicalDatastoreType.OPERATIONAL, IidFactory.endpointIid(ep.getL2Context(), ep.getMacAddress()), ep);
return ep;
}
- private OfOverlayContext getOfOverlayContextFromL3Endpoint(OfOverlayL3Context ofL3Ctx) {
- OfOverlayContextBuilder ofBuilder = new OfOverlayContextBuilder();
- if (ofL3Ctx.getInterfaceId() != null) {
- ofBuilder.setInterfaceId(ofL3Ctx.getInterfaceId());
- }
- if (ofL3Ctx.getLocationType() != null) {
- ofBuilder.setLocationType(ofL3Ctx.getLocationType());
- }
- if (ofL3Ctx.getNodeConnectorId() != null) {
- ofBuilder.setNodeConnectorId(ofL3Ctx.getNodeConnectorId());
- }
- if (ofL3Ctx.getNodeId() != null) {
- ofBuilder.setNodeId(ofL3Ctx.getNodeId());
- }
- if (ofL3Ctx.getPortName() != null) {
- ofBuilder.setPortName(ofL3Ctx.getPortName());
- }
-
- return ofBuilder.build();
- }
-
private Set<EndpointGroupId> getEndpointGroupsFromEndpoint(Endpoint ep) {
if (ep == null)
return new HashSet<>();