<build>
<plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <configuration>
+ <propertyExpansion>checkstyle.checker.severity=error</propertyExpansion>
+ </configuration>
+ </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
*/
package org.opendaylight.ovsdb.openstack.netvirt.sfc;
-/**
- * @author Arun Yerra
- */
-import com.google.common.base.Preconditions;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import java.util.Collection;
+import com.google.common.base.Preconditions;
import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
import org.opendaylight.ovsdb.openstack.netvirt.sfc.openflow13.INetvirtSfcOF13Provider;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import java.util.Collection;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* AbstractChangeListner implemented basic {@link AsyncDataChangeEvent} processing for
* netvirt-sfc data change listener.
- *
*/
-public abstract class AbstractDataTreeListener <T extends DataObject> implements INetvirtSfcDataProcessor<T>{
+public abstract class AbstractDataTreeListener<T extends DataObject> implements INetvirtSfcDataProcessor<T> {
private static final Logger LOG = LoggerFactory.getLogger(AbstractDataTreeListener.class);
protected INetvirtSfcOF13Provider provider;
protected final Class<T> clazz;
- public AbstractDataTreeListener (INetvirtSfcOF13Provider provider, Class<T> clazz) {
+ public AbstractDataTreeListener(INetvirtSfcOF13Provider provider, Class<T> clazz) {
this.provider = Preconditions.checkNotNull(provider, "provider can not be null!");
this.clazz = Preconditions.checkNotNull(clazz, "Class can not be null!");
}
final DataObjectModification<T> mod = change.getRootNode();
LOG.info("Received Data Tree Changed Update of Type={} for Key={}", mod.getModificationType(), key);
switch (mod.getModificationType()) {
- case DELETE:
- remove(key, mod.getDataBefore());
- break;
- case SUBTREE_MODIFIED:
- update(key, mod.getDataBefore(), mod.getDataAfter());
- break;
- case WRITE:
- if (mod.getDataBefore() == null) {
- add(key, mod.getDataAfter());
- } else {
+ case DELETE:
+ remove(key, mod.getDataBefore());
+ break;
+ case SUBTREE_MODIFIED:
update(key, mod.getDataBefore(), mod.getDataAfter());
- }
- break;
- default:
- throw new IllegalArgumentException("Unhandled modification type " + mod.getModificationType());
+ break;
+ case WRITE:
+ if (mod.getDataBefore() == null) {
+ add(key, mod.getDataAfter());
+ } else {
+ update(key, mod.getDataBefore(), mod.getDataAfter());
+ }
+ break;
+ default:
+ throw new IllegalArgumentException("Unhandled modification type " + mod.getModificationType());
}
}
}
* 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.ovsdb.openstack.netvirt.sfc;
-/**
- * @author Arun Yerra
- *
- */
+package org.opendaylight.ovsdb.openstack.netvirt.sfc;
import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
import org.opendaylight.yangtools.yang.binding.DataObject;
/**
* netvirt-sfc-dcl processor
* org.opendaylight.ovsdb.openstack.netvirt.sfc
- *
- * Created: Oct 05, 2015
*/
-public interface INetvirtSfcDataProcessor <D extends DataObject> extends AutoCloseable, DataTreeChangeListener<D> {
+public interface INetvirtSfcDataProcessor<D extends DataObject> extends AutoCloseable, DataTreeChangeListener<D> {
/**
* Method removes DataObject which is identified by InstanceIdentifier.
void remove(InstanceIdentifier<D> identifier, D del);
/**
- * Method updates the original DataObject to the update DataObject
- * Both are identified by same InstanceIdentifier
+ * Method updates the original DataObject to the update DataObject.
+ * Both are identified by same InstanceIdentifier.
*
* @param identifier - the whole path to DataObject
* @param original - original DataObject (for update)
* 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.ovsdb.openstack.netvirt.sfc;
-/**
- * @author Arun Yerra
- *
- */
+package org.opendaylight.ovsdb.openstack.netvirt.sfc;
import com.google.common.base.Preconditions;
-import java.util.concurrent.Callable;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.ovsdb.openstack.netvirt.sfc.openflow13.INetvirtSfcOF13Provider;
import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev141010.AccessLists;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev141010.access.lists.AccessList;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev141010.access.lists.AccessListKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.Classifiers;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.classifiers.Classifier;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.classifiers.classifier.sffs.Sff;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * Data tree listener for AccessList.
+ */
public class NetvirtSfcAclListener extends AbstractDataTreeListener<AccessList> {
private static final Logger LOG = LoggerFactory.getLogger(NetvirtSfcAclListener.class);
private ListenerRegistration<NetvirtSfcAclListener> listenerRegistration;
private MdsalUtils dbutils;
- public NetvirtSfcAclListener (final INetvirtSfcOF13Provider provider, final DataBroker db) {
+ /**
+ * {@link NetvirtSfcAclListener} constructor.
+ * @param provider OpenFlow 1.3 Provider
+ * @param db MdSal {@link DataBroker}
+ */
+ public NetvirtSfcAclListener(final INetvirtSfcOF13Provider provider, final DataBroker db) {
super(provider, AccessList.class);
Preconditions.checkNotNull(db, "DataBroker can not be null!");
}
private void registrationListener(final DataBroker db) {
- final DataTreeIdentifier<AccessList> treeId = new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, getIetfAclIid());
+ final DataTreeIdentifier<AccessList> treeId =
+ new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, getIetfAclIid());
try {
LOG.info("Registering Data Change Listener for Netvirt AccesList configuration.");
listenerRegistration = db.registerDataTreeChangeListener(treeId, this);
String aclName = removeDataObj.getAclName();
Classifiers classifiers = dbutils.read(LogicalDatastoreType.CONFIGURATION, getClassifierIid());
- if(classifiers != null) {
- for(Classifier classifier : classifiers.getClassifier()) {
- if(classifier.getAcl().equalsIgnoreCase(aclName)) {
- if(classifier.getSffs() != null) {
- for(Sff sff : classifier.getSffs().getSff()) {
+ if (classifiers != null) {
+ for (Classifier classifier : classifiers.getClassifier()) {
+ if (classifier.getAcl().equalsIgnoreCase(aclName)) {
+ if (classifier.getSffs() != null) {
+ for (Sff sff : classifier.getSffs().getSff()) {
provider.removeClassifierRules(sff, removeDataObj);
}
}
}
}
}
- return;
}
@Override
String aclName = addDataObj.getAclName();
LOG.debug("Adding accesslist = {}", identifier);
Classifiers classifiers = dbutils.read(LogicalDatastoreType.CONFIGURATION, getClassifierIid());
- if(classifiers != null) {
- for(Classifier classifier : classifiers.getClassifier()) {
- if(classifier.getAcl().equalsIgnoreCase(aclName)) {
- if(classifier.getSffs() != null) {
- for(Sff sff : classifier.getSffs().getSff()) {
+ if (classifiers != null) {
+ for (Classifier classifier : classifiers.getClassifier()) {
+ if (classifier.getAcl().equalsIgnoreCase(aclName)) {
+ if (classifier.getSffs() != null) {
+ for (Sff sff : classifier.getSffs().getSff()) {
provider.addClassifierRules(sff, addDataObj);
}
}
}
}
}
- return;
}
- private InstanceIdentifier<Classifiers> getClassifierIid () {
+ private InstanceIdentifier<Classifiers> getClassifierIid() {
return InstanceIdentifier.create(Classifiers.class);
}
- public InstanceIdentifier<AccessList> getIetfAclIid () {
+ public InstanceIdentifier<AccessList> getIetfAclIid() {
return InstanceIdentifier.create(AccessLists.class).child(AccessList.class);
}
- public InstanceIdentifier<AccessListEntry> getIetfAclEntryIid (String aclName, String ruleName) {
- return InstanceIdentifier.create(AccessLists.class).child(AccessList.class, new AccessListKey(aclName)).
- child(AccessListEntries.class).child(AccessListEntry.class, new AccessListEntryKey(ruleName));
+ /**
+ * Create an {@link AccessListEntry} {@link InstanceIdentifier}.
+ * @param aclName is the name of the ACL
+ * @param ruleName is the name of the rule
+ * @return the {@link AccessListEntry} {@link InstanceIdentifier}
+ */
+ public InstanceIdentifier<AccessListEntry> getIetfAclEntryIid(String aclName, String ruleName) {
+ return InstanceIdentifier.create(AccessLists.class).child(AccessList.class,
+ new AccessListKey(aclName)).child(AccessListEntries.class).child(AccessListEntry.class,
+ new AccessListEntryKey(ruleName));
}
}
* 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.ovsdb.openstack.netvirt.sfc;
-/**
- * @author Arun Yerra
- *
- */
+package org.opendaylight.ovsdb.openstack.netvirt.sfc;
import com.google.common.base.Preconditions;
-import java.util.concurrent.Callable;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.ovsdb.openstack.netvirt.sfc.openflow13.INetvirtSfcOF13Provider;
import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev141010.AccessLists;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev141010.access.lists.AccessList;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev141010.access.lists.AccessListKey;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev141010.access.lists.access.list.access.list.entries.AccessListEntry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.Classifiers;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.classifiers.Classifier;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.classifiers.classifier.Sffs;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.classifiers.classifier.sffs.Sff;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * Data tree listener for Classifier.
+ *
+ * @author Arun Yerra
+ */
public class NetvirtSfcClassifierListener extends AbstractDataTreeListener<Classifier> {
-
private static final Logger LOG = LoggerFactory.getLogger(NetvirtSfcClassifierListener.class);
private MdsalUtils dbutils;
private ListenerRegistration<NetvirtSfcClassifierListener> listenerRegistration;
- public NetvirtSfcClassifierListener (final INetvirtSfcOF13Provider provider, final DataBroker db) {
+ /**
+ * {@link NetvirtSfcClassifierListener} constructor.
+ * @param provider OpenFlow 1.3 Provider
+ * @param db MdSal {@link DataBroker}
+ */
+ public NetvirtSfcClassifierListener(final INetvirtSfcOF13Provider provider, final DataBroker db) {
super(provider, Classifier.class);
Preconditions.checkNotNull(db, "DataBroker can not be null!");
dbutils = new MdsalUtils(db);
}
private void registrationListener(final DataBroker db) {
- final DataTreeIdentifier<Classifier> treeId = new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, getClassifierIid());
+ final DataTreeIdentifier<Classifier> treeId =
+ new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, getClassifierIid());
try {
LOG.info("Registering Data Change Listener for Netvirt Classifier configuration.");
listenerRegistration = db.registerDataTreeChangeListener(treeId, this);
String aclName = removeDataObj.getAcl();
// Read the ACL information from data store and make sure it exists.
AccessList acl = dbutils.read(LogicalDatastoreType.CONFIGURATION,getIetfAclIid(aclName));
- if(acl == null) {
+ if (acl == null) {
LOG.debug("IETF ACL with name ={} is not yet configured. skip this operation", aclName);
return;
}
- if(removeDataObj.getSffs() != null) {
- for(Sff sff : removeDataObj.getSffs().getSff()) {
+
+ if (removeDataObj.getSffs() != null) {
+ for (Sff sff : removeDataObj.getSffs().getSff()) {
// Netvirt classifier binds an ACL with service function forwarder that is identified by SFF name.
// SFF validation can be done with SFC Provider APIs, as SFF is configured within SFC project.
// Netvirt SFC provider will validate the SFF using SFC provider APIs.
String aclName = addDataObj.getAcl();
// Read the ACL information from data store and make sure it exists.
AccessList acl = dbutils.read(LogicalDatastoreType.CONFIGURATION,getIetfAclIid(aclName));
- if(acl == null) {
+ if (acl == null) {
LOG.debug("IETF ACL with name ={} is not yet configured. skip this operation", aclName);
return;
}
- if(addDataObj.getSffs() != null) {
- for(Sff sff : addDataObj.getSffs().getSff()) {
+
+ if (addDataObj.getSffs() != null) {
+ for (Sff sff : addDataObj.getSffs().getSff()) {
// Netvirt classifier binds an ACL with service function forwarder that is identified by SFF name.
// SFF validation can be done with SFC Provider APIs, as SFF is configured within SFC project.
// Netvirt SFC provider will validate the SFF using SFC provider APIs.
}
}
- public InstanceIdentifier<Classifier> getClassifierIid () {
+ public InstanceIdentifier<Classifier> getClassifierIid() {
return InstanceIdentifier.create(Classifiers.class).child(Classifier.class);
}
- private InstanceIdentifier<AccessList> getIetfAclIid (String aclName) {
+ private InstanceIdentifier<AccessList> getIetfAclIid(String aclName) {
return InstanceIdentifier.create(AccessLists.class).child(AccessList.class, new AccessListKey(aclName));
}
-
}
package org.opendaylight.ovsdb.openstack.netvirt.sfc;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import com.google.common.base.Preconditions;
-
-import org.osgi.framework.BundleContext;
-
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
-import org.opendaylight.ovsdb.openstack.netvirt.sfc.openflow13.NetvirtSfcOF13Provider;
-import org.opendaylight.ovsdb.openstack.netvirt.sfc.openflow13.INetvirtSfcOF13Provider;
import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
+import org.opendaylight.ovsdb.openstack.netvirt.sfc.openflow13.INetvirtSfcOF13Provider;
+import org.opendaylight.ovsdb.openstack.netvirt.sfc.openflow13.NetvirtSfcOF13Provider;
+import org.osgi.framework.BundleContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class NetvirtSfcProvider implements BindingAwareProvider, AutoCloseable {
-
private static final Logger LOG = LoggerFactory.getLogger(NetvirtSfcProvider.class);
private DataBroker dataBroker = null;
private BundleContext bundleContext = null;
private NetvirtSfcClassifierListener classfierListener;
private INetvirtSfcOF13Provider provider;
- public NetvirtSfcProvider (BundleContext bundleContext) {
+ public NetvirtSfcProvider(BundleContext bundleContext) {
LOG.info("NetvirtProvider: bundleContext: {}", bundleContext);
this.bundleContext = bundleContext;
}
LOG.info("NetvirtSfcProvider Session Initiated");
dataBroker = session.getSALService(DataBroker.class);
- provider = new NetvirtSfcOF13Provider (this.dataBroker);
+ provider = new NetvirtSfcOF13Provider(this.dataBroker);
aclListener = new NetvirtSfcAclListener(provider, this.dataBroker);
- classfierListener = new NetvirtSfcClassifierListener (provider, this.dataBroker);
+ classfierListener = new NetvirtSfcClassifierListener(provider, this.dataBroker);
}
@Override
/*
- * Copyright (c) 2013, 2015 Dell, Inc. and others. All rights reserved.
+ * Copyright (c) 2015 Dell, 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.ovsdb.openstack.netvirt.sfc.openflow13;
-/**
- * @author Arun Yerra
- *
- */
+package org.opendaylight.ovsdb.openstack.netvirt.sfc.openflow13;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev141010.access.lists.AccessList;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.classifiers.classifier.sffs.Sff;
+/**
+ * Open vSwitch OpenFlow 1.3 Networking Provider for Netvirt SFC
+ * @author Arun Yerra
+ */
public interface INetvirtSfcOF13Provider {
/**
/*
- * Copyright (c) 2013, 2015 Dell, Inc. and others. All rights reserved.
+ * Copyright (c) 2015 Dell, 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.ovsdb.openstack.netvirt.sfc.openflow13;
-/**
- * @author Arun Yerra
- *
- */
+package org.opendaylight.ovsdb.openstack.netvirt.sfc.openflow13;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import com.google.common.base.Preconditions;
-
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
-import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev141010.access.lists.AccessList;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.classifiers.classifier.sffs.Sff;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+/**
+ * Open vSwitch OpenFlow 1.3 Networking Provider for Netvirt SFC
+ * @author Arun Yerra
+ */
public class NetvirtSfcOF13Provider implements INetvirtSfcOF13Provider{
private final DataBroker dataService;
- public NetvirtSfcOF13Provider (final DataBroker dataBroker) {
+ public NetvirtSfcOF13Provider(final DataBroker dataBroker) {
this.dataService = Preconditions.checkNotNull(dataBroker, "DataBroker can not be null!");
- }
+ }
@Override
public void addClassifierRules(Sff sff, AccessList acl) {