final IpPrefix changeKey = changePath.firstKeyOf(EndpointForwardingTemplateBySubnet.class).getIpPrefix();
SxpListenerUtil.updateCachedDao(templateCachedDao, changeKey, change);
- //TODO: handle removal (now causes NPE)
final EndpointForwardingTemplateBySubnet epForwardingTemplate = change.getRootNode().getDataAfter();
- processWithEPTemplates(epForwardingTemplate);
+ if (epForwardingTemplate == null) {
+ LOG.debug("EPForwarding template removed - NOOP {}", change.getRootNode().getDataBefore());
+ //TODO: handle removal (update cache)
+ } else {
+ processWithEPTemplates(epForwardingTemplate);
+ }
}
}
public ListenableFuture<RpcResult<Void>>
apply(final Optional<Pair<MasterDatabaseBinding, EndpointPolicyTemplateBySgt>> input) throws Exception {
final ListenableFuture<RpcResult<Void>> result;
- if (input == null || !input.isPresent()) {
- LOG.debug("no epPolicyTemplate available for ip-prefix: {}", epForwardingTemplate.getIpPrefix());
+ if (! input.isPresent()) {
+ LOG.debug("no pair [epPolicyTemplate, ip-sgt-binding] available for ip-prefix: {}", epForwardingTemplate.getIpPrefix());
result = Futures.immediateFuture(
RpcResultBuilder.<Void>failed()
.withError(RpcError.ErrorType.APPLICATION,
- "no epForwardingTemplate available for ip-prefix " + epForwardingTemplate.getIpPrefix())
+ "no pair [epPolicyTemplate, ip-sgt-binding] available for ip-prefix " + epForwardingTemplate.getIpPrefix())
.build());
} else {
LOG.trace("processing epForwardingTemplate event for ip-prefix: {}", epForwardingTemplate.getIpPrefix());
final Pair<MasterDatabaseBinding, EndpointPolicyTemplateBySgt> pair = input.get();
final MasterDatabaseBinding sxpMasterDBBinding = pair.getLeft();
final EndpointPolicyTemplateBySgt epPolicyTemplate = pair.getRight();
- LOG.trace("processing epForwardingTemplate event with resolved sxpMasterDb entry and " +
- "epPolicyTemplate for sgt/ip-prefix: {}/{}",
- sxpMasterDBBinding.getSecurityGroupTag(), sxpMasterDBBinding.getImplementedInterface());
- result = sxpMapperReactor.processTemplatesAndSxpMasterDB(epPolicyTemplate, epForwardingTemplate, sxpMasterDBBinding);
+ if (epPolicyTemplate != null && sxpMasterDBBinding != null) {
+ LOG.trace("processing epForwardingTemplate event with resolved sxpMasterDb entry and " +
+ "epPolicyTemplate for sgt/ip-prefix: {}/{}",
+ sxpMasterDBBinding.getSecurityGroupTag(), sxpMasterDBBinding.getImplementedInterface());
+ result = sxpMapperReactor.processTemplatesAndSxpMasterDB(epPolicyTemplate, epForwardingTemplate, sxpMasterDBBinding);
+ } else {
+ LOG.debug("Skipped ep-forwarding-template processing");
+ result = Futures.immediateFuture(RpcResultBuilder.<Void>success().build());
+ }
}
return result;
public ListenableFuture<Optional<Pair<MasterDatabaseBinding, EndpointPolicyTemplateBySgt>>>
apply(final Optional<MasterDatabaseBinding> input) throws Exception {
final ListenableFuture<Pair<MasterDatabaseBinding, EndpointPolicyTemplateBySgt>> result;
- if (input == null || !input.isPresent()) {
+ if (! input.isPresent()) {
LOG.debug("no sxpMasterDB entry available for ip-prefix: {}", epFowardingTemplate.getIpPrefix());
result = Futures.immediateFuture(null);
} else {
final EndpointPolicyTemplateBySgt epPolicyTemplate = change.getRootNode().getDataAfter();
// skip generated template
- if (epPolicyTemplate != null && !TemplateGenerated.class.equals(epPolicyTemplate.getOrigin())) {
+ if (epPolicyTemplate != null && ! TemplateGenerated.class.equals(epPolicyTemplate.getOrigin())) {
processWithEPTemplates(epPolicyTemplate);
} else {
LOG.trace("skipping ep-policy-template processing: {}", epPolicyTemplate);
apply(final List<Pair<MasterDatabaseBinding, EndpointForwardingTemplateBySubnet>> input) throws Exception {
final ListenableFuture<List<RpcResult<Void>>> result;
if (input == null || input.isEmpty()) {
- LOG.debug("no epForwardingTemplate available for sgt: {}", epPolicyTemplate.getSgt());
+ LOG.debug("no pair [epForwardingTemplate, ip-sgt-binding] available for sgt: {}", epPolicyTemplate.getSgt());
result = Futures.immediateFuture(Collections.singletonList(
RpcResultBuilder.<Void>failed()
.withError(RpcError.ErrorType.APPLICATION,
- "no epForwardingTemplate available for sgt " + epPolicyTemplate.getSgt())
+ "no pair [epForwardingTemplate, ip-sgt-binding] available for sgt " + epPolicyTemplate.getSgt())
.build()));
} else {
LOG.trace("processing epPolicyTemplate event for sgt: {}", epPolicyTemplate.getSgt());
import com.google.common.base.Function;
import com.google.common.collect.Range;
+import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.Collection;
private ListenableFuture<Optional<String>> queryIseOnSgt(final IseContext iseContext, @Nonnull final Sgt sgt) {
final ListenableFuture<Collection<SgtInfo>> sgtUpdateFu = iseSgtHarvester.harvestAll(iseContext);
+
+ Futures.addCallback(sgtUpdateFu, new FutureCallback<Collection<SgtInfo>>() {
+ @Override
+ public void onSuccess(@Nullable final Collection<SgtInfo> result) {
+ final Integer amount = Optional.ofNullable(result).map(Collection::size).orElse(0);
+ LOG.debug("[epPolicyTemplateProvider] harvestAll succeeded: {}", amount);
+ }
+
+ @Override
+ public void onFailure(final Throwable t) {
+ LOG.debug("[epPolicyTemplateProvider] harvestAll FAILED: {}", t.getMessage());
+ }
+ });
+
return Futures.transform(sgtUpdateFu, new Function<Collection<SgtInfo>, Optional<String>>() {
@Nullable
@Override
// expected relation (ise : tenant) == (1:1)
return iseContext
.filter(context ->
- Range.closed(context.getIseSourceConfig().getSgtRangeMin().getValue(),
- context.getIseSourceConfig().getSgtRangeMax().getValue())
- .contains(sgt.getValue())
+ context.getIseSourceConfig() != null && Range.closed(
+ context.getIseSourceConfig().getSgtRangeMin().getValue(),
+ context.getIseSourceConfig().getSgtRangeMax().getValue()
+ ).contains(sgt.getValue())
);
}
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.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.groupbasedpolicy.sxp.integration.sxp.ise.adapter.model.rev160630.GbpSxpIseAdapter;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.groupbasedpolicy.sxp.integration.sxp.ise.adapter.model.rev160630.gbp.sxp.ise.adapter.IseHarvestStatus;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.groupbasedpolicy.sxp.integration.sxp.ise.adapter.model.rev160630.gbp.sxp.ise.adapter.IseHarvestStatusBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.groupbasedpolicy.sxp.integration.sxp.ise.adapter.model.rev160630.gbp.sxp.ise.adapter.IseSourceConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.groupbasedpolicy.sxp.integration.sxp.ise.adapter.model.rev160630.gbp.sxp.ise.adapter.ise.source.config.ConnectionConfig;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
final IseContext iseContext = new IseContext(iseSourceConfig);
templateProviderFacade.assignIseContext(iseContext);
if (iseSourceConfig != null) {
+ final Optional<ConnectionConfig> connectionConfig = Optional.ofNullable(iseSourceConfig.getConnectionConfig());
+ LOG.debug("Ise-source config assigned: {} -> {}", iseSourceConfig.getTenant(),
+ connectionConfig.map(ConnectionConfig::getIseRestUrl).orElse(new Uri("n/a")));
pool.submit(() -> {
final ListenableFuture<Collection<SgtInfo>> harvestResult = gbpIseSgtHarvester.harvestAll(iseContext);
Futures.addCallback(harvestResult, new FutureCallback<Collection<SgtInfo>>() {
@Override
public void onSuccess(@Nullable final Collection<SgtInfo> result) {
- LOG.debug("ise harvest finished, outcome: {}", result);
- storeOutcome(true, Optional.ofNullable(result).map(Collection::size).orElse(0), null);
+ final Integer counter = Optional.ofNullable(result).map(Collection::size).orElse(0);
+ LOG.debug("ise harvest finished, outcome: {}", counter);
+ storeOutcome(true, counter, null);
}
@Override
LOG.debug("failed to finish ise-sgt-harvest task properly on time", e);
}
});
+ } else {
+ LOG.debug("Ise-source config removed");
}
}
}
@Override
public void close() throws Exception {
- if (!pool.isTerminated()) {
+ if (! pool.isTerminated()) {
pool.shutdown();
final boolean terminated = pool.awaitTermination(10, TimeUnit.SECONDS);
if (! terminated) {
@Override
public ListenableFuture<Collection<SgtInfo>> harvestAll(@Nonnull final IseContext iseContext) {
+ LOG.debug("ise-source: harvestAll {} -> {}", iseContext.getIseSourceConfig().getTenant(),
+ iseContext.getIseSourceConfig().getConnectionConfig().getIseRestUrl());
ListenableFuture<Collection<SgtInfo>> result;
try {
final IseSourceConfig iseSourceConfig = iseContext.getIseSourceConfig();
wTx.put(LogicalDatastoreType.CONFIGURATION, epPolicyTemplatePath, epPolicyTemplate, createParent);
createParent = false;
}
+ LOG.trace("harvested ep-policy-templates submitted: {} -> {}", tenantId, sgtInfos.size());
return wTx.submit();
}
}