import javax.annotation.Nonnull;
import javax.annotation.Nullable;
+import org.opendaylight.groupbasedpolicy.api.EndpointAugmentor;
import org.opendaylight.groupbasedpolicy.api.NetworkDomainAugmentor;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.endpoint.locations.AddressEndpointLocation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.endpoint.locations.ContainmentEndpointLocation;
}
public Endpoints buildEndoints(EndpointInfo epInfo, EndpointLocationInfo epLocInfo,
- Map<InstanceIdentifier<?>, RendererName> rendererByNode) {
+ Map<InstanceIdentifier<?>, RendererName> rendererByNode, Set<EndpointAugmentor> augmentors) {
List<AddressEndpointWithLocation> epsWithLoc =
- resolveEpsWithLoc(getAddressEndpointKeys(), epInfo, epLocInfo, rendererByNode);
+ resolveEpsWithLoc(getAddressEndpointKeys(), epInfo, epLocInfo, rendererByNode, augmentors);
List<ContainmentEndpointWithLocation> contEpsWithLoc =
- resolveContEpsWithLoc(getContainmentEndpointKeys(), epInfo, epLocInfo);
+ resolveContEpsWithLoc(getContainmentEndpointKeys(), epInfo, epLocInfo, augmentors);
return new EndpointsBuilder().setAddressEndpointWithLocation(epsWithLoc)
.setContainmentEndpointWithLocation(contEpsWithLoc)
.build();
private static List<AddressEndpointWithLocation> resolveEpsWithLoc(Set<AddressEndpointKey> epKeys,
EndpointInfo epInfo, EndpointLocationInfo epLocInfo,
- Map<InstanceIdentifier<?>, RendererName> rendererByNode) {
+ Map<InstanceIdentifier<?>, RendererName> rendererByNode, Set<EndpointAugmentor> augmentors) {
List<AddressEndpointWithLocation> result = new ArrayList<>();
for (AddressEndpointKey epKey : epKeys) {
Optional<AddressEndpoint> potentialEp = epInfo.getEndpoint(epKey);
Optional<AddressEndpointLocation> potentionalEpLoc = epLocInfo.getAdressEndpointLocation(epKey);
Preconditions.checkArgument(potentionalEpLoc.isPresent());
RendererName rendererName = resolveRendererName(potentionalEpLoc.get(), rendererByNode);
- result.add(createEpWithLoc(potentialEp.get(), potentionalEpLoc.get(), rendererName));
+ result.add(createEpWithLoc(potentialEp.get(), potentionalEpLoc.get(), rendererName, augmentors));
}
return result;
}
}
private static AddressEndpointWithLocation createEpWithLoc(AddressEndpoint ep, AddressEndpointLocation epLoc,
- RendererName rendererName) {
- return new AddressEndpointWithLocationBuilder().setAddress(ep.getAddress())
+ RendererName rendererName, Set<EndpointAugmentor> augmentors) {
+ AddressEndpointWithLocationBuilder addrEpWithLoc = new AddressEndpointWithLocationBuilder()
+ .setAddress(ep.getAddress())
.setAddressType(ep.getAddressType())
.setContextId(ep.getContextId())
.setContextType(ep.getContextType())
.setTimestamp(ep.getTimestamp())
.setAbsoluteLocation(epLoc.getAbsoluteLocation())
.setRelativeLocations(epLoc.getRelativeLocations())
- .setRendererName(rendererName)
- .build();
+ .setRendererName(rendererName);
+ for (EndpointAugmentor augmentor : augmentors) {
+ Entry<Class<? extends Augmentation<AddressEndpointWithLocation>>, Augmentation<AddressEndpointWithLocation>> addrEpWithLocAug =
+ augmentor.buildAddressEndpointWithLocationAugmentation(ep);
+ if (addrEpWithLocAug != null) {
+ addrEpWithLoc.addAugmentation(addrEpWithLocAug.getKey(), addrEpWithLocAug.getValue());
+ }
+ }
+ return addrEpWithLoc.build();
}
private static List<ContainmentEndpointWithLocation> resolveContEpsWithLoc(Set<ContainmentEndpointKey> contEpKeys,
- EndpointInfo epInfo, EndpointLocationInfo epLocInfo) {
+ EndpointInfo epInfo, EndpointLocationInfo epLocInfo, Set<EndpointAugmentor> augmentors) {
List<ContainmentEndpointWithLocation> result = new ArrayList<>();
for (ContainmentEndpointKey contEpKey : contEpKeys) {
Optional<ContainmentEndpoint> potentialContEp = epInfo.getContainmentEndpoint(contEpKey);
Optional<ContainmentEndpointLocation> potentialContEpLoc =
epLocInfo.getContainmentEndpointLocation(contEpKey);
Preconditions.checkArgument(potentialContEpLoc.isPresent());
- result.add(createContEpWithLoc(potentialContEp.get(), potentialContEpLoc.get()));
+ result.add(createContEpWithLoc(potentialContEp.get(), potentialContEpLoc.get(), augmentors));
}
return result;
}
private static ContainmentEndpointWithLocation createContEpWithLoc(ContainmentEndpoint contEp,
- ContainmentEndpointLocation contEpLoc) {
- return new ContainmentEndpointWithLocationBuilder().setContextId(contEp.getContextId())
+ ContainmentEndpointLocation contEpLoc, Set<EndpointAugmentor> augmentors) {
+ ContainmentEndpointWithLocationBuilder contEpWithLoc = new ContainmentEndpointWithLocationBuilder()
+ .setContextId(contEp.getContextId())
.setContextType(contEp.getContextType())
.setTenant(contEp.getTenant())
.setChildEndpoint(contEp.getChildEndpoint())
.setCondition(contEp.getCondition())
.setNetworkContainment(contEp.getNetworkContainment())
.setTimestamp(contEp.getTimestamp())
- .setRelativeLocations(contEpLoc.getRelativeLocations())
- .build();
+ .setRelativeLocations(contEpLoc.getRelativeLocations());
+ for (EndpointAugmentor augmentor : augmentors) {
+ Entry<Class<? extends Augmentation<ContainmentEndpointWithLocation>>, Augmentation<ContainmentEndpointWithLocation>> contEpWithLocAug =
+ augmentor.buildContainmentEndpointWithLocationAugmentation(contEp);
+ if (contEpWithLocAug != null) {
+ contEpWithLoc.addAugmentation(contEpWithLocAug.getKey(), contEpWithLocAug.getValue());
+ }
+ }
+ return contEpWithLoc.build();
}
public RuleGroups buildRuluGroups(ResolvedPolicyInfo policyInfo) {
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.groupbasedpolicy.base_endpoint.EndpointAugmentorRegistryImpl;
import org.opendaylight.groupbasedpolicy.dto.ConsEpgKey;
import org.opendaylight.groupbasedpolicy.dto.EpgKeyDto;
import org.opendaylight.groupbasedpolicy.dto.ProvEpgKey;
private final DataBroker dataProvider;
private final NetworkDomainAugmentorRegistryImpl netDomainAugmentorRegistry;
+ private final EndpointAugmentorRegistryImpl epAugmentorRegistry;
private final Set<RendererName> processingRenderers = new HashSet<>();
private Map<InstanceIdentifier<?>, RendererName> rendererByNode = new HashMap<>();
private ResolvedPolicyInfo policyInfo;
private final ForwardingListener forwardingListener;
private final RenderersListener renderersListener;
- public RendererManager(DataBroker dataProvider, NetworkDomainAugmentorRegistryImpl netDomainAugmentorRegistry) {
+ public RendererManager(DataBroker dataProvider, NetworkDomainAugmentorRegistryImpl netDomainAugmentorRegistry,
+ EndpointAugmentorRegistryImpl epAugmentorRegistry) {
this.dataProvider = checkNotNull(dataProvider);
this.netDomainAugmentorRegistry = checkNotNull(netDomainAugmentorRegistry);
+ this.epAugmentorRegistry = checkNotNull(epAugmentorRegistry);
endpointsListener = new EndpointsListener(this, dataProvider);
endpointLocationsListener = new EndpointLocationsListener(this, dataProvider);
resolvedPoliciesListener = new ResolvedPoliciesListener(this, dataProvider);
configBuilder.setRendererEndpoints(rendererEndpoints);
org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.renderer.policy.configuration.Endpoints endpoints =
- rendererPolicyBuilder.buildEndoints(epInfo, epLocInfo, rendererByNode);
+ rendererPolicyBuilder.buildEndoints(epInfo, epLocInfo, rendererByNode, epAugmentorRegistry.getEndpointAugmentors());
configBuilder.setEndpoints(endpoints);
RuleGroups ruleGroups = rendererPolicyBuilder.buildRuluGroups(policyInfo);
configBuilder.setRuleGroups(ruleGroups);
RendererForwarding rendererForwarding = rendererPolicyBuilder.buildRendererForwarding(forwarding,
- netDomainAugmentorRegistry.getEndpointAugmentors());
+ netDomainAugmentorRegistry.getNetworkDomainAugmentors());
configBuilder.setRendererForwarding(rendererForwarding);
return Optional.of(configBuilder.build());
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.groupbasedpolicy.base_endpoint.EndpointAugmentorRegistryImpl;
import org.opendaylight.groupbasedpolicy.forwarding.NetworkDomainAugmentorRegistryImpl;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.EndpointLocations;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.EndpointLocationsBuilder;
@Mock
private NetworkDomainAugmentorRegistryImpl netDomainAugmentorRegistry;
@Mock
+ private EndpointAugmentorRegistryImpl epAugmentorRegistry;
+ @Mock
private WriteTransaction wTx;
@Mock
private CheckedFuture<Void, TransactionCommitFailedException> submitFuture;
public void init() {
Mockito.when(dataProvider.newWriteOnlyTransaction()).thenReturn(wTx);
Mockito.when(wTx.submit()).thenReturn(submitFuture);
- Mockito.when(netDomainAugmentorRegistry.getEndpointAugmentors()).thenReturn(Collections.emptySet());
- rendererManager = new RendererManager(dataProvider, netDomainAugmentorRegistry);
+ Mockito.when(netDomainAugmentorRegistry.getNetworkDomainAugmentors()).thenReturn(Collections.emptySet());
+ Mockito.when(epAugmentorRegistry.getEndpointAugmentors()).thenReturn(Collections.emptySet());
+ rendererManager = new RendererManager(dataProvider, netDomainAugmentorRegistry, epAugmentorRegistry);
RendererManager.resetVersion();
}