<feature>war</feature>
<feature version='${aaa.version}'>odl-aaa-authn</feature>
<feature version="${project.version}">odl-groupbasedpolicy-base</feature>
+ <feature version="${restconf.version}">odl-restconf</feature>
<bundle>mvn:org.opendaylight.groupbasedpolicy/iovisor-renderer/{{VERSION}}</bundle>
<bundle>mvn:com.sun.jersey/jersey-core/${jersey.version}</bundle>
<bundle>mvn:com.sun.jersey/jersey-server/${jersey.version}</bundle>
/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
import org.opendaylight.groupbasedpolicy.api.EpRendererAugmentation;
import org.opendaylight.groupbasedpolicy.api.EpRendererAugmentationRegistry;
+import org.opendaylight.groupbasedpolicy.util.IidFactory;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.EndpointService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.Endpoints;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.EndpointsBuilder;
* information about endpoints.
*/
public class EndpointRpcRegistry implements EndpointService, EpRendererAugmentationRegistry, AutoCloseable {
- private static final Logger LOG =
- LoggerFactory.getLogger(EndpointRpcRegistry.class);
+
+ private static final Logger LOG = LoggerFactory.getLogger(EndpointRpcRegistry.class);
private final DataBroker dataProvider;
private final RpcProviderRegistry rpcRegistry;
private final BindingAwareBroker.RpcRegistration<EndpointService> rpcRegistration;
- final static ConcurrentMap<String, EpRendererAugmentation> registeredRenderers = new ConcurrentHashMap<String, EpRendererAugmentation>();
+ final static ConcurrentMap<String, EpRendererAugmentation> registeredRenderers =
+ new ConcurrentHashMap<String, EpRendererAugmentation>();
/**
* This method registers a renderer for endpoint RPC API. This method
* registration is only allowed.
*
* @param epRendererAugmentation
- * - specific implementation RPC augmentation, if any. Otherwise
- * NULL
+ * - specific implementation RPC augmentation, if any. Otherwise
+ * NULL
*/
@Override
public void register(EpRendererAugmentation epRendererAugmentation) {
}
/**
- *
* @param regImp the endpoint augmentation
*/
@Override
* Constructor
*
* @param dataProvider the {@link DataBroker}
- * @param rpcRegistry the {@link RpcProviderRegistry}
+ * @param rpcRegistry the {@link RpcProviderRegistry}
*/
public EndpointRpcRegistry(DataBroker dataProvider, RpcProviderRegistry rpcRegistry) {
this.dataProvider = dataProvider;
this.rpcRegistry = rpcRegistry;
if (this.rpcRegistry != null) {
- rpcRegistration =
- this.rpcRegistry.addRpcImplementation(EndpointService.class, this);
+ rpcRegistration = this.rpcRegistry.addRpcImplementation(EndpointService.class, this);
LOG.debug("Added RPC Implementation Correctly");
} else {
rpcRegistration = null;
}
if (dataProvider != null) {
- InstanceIdentifier<Endpoints> iid =
- InstanceIdentifier.builder(Endpoints.class).build();
+ InstanceIdentifier<Endpoints> iid = InstanceIdentifier.builder(Endpoints.class).build();
WriteTransaction t = this.dataProvider.newWriteOnlyTransaction();
- t.put(LogicalDatastoreType.OPERATIONAL,
- iid, new EndpointsBuilder().build());
+ t.put(LogicalDatastoreType.OPERATIONAL, iid, new EndpointsBuilder().build());
CheckedFuture<Void, TransactionCommitFailedException> f = t.submit();
Futures.addCallback(f, new FutureCallback<Void>() {
+
@Override
public void onFailure(Throwable t) {
LOG.error("Could not write endpoint base container", t);
* earlier.
*
* @param input
- * the input object
+ * the input object
*/
private EndpointBuilder buildEndpoint(RegisterEndpointInput input) {
EndpointBuilder eb = new EndpointBuilder(input);
- for (Entry<String, EpRendererAugmentation> entry : registeredRenderers
- .entrySet()) {
+ for (Entry<String, EpRendererAugmentation> entry : registeredRenderers.entrySet()) {
try {
Map.Entry<Class<? extends Augmentation<Endpoint>>, Augmentation<Endpoint>> augmentationEntry =
entry.getValue().buildEndpointAugmentation(input);
eb.addAugmentation(augmentationEntry.getKey(), augmentationEntry.getValue());
}
} catch (Exception e) {
- LOG.warn("Endpoint Augmentation error while processing "
- + entry.getKey() + ". Reason: ", e);
+ LOG.warn("Endpoint Augmentation error while processing " + entry.getKey() + ". Reason: ", e);
}
}
return eb;
* earlier.
*
* @param input
- * the input object
+ * the input object
*/
private EndpointL3Builder buildEndpointL3(RegisterEndpointInput input) {
EndpointL3Builder eb = new EndpointL3Builder(input);
- for (Entry<String, EpRendererAugmentation> entry : registeredRenderers
- .entrySet()) {
+ for (Entry<String, EpRendererAugmentation> entry : registeredRenderers.entrySet()) {
try {
Map.Entry<Class<? extends Augmentation<EndpointL3>>, Augmentation<EndpointL3>> augmentationEntry =
entry.getValue().buildEndpointL3Augmentation(input);
eb.addAugmentation(augmentationEntry.getKey(), augmentationEntry.getValue());
}
} catch (Exception e) {
- LOG.warn("L3 endpoint Augmentation error while processing "
- + entry.getKey() + ". Reason: ", e);
+ LOG.warn("L3 endpoint Augmentation error while processing " + entry.getKey() + ". Reason: ", e);
}
}
return eb;
* earlier.
*
* @param input
- * the input object
+ * the input object
*/
private EndpointL3PrefixBuilder buildL3PrefixEndpoint(RegisterL3PrefixEndpointInput input) {
EndpointL3PrefixBuilder eb = new EndpointL3PrefixBuilder(input);
- for (Entry<String, EpRendererAugmentation> entry : registeredRenderers
- .entrySet()) {
+ for (Entry<String, EpRendererAugmentation> entry : registeredRenderers.entrySet()) {
try {
Map.Entry<Class<? extends Augmentation<EndpointL3Prefix>>, Augmentation<EndpointL3Prefix>> augmentationEntry =
entry.getValue().buildL3PrefixEndpointAugmentation(input);
eb.addAugmentation(augmentationEntry.getKey(), augmentationEntry.getValue());
}
} catch (Exception e) {
- LOG.warn("L3 endpoint Augmentation error while processing "
- + entry.getKey() + ". Reason: ", e);
+ LOG.warn("L3 endpoint Augmentation error while processing " + entry.getKey() + ". Reason: ", e);
}
}
return eb;
}
@Override
- public Future<RpcResult<Void>>
- registerEndpoint(RegisterEndpointInput input) {
+ public Future<RpcResult<Void>> registerEndpoint(RegisterEndpointInput input) {
long timestamp = System.currentTimeMillis();
// TODO: Replicate RPC feedback implemented in L3Prefix register for
// unmet requirements.
WriteTransaction t = dataProvider.newWriteOnlyTransaction();
- if (input.getL2Context() != null &&
- input.getMacAddress() != null) {
- Endpoint ep = buildEndpoint(input)
- .setTimestamp(timestamp)
- .build();
+ if (input.getL2Context() != null && input.getMacAddress() != null) {
+ Endpoint ep = buildEndpoint(input).setTimestamp(timestamp).build();
- EndpointKey key =
- new EndpointKey(ep.getL2Context(), ep.getMacAddress());
- InstanceIdentifier<Endpoint> iid =
- InstanceIdentifier.builder(Endpoints.class)
- .child(Endpoint.class, key)
- .build();
- t.put(LogicalDatastoreType.OPERATIONAL, iid, ep, true);
+ EndpointKey key = new EndpointKey(ep.getL2Context(), ep.getMacAddress());
+ t.put(LogicalDatastoreType.OPERATIONAL, IidFactory.endpointIid(key), ep, true);
}
if (input.getL3Address() != null) {
for (L3Address l3addr : input.getL3Address()) {
- EndpointL3Key key3 = new EndpointL3Key(l3addr.getIpAddress(),
- l3addr.getL3Context());
- EndpointL3 ep3 = buildEndpointL3(input)
- .setIpAddress(key3.getIpAddress())
- .setL3Context(key3.getL3Context())
- .setTimestamp(timestamp)
- .build();
- InstanceIdentifier<EndpointL3> iid_l3 =
- InstanceIdentifier.builder(Endpoints.class)
- .child(EndpointL3.class, key3)
- .build();
- t.put(LogicalDatastoreType.OPERATIONAL, iid_l3, ep3, true);
+ EndpointL3Key key3 = new EndpointL3Key(l3addr.getIpAddress(), l3addr.getL3Context());
+ EndpointL3 ep3 = buildEndpointL3(input).setIpAddress(key3.getIpAddress())
+ .setL3Context(key3.getL3Context())
+ .setTimestamp(timestamp)
+ .build();
+ t.put(LogicalDatastoreType.OPERATIONAL, IidFactory.l3EndpointIid(key3), ep3, true);
}
}
ListenableFuture<Void> r = t.submit();
public Future<RpcResult<Void>> registerL3PrefixEndpoint(RegisterL3PrefixEndpointInput input) {
if (input.getL3Context() == null) {
- return Futures.immediateFuture(RpcResultBuilder.<Void> failed()
- .withError(ErrorType.RPC, "L3 Prefix Endpoint must have L3Context.").build());
+ return Futures.immediateFuture(RpcResultBuilder.<Void>failed()
+ .withError(ErrorType.RPC, "L3 Prefix Endpoint must have L3Context.")
+ .build());
}
if (input.getIpPrefix() == null) {
- return Futures.immediateFuture(RpcResultBuilder.<Void> failed()
- .withError(ErrorType.RPC, "L3 Prefix Endpoint must have ip-prefix.").build());
+ return Futures.immediateFuture(RpcResultBuilder.<Void>failed()
+ .withError(ErrorType.RPC, "L3 Prefix Endpoint must have ip-prefix.")
+ .build());
}
if (input.getTenant() == null) {
- return Futures.immediateFuture(RpcResultBuilder.<Void> failed()
- .withError(ErrorType.RPC, "L3 Prefix Endpoint must have tenant.").build());
+ return Futures.immediateFuture(RpcResultBuilder.<Void>failed()
+ .withError(ErrorType.RPC, "L3 Prefix Endpoint must have tenant.")
+ .build());
}
WriteTransaction t = dataProvider.newWriteOnlyTransaction();
EndpointL3Prefix epL3Prefix = buildL3PrefixEndpoint(input).setTimestamp(timestamp).build();
InstanceIdentifier<EndpointL3Prefix> iid_l3prefix =
- InstanceIdentifier.builder(Endpoints.class)
- .child(EndpointL3Prefix.class, epL3PrefixKey)
- .build();
+ InstanceIdentifier.builder(Endpoints.class).child(EndpointL3Prefix.class, epL3PrefixKey).build();
t.put(LogicalDatastoreType.OPERATIONAL, iid_l3prefix, epL3Prefix);
ListenableFuture<Void> r = t.submit();
}
@Override
- public Future<RpcResult<Void>>
- unregisterEndpoint(UnregisterEndpointInput input) {
+ public Future<RpcResult<Void>> unregisterEndpoint(UnregisterEndpointInput input) {
WriteTransaction t = dataProvider.newWriteOnlyTransaction();
if (input.getL2() != null) {
for (L2 l2a : input.getL2()) {
- EndpointKey key =
- new EndpointKey(l2a.getL2Context(),
- l2a.getMacAddress());
+ EndpointKey key = new EndpointKey(l2a.getL2Context(), l2a.getMacAddress());
InstanceIdentifier<Endpoint> iid =
- InstanceIdentifier.builder(Endpoints.class)
- .child(Endpoint.class, key).build();
+ InstanceIdentifier.builder(Endpoints.class).child(Endpoint.class, key).build();
t.delete(LogicalDatastoreType.OPERATIONAL, iid);
}
}
if (input.getL3() != null) {
for (L3 l3addr : input.getL3()) {
- EndpointL3Key key3 =
- new EndpointL3Key(l3addr.getIpAddress(),
- l3addr.getL3Context());
+ EndpointL3Key key3 = new EndpointL3Key(l3addr.getIpAddress(), l3addr.getL3Context());
InstanceIdentifier<EndpointL3> iid_l3 =
- InstanceIdentifier.builder(Endpoints.class)
- .child(EndpointL3.class, key3)
- .build();
+ InstanceIdentifier.builder(Endpoints.class).child(EndpointL3.class, key3).build();
t.delete(LogicalDatastoreType.OPERATIONAL, iid_l3);
}
}
}
@Override
- public Future<RpcResult<Void>>
- setEndpointGroupConditions(SetEndpointGroupConditionsInput input) {
+ public Future<RpcResult<Void>> setEndpointGroupConditions(SetEndpointGroupConditionsInput input) {
WriteTransaction t = dataProvider.newWriteOnlyTransaction();
- ConditionMappingKey key =
- new ConditionMappingKey(input.getEndpointGroup());
+ ConditionMappingKey key = new ConditionMappingKey(input.getEndpointGroup());
for (EndpointGroupCondition condition : input.getEndpointGroupCondition()) {
- EndpointGroupConditionKey ckey =
- new EndpointGroupConditionKey(condition.getCondition());
- InstanceIdentifier<EndpointGroupCondition> iid =
- InstanceIdentifier.builder(Endpoints.class)
- .child(ConditionMapping.class, key)
- .child(EndpointGroupCondition.class, ckey)
- .build();
+ EndpointGroupConditionKey ckey = new EndpointGroupConditionKey(condition.getCondition());
+ InstanceIdentifier<EndpointGroupCondition> iid = InstanceIdentifier.builder(Endpoints.class)
+ .child(ConditionMapping.class, key)
+ .child(EndpointGroupCondition.class, ckey)
+ .build();
t.put(LogicalDatastoreType.OPERATIONAL, iid, condition);
}
}
@Override
- public Future<RpcResult<Void>>
- unsetEndpointGroupConditions(UnsetEndpointGroupConditionsInput input) {
+ public Future<RpcResult<Void>> unsetEndpointGroupConditions(UnsetEndpointGroupConditionsInput input) {
WriteTransaction t = dataProvider.newWriteOnlyTransaction();
- ConditionMappingKey key =
- new ConditionMappingKey(input.getEndpointGroup());
+ ConditionMappingKey key = new ConditionMappingKey(input.getEndpointGroup());
for (EndpointGroupCondition condition : input.getEndpointGroupCondition()) {
- EndpointGroupConditionKey ckey =
- new EndpointGroupConditionKey(condition.getCondition());
- InstanceIdentifier<EndpointGroupCondition> iid =
- InstanceIdentifier.builder(Endpoints.class)
- .child(ConditionMapping.class, key)
- .child(EndpointGroupCondition.class, ckey)
- .build();
+ EndpointGroupConditionKey ckey = new EndpointGroupConditionKey(condition.getCondition());
+ InstanceIdentifier<EndpointGroupCondition> iid = InstanceIdentifier.builder(Endpoints.class)
+ .child(ConditionMapping.class, key)
+ .child(EndpointGroupCondition.class, ckey)
+ .build();
t.delete(LogicalDatastoreType.OPERATIONAL, iid);
}
return Futures.transform(r, futureTrans);
}
- Function<Void, RpcResult<Void>> futureTrans =
- new Function<Void, RpcResult<Void>>() {
- @Override
- public RpcResult<Void> apply(Void input) {
- return RpcResultBuilder.<Void> success().build();
- }
- };
+ Function<Void, RpcResult<Void>> futureTrans = new Function<Void, RpcResult<Void>>() {
+
+ @Override
+ public RpcResult<Void> apply(Void input) {
+ return RpcResultBuilder.<Void>success().build();
+ }
+ };
}
import org.opendaylight.groupbasedpolicy.api.Validator;
import org.opendaylight.groupbasedpolicy.dto.EgKey;
import org.opendaylight.groupbasedpolicy.dto.IndexedTenant;
-import org.opendaylight.groupbasedpolicy.sf.DataTreeChangeHandler;
import org.opendaylight.groupbasedpolicy.util.DataStoreHelper;
+import org.opendaylight.groupbasedpolicy.util.DataTreeChangeHandler;
import org.opendaylight.groupbasedpolicy.util.IidFactory;
import org.opendaylight.groupbasedpolicy.util.InheritanceUtils;
import org.opendaylight.groupbasedpolicy.util.PolicyInfoUtils;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ActionDefinitionId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ClassifierDefinitionId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ActionDefinition;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.Renderers;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.Renderer;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.Capabilities;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.capabilities.SupportedActionDefinition;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.capabilities.SupportedClassifierDefinition;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
public SupportedActionDefinitionListener(DataBroker dataProvider) {
this.dataProvider = checkNotNull(dataProvider);
registration =
- dataProvider.registerDataTreeChangeListener(
- new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL,
- InstanceIdentifier.builder(Renderers.class)
- .child(Renderer.class)
- .child(Capabilities.class)
- .child(SupportedActionDefinition.class)
- .build()),
- this);
+ dataProvider.registerDataTreeChangeListener(new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL,
+ IidFactory.supportedActionDefinitionIidWildcard()), this);
}
@Override
case SUBTREE_MODIFIED:
ActionDefinitionId actionDefinitionId = rootNode.getDataAfter().getActionDefinitionId();
ReadWriteTransaction rwTx = dataProvider.newReadWriteTransaction();
- Optional<ActionDefinition> potentialAdFromConfDs = DataStoreHelper.readFromDs(
- LogicalDatastoreType.CONFIGURATION, IidFactory.actionDefinitionIid(actionDefinitionId), rwTx);
+ Optional<ActionDefinition> potentialAdFromConfDs =
+ DataStoreHelper.readFromDs(LogicalDatastoreType.CONFIGURATION,
+ IidFactory.actionDefinitionIid(actionDefinitionId), rwTx);
if (!potentialAdFromConfDs.isPresent()) {
LOG.error("Action-definition with ID {} does not exist in CONF datastore.", actionDefinitionId);
return;
}
- // TODO union and validation need to be finished
+ // TODO validation needs to be finished - this is effectively a union.
ActionDefinition ad = potentialAdFromConfDs.get();
rwTx.put(LogicalDatastoreType.OPERATIONAL, IidFactory.actionDefinitionIid(actionDefinitionId), ad);
DataStoreHelper.submitToDs(rwTx);
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.groupbasedpolicy.api.PolicyValidatorRegistry;
import org.opendaylight.groupbasedpolicy.util.DataStoreHelper;
+import org.opendaylight.groupbasedpolicy.util.DataTreeChangeHandler;
import org.opendaylight.groupbasedpolicy.util.IidFactory;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ClassifierDefinitionId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ParameterName;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ClassifierDefinition;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ClassifierDefinitionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.RendererName;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.Renderers;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.Renderer;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.Capabilities;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.capabilities.SupportedClassifierDefinition;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
private final PolicyValidatorRegistry validatorRegistry;
public SupportedClassifierDefinitionListener(DataBroker dataProvider, PolicyValidatorRegistry validatorRegistry) {
- super(dataProvider,
- new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL,
- InstanceIdentifier.builder(Renderers.class)
- .child(Renderer.class)
- .child(Capabilities.class)
- .child(SupportedClassifierDefinition.class)
- .build()));
+ super(dataProvider, new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL,
+ IidFactory.supportedClassifierDefinitionIidWildcard()));
this.validatorRegistry = validatorRegistry;
if (validatorRegistry == null) {
LOG.info(
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.groupbasedpolicy.sf;
+package org.opendaylight.groupbasedpolicy.util;
import static com.google.common.base.Preconditions.checkNotNull;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.Renderers;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.Renderer;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.RendererKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.Capabilities;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.Interests;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.capabilities.SupportedActionDefinition;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.capabilities.SupportedClassifierDefinition;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.interests.FollowedTenants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.interests.followed.tenants.FollowedTenant;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.interests.followed.tenants.FollowedTenantKey;
throw new UnsupportedOperationException();
}
- private static final InstanceIdentifier<Endpoints> ENDPOINTS_IID = InstanceIdentifier.builder(Endpoints.class).build();
+ private static final InstanceIdentifier<Endpoints> ENDPOINTS_IID =
+ InstanceIdentifier.builder(Endpoints.class).build();
public static InstanceIdentifier<Tenant> tenantIid(TenantId id) {
return InstanceIdentifier.builder(Tenants.class).child(Tenant.class, new TenantKey(id)).build();
.build();
}
- public static InstanceIdentifier<Clause> clauseIid(TenantId tenantId, ContractId contractId, ClauseName clauseName) {
+ public static InstanceIdentifier<Clause> clauseIid(TenantId tenantId, ContractId contractId,
+ ClauseName clauseName) {
return InstanceIdentifier.builder(Tenants.class)
.child(Tenant.class, new TenantKey(tenantId))
.child(Policy.class)
.build();
}
- public static InstanceIdentifier<L2FloodDomain> l2FloodDomainIid(TenantId tenantId, L2FloodDomainId l2FloodDomainId) {
+ public static InstanceIdentifier<L2FloodDomain> l2FloodDomainIid(TenantId tenantId,
+ L2FloodDomainId l2FloodDomainId) {
return InstanceIdentifier.builder(Tenants.class)
.child(Tenant.class, new TenantKey(tenantId))
.child(ForwardingContext.class)
/**
* Get the {@link Endpoint} {@link InstanceIdentifier} based on the {@link EndpointKey}
+ *
* @param endpointKey The {@link EndpointKey} of a particular {@link Endpoint}
* @return The {@link InstanceIdentifier} of the {@link Endpoint}
*/
return IidFactory.endpointIid(new EndpointKey(l2Context, macAddress));
}
+ public static InstanceIdentifier<EndpointL3> l3EndpointIid(EndpointL3Key endpointL3Key) {
+ return InstanceIdentifier.builder(Endpoints.class).child(EndpointL3.class, endpointL3Key).build();
+ }
+
public static InstanceIdentifier<EndpointL3> l3EndpointIid(L3ContextId l3Context, IpAddress ipAddress) {
- return InstanceIdentifier.builder(Endpoints.class)
- .child(EndpointL3.class, new EndpointL3Key(ipAddress, l3Context))
- .build();
+ return IidFactory.l3EndpointIid(new EndpointL3Key(ipAddress, l3Context));
}
public static InstanceIdentifier<EndpointL3> l3EndpointsIidWildcard() {
- return InstanceIdentifier.builder(Endpoints.class)
- .child(EndpointL3.class)
- .build();
+ return InstanceIdentifier.builder(Endpoints.class).child(EndpointL3.class).build();
}
public static InstanceIdentifier<EndpointL3Prefix> endpointL3PrefixIid(L3ContextId l3Context, IpPrefix ipPrefix) {
.build();
}
+ public static InstanceIdentifier<SupportedActionDefinition> supportedActionDefinitionIidWildcard() {
+ return InstanceIdentifier.builder(Renderers.class)
+ .child(Renderer.class)
+ .child(Capabilities.class)
+ .child(SupportedActionDefinition.class)
+ .build();
+ }
+
+ public static InstanceIdentifier<SupportedClassifierDefinition> supportedClassifierDefinitionIidWildcard() {
+ return InstanceIdentifier.builder(Renderers.class)
+ .child(Renderer.class)
+ .child(Capabilities.class)
+ .child(SupportedClassifierDefinition.class)
+ .build();
+ }
}
</data-broker>
<ep-renderer-augmentation-registry>
- <type xmlns:epr="urn:opendaylight:params:xml:ns:yang:controller:config:groupbasedpolicy">epr:ep-renderer-augmentation-registry</type>
+ <type xmlns:gbp="urn:opendaylight:params:xml:ns:yang:controller:config:groupbasedpolicy">gbp:ep-renderer-augmentation-registry</type>
<name>ep-renderer-augmentation-registry</name>
</ep-renderer-augmentation-registry>
+ <policy-validator-registry>
+ <type xmlns:gbp="urn:opendaylight:params:xml:ns:yang:controller:config:groupbasedpolicy">gbp:policy-validator-registry</type>
+ <name>policy-validator-registry</name>
+ </policy-validator-registry>
+
</module>
</modules>
</data>
import org.opendaylight.groupbasedpolicy.renderer.iovisor.IovisorRenderer;
-public class IovisorProviderModule extends org.opendaylight.controller.config.yang.config.iovisor_provider.impl.AbstractIovisorProviderModule {
- public IovisorProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+public class IovisorProviderModule
+ extends org.opendaylight.controller.config.yang.config.iovisor_provider.impl.AbstractIovisorProviderModule {
+
+ public IovisorProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
+ org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
super(identifier, dependencyResolver);
}
- public IovisorProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.controller.config.yang.config.iovisor_provider.impl.IovisorProviderModule oldModule, java.lang.AutoCloseable oldInstance) {
+ public IovisorProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
+ org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
+ org.opendaylight.controller.config.yang.config.iovisor_provider.impl.IovisorProviderModule oldModule,
+ java.lang.AutoCloseable oldInstance) {
super(identifier, dependencyResolver, oldModule, oldInstance);
}
@Override
public java.lang.AutoCloseable createInstance() {
- return new IovisorRenderer(getDataBrokerDependency(),
- getEpRendererAugmentationRegistryDependency());
+ return new IovisorRenderer(getDataBrokerDependency(), getEpRendererAugmentationRegistryDependency(),
+ getPolicyValidatorRegistryDependency());
}
}
package org.opendaylight.groupbasedpolicy.renderer.iovisor;
+import java.util.Map.Entry;
+
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.groupbasedpolicy.api.EpRendererAugmentationRegistry;
+import org.opendaylight.groupbasedpolicy.api.PolicyValidatorRegistry;
+import org.opendaylight.groupbasedpolicy.dto.EpKey;
import org.opendaylight.groupbasedpolicy.renderer.iovisor.endpoint.EndpointManager;
import org.opendaylight.groupbasedpolicy.renderer.iovisor.module.IovisorModuleManager;
+import org.opendaylight.groupbasedpolicy.renderer.iovisor.sf.Action;
+import org.opendaylight.groupbasedpolicy.renderer.iovisor.sf.ActionDefinitionListener;
+import org.opendaylight.groupbasedpolicy.renderer.iovisor.sf.ClassifierDefinitionListener;
+import org.opendaylight.groupbasedpolicy.renderer.iovisor.sf.SubjectFeatures;
+import org.opendaylight.groupbasedpolicy.util.DataStoreHelper;
+import org.opendaylight.groupbasedpolicy.util.IidFactory;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ActionDefinitionId;
+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.policy.rev140421.SubjectFeatureDefinitions;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ActionDefinition;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ClassifierDefinition;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.RendererName;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.interests.followed.tenants.followed.tenant.FollowedEndpointGroup;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.interests.followed.tenants.followed.tenant.FollowedEndpointGroupBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.resolved.policy.rev150828.ResolvedPolicies;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.resolved.policy.rev150828.resolved.policies.ResolvedPolicy;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private EndpointManager endPointManager;
private IovisorModuleManager iovisorModuleManager;
+ public static final RendererName RENDERER_NAME = new RendererName("IOVisor");
+ private final ClassifierDefinitionListener classifierDefinitionListener;
+ private ActionDefinitionListener actionDefinitionListener;
+ private ResolvedPolicyListener resolvedPolicyListener;
+ private DataBroker dataBroker;
- public IovisorRenderer(DataBroker dataBroker,
- EpRendererAugmentationRegistry epRendererAugmentationRegistry) {
- LOG.info("IOVisor Renderer has Started");
+ public IovisorRenderer(DataBroker dataBroker, EpRendererAugmentationRegistry epRendererAugmentationRegistry,
+ PolicyValidatorRegistry policyValidatorRegistry) {
+ if (dataBroker != null)
+ this.dataBroker = dataBroker;
this.endPointManager = new EndpointManager(dataBroker, epRendererAugmentationRegistry);
this.iovisorModuleManager = new IovisorModuleManager(dataBroker);
+ this.resolvedPolicyListener =
+ new ResolvedPolicyListener(dataBroker, new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL,
+ InstanceIdentifier.builder(ResolvedPolicies.class).child(ResolvedPolicy.class).build()));
+ classifierDefinitionListener = new ClassifierDefinitionListener(dataBroker, new DataTreeIdentifier<>(
+ LogicalDatastoreType.CONFIGURATION,
+ InstanceIdentifier.builder(SubjectFeatureDefinitions.class).child(ClassifierDefinition.class).build()));
+ actionDefinitionListener = new ActionDefinitionListener(dataBroker, new DataTreeIdentifier<>(
+ LogicalDatastoreType.CONFIGURATION,
+ InstanceIdentifier.builder(SubjectFeatureDefinitions.class).child(ActionDefinition.class).build()));
+
+ for (Entry<ActionDefinitionId, Action> entry : SubjectFeatures.getActions().entrySet()) {
+ policyValidatorRegistry.register(entry.getKey(), entry.getValue());
+ }
+ LOG.info("IOVisor Renderer has Started");
+
+ }
+
+ // TODO PUNT THIS....
+ public void endpointPolicyUpdated(TenantId tenantId, EndpointGroupId epgId, EpKey epKey) {
+ // TODO a renderer should remove followed-EPG and followed-tenant at some point
+ if (dataBroker == null) {
+ LOG.error("DataBroker is null. Cannot write followed-epg {}", epKey);
+ return;
+ }
+ WriteTransaction wTx = dataBroker.newWriteOnlyTransaction();
+ FollowedEndpointGroup followedEpg = new FollowedEndpointGroupBuilder().setId(epgId).build();
+ wTx.put(LogicalDatastoreType.OPERATIONAL, IidFactory.followedEndpointgroupIid(RENDERER_NAME, tenantId, epgId),
+ followedEpg, true);
+ DataStoreHelper.submitToDs(wTx);
}
@Override
if (endPointManager != null) {
endPointManager.close();
}
+ if (classifierDefinitionListener != null)
+ classifierDefinitionListener.close();
+ if (actionDefinitionListener != null)
+ actionDefinitionListener.close();
if (iovisorModuleManager != null) {
iovisorModuleManager.close();
+ if (resolvedPolicyListener != null)
+ resolvedPolicyListener.close();
}
}
}
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.groupbasedpolicy.renderer.iovisor;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
+import org.opendaylight.groupbasedpolicy.util.DataTreeChangeHandler;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.resolved.policy.rev150828.resolved.policies.ResolvedPolicy;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ResolvedPolicyListener extends DataTreeChangeHandler<ResolvedPolicy> {
+
+ protected ResolvedPolicyListener(DataBroker dataProvider, DataTreeIdentifier<ResolvedPolicy> pointOfInterest) {
+ super(dataProvider, pointOfInterest);
+ LOG.info("Initialised ResolvedPolicyListener");
+ }
+
+ private static final Logger LOG = LoggerFactory.getLogger(ResolvedPolicyListener.class);
+
+ @Override
+ protected void onWrite(DataObjectModification<ResolvedPolicy> rootNode,
+ InstanceIdentifier<ResolvedPolicy> rootIdentifier) {
+ LOG.info("Not implemented yet");
+
+ }
+
+ @Override
+ protected void onDelete(DataObjectModification<ResolvedPolicy> rootNode,
+ InstanceIdentifier<ResolvedPolicy> rootIdentifier) {
+ LOG.info("Not implemented yet");
+
+ }
+
+ @Override
+ protected void onSubreeModified(DataObjectModification<ResolvedPolicy> rootNode,
+ InstanceIdentifier<ResolvedPolicy> rootIdentifier) {
+ LOG.info("Not implemented yet");
+
+ }
+
+}
package org.opendaylight.groupbasedpolicy.renderer.iovisor.endpoint;
-import java.util.Map;
-import java.util.Map.Entry;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Collection;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
+import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.groupbasedpolicy.renderer.iovisor.utils.IovisorModuleUtils;
import org.opendaylight.groupbasedpolicy.util.IidFactory;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.Endpoint;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointBuilder;
-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.iovisor.rev151030.IovisorModuleAugmentation;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.base.Preconditions;
-
-public class EndpointListener implements DataChangeListener, AutoCloseable {
+public class EndpointListener implements DataTreeChangeListener<EndpointL3>, AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(EndpointListener.class);
- private final ListenerRegistration<DataChangeListener> registerListener;
-
- private DataBroker dataBroker;
+ private final DataBroker dataProvider;
+ private final ListenerRegistration<EndpointListener> registration;
+ private final EndpointManager endpointManager;
- public EndpointListener(DataBroker dataBroker) {
- this.dataBroker = dataBroker;
- this.registerListener = dataBroker.registerDataChangeListener(
- LogicalDatastoreType.OPERATIONAL,
- IidFactory.endpointsIidWildcard().child(Endpoint.class),
- this,
- AsyncDataBroker.DataChangeScope.SUBTREE);
+ public EndpointListener(DataBroker dataProvider, EndpointManager endpointManager) {
+ this.dataProvider = checkNotNull(dataProvider);
+ registration = dataProvider.registerDataTreeChangeListener(
+ new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, IidFactory.l3EndpointsIidWildcard()), this);
+ this.endpointManager = endpointManager;
}
@Override
- public void onDataChanged(AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes) {
- created(changes.getCreatedData());
- updated(changes.getUpdatedData());
- removed(changes);
- }
-
- /**
- * Process created events.
- *
- * @param created
- * Created data
- */
- private void created(Map<InstanceIdentifier<?>, DataObject> created) {
- for (Entry<InstanceIdentifier<?>, DataObject> newEndpoint : created.entrySet()) {
- Endpoint endpoint = fromMd(newEndpoint.getKey(), (Endpoint) newEndpoint.getValue());
- LOG.debug("Endpoint CREATED {}", endpoint);
-
- // Validate the IOVisorModuleInstance
- IovisorModuleAugmentation iovisorModuleAugmentation = endpoint.getAugmentation(IovisorModuleAugmentation.class);
- Preconditions.checkNotNull(iovisorModuleAugmentation.getUri(), "At this point, the Endpoint should be provided with a IovisorModuleInstance");
- if (IovisorModuleUtils.validateIovisorModuleInstance(dataBroker, iovisorModuleAugmentation.getUri())) {
- LOG.debug("This Endpoint {} provides a valid IovisorModuleInstance {}", endpoint, iovisorModuleAugmentation.getUri());
- // TODO process validated endpoint
+ public void onDataTreeChanged(Collection<DataTreeModification<EndpointL3>> changes) {
+ for (DataTreeModification<EndpointL3> change : changes) {
+ DataObjectModification<EndpointL3> rootNode = change.getRootNode();
+ switch (rootNode.getModificationType()) {
+ case WRITE:
+ case SUBTREE_MODIFIED:
+ LOG.info("Received Endpoint {}", rootNode.getDataAfter().getIpAddress());
+ if (rootNode.getDataAfter().getAugmentation(IovisorModuleAugmentation.class) != null) {
+ endpointManager.processEndpoint(rootNode.getDataAfter());
+ } else {
+ LOG.info("Endpoint did not have IOVisor Module Augmentation (Location URI). Ignoring");
+ }
+ break;
+ case DELETE:
+ LOG.warn("Received Endpoint {} but DELETE not implemented yet",
+ rootNode.getDataAfter().getIpAddress());
}
}
}
- /**
- * Process updated events.
- *
- * @param updated
- * updated data
- */
- private void updated(Map<InstanceIdentifier<?>, DataObject> updated) {
- for (Entry<InstanceIdentifier<?>, DataObject> updatedEndpoint : updated.entrySet()) {
- Endpoint endpoint = fromMd(updatedEndpoint.getKey(), (Endpoint) updatedEndpoint.getValue());
- LOG.debug("Endpoint UPDATED {}", endpoint);
- //TODO process updated event
-
- }
- }
-
- /**
- * Process REMOVED data.
- *
- * @param changes
- * Changes data
- */
- private void removed(AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes) {
- for (InstanceIdentifier<?> deletedEndpointPath : changes.getRemovedPaths()) {
- Endpoint endpoint = fromMd(deletedEndpointPath, (Endpoint) changes.getOriginalData().get(deletedEndpointPath));
- LOG.debug("Endpoint REMOVED {}", endpoint);
- // TODO process removed event
- }
- }
-
- /**
- * Get the object from MD-SAL based on the instance identifier.
- *
- * @param iid
- * {@link InstanceIdentifier} of the related event
- * @param endpoint
- * Endpoint from the related event
- * @return Endpoint constructed from the one gathered in the related event
- */
- private Endpoint fromMd(InstanceIdentifier<?> iid, Endpoint endpoint) {
- EndpointBuilder result = new EndpointBuilder();
-
- final EndpointKey endpointKey = iid.firstKeyOf(Endpoint.class);
- if (endpointKey != null) {
- result.setKey(endpointKey);
- }
-
- result.setCondition(endpoint.getCondition());
- result.setEndpointGroup(endpoint.getEndpointGroup());
- result.setEndpointGroups(endpoint.getEndpointGroups());
- result.setL2Context(endpoint.getL2Context());
- result.setL3Address(endpoint.getL3Address());
- result.setMacAddress(endpoint.getMacAddress());
- result.setNetworkContainment(endpoint.getNetworkContainment());
- result.setTenant(endpoint.getTenant());
- result.setTimestamp(endpoint.getTimestamp());
-
- return result.build();
- }
-
@Override
public void close() throws Exception {
- if (registerListener != null)
- registerListener.close();
+ registration.close();
}
+
}
package org.opendaylight.groupbasedpolicy.renderer.iovisor.endpoint;
-import java.util.Map.Entry;
-
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.groupbasedpolicy.api.EpRendererAugmentation;
import org.opendaylight.groupbasedpolicy.api.EpRendererAugmentationRegistry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterEndpointInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterL3PrefixEndpointInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.Endpoint;
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.yangtools.yang.binding.Augmentation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.Preconditions;
-public class EndpointManager implements EpRendererAugmentation, AutoCloseable {
+public class EndpointManager implements AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(EndpointManager.class);
private EndpointListener endpointListener;
- private EpRendererAugmentationRegistry epRendererAugmentationRegistry;
+ private final IovisorEndpointAug iovisorEndpointAug;
- public EndpointManager(DataBroker dataBroker,
- EpRendererAugmentationRegistry epRendererAugmentationRegistry) {
- LOG.info("Initialized IOVisor EndpointManager");
+ public EndpointManager(DataBroker dataBroker, EpRendererAugmentationRegistry epRendererAugmentationRegistry) {
Preconditions.checkNotNull(dataBroker, "DataBroker instance must not be null");
+ iovisorEndpointAug = new IovisorEndpointAug(epRendererAugmentationRegistry);
+ endpointListener = new EndpointListener(dataBroker, this);
+ LOG.info("Initialized IOVisor EndpointManager");
+ }
- this.epRendererAugmentationRegistry = epRendererAugmentationRegistry;
- this.endpointListener = new EndpointListener(dataBroker);
+ public void processEndpoint(EndpointL3 endpoint) {
+ /*
+ * Is Augmentation valid?
+ * - IPAddress or a name that can be resolved to an IPAddress
+ */
- epRendererAugmentationRegistry.register(this);
- }
+ /*
+ * IOVisorModule registered?
+ * - In this rev, we will register the IOVisorModule (agent)
+ */
- @Override
- public void close() throws Exception {
- if (endpointListener != null) {
- endpointListener.close();
- }
- epRendererAugmentationRegistry.unregister(this);
- }
+ /*
+ * Validate there is a resolved policy for tenant/EPGs.
+ * - If so, add to resolved policy endpoint map thing
+ * - If not, wait until there is (listener)
+ * .... not real sure on this one... chicken and egg.
+ */
- @Override
- public Entry<Class<? extends Augmentation<Endpoint>>, Augmentation<Endpoint>> buildEndpointAugmentation(
- RegisterEndpointInput input) {
- // TODO Auto-generated method stub
- return null;
- }
+ /*
+ * Validate there is a valid forwarding model
+ *
+ */
- @Override
- public Entry<Class<? extends Augmentation<EndpointL3>>, Augmentation<EndpointL3>> buildEndpointL3Augmentation(
- RegisterEndpointInput input) {
- // TODO Auto-generated method stub
- return null;
+ LOG.info("Processed Endpoint {}", endpoint);
}
@Override
- public Entry<Class<? extends Augmentation<EndpointL3Prefix>>, Augmentation<EndpointL3Prefix>> buildL3PrefixEndpointAugmentation(
- RegisterL3PrefixEndpointInput input) {
- // TODO Auto-generated method stub
- return null;
+ public void close() throws Exception {
+ if (iovisorEndpointAug != null)
+ iovisorEndpointAug.close();
+ if (endpointListener != null)
+ endpointListener.close();
+
}
-}
\ No newline at end of file
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.groupbasedpolicy.renderer.iovisor.endpoint;
+
+import java.util.AbstractMap.SimpleImmutableEntry;
+import java.util.Map.Entry;
+
+import org.opendaylight.groupbasedpolicy.api.EpRendererAugmentation;
+import org.opendaylight.groupbasedpolicy.api.EpRendererAugmentationRegistry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterEndpointInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterL3PrefixEndpointInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.Endpoint;
+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.iovisor.rev151030.IovisorModuleAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.iovisor.rev151030.IovisorModuleAugmentationBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.iovisor.rev151030.IovisorModuleAugmentationInput;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class IovisorEndpointAug implements EpRendererAugmentation, AutoCloseable {
+
+ private static final Logger LOG = LoggerFactory.getLogger(IovisorEndpointAug.class);
+
+ private EpRendererAugmentationRegistry epRendererAugmentationRegistry;
+
+ public IovisorEndpointAug(EpRendererAugmentationRegistry epRendererAugmentationRegistry) {
+ this.epRendererAugmentationRegistry = epRendererAugmentationRegistry;
+ this.epRendererAugmentationRegistry.register(this);
+ LOG.info("IovisorRenderer: Registered endpoint augmentation");
+ }
+
+ @Override
+ public void close() throws Exception {
+ epRendererAugmentationRegistry.unregister(this);
+ }
+
+ @Override
+ public Entry<Class<? extends Augmentation<Endpoint>>, Augmentation<Endpoint>> buildEndpointAugmentation(
+ RegisterEndpointInput input) {
+ LOG.info("IovisorRenderer does not Augment Endpoint class");
+ return null;
+ }
+
+ @Override
+ public Entry<Class<? extends Augmentation<EndpointL3>>, Augmentation<EndpointL3>> buildEndpointL3Augmentation(
+ RegisterEndpointInput input) {
+ IovisorModuleAugmentationInput iomAugInput = input.getAugmentation(IovisorModuleAugmentationInput.class);
+ if (iomAugInput == null) {
+ return null;
+ }
+ return new SimpleImmutableEntry<Class<? extends Augmentation<EndpointL3>>, Augmentation<EndpointL3>>(
+ IovisorModuleAugmentation.class, new IovisorModuleAugmentationBuilder(iomAugInput).build());
+
+ }
+
+ @Override
+ public Entry<Class<? extends Augmentation<EndpointL3Prefix>>, Augmentation<EndpointL3Prefix>> buildL3PrefixEndpointAugmentation(
+ RegisterL3PrefixEndpointInput input) {
+ LOG.info("IovisorRenderer does not Augment EndpointL3Prefix class");
+ return null;
+ }
+}
/*
- * Copyright (c) 2015 Inocybe Technologies and others. All rights reserved.
+ * Copyright (c) 2015 Inocybe Technologies and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
private IovisorModuleListener iovisorModuleListener;
public IovisorModuleManager(DataBroker dataBroker) {
- LOG.info("Initialized IOVisor IovisorModuleManager");
Preconditions.checkNotNull(dataBroker, "DataBroker instance must not be null");
this.iovisorModuleListener = new IovisorModuleListener(dataBroker);
+ LOG.info("Initialized IOVisor IovisorModuleManager");
}
@Override
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.groupbasedpolicy.renderer.iovisor.sf;
+
+import java.util.List;
+
+import org.opendaylight.groupbasedpolicy.api.Validator;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ActionDefinitionId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ActionDefinition;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.subject.feature.instances.ActionInstance;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.capabilities.supported.action.definition.SupportedParameterValues;
+
+/**
+ * Represent an action definition, and provide tools for generating
+ * flow instructions based on the action
+ */
+public abstract class Action implements Validator<ActionInstance> {
+
+ /**
+ * Get the action definition for this action
+ *
+ * @return the {@link ActionDefinition} for this action
+ */
+ public abstract ActionDefinitionId getId();
+
+ /**
+ * Get the action definition for this action
+ *
+ * @return the {@link ActionDefinition} for this action
+ */
+ public abstract ActionDefinition getActionDef();
+
+ /**
+ * The result represents supported parameters for the action by renderer
+ *
+ * @return list of supported parameters by the action
+ */
+ public abstract List<SupportedParameterValues> getSupportedParameterValues();
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.groupbasedpolicy.renderer.iovisor.sf;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.groupbasedpolicy.renderer.iovisor.IovisorRenderer;
+import org.opendaylight.groupbasedpolicy.util.DataTreeChangeHandler;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ActionDefinition;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.Renderers;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.Renderer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.RendererKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.Capabilities;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.capabilities.SupportedActionDefinition;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.capabilities.SupportedActionDefinitionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.capabilities.SupportedActionDefinitionKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+
+public class ActionDefinitionListener extends DataTreeChangeHandler<ActionDefinition> {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ActionDefinitionListener.class);
+ private static final InstanceIdentifier<Capabilities> CAPABILITIES_IID = InstanceIdentifier.builder(Renderers.class)
+ .child(Renderer.class, new RendererKey(IovisorRenderer.RENDERER_NAME))
+ .child(Capabilities.class)
+ .build();
+ private static String PUT = "stored";
+ private static String DELETED = "removed";
+
+ public ActionDefinitionListener(DataBroker dataProvider, DataTreeIdentifier<ActionDefinition> pointOfInterest) {
+ super(dataProvider, pointOfInterest);
+ }
+
+ private SupportedActionDefinition createSupportedActionDefinition(Action action) {
+ return new SupportedActionDefinitionBuilder().setActionDefinitionId(action.getId())
+ .setSupportedParameterValues(action.getSupportedParameterValues())
+ .build();
+ }
+
+ private FutureCallback<Void> logDebugResult(final SupportedActionDefinitionKey supportedActionDefinitionKey,
+ final String putOrDeleted) {
+ return new FutureCallback<Void>() {
+
+ @Override
+ public void onSuccess(Void result) {
+ LOG.debug("Capability of renerer {} was {}: {}", IovisorRenderer.RENDERER_NAME.getValue(), putOrDeleted,
+ supportedActionDefinitionKey);
+ }
+
+ @Override
+ public void onFailure(Throwable t) {
+ LOG.error("Capability of renderer {} was NOT {}: {}", IovisorRenderer.RENDERER_NAME.getValue(),
+ putOrDeleted, supportedActionDefinitionKey, t);
+ }
+ };
+ }
+
+ @Override
+ protected void onWrite(DataObjectModification<ActionDefinition> rootNode,
+ InstanceIdentifier<ActionDefinition> rootIdentifier) {
+ onSubreeModified(rootNode, rootIdentifier);
+ }
+
+ @Override
+ protected void onDelete(DataObjectModification<ActionDefinition> rootNode,
+ InstanceIdentifier<ActionDefinition> rootIdentifier) {
+ ActionDefinition actionDefinitionBefore = checkNotNull(rootNode.getDataBefore());
+ Action ourAction = SubjectFeatures.getAction(actionDefinitionBefore.getId());
+ if (ourAction != null) {
+ SupportedActionDefinitionKey supportedActionDefinitionKey =
+ new SupportedActionDefinitionKey(ourAction.getId());
+ WriteTransaction wTx = dataProvider.newWriteOnlyTransaction();
+ wTx.delete(LogicalDatastoreType.OPERATIONAL,
+ CAPABILITIES_IID.child(SupportedActionDefinition.class, supportedActionDefinitionKey));
+ Futures.addCallback(wTx.submit(), logDebugResult(supportedActionDefinitionKey, DELETED));
+ }
+ }
+
+ @Override
+ protected void onSubreeModified(DataObjectModification<ActionDefinition> rootNode,
+ InstanceIdentifier<ActionDefinition> rootIdentifier) {
+ ActionDefinition actionDefinitionAfter = checkNotNull(rootNode.getDataAfter());
+ Action ourAction = SubjectFeatures.getAction(actionDefinitionAfter.getId());
+ if (ourAction != null) {
+ SupportedActionDefinition supportedActionDefinition = createSupportedActionDefinition(ourAction);
+ WriteTransaction wTx = dataProvider.newWriteOnlyTransaction();
+ wTx.put(LogicalDatastoreType.OPERATIONAL,
+ CAPABILITIES_IID.child(SupportedActionDefinition.class, supportedActionDefinition.getKey()),
+ supportedActionDefinition, true);
+ Futures.addCallback(wTx.submit(), logDebugResult(supportedActionDefinition.getKey(), PUT));
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.groupbasedpolicy.renderer.iovisor.sf;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.opendaylight.groupbasedpolicy.api.ValidationResult;
+import org.opendaylight.groupbasedpolicy.api.sf.AllowActionDefinition;
+import org.opendaylight.groupbasedpolicy.dto.ValidationResultBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ActionDefinitionId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ActionDefinition;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.subject.feature.instances.ActionInstance;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.capabilities.supported.action.definition.SupportedParameterValues;
+
+/**
+ * Allow action
+ */
+public class AllowAction extends Action {
+
+ @Override
+ public ActionDefinitionId getId() {
+ return AllowActionDefinition.ID;
+ }
+
+ @Override
+ public ActionDefinition getActionDef() {
+ return AllowActionDefinition.DEFINITION;
+ }
+
+ @Override
+ public ValidationResult validate(ActionInstance actionInstance) {
+ return new ValidationResultBuilder().success().build();
+ }
+
+ @Override
+ public List<SupportedParameterValues> getSupportedParameterValues() {
+ // allow action definition has no parameter
+ return Collections.emptyList();
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.groupbasedpolicy.renderer.iovisor.sf;
+
+import java.util.List;
+
+import com.google.common.base.Preconditions;
+
+public class ClassificationResult {
+
+ private final String errorMessage;
+ private final boolean isSuccessful;
+
+ /**
+ * @param errorMessage cannot be {@code null}
+ */
+ public ClassificationResult(String errorMessage) {
+ this.errorMessage = Preconditions.checkNotNull(errorMessage);
+ this.isSuccessful = false;
+ }
+
+ /**
+ * @param matches cannot be {@code null}
+ */
+ public ClassificationResult(List<String> matches) {
+ errorMessage = "";
+ this.isSuccessful = true;
+ }
+
+ /**
+ * @return contains error message if {@link #isSuccessfull()} == {@code false}
+ */
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+
+ /**
+ * @return {@code true} if {@link ClassificationResult} contains result. {@code false} if
+ * {@link ClassificationResult} contains error message.
+ */
+ public boolean isSuccessfull() {
+ return isSuccessful;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.groupbasedpolicy.renderer.iovisor.sf;
+
+import java.util.List;
+import java.util.Map;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ClassifierDefinitionId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ClassifierDefinition;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.instance.ParameterValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.capabilities.supported.classifier.definition.SupportedParameterValues;
+
+/**
+ * Represent a classifier definition, and provide tools for generating flow
+ * rules based on the classifier
+ */
+public abstract class Classifier {
+
+ protected final Classifier parent;
+
+ public static final EtherTypeClassifier ETHER_TYPE_CL = new EtherTypeClassifier(null);
+ public static final IpProtoClassifier IP_PROTO_CL = new IpProtoClassifier(ETHER_TYPE_CL);
+ public static final L4Classifier L4_CL = new L4Classifier(IP_PROTO_CL);
+
+ protected Classifier(Classifier parent) {
+ this.parent = parent;
+ }
+
+ /**
+ * Get the classifier definition id for this classifier
+ *
+ * @return the {@link ClassifierDefinitionId} for this classifier
+ */
+ public abstract ClassifierDefinitionId getId();
+
+ /**
+ * Get the classifier definition for this classifier
+ *
+ * @return the {@link ClassifierDefinition} for this classifier
+ */
+ public abstract ClassifierDefinition getClassifierDefinition();
+
+ /**
+ * @return parent classifier, see {@link Classifier}
+ */
+ public final Classifier getParent() {
+ return parent;
+ }
+
+ /**
+ * The result represents supported parameters for the classifier by renderer
+ *
+ * @return list of supported parameters by the classifier
+ */
+ public abstract List<SupportedParameterValues> getSupportedParameterValues();
+
+ /**
+ * Checks presence of required {@code params} in order to decide if classifier can update
+ * {@code matches} properly
+ *
+ * @param params inserted parameters, not null
+ * @throws IllegalArgumentException when any of required {@code params} is not present
+ */
+ protected abstract void checkPresenceOfRequiredParams(Map<String, ParameterValue> params);
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.groupbasedpolicy.renderer.iovisor.sf;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.groupbasedpolicy.renderer.iovisor.IovisorRenderer;
+import org.opendaylight.groupbasedpolicy.util.DataTreeChangeHandler;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ClassifierDefinition;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.Renderers;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.Renderer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.RendererKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.Capabilities;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.capabilities.SupportedClassifierDefinition;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.capabilities.SupportedClassifierDefinitionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.capabilities.SupportedClassifierDefinitionKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+
+public class ClassifierDefinitionListener extends DataTreeChangeHandler<ClassifierDefinition> {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ClassifierDefinitionListener.class);
+
+ private static final String PUT = "stored";
+ private static final String DELETED = "removed";
+ private static final InstanceIdentifier<Capabilities> CAPABILITIES_IID = InstanceIdentifier.builder(Renderers.class)
+ .child(Renderer.class, new RendererKey(IovisorRenderer.RENDERER_NAME))
+ .child(Capabilities.class)
+ .build();
+
+ public ClassifierDefinitionListener(DataBroker dataBroker,
+ DataTreeIdentifier<ClassifierDefinition> pointOfInterest) {
+ super(dataBroker, pointOfInterest);
+ }
+
+ private SupportedClassifierDefinition createSupportedClassifierDefinition(Classifier classifier) {
+ SupportedClassifierDefinitionBuilder scdBuilder =
+ new SupportedClassifierDefinitionBuilder().setClassifierDefinitionId(classifier.getId())
+ .setSupportedParameterValues(classifier.getSupportedParameterValues());
+ if (classifier.getParent() != null) {
+ scdBuilder.setParentClassifierDefinitionId(classifier.getParent().getId());
+ }
+ return scdBuilder.build();
+ }
+
+ private FutureCallback<Void> logDebugResult(final SupportedClassifierDefinitionKey supportedClassifierDefinitionKey,
+ final String putOrDeleted) {
+ return new FutureCallback<Void>() {
+
+ @Override
+ public void onSuccess(Void result) {
+ LOG.debug("Capability of renerer {} was {}: {}", IovisorRenderer.RENDERER_NAME.getValue(), putOrDeleted,
+ supportedClassifierDefinitionKey);
+ }
+
+ @Override
+ public void onFailure(Throwable t) {
+ LOG.error("Capability of renderer {} was NOT {}: {}", IovisorRenderer.RENDERER_NAME.getValue(),
+ putOrDeleted, supportedClassifierDefinitionKey, t);
+ }
+ };
+ }
+
+ @Override
+ protected void onWrite(DataObjectModification<ClassifierDefinition> rootNode,
+ InstanceIdentifier<ClassifierDefinition> rootIdentifier) {
+ onSubreeModified(rootNode, rootIdentifier);
+ }
+
+ @Override
+ protected void onDelete(DataObjectModification<ClassifierDefinition> rootNode,
+ InstanceIdentifier<ClassifierDefinition> rootIdentifier) {
+ ClassifierDefinition classifierDefinitionBefore = checkNotNull(rootNode.getDataBefore());
+ Classifier ourClassifier = SubjectFeatures.getClassifier(classifierDefinitionBefore.getId());
+ if (ourClassifier != null) {
+ SupportedClassifierDefinitionKey supportedClassifierDefinitionKey =
+ new SupportedClassifierDefinitionKey(ourClassifier.getId());
+ WriteTransaction wTx = dataProvider.newWriteOnlyTransaction();
+ wTx.delete(LogicalDatastoreType.OPERATIONAL,
+ CAPABILITIES_IID.child(SupportedClassifierDefinition.class, supportedClassifierDefinitionKey));
+ Futures.addCallback(wTx.submit(), logDebugResult(supportedClassifierDefinitionKey, DELETED));
+ }
+ }
+
+ @Override
+ protected void onSubreeModified(DataObjectModification<ClassifierDefinition> rootNode,
+ InstanceIdentifier<ClassifierDefinition> rootIdentifier) {
+ ClassifierDefinition classifierDefinitionAfter = checkNotNull(rootNode.getDataAfter());
+ Classifier ourClassifier = SubjectFeatures.getClassifier(classifierDefinitionAfter.getId());
+ if (ourClassifier != null) {
+ SupportedClassifierDefinition supportedClassifierDefinition =
+ createSupportedClassifierDefinition(ourClassifier);
+ WriteTransaction wTx = dataProvider.newWriteOnlyTransaction();
+ wTx.put(LogicalDatastoreType.OPERATIONAL,
+ CAPABILITIES_IID.child(SupportedClassifierDefinition.class, supportedClassifierDefinition.getKey()),
+ supportedClassifierDefinition, true);
+ Futures.addCallback(wTx.submit(), logDebugResult(supportedClassifierDefinition.getKey(), PUT));
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.groupbasedpolicy.renderer.iovisor.sf;
+
+import java.util.List;
+import java.util.Map;
+
+import org.opendaylight.groupbasedpolicy.api.sf.EtherTypeClassifierDefinition;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ClassifierDefinitionId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ParameterName;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ClassifierDefinition;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.instance.ParameterValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.has.parameters.type.parameter.type.IntBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.capabilities.supported.classifier.definition.SupportedParameterValues;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.capabilities.supported.classifier.definition.SupportedParameterValuesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.supported._int.value.fields.SupportedIntValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.supported._int.value.fields.SupportedIntValueBuilder;
+
+import com.google.common.collect.ImmutableList;
+
+/**
+ * Match on the ether type of the traffic
+ */
+public class EtherTypeClassifier extends Classifier {
+
+ protected EtherTypeClassifier(Classifier parent) {
+ super(parent);
+ }
+
+ @Override
+ public ClassifierDefinitionId getId() {
+ return EtherTypeClassifierDefinition.ID;
+ }
+
+ @Override
+ public ClassifierDefinition getClassifierDefinition() {
+ return EtherTypeClassifierDefinition.DEFINITION;
+ }
+
+ @Override
+ public List<SupportedParameterValues> getSupportedParameterValues() {
+
+ List<SupportedIntValue> values = ImmutableList.of(
+ new SupportedIntValueBuilder().setValue(EtherTypeClassifierDefinition.ARP_VALUE).build(),
+ new SupportedIntValueBuilder().setValue(EtherTypeClassifierDefinition.IPv4_VALUE).build(),
+ new SupportedIntValueBuilder().setValue(EtherTypeClassifierDefinition.IPv6_VALUE).build());
+ SupportedParameterValuesBuilder b = new SupportedParameterValuesBuilder();
+ b.setParameterName(new ParameterName(EtherTypeClassifierDefinition.ETHERTYPE_PARAM));
+ b.setParameterType(new IntBuilder().setSupportedIntValue(values).build());
+
+ return ImmutableList.of(b.build());
+ }
+
+ @Override
+ protected void checkPresenceOfRequiredParams(Map<String, ParameterValue> params) {
+ if (params.get(EtherTypeClassifierDefinition.ETHERTYPE_PARAM) == null) {
+ throw new IllegalArgumentException(
+ "Parameter " + EtherTypeClassifierDefinition.ETHERTYPE_PARAM + " not specified.");
+ }
+ if (params.get(EtherTypeClassifierDefinition.ETHERTYPE_PARAM).getIntValue() == null) {
+ throw new IllegalArgumentException(
+ "Value of " + EtherTypeClassifierDefinition.ETHERTYPE_PARAM + " parameter is not present.");
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.groupbasedpolicy.renderer.iovisor.sf;
+
+import java.util.List;
+import java.util.Map;
+
+import org.opendaylight.groupbasedpolicy.api.sf.IpProtoClassifierDefinition;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ClassifierDefinitionId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ParameterName;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ClassifierDefinition;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.instance.ParameterValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.has.parameters.type.parameter.type.IntBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.capabilities.supported.classifier.definition.SupportedParameterValues;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.capabilities.supported.classifier.definition.SupportedParameterValuesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.supported._int.value.fields.SupportedIntValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.supported._int.value.fields.SupportedIntValueBuilder;
+
+import com.google.common.collect.ImmutableList;
+
+/**
+ * Match on the IP protocol of IP traffic
+ */
+public class IpProtoClassifier extends Classifier {
+
+ protected IpProtoClassifier(Classifier parent) {
+ super(parent);
+ }
+
+ @Override
+ public ClassifierDefinitionId getId() {
+ return IpProtoClassifierDefinition.ID;
+ }
+
+ @Override
+ public ClassifierDefinition getClassifierDefinition() {
+ return IpProtoClassifierDefinition.DEFINITION;
+ }
+
+ @Override
+ public List<SupportedParameterValues> getSupportedParameterValues() {
+
+ List<SupportedIntValue> values = ImmutableList.of(
+ new SupportedIntValueBuilder().setValue(IpProtoClassifierDefinition.ICMP_VALUE).build(),
+ new SupportedIntValueBuilder().setValue(IpProtoClassifierDefinition.SCTP_VALUE).build(),
+ new SupportedIntValueBuilder().setValue(IpProtoClassifierDefinition.TCP_VALUE).build(),
+ new SupportedIntValueBuilder().setValue(IpProtoClassifierDefinition.UDP_VALUE).build());
+ SupportedParameterValuesBuilder b = new SupportedParameterValuesBuilder();
+ b.setParameterName(new ParameterName(IpProtoClassifierDefinition.PROTO_PARAM));
+ b.setParameterType(new IntBuilder().setSupportedIntValue(values).build());
+
+ return ImmutableList.of(b.build());
+ }
+
+ @Override
+ protected void checkPresenceOfRequiredParams(Map<String, ParameterValue> params) {
+ if (params.get(IpProtoClassifierDefinition.PROTO_PARAM) == null) {
+ throw new IllegalArgumentException(
+ "Parameter " + IpProtoClassifierDefinition.PROTO_PARAM + " not specified.");
+ }
+ if (params.get(IpProtoClassifierDefinition.PROTO_PARAM).getIntValue() == null) {
+ throw new IllegalArgumentException(
+ "Value of " + IpProtoClassifierDefinition.PROTO_PARAM + " parameter is not present.");
+ }
+ }
+
+ /**
+ * Return the IpProtocol value. May return null.
+ *
+ * @param params the parameters of classifier-instance inserted by user
+ * @return the IpProtocol value
+ */
+ public static Long getIpProtoValue(Map<String, ParameterValue> params) {
+ if (params == null) {
+ return null;
+ }
+ if (params.get(IpProtoClassifierDefinition.PROTO_PARAM) == null) {
+ return null;
+ }
+ Long proto = params.get(IpProtoClassifierDefinition.PROTO_PARAM).getIntValue();
+ if (proto != null) {
+ return proto;
+ }
+ return null;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.groupbasedpolicy.renderer.iovisor.sf;
+
+import java.util.List;
+import java.util.Map;
+
+import org.opendaylight.groupbasedpolicy.api.sf.L4ClassifierDefinition;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ClassifierDefinitionId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ParameterName;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ClassifierDefinition;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.instance.ParameterValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.instance.parameter.value.RangeValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.has.parameters.type.parameter.type.IntBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.has.parameters.type.parameter.type.RangeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.capabilities.supported.classifier.definition.SupportedParameterValues;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.capabilities.supported.classifier.definition.SupportedParameterValuesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.supported._int.value.fields.SupportedIntValueInRange;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.supported._int.value.fields.SupportedIntValueInRangeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.supported.range.value.fields.SupportedRangeValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.supported.range.value.fields.SupportedRangeValueBuilder;
+
+import com.google.common.collect.ImmutableList;
+
+/**
+ * Match against TCP or UDP, and source and/or destination ports
+ */
+public class L4Classifier extends Classifier {
+
+ protected L4Classifier(Classifier parent) {
+ super(parent);
+ }
+
+ @Override
+ public ClassifierDefinitionId getId() {
+ return L4ClassifierDefinition.ID;
+ }
+
+ @Override
+ public ClassifierDefinition getClassifierDefinition() {
+ return L4ClassifierDefinition.DEFINITION;
+ }
+
+ @Override
+ public List<SupportedParameterValues> getSupportedParameterValues() {
+ List<SupportedIntValueInRange> allPossiblePortsIntInRange =
+ ImmutableList.of(new SupportedIntValueInRangeBuilder().setMin(1L).setMax(65535L).build());
+ List<SupportedRangeValue> allPossiblePortsRange =
+ ImmutableList.of(new SupportedRangeValueBuilder().setMin(1L).setMax(65535L).build());
+
+ SupportedParameterValues srcPorts = new SupportedParameterValuesBuilder()
+ .setParameterName(new ParameterName(L4ClassifierDefinition.SRC_PORT_PARAM))
+ .setParameterType(new IntBuilder().setSupportedIntValueInRange(allPossiblePortsIntInRange).build())
+ .build();
+ SupportedParameterValues dstPorts = new SupportedParameterValuesBuilder()
+ .setParameterName(new ParameterName(L4ClassifierDefinition.DST_PORT_PARAM))
+ .setParameterType(new IntBuilder().setSupportedIntValueInRange(allPossiblePortsIntInRange).build())
+ .build();
+
+ SupportedParameterValues srcPortsRange = new SupportedParameterValuesBuilder()
+ .setParameterName(new ParameterName(L4ClassifierDefinition.SRC_PORT_RANGE_PARAM))
+ .setParameterType(new RangeBuilder().setSupportedRangeValue(allPossiblePortsRange).build())
+ .build();
+ SupportedParameterValues dstPortsRange = new SupportedParameterValuesBuilder()
+ .setParameterName(new ParameterName(L4ClassifierDefinition.DST_PORT_RANGE_PARAM))
+ .setParameterType(new RangeBuilder().setSupportedRangeValue(allPossiblePortsRange).build())
+ .build();
+
+ return ImmutableList.of(srcPorts, dstPorts, srcPortsRange, dstPortsRange);
+ }
+
+ @Override
+ protected void checkPresenceOfRequiredParams(Map<String, ParameterValue> params) {
+ validatePortParam(params, L4ClassifierDefinition.SRC_PORT_PARAM, L4ClassifierDefinition.SRC_PORT_RANGE_PARAM);
+ validatePortParam(params, L4ClassifierDefinition.DST_PORT_PARAM, L4ClassifierDefinition.DST_PORT_RANGE_PARAM);
+ validateRange(params, L4ClassifierDefinition.SRC_PORT_RANGE_PARAM);
+ validateRange(params, L4ClassifierDefinition.DST_PORT_RANGE_PARAM);
+ }
+
+ private void validatePortParam(Map<String, ParameterValue> params, String portParam, String portRangeParam) {
+ if (params.get(portParam) != null) {
+ StringBuilder paramLog = new StringBuilder();
+ if (params.get(portParam).getIntValue() == null) {
+ paramLog.append("Value of ").append(portParam).append(" parameter is not specified.");
+ throw new IllegalArgumentException(paramLog.toString());
+ }
+ if (params.get(portRangeParam) != null) {
+ paramLog.append("Source port parameters ")
+ .append(portParam)
+ .append(" and ")
+ .append(portRangeParam)
+ .append(" are mutually exclusive.");
+ throw new IllegalArgumentException(paramLog.toString());
+ }
+ }
+ }
+
+ private void validateRange(Map<String, ParameterValue> params, String portRangeParam) {
+ if (params.get(portRangeParam) != null) {
+ validateRangeValue(params.get(portRangeParam).getRangeValue());
+ }
+ }
+
+ private void validateRangeValue(RangeValue rangeValueParam) {
+ if (rangeValueParam == null) {
+ throw new IllegalArgumentException("Range parameter is specifiet but value is not present.");
+ }
+ final Long min = rangeValueParam.getMin();
+ final Long max = rangeValueParam.getMax();
+ if (min > max) {
+ throw new IllegalArgumentException("Range value mismatch. " + min + " is greater than MAX " + max + ".");
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.groupbasedpolicy.renderer.iovisor.sf;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.opendaylight.groupbasedpolicy.api.sf.EtherTypeClassifierDefinition;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.instance.ParameterValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.instance.ParameterValueBuilder;
+
+public abstract class ParamDerivator {
+
+ /**
+ * TODO: These are buried somewhere in MDSAL MODEL but NFI how to tease them out. Seems
+ * ridiculous we have to pull these sort of things
+ * in from OFP of LLDP or some such. Quicker to just define them here and rant about it in a
+ * comment.
+ */
+
+ /**
+ * IPv4 ethertype
+ */
+ public static final Long IPv4 = Long.valueOf(0x0800);
+ /**
+ * IPv6 ethertype
+ */
+ public static final Long IPv6 = Long.valueOf(0x86DD);
+
+ /**
+ * It is possible to derive missing parameters.
+ * <p>
+ * Examle:
+ * <p>
+ * Ether-type parameter is missing. Derivation policy might instruct: ipv4 and ipv6 flows need
+ * to be created if ether-type parameter is not present. In this case two derivations of
+ * {@code params} should be returned. One with ipv4 ether-type, the other with ipv6.
+ *
+ * @param params parameters inserted by user
+ * @return list of {@code params} updated with derived values
+ */
+ public abstract List<Map<String, ParameterValue>> deriveParameter(Map<String, ParameterValue> params);
+
+ public static final ParamDerivator ETHER_TYPE_DERIVATOR = new ParamDerivator() {
+
+ @Override
+ public List<Map<String, ParameterValue>> deriveParameter(Map<String, ParameterValue> params) {
+
+ if (!params.containsKey(EtherTypeClassifierDefinition.ETHERTYPE_PARAM)) {
+ Map<String, ParameterValue> ipv4Params = new HashMap<>(params);
+ Map<String, ParameterValue> ipv6Params = new HashMap<>(params);
+ ipv4Params.put(EtherTypeClassifierDefinition.ETHERTYPE_PARAM,
+ new ParameterValueBuilder().setIntValue(IPv4).build());
+ ipv6Params.put(EtherTypeClassifierDefinition.ETHERTYPE_PARAM,
+ new ParameterValueBuilder().setIntValue(IPv6).build());
+ List<Map<String, ParameterValue>> derivedParams = new ArrayList<>();
+ derivedParams.add(ipv4Params);
+ derivedParams.add(ipv6Params);
+ return derivedParams;
+ }
+ return Collections.singletonList(params);
+ }
+ };
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.groupbasedpolicy.renderer.iovisor.sf;
+
+import java.util.List;
+import java.util.Map;
+
+import org.opendaylight.groupbasedpolicy.api.sf.AllowActionDefinition;
+import org.opendaylight.groupbasedpolicy.api.sf.EtherTypeClassifierDefinition;
+import org.opendaylight.groupbasedpolicy.api.sf.IpProtoClassifierDefinition;
+import org.opendaylight.groupbasedpolicy.api.sf.L4ClassifierDefinition;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ActionDefinitionId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ClassifierDefinitionId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.SubjectFeatureDefinitions;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.SubjectFeatureDefinitionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ActionDefinition;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ClassifierDefinition;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Collections2;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * Defines the subject features that are supported by the OF overlay renderer
+ */
+public class SubjectFeatures {
+
+ private static final Map<ClassifierDefinitionId, Classifier> classifiers =
+ ImmutableMap.of(EtherTypeClassifierDefinition.ID, Classifier.ETHER_TYPE_CL, IpProtoClassifierDefinition.ID,
+ Classifier.IP_PROTO_CL, L4ClassifierDefinition.ID, Classifier.L4_CL);
+
+ private static final List<ClassifierDefinition> classifierDefs = ImmutableList
+ .copyOf(Collections2.transform(classifiers.values(), new Function<Classifier, ClassifierDefinition>() {
+
+ @Override
+ public ClassifierDefinition apply(Classifier input) {
+ return input.getClassifierDefinition();
+ }
+ }));
+
+ private static final Map<ActionDefinitionId, Action> actions =
+ ImmutableMap.<ActionDefinitionId, Action>of(AllowActionDefinition.ID, new AllowAction());
+
+ private static final List<ActionDefinition> actionDefs =
+ ImmutableList.copyOf(Collections2.transform(actions.values(), new Function<Action, ActionDefinition>() {
+
+ @Override
+ public ActionDefinition apply(Action input) {
+ return input.getActionDef();
+ }
+ }));
+
+ public static final SubjectFeatureDefinitions IOVISOR_FEATURES = new SubjectFeatureDefinitionsBuilder()
+ .setActionDefinition(actionDefs).setClassifierDefinition(classifierDefs).build();
+
+ /**
+ * Get the {@link Classifier} associated with the given
+ * {@link ClassifierDefinitionId}
+ *
+ * @param id the {@link ClassifierDefinitionId} to look up
+ * @return the {@link Classifier} if one exists, or <code>null</code>
+ * otherwise
+ */
+ public static Classifier getClassifier(ClassifierDefinitionId id) {
+ return classifiers.get(id);
+ }
+
+ public static Map<ActionDefinitionId, Action> getActions() {
+ return actions;
+ }
+
+ /**
+ * Get the {@link Action} associated with the given
+ * {@link ActionDefinitionId}
+ *
+ * @param id the {@link ActionDefinitionId} to look up
+ * @return the {@link Action} if one exists, or <code>null</code>
+ * otherwise
+ */
+ public static Action getAction(ActionDefinitionId id) {
+ return actions.get(id);
+ }
+}
}
}
}
- // EpRendererAugmentationRegistrar service
+ // EpRendererAugmentationRegistry service
container ep-renderer-augmentation-registry {
uses config:service-ref {
refine type {
}
}
}
+ // PolicyProviderRegistry service
+ container policy-validator-registry {
+ uses config:service-ref {
+ refine type {
+ mandatory true;
+ config:required-identity gbpcfg:policy-validator-registry;
+ }
+ }
+ }
}
}
}
/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
}
}
- augment "/endpoint:endpoints/endpoint:endpoint" {
+ augment "/endpoint:endpoints/endpoint:endpoint-l3" {
description "Augmentation adding the IOVisor module location";
ext:augment-identifier "iovisor-module-augmentation";
uses iovisor-module;
}
+
+ augment "/endpoint:register-endpoint/endpoint:input" {
+ description "Augmentation adding the IOVisor module location";
+ ext:augment-identifier "iovisor-module-augmentation-input";
+ uses iovisor-module;
+ }
}
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.groupbasedpolicy.renderer.iovisor;
+
+import org.junit.Test;
+
+public class IovisorRendererTest {
+
+ @Test
+ public void IovisorRendererClassTest() {
+ // TODO Implement me
+ }
+
+ @Test
+ public void endpointPolicyUpdatedTest() {
+ // TODO implement me
+ }
+}
*/
package org.opendaylight.groupbasedpolicy.renderer.iovisor.endpoint;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.when;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.Collection;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
import org.opendaylight.groupbasedpolicy.renderer.iovisor.utils.IovisorModuleUtils;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.Endpoints;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.Endpoint;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.iovisor.rev151030.IovisorModuleAugmentation;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.powermock.api.mockito.PowerMockito;
-import org.powermock.api.support.membermodification.MemberMatcher;
-import org.powermock.api.support.membermodification.MemberModifier;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
@PrepareForTest({EndpointListener.class, IovisorModuleUtils.class})
public class EndpointListenerTest {
- @Mock EndpointListener endpointListner;
- @Mock DataBroker dataBroker;
- @Mock ListenerRegistration<DataChangeListener> registerListener;
+ @Mock
+ EndpointListener endpointListner;
+ @Mock
+ DataBroker dataBroker;
+ @Mock
+ ListenerRegistration<DataChangeListener> registerListener;
- @Mock AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes;
+ @Mock
+ Collection<DataTreeModification<Endpoint>> changes;
@Before
public void setUp() {
endpointListner = PowerMockito.mock(EndpointListener.class, Mockito.CALLS_REAL_METHODS);
}
- @Test
- public void onDataChangedTest() throws Exception {
- MemberModifier.suppress(MemberMatcher.method(EndpointListener.class, "created", Map.class));
- MemberModifier.suppress(MemberMatcher.method(EndpointListener.class, "updated", Map.class));
- MemberModifier.suppress(MemberMatcher.method(EndpointListener.class, "removed", AsyncDataChangeEvent.class));
-
- endpointListner.onDataChanged(changes);
-
- PowerMockito.verifyPrivate(endpointListner, times(1)).invoke("created", any(Map.class));
- PowerMockito.verifyPrivate(endpointListner, times(1)).invoke("updated", any(Map.class));
- PowerMockito.verifyPrivate(endpointListner, times(1)).invoke("removed", any(AsyncDataChangeEvent.class));
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void createdTest() throws Exception {
- InstanceIdentifier<?> endpointIid = InstanceIdentifier.create(Endpoints.class)
- .child(Endpoint.class)
- .augmentation(IovisorModuleAugmentation.class);
-
- IovisorModuleAugmentation aug = mock(IovisorModuleAugmentation.class);
- when(aug.getUri()).thenReturn(mock(Uri.class));
-
- Endpoint endpoint = mock(Endpoint.class);
- when(endpoint.getAugmentation(any(Class.class))).thenReturn(aug);
-
- PowerMockito.doReturn(endpoint).when(endpointListner, "fromMd", any(InstanceIdentifier.class), any(Endpoint.class));
-
- Map<InstanceIdentifier<?>, DataObject> created = new HashMap<>();
- created.put(endpointIid, endpoint);
- when(changes.getCreatedData()).thenReturn(created);
-
- PowerMockito.mockStatic(IovisorModuleUtils.class);
- PowerMockito.when(IovisorModuleUtils.validateIovisorModuleInstance(any(DataBroker.class), any(Uri.class))).thenReturn(true);
-
- endpointListner.onDataChanged(changes);
- PowerMockito.verifyPrivate(endpointListner, times(1)).invoke("fromMd", any(InstanceIdentifier.class), any(Endpoint.class));
-
- // TODO test what happens when the validateIovisorModuleInstance returns
- // true or false. (Not yet implemented)
- }
-
@Test
public void updatedTest() {
// Nothing to test
public void removedTest() {
// Nothing to test
}
-}
\ No newline at end of file
+}
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
+ // maintain external endpoints map
if (newLoc == null && oldLoc == null) {
if (newEp != null && newEpKey != null) {
externalEndpointsWithoutLocation.put(newEpKey, newEp);
return;
}
- //maintain endpoint maps
- //new endpoint
+ // maintain endpoint maps
+ // new endpoint
if (newEp != null && newEpKey != null) {
endpoints.put(newEpKey, newEp);
+ // TODO This and the create endpoint / update endpoint section will cause switchUpdate
+ // to be called twice. Consider removing
notifyEndpointUpdated(newEpKey);
}
- //odl endpoint
+ // odl endpoint
else if (oldEpKey != null) {
endpoints.remove(oldEpKey);
+ // TODO This and the create endpoint / update endpoint section will cause switchUpdate
+ // to be called twice. Consider removing
notifyEndpointUpdated(oldEpKey);
}
- //create endpoint
+ // 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()))) {
+ // 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
+ // endpoint was moved, new location exists but is different from old one
if (oldLoc != null && !(oldLoc.getValue().equals(newLoc.getValue()))) {
- //remove old endpoint
+ // remove old endpoint
removeEndpoint(oldEp, oldLoc, oldEpKey, oldEpgIds);
notifyOldLoc = true;
notifyOldEg = true;
}
- //add moved endpoint
+ // add moved endpoint
createEndpoint(newLoc, newEpKey, newEpgIds, tenantId);
notifyNewLoc = true;
notifyNewEg = true;
}
- //remove endpoint
+ // remove endpoint
if (oldEp != null && newEp == null) {
removeEndpoint(oldEp, oldLoc, oldEpKey, oldEpgIds);
notifyOldLoc = true;
notifyOldEg = true;
}
- //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
}
- //auto closeable
+ // auto closeable
@Override
public void close() throws Exception {
if (endpointListener != null)
protected boolean isInternal(Endpoint ep) {
Preconditions.checkNotNull(ep);
OfOverlayContext ofc = ep.getAugmentation(OfOverlayContext.class);
- return ofc == null || ofc.getLocationType() == null || ofc.getLocationType().equals(EndpointLocation.LocationType.Internal);
+ return ofc == null || ofc.getLocationType() == null
+ || ofc.getLocationType().equals(EndpointLocation.LocationType.Internal);
}
public boolean isExternal(Endpoint ep) {
* 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));
+ || (input.getAugmentation(OfOverlayL3Nat.class).getNaptTranslations() == null) || (input
+ .getAugmentation(OfOverlayL3Nat.class).getNaptTranslations().getNaptTranslation() == null));
}
});
if (l3Endpoints == null) {
/**
* 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}
+ * @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)) {
+ || (endpointL3.getAugmentation(OfOverlayL3Nat.class).getNaptTranslations() == null) || (endpointL3
+ .getAugmentation(OfOverlayL3Nat.class).getNaptTranslations().getNaptTranslation() == null)) {
return null;
}
return endpointL3.getAugmentation(OfOverlayL3Nat.class).getNaptTranslations().getNaptTranslation();
* 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
}
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;
}
public class ClassifierDefinitionListener implements DataTreeChangeListener<ClassifierDefinition>, AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(ClassifierDefinitionListener.class);
- private static final InstanceIdentifier<Capabilities> CAPABILITIES_IID = InstanceIdentifier.builder(Renderers.class)
+ private static final InstanceIdentifier<Capabilities> RENDERER_CAPABILITIES_IID = InstanceIdentifier.builder(Renderers.class)
.child(Renderer.class, new RendererKey(OFOverlayRenderer.RENDERER_NAME))
.child(Capabilities.class)
.build();
SupportedClassifierDefinition supportedClassifierDefinition =
createSupportedClassifierDefinition(ourClassifier);
WriteTransaction wTx = dataProvider.newWriteOnlyTransaction();
- wTx.put(LogicalDatastoreType.OPERATIONAL, CAPABILITIES_IID
+ wTx.put(LogicalDatastoreType.OPERATIONAL, RENDERER_CAPABILITIES_IID
.child(SupportedClassifierDefinition.class, supportedClassifierDefinition.getKey()),
supportedClassifierDefinition, true);
Futures.addCallback(wTx.submit(), logDebugResult(supportedClassifierDefinition.getKey(), PUT));
SupportedClassifierDefinitionKey supportedClassifierDefinitionKey =
new SupportedClassifierDefinitionKey(ourClassifier.getId());
WriteTransaction wTx = dataProvider.newWriteOnlyTransaction();
- wTx.delete(LogicalDatastoreType.OPERATIONAL, CAPABILITIES_IID
+ wTx.delete(LogicalDatastoreType.OPERATIONAL, RENDERER_CAPABILITIES_IID
.child(SupportedClassifierDefinition.class, supportedClassifierDefinitionKey));
Futures.addCallback(wTx.submit(), logDebugResult(supportedClassifierDefinitionKey, DELETED));
}