+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Copyright (C) 2014 Red Hat, 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
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>config-parent</artifactId>
- <version>0.4.0-SNAPSHOT</version>
- <relativePath/>
- </parent>
-
- <groupId>org.opendaylight.ovsdb</groupId>
- <artifactId>ovssfc</artifactId>
- <version>1.2.1-SNAPSHOT</version>
- <packaging>bundle</packaging>
- <description>The OVSDB Plugin integration project is a project for OpenDaylight that will implement the Open vSwitch Database RFC 7047 management protocol allowing the Southbound configuration of vSwitches and a network virtualization implementation.</description>
- <url>https://wiki.opendaylight.org/view/OVSDB_Integration:Main</url>
- <licenses>
- <license>
- <name>Eclipse Public License v1.0</name>
- <url>http://www.eclipse.org/legal/epl-v10.html</url>
- </license>
- </licenses>
- <developers>
- <developer>
- <name>Sam Hague</name>
- <email>shague@gmail.com</email>
- <url>https://github.com/shague</url>
- </developer>
- </developers>
- <scm>
- <connection>scm:git:ssh://git.opendaylight.org:29418/ovsdb.git</connection>
- <developerConnection>scm:git:ssh://git.opendaylight.org:29418/ovsdb.git</developerConnection>
- <tag>HEAD</tag>
- <url>https://wiki.opendaylight.org/view/OVSDB_Integration:Main</url>
- </scm>
-
- <properties>
- <openflowplugin.version>0.2.0-SNAPSHOT</openflowplugin.version>
- <sfc.version>0.2.0-SNAPSHOT</sfc.version>
- </properties>
-
- <dependencies>
- <!-- project specific dependencies -->
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>library</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>plugin</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>schema.openvswitch</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>utils.mdsal-openflow</artifactId>
- <version>${project.version}</version>
- </dependency>
- <!-- openflowplugin dependencies -->
- <dependency>
- <groupId>org.opendaylight.openflowplugin.model</groupId>
- <artifactId>model-flow-base</artifactId>
- <version>${openflowplugin.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.openflowplugin.model</groupId>
- <artifactId>model-flow-service</artifactId>
- <version>${openflowplugin.version}</version>
- </dependency>
- <!-- sfc dependencies -->
- <dependency>
- <groupId>org.opendaylight.sfc</groupId>
- <artifactId>sfc-model</artifactId>
- <version>${sfc.version}</version>
- </dependency>
- <!-- mdsal dependencies -->
- <dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>ietf-inet-types</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>opendaylight-l2-types</artifactId>
- </dependency>
- <!-- testing dependencies -->
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-</project>
\ No newline at end of file
+++ /dev/null
-/*
-* Copyright (C) 2014 Red Hat, 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
-*
-* Authors : Sam Hague
-*/
-package org.opendaylight.controller.config.yang.config.ovssfc_provider.impl;
-
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.ovsdb.ovssfc.OvsSfcProvider;
-
-public class OvsSfcProviderModule extends org.opendaylight.controller.config.yang.config.ovssfc_provider.impl.AbstractOvsSfcProviderModule {
- public OvsSfcProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
- super(identifier, dependencyResolver);
- }
-
- public OvsSfcProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.controller.config.yang.config.ovssfc_provider.impl.OvsSfcProviderModule oldModule, java.lang.AutoCloseable oldInstance) {
- super(identifier, dependencyResolver, oldModule, oldInstance);
- }
-
- @Override
- public void customValidation() {
- // add custom validation form module attributes here.
- }
-
- @Override
- public java.lang.AutoCloseable createInstance() {
- DataBroker dataBroker = getDataBrokerDependency();
- final OvsSfcProvider ovsSfcProvider = new OvsSfcProvider(dataBroker);
-
- final class AutoCloseableSfc implements AutoCloseable {
-
- @Override
- public void close() throws Exception {
- ovsSfcProvider.close();
- }
- }
-
- AutoCloseable ret = new AutoCloseableSfc();
- return ret;
- }
-
-}
+++ /dev/null
-/*
-* Generated file
-*
-* Generated from: yang module name: ovssfc-provider-impl yang module local name: ovssfc-provider-impl
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Mon Aug 11 13:45:11 EDT 2014
-*
-* Do not modify this file unless it is present under src/main directory
-*/
-package org.opendaylight.controller.config.yang.config.ovssfc_provider.impl;
-public class OvsSfcProviderModuleFactory extends org.opendaylight.controller.config.yang.config.ovssfc_provider.impl.AbstractOvsSfcProviderModuleFactory {
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2014, 2015 Red Hat, 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.ovssfc;
-
-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.LogicalDatastoreType;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-public abstract class AbstractDataListener implements DataChangeListener {
- private DataBroker dataBroker;
- private InstanceIdentifier<?> iID;
- private ListenerRegistration<DataChangeListener> dataChangeListenerRegistration;
-
- public void setDataBroker (DataBroker dataBroker) {
- this.dataBroker = dataBroker;
- }
-
- public void setIID (InstanceIdentifier<?> IID) {
- this.iID = IID;
- }
-
- public void registerAsDataChangeListener () {
- dataChangeListenerRegistration = dataBroker.registerDataChangeListener(LogicalDatastoreType.CONFIGURATION,
- iID, this, DataBroker.DataChangeScope.SUBTREE);
- }
-
- public void registerAsDataChangeListener (AsyncDataBroker.DataChangeScope dataChangeScope) {
- dataChangeListenerRegistration = dataBroker.registerDataChangeListener(LogicalDatastoreType.CONFIGURATION,
- iID, this, dataChangeScope);
- }
-
- public void closeDataChangeListener () {
- dataChangeListenerRegistration.close();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014, 2015 Red Hat, 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.ovssfc;
-
-//import com.google.common.base.Optional;
-//import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-//import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-//import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.acl.rev140701.Actions1;
-//import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.acl.rev140701.Actions1Builder;
-//import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.acl.rev140701.access.lists.access.list.access.list.entries.actions.SfcAction;
-//import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.acl.rev140701.access.lists.access.list.access.list.entries.actions.sfc.action.AclServiceFunctionPath;
-//import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.acl.rev140701.access.lists.access.list.access.list.entries.actions.sfc.action.AclServiceFunctionPathBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev140520.AccessLists;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev140520.AccessListsBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev140520.access.lists.AccessList;
-//import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev140520.access.lists.AccessListBuilder;
-//import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev140520.access.lists.access.list.AccessListEntries;
-//import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev140520.access.lists.access.list.AccessListEntriesBuilder;
-//import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev140520.access.lists.access.list.access.list.entries.ActionsBuilder;
-//import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev140520.access.lists.access.list.access.list.entries.MatchesBuilder;
-//import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev140520.access.lists.access.list.access.list.entries.matches.ace.type.AceIpBuilder;
-//import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
-//import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.packet.fields.rev140625.acl.transport.header.fields.DestinationPortRangeBuilder;
-//import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-//import java.util.ArrayList;
-//import java.util.List;
-//import java.util.concurrent.ExecutionException;
-
-public class AclUtils {
- private static final Logger logger = LoggerFactory.getLogger(AclUtils.class);
- private AccessList accessList;
- private AccessLists accessLists;
-
- public AclUtils () {
- // TODO: remove these when then acl restconf is fixed
- //setAccessList();
- //setAccessLists();
- }
-/*
- public AccessLists readAccessLists () {
- InstanceIdentifier<AccessLists> iID =
- InstanceIdentifierUtils.createAccessListsPath();
-
- ReadOnlyTransaction readTx = OvsSfcProvider.getOvsSfcProvider().getDataBroker().newReadOnlyTransaction();
- Optional<AccessLists> dataObject = null;
- try {
- dataObject = readTx.read(LogicalDatastoreType.CONFIGURATION, iID).get();
- } catch (InterruptedException | ExecutionException e) {
- e.printStackTrace();
- }
- if ((dataObject != null) && (dataObject.get() != null)) {
- logger.trace("\nOVSSFC {}\n acl: {}",
- Thread.currentThread().getStackTrace()[1], dataObject.get().toString());
- return dataObject.get();
- } else {
- logger.trace("\nOVSSFC {}, acl: null", Thread.currentThread().getStackTrace()[1]);
- return null;
- }
- }
-
- public AccessListEntries getAccessList (String servicePathName) {
- AccessListEntries accessListEntry = null;
- // TODO: revert when reston fix is in
- //AccessLists accessLists = readAccessLists();
- AccessLists accessLists = this.accessLists;
-
- List<AccessList> accessListList = accessLists.getAccessList();
- for (AccessList accessList : accessListList) {
- List<AccessListEntries> accessListEntriesList = accessList.getAccessListEntries();
- for (AccessListEntries accessListEntries : accessListEntriesList) {
- SfcAction sfcAction = accessListEntries.getActions().getAugmentation(Actions1.class).getSfcAction();
- //String aclServicePathName = ((AclServiceFunctionPath)sfcAction).getServiceFunctionPath();
- //if (servicePathName.equals(aclServicePathName)) {
- // accessListEntry = accessListEntries;
- // break;
- //}
- }
- }
-
- return accessListEntry;
- }
-
- public AccessListEntries getAccessList () {
- AccessListEntries accessListEntry = null;
-
- setAccessList();
-
- List<AccessListEntries> accessListEntriesList = accessList.getAccessListEntries();
- for (AccessListEntries accessListEntries : accessListEntriesList) {
- accessListEntry = accessListEntries;
- }
-
- return accessListEntry;
- }
-
- private AccessList setAccessList () {
- PortNumber portNumber = new PortNumber(80);
- DestinationPortRangeBuilder destinationPortRangeBuilder = new DestinationPortRangeBuilder();
- destinationPortRangeBuilder.setLowerPort(portNumber);
- destinationPortRangeBuilder.setUpperPort(portNumber);
-
- AceIpBuilder aceIpBuilder = new AceIpBuilder();
- aceIpBuilder.setDestinationPortRange(destinationPortRangeBuilder.build());
-
- MatchesBuilder matchesBuilder = new MatchesBuilder();
- matchesBuilder.setAceType(aceIpBuilder.build());
-
- //AclServiceFunctionPathBuilder aclServiceFunctionPathBuilder = new AclServiceFunctionPathBuilder();
- //aclServiceFunctionPathBuilder.setServiceFunctionPath("sfp1");
-
- Actions1Builder actions1Builder = new Actions1Builder();
- //actions1Builder.setSfcAction(aclServiceFunctionPathBuilder.build());
-
- ActionsBuilder actionsBuilder = new ActionsBuilder();
- actionsBuilder.addAugmentation(Actions1.class, actions1Builder.build());
-
- AccessListEntriesBuilder accessListEntriesBuilder = new AccessListEntriesBuilder();
- accessListEntriesBuilder.setRuleName("http");
- accessListEntriesBuilder.setMatches(matchesBuilder.build());
- accessListEntriesBuilder.setActions(actionsBuilder.build());
- List<AccessListEntries> accessListEntriesList = new ArrayList<>();
- accessListEntriesList.add(accessListEntriesBuilder.build());
-
- AccessListBuilder accessListBuilder = new AccessListBuilder();
- accessListBuilder.setAclName("http");
- accessListBuilder.setAccessListEntries(accessListEntriesList);
-
- logger.trace("acl: {}", accessListBuilder.build());
- accessList = accessListBuilder.build();
- return accessListBuilder.build();
- }
-
- private AccessLists setAccessLists () {
- PortNumber portNumber = new PortNumber(80);
- DestinationPortRangeBuilder destinationPortRangeBuilder = new DestinationPortRangeBuilder();
- destinationPortRangeBuilder.setLowerPort(portNumber);
- destinationPortRangeBuilder.setUpperPort(portNumber);
-
- AceIpBuilder aceIpBuilder = new AceIpBuilder();
- aceIpBuilder.setDestinationPortRange(destinationPortRangeBuilder.build());
-
- MatchesBuilder matchesBuilder = new MatchesBuilder();
- matchesBuilder.setAceType(aceIpBuilder.build());
-
- //AclServiceFunctionPathBuilder aclServiceFunctionPathBuilder = new AclServiceFunctionPathBuilder();
- //aclServiceFunctionPathBuilder.setServiceFunctionPath("sfp1");
-
- Actions1Builder actions1Builder = new Actions1Builder();
- //actions1Builder.setSfcAction(aclServiceFunctionPathBuilder.build());
-
- ActionsBuilder actionsBuilder = new ActionsBuilder();
- actionsBuilder.addAugmentation(Actions1.class, actions1Builder.build());
-
- AccessListEntriesBuilder accessListEntriesBuilder = new AccessListEntriesBuilder();
- accessListEntriesBuilder.setRuleName("http");
- accessListEntriesBuilder.setMatches(matchesBuilder.build());
- accessListEntriesBuilder.setActions(actionsBuilder.build());
- List<AccessListEntries> accessListEntriesList = new ArrayList<>();
- accessListEntriesList.add(accessListEntriesBuilder.build());
-
- AccessListBuilder accessListBuilder = new AccessListBuilder();
- accessListBuilder.setAclName("http");
- accessListBuilder.setAccessListEntries(accessListEntriesList);
- List<AccessList> accessListList = new ArrayList<>();
- accessListList.add(accessListBuilder.build());
-
- AccessListsBuilder accessListsBuilder = new AccessListsBuilder();
- accessListsBuilder.setAccessList(accessListList);
-
- logger.trace("acls: {}", accessListsBuilder.build());
- accessLists = accessListsBuilder.build();
- return accessListsBuilder.build();
- }
-*/
-}
+++ /dev/null
-/*
- * Copyright (c) 2014, 2015 Red Hat, 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.ovssfc;
-
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.TimeUnit;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.ServiceFunctionPaths;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.ServiceFunctionPath;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class EventHandler {
- private static final Logger logger = LoggerFactory.getLogger(EventHandler.class);
- private ExecutorService eventHandler;
- private BlockingQueue<SfcEvent> events;
-
- void init () {
- eventHandler = Executors.newSingleThreadExecutor();
- this.events = new LinkedBlockingQueue<>();
- }
-
- void start () {
- eventHandler.submit(new Runnable() {
- @Override
- public void run() {
- while (true) {
- SfcEvent ev;
- try {
- ev = events.take();
- } catch (InterruptedException e) {
- logger.info("The event handler thread was interrupted, shutting down", e);
- return;
- }
- logger.trace("\nOVSSFC: {}, event: {}", Thread.currentThread().getStackTrace()[1], ev);
- switch (ev.getType()) {
- case SFP:
- try {
- OvsSfcProvider.getOvsSfcProvider().sfp.processSfp(ev.getAction(), ev.serviceFunctionPath);
- } catch (Exception e) {
- logger.error("Exception caught in processSfp {}", ev, e);
- }
- break;
- case SFPS:
- try {
- OvsSfcProvider.getOvsSfcProvider().sfp.processSfps(ev.getAction(), ev.serviceFunctionPaths);
- } catch (Exception e) {
- logger.error("Exception caught in processSfps {}", ev, e);
- }
- break;
- default:
- logger.warn("Unable to process {}", ev);
- }
- }
- }
- });
- }
-
- void stop () throws InterruptedException{
- // stop accepting new tasks
- eventHandler.shutdown();
-
- if (!eventHandler.awaitTermination(100, TimeUnit.MICROSECONDS)) {
- System.out.println("Still waiting...");
- //System.exit(0);
- }
- System.out.println("Exiting normally...");
-
-/*
- try {
- // Wait a while for existing tasks to terminate
- if (!eventHandler.awaitTermination(10, TimeUnit.SECONDS)) {
- eventHandler.shutdownNow();
- // Wait a while for tasks to respond to being cancelled
- if (!eventHandler.awaitTermination(10, TimeUnit.SECONDS)) {
- logger.error("EventHandler did not terminate");
- }
- }
- } catch (InterruptedException e) {
- // (Re-)Cancel if current thread also interrupted
- eventHandler.shutdownNow();
- // Preserve interrupt status
- Thread.currentThread().interrupt();
- }
-*/
- }
-
- public void enqueueSfpEvent (SfcEvent.Action action, ServiceFunctionPath serviceFunctionPath) {
- SfcEvent event = new SfcEvent(SfcEvent.Type.SFP, action, serviceFunctionPath);
- enqueueEvent(event);
- }
-
- public void enqueueSfpsEvent (SfcEvent.Action action, ServiceFunctionPaths serviceFunctionPaths) {
- SfcEvent event = new SfcEvent(SfcEvent.Type.SFPS, action, serviceFunctionPaths);
- enqueueEvent(event);
- }
-
- public void enqueueEvent (SfcEvent event) {
- try {
- events.put(event);
- } catch (InterruptedException e) {
- logger.error("Thread was interrupted while trying to enqueue event ", e);
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014, 2015 Red Hat, 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.ovssfc;
-
-import com.google.common.collect.Lists;
-import com.google.common.util.concurrent.CheckedFuture;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
-//import org.opendaylight.ovsdb.utils.mdsal.openflow.ActionUtils;
-import org.opendaylight.ovsdb.utils.mdsal.openflow.InstructionUtils;
-import org.opendaylight.ovsdb.utils.mdsal.openflow.MatchUtils;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
-//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.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
-//import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.OutputPortValues;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.List;
-import java.util.concurrent.ExecutionException;
-
-public class Flows {
- private static final Logger logger = LoggerFactory.getLogger(Flows.class);
- private OvsSfcProvider ovsSfcProvider = OvsSfcProvider.getOvsSfcProvider();
- private static final short TABLE_0_DEFAULT_INGRESS = 0;
- private static final short TABLE_1_CLASSIFIER = 5;
- private static final short TABLE_2_NEXTHOP = 6;
- private static final short SFC_PRIORITY = 100;
- private static final String OPENFLOW = "openflow:";
-
- private NodeBuilder createNodeBuilder (String nodeId) {
- NodeBuilder builder = new NodeBuilder();
- builder.setId(new NodeId(nodeId));
- builder.setKey(new NodeKey(builder.getId()));
- return builder;
- }
-
- private void removeFlow(FlowBuilder flowBuilder, NodeBuilder nodeBuilder) {
- DataBroker dataBroker = OvsSfcProvider.getOvsSfcProvider().getDataBroker();
- if (dataBroker == null) {
- logger.error("ERROR finding reference for DataBroker. Please check MD-SAL support on the Controller.");
- return;
- }
-
- WriteTransaction modification = dataBroker.newWriteOnlyTransaction();
- InstanceIdentifier<Flow> path1 = InstanceIdentifier.builder(Nodes.class)
- .child(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory
- .rev130819.nodes.Node.class, nodeBuilder.getKey())
- .augmentation(FlowCapableNode.class).child(Table.class,
- new TableKey(flowBuilder.getTableId())).child(Flow.class, flowBuilder.getKey()).build();
- //modification.delete(LogicalDatastoreType.OPERATIONAL, nodeBuilderToInstanceId(nodeBuilder));
- //modification.delete(LogicalDatastoreType.OPERATIONAL, path1);
- //modification.delete(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(nodeBuilder));
- modification.delete(LogicalDatastoreType.CONFIGURATION, path1);
-
- CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
- try {
- commitFuture.get(); // TODO: Make it async (See bug 1362)
- logger.debug("Transaction success for deletion of Flow "+flowBuilder.getFlowName());
- } catch (InterruptedException|ExecutionException e) {
- logger.error(e.getMessage(), e);
- }
- }
-
- private void writeFlow (FlowBuilder flowBuilder, NodeBuilder nodeBuilder) {
- DataBroker dataBroker = OvsSfcProvider.getOvsSfcProvider().getDataBroker();
- if (dataBroker == null) {
- logger.error("ERROR finding reference for DataBroker. Please check MD-SAL support on the Controller.");
- return;
- }
-
- ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
- InstanceIdentifier<Flow> path1 = InstanceIdentifier
- .builder(Nodes.class).child(
- org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node.class,
- nodeBuilder.getKey())
- .augmentation(FlowCapableNode.class).child(Table.class,
- new TableKey(flowBuilder.getTableId()))
- .child(Flow.class, flowBuilder.getKey()).build();
-
- //modification.put(LogicalDatastoreType.OPERATIONAL, path1, flowBuilder.build());
- modification.put(LogicalDatastoreType.CONFIGURATION, path1, flowBuilder.build(), true /*createMissingParents*/);
-
- CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
- try {
- commitFuture.get(); // TODO: Make it async (See bug 1362)
- logger.debug("Transaction success for write of Flow "+flowBuilder.getFlowName());
- } catch (InterruptedException|ExecutionException e) {
- logger.error(e.getMessage(), e);
- }
- }
-
- private void writeLLDPRule(Long dpidLong) {
-
- String nodeName = OPENFLOW + dpidLong;
- EtherType etherType = new EtherType(0x88CCL);
-
- MatchBuilder matchBuilder = new MatchBuilder();
- NodeBuilder nodeBuilder = createNodeBuilder(nodeName);
- FlowBuilder flowBuilder = new FlowBuilder();
-
- // Create Match(es) and Set them in the FlowBuilder Object
- flowBuilder.setMatch(MatchUtils.createEtherTypeMatch(matchBuilder, etherType).build());
-
- // Create the OF Actions and Instructions
- InstructionBuilder ib = new InstructionBuilder();
- InstructionsBuilder isb = new InstructionsBuilder();
-
- // Instructions List Stores Individual Instructions
- List<Instruction> instructions = Lists.newArrayList();
-
- // Call the InstructionBuilder Methods Containing Actions
- InstructionUtils.createSendToControllerInstructions(nodeName, ib);
- ib.setOrder(0);
- ib.setKey(new InstructionKey(0));
- instructions.add(ib.build());
-
- // Add InstructionBuilder to the Instruction(s)Builder List
- isb.setInstruction(instructions);
-
- // Add InstructionsBuilder to FlowBuilder
- flowBuilder.setInstructions(isb.build());
-
- String flowId = "LLDP";
- flowBuilder.setId(new FlowId(flowId));
- FlowKey key = new FlowKey(new FlowId(flowId));
- flowBuilder.setPriority(10);
- flowBuilder.setBarrier(false);
- flowBuilder.setTableId((short) 0);
- flowBuilder.setKey(key);
- flowBuilder.setFlowName(flowId);
- flowBuilder.setHardTimeout(0);
- flowBuilder.setIdleTimeout(0);
- writeFlow(flowBuilder, nodeBuilder);
- }
-
- /*
- * Create a NORMAL Table Miss Flow Rule
- * Match: any
- * Action: forward to NORMAL pipeline
- */
- private void writeNormalRule (Long dpidLong) {
- String nodeName = OPENFLOW + dpidLong;
-
- MatchBuilder matchBuilder = new MatchBuilder();
- NodeBuilder nodeBuilder = createNodeBuilder(nodeName);
- FlowBuilder flowBuilder = new FlowBuilder();
-
- //flowBuilder.setMatch(MatchUtils.createInPortMatch(matchBuilder, dpidLong, 1L).build());
-
- // Create the OF Actions and Instructions
- InstructionBuilder ib = new InstructionBuilder();
- InstructionsBuilder isb = new InstructionsBuilder();
-
- // Instructions List Stores Individual Instructions
- List<Instruction> instructions = Lists.newArrayList();
-
- // Call the InstructionBuilder Methods Containing Actions
- InstructionUtils.createNormalInstructions(nodeName, ib);
- ib.setOrder(0);
- ib.setKey(new InstructionKey(0));
- instructions.add(ib.build());
-
- // Add InstructionBuilder to the Instruction(s)Builder List
- isb.setInstruction(instructions);
-
- // Add InstructionsBuilder to FlowBuilder
- flowBuilder.setInstructions(isb.build());
-
- String flowId = "NORMAL";
- flowBuilder.setId(new FlowId(flowId));
- FlowKey key = new FlowKey(new FlowId(flowId));
- flowBuilder.setMatch(matchBuilder.build());
- flowBuilder.setPriority(10);
- flowBuilder.setBarrier(false);
- flowBuilder.setTableId(TABLE_0_DEFAULT_INGRESS);
- flowBuilder.setKey(key);
- flowBuilder.setFlowName(flowId);
- flowBuilder.setHardTimeout(0);
- flowBuilder.setIdleTimeout(0);
- writeFlow(flowBuilder, nodeBuilder);
- }
-
- public void initializeFlowRules (Long dpid) {
- /*
- * Table(0) Rule #1
- * ----------------
- * Match: LLDP (0x88CCL)
- * Action: Packet_In to Controller Reserved Port
- */
-
- //Uri value = new Uri(OutputPortValues.CONTROLLER.toString());
- //Uri value2 = new Uri(InputPortValues);
-
- writeLLDPRule(dpid);
- writeNormalRule(dpid);
- }
-
- public static MatchBuilder createInPortLocalMatch(MatchBuilder matchBuilder, Long dpidLong, String portId) {
-
- NodeConnectorId ncid = new NodeConnectorId("openflow:" + dpidLong + ":" + portId);
- logger.debug("createInPortMatch() Node Connector ID is - Type=openflow: DPID={} inPort={} ", dpidLong, "LOCAL");
- matchBuilder.setInPort(NodeConnectorId.getDefaultInstance(ncid.getValue()));
- matchBuilder.setInPort(ncid);
-
- return matchBuilder;
- }
-
- /*
- * Match: in_port, tcp, tcp_dst
- * Actions: mod_vlan_vid, resubmit(,30)
- */
- public void writeIngressAcl (Long dpid, long inPort, int vlan, boolean write) {
- String nodeName = OPENFLOW + dpid;
-
- MatchBuilder matchBuilder = new MatchBuilder();
- NodeBuilder nodeBuilder = createNodeBuilder(nodeName);
- FlowBuilder flowBuilder = new FlowBuilder();
-
- //flowBuilder.setMatch(createInPortLocalMatch(matchBuilder, dpid, OutputPortValues.LOCAL.toString()).build());
- PortNumber portNumber = new PortNumber(80);
- //flowBuilder.setMatch(MatchUtils.createSetDstTcpMatch(matchBuilder, portNumber).build());
-
- String flowId = "ingressAcl_"+portNumber.getValue();
- flowBuilder.setId(new FlowId(flowId));
- FlowKey key = new FlowKey(new FlowId(flowId));
- flowBuilder.setMatch(matchBuilder.build());
- flowBuilder.setPriority(100);
- //flowBuilder.setStrict(true);
- flowBuilder.setBarrier(false);
- flowBuilder.setTableId(TABLE_0_DEFAULT_INGRESS);
- flowBuilder.setKey(key);
- flowBuilder.setFlowName(flowId);
- flowBuilder.setHardTimeout(0);
- flowBuilder.setIdleTimeout(0);
-
- if (write) {
- // Create the OF Actions and Instructions
- InstructionBuilder ib = new InstructionBuilder();
- InstructionsBuilder isb = new InstructionsBuilder();
-
- // Instructions List Stores Individual Instructions
- List<Instruction> instructions = Lists.newArrayList();
-
- // Call the InstructionBuilder Methods Containing Actions
-/*
- // GOTO Instructions Need to be added first to the List
- InstructionUtils.createGotoTableInstructions(ib, (short)5);
- ib.setOrder(0);
- ib.setKey(new InstructionKey(0));
- instructions.add(ib.build());
-*/
- // Set VLAN ID Instruction
- InstructionUtils.createSetVlanInstructions(ib, new VlanId(vlan));
- ib.setOrder(0);
- ib.setKey(new InstructionKey(0));
- instructions.add(ib.build());
- // Add InstructionBuilder to the Instruction(s)Builder List
- isb.setInstruction(instructions);
-
- // Add InstructionsBuilder to FlowBuilder
- flowBuilder.setInstructions(isb.build());
-
- //ActionUtils.nxResubmitAction(0, (short)6);
- writeFlow(flowBuilder, nodeBuilder);
- } else {
- removeFlow(flowBuilder, nodeBuilder);
- }
-
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014, 2015 Red Hat, 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.ovssfc;
-
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.ServiceFunctions;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.functions.ServiceFunction;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.functions.ServiceFunctionKey;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.ServiceFunctionChains;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.ServiceFunctionForwarders;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarder;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarderKey;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.ServiceFunctionPaths;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.ServiceFunctionPath;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev140520.AccessLists;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-public final class InstanceIdentifierUtils {
-
- private InstanceIdentifierUtils() {
- throw new UnsupportedOperationException("Utility class should never be instantiated");
- }
-
- public static final InstanceIdentifier<AccessLists> createAccessListsPath () {
- return InstanceIdentifier.builder(AccessLists.class).build();
- }
-
- public static final InstanceIdentifier<ServiceFunctionChains> createServiceFunctionChainsPath () {
- return InstanceIdentifier.builder(ServiceFunctionChains.class).build();
- }
-
- public static final InstanceIdentifier<ServiceFunctionForwarder> createServiceFunctionForwarderPath () {
- return InstanceIdentifier.builder(ServiceFunctionForwarders.class)
- .child(ServiceFunctionForwarder.class).build();
- }
-
- public static final InstanceIdentifier<ServiceFunctionForwarder> createServiceFunctionForwarderPath (String name) {
- ServiceFunctionForwarderKey serviceFunctionForwarderKey = new ServiceFunctionForwarderKey(name);
- return InstanceIdentifier.builder(ServiceFunctionForwarders.class)
- .child(ServiceFunctionForwarder.class, serviceFunctionForwarderKey)
- .build();
- }
-
- public static final InstanceIdentifier<ServiceFunctionForwarders> createServiceFunctionForwardersPath () {
- return InstanceIdentifier.builder(ServiceFunctionForwarders.class).build();
- }
-
- public static final InstanceIdentifier<ServiceFunction> createServiceFunctionPath (String name) {
- ServiceFunctionKey serviceFunctionKey = new ServiceFunctionKey(name);
- return InstanceIdentifier.builder(ServiceFunctions.class)
- .child(ServiceFunction.class, serviceFunctionKey)
- .build();
- }
-
- public static final InstanceIdentifier<ServiceFunctionPaths> createServiceFunctionPathsPath () {
- return InstanceIdentifier.builder(ServiceFunctionPaths.class).build();
- }
-
- public static final InstanceIdentifier<ServiceFunctionPath> createServiceFunctionPathPath () {
- return InstanceIdentifier.builder(ServiceFunctionPaths.class)
- .child(ServiceFunctionPath.class).build();
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (c) 2014, 2015 Red Hat, 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.ovssfc;
-
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class OvsSfcProvider implements AutoCloseable {
- private static final Logger logger = LoggerFactory.getLogger(OvsSfcProvider.class);
- private static OvsSfcProvider ovsSfcProvider;
- private DataBroker dataBroker;
- private SfcDataListener sfcDataListener;
- private SffDataListener sffDataListener;
- private SfpDataListener sfpDataListener;
- protected SfpHandler sfp;
- protected EventHandler eventHandler;
- protected AclUtils aclUtils;
- protected OvsUtils ovsUtils;
- protected SfUtils sfUtils;
- protected SffUtils sffUtils;
- protected Flows flows;
-
- public OvsSfcProvider (DataBroker dataBroker) {
- ovsSfcProvider = this;
- setDataBroker(dataBroker);
-
- sfcDataListener = new SfcDataListener(dataBroker);
- sffDataListener = new SffDataListener(dataBroker);
- sfpDataListener = new SfpDataListener(dataBroker);
- aclUtils = new AclUtils();
- ovsUtils = new OvsUtils();
- sfUtils = new SfUtils();
- sffUtils = new SffUtils();
- flows = new Flows();
- sfp = new SfpHandler();
- eventHandler = new EventHandler();
- eventHandler.init();
- eventHandler.start();
-
- logger.info("Initialized");
- }
-
- public void setDataBroker (DataBroker dataBroker) {
- this.dataBroker = dataBroker;
- }
-
- public DataBroker getDataBroker () {
- return this.dataBroker;
- }
-
- public static OvsSfcProvider getOvsSfcProvider () {
- return OvsSfcProvider.ovsSfcProvider;
- }
-
- @Override
- public void close () throws Exception {
- sfcDataListener.closeDataChangeListener();
- sffDataListener.closeDataChangeListener();
- sfpDataListener.closeDataChangeListener();
- logger.info("Closed");
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014, 2015 Red Hat, 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.ovssfc;
-
-import com.google.common.base.Preconditions;
-import org.opendaylight.controller.sal.core.Node;
-import org.opendaylight.controller.sal.utils.HexEncode;
-import org.opendaylight.controller.sal.utils.ServiceHelper;
-import org.opendaylight.ovsdb.lib.notation.Row;
-import org.opendaylight.ovsdb.plugin.api.OvsdbConfigurationService;
-import org.opendaylight.ovsdb.plugin.api.OvsdbConnectionService;
-import org.opendaylight.ovsdb.schema.openvswitch.Bridge;
-import org.opendaylight.ovsdb.schema.openvswitch.OpenVSwitch;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-public class OvsUtils {
- private static final Logger logger = LoggerFactory.getLogger(OvsUtils.class);
- private OvsSfcProvider ovsSfcProvider = OvsSfcProvider.getOvsSfcProvider();
-
- private OvsdbConnectionService getOvsdbConnectionService () {
- return (OvsdbConnectionService) ServiceHelper.getGlobalInstance(OvsdbConnectionService.class, this);
- }
-
- private OvsdbConfigurationService getOvsdbConfigurationService () {
- return (OvsdbConfigurationService) ServiceHelper.getGlobalInstance(OvsdbConfigurationService.class, this);
- }
-
- public Node getNodeFromSystemId (String systemId) {
- Node node = null;
-
- OvsdbConnectionService connectionService = getOvsdbConnectionService();
- Preconditions.checkNotNull(connectionService);
- List<Node> ovsNodes = connectionService.getNodes();
- if (ovsNodes != null) {
- for (Node ovsNode : ovsNodes) {
- if (systemId.equals(getSystemId(ovsNode))) {
- node = ovsNode;
- }
- }
- }
-
- logger.trace("\nOVSSFC {}\n ovsNode: {}",
- Thread.currentThread().getStackTrace()[1],
- node != null ? node.toString() : "");
-
- return node;
- }
-
-
- public String getSystemId (Node ovsNode) {
- String systemId = "";
-
- if (ovsNode == null) {
- return systemId;
- }
- OvsdbConfigurationService ovsdbConfigurationService = getOvsdbConfigurationService();
- if (ovsdbConfigurationService == null) {
- return systemId;
- }
-
- Map<String, Row> table =
- ovsdbConfigurationService.getRows(ovsNode, ovsdbConfigurationService.getTableName(ovsNode, OpenVSwitch.class));
-
- if (table == null) {
- logger.error("OpenVSwitch table is null for Node {} ", ovsNode);
- return systemId;
- }
-
- // Loop through all the Open_vSwitch rows looking for the first occurrence of external_ids.
- // The specification does not restrict the number of rows so we choose the first we find.
- for (Row row : table.values()) {
- OpenVSwitch ovsRow = ovsdbConfigurationService.getTypedRow(ovsNode, OpenVSwitch.class, row);
- Map<String, String> externalIds = ovsRow.getExternalIdsColumn().getData();
- if (externalIds == null) {
- continue;
- }
-
- systemId = externalIds.get("system-id");
- }
-
- logger.trace("\nOVSSFC {}\n system-id: {}",
- Thread.currentThread().getStackTrace()[1],
- systemId);
-
- return systemId;
- }
-
- public String getBridgeUUID (Node ovsNode, String bridgeName) {
- String uuid = "";
-
- if (ovsNode == null) {
- return uuid;
- }
-
- OvsdbConfigurationService ovsdbConfigurationService = getOvsdbConfigurationService();
- if (ovsdbConfigurationService == null) {
- return uuid;
- }
-
- try {
- Map<String, Row> table = ovsdbConfigurationService.
- getRows(ovsNode, ovsdbConfigurationService.getTableName(ovsNode, Bridge.class));
-
- if (table != null) {
- for (String key : table.keySet()) {
- Bridge bridge = ovsdbConfigurationService.getTypedRow(ovsNode, Bridge.class, table.get(key));
- if (bridge.getName().equals(bridgeName)) {
- uuid = key;
- }
- }
- }
- } catch (Exception e) {
- logger.error("Error getting Bridge Identifier for {} / {}", ovsNode, bridgeName, e);
- }
-
- logger.trace("\nOVSSFC {}\n uuid: {}",
- Thread.currentThread().getStackTrace()[1],
- uuid);
-
- return uuid;
- }
-
- public Long getDpid (Node ovsNode, String bridgeName) {
- Long dpid = 0L;
-
- if (ovsNode == null) {
- return dpid;
- }
-
- logger.trace("\nOVSSFC Enter {}\n ovsNode: {}, bridgeName: {}",
- Thread.currentThread().getStackTrace()[1],
- ovsNode, bridgeName);
-
- String bridgeUuid = ovsSfcProvider.ovsUtils.getBridgeUUID(ovsNode, bridgeName);
- if (bridgeUuid == null) {
- return dpid;
- }
-
- logger.trace("\nOVSSFC {}\n ovsNode: {}, bridgeName: {}, uuid: {}",
- Thread.currentThread().getStackTrace()[1],
- ovsNode, bridgeName, bridgeUuid);
-
- OvsdbConfigurationService ovsdbConfigurationService = getOvsdbConfigurationService();
- try {
- Row bridgeRow = ovsdbConfigurationService
- .getRow(ovsNode, ovsdbConfigurationService.getTableName(ovsNode, Bridge.class), bridgeUuid);
- Bridge bridge = ovsdbConfigurationService.getTypedRow(ovsNode, Bridge.class, bridgeRow);
- Set<String> dpids = bridge.getDatapathIdColumn().getData();
- if (dpids != null && !dpids.isEmpty()) {
- dpid = HexEncode.stringToLong((String) dpids.toArray()[0]);
- }
- } catch (Exception e) {
- logger.error("Error finding Bridge's OF DPID", e);
- }
- return dpid;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014, 2015 Red Hat, 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.ovssfc;
-
-import com.google.common.base.Optional;
-import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.functions.ServiceFunction;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.concurrent.ExecutionException;
-
-public class SfUtils {
- private static final Logger logger = LoggerFactory.getLogger(SfUtils.class);
-
- public ServiceFunction readServiceFunction (String name) {
- InstanceIdentifier<ServiceFunction> iID =
- InstanceIdentifierUtils.createServiceFunctionPath(name);
-
- ReadOnlyTransaction readTx = OvsSfcProvider.getOvsSfcProvider().getDataBroker().newReadOnlyTransaction();
- Optional<ServiceFunction> dataObject = null;
- try {
- dataObject = readTx.read(LogicalDatastoreType.CONFIGURATION, iID).get();
- } catch (InterruptedException | ExecutionException e) {
- e.printStackTrace();
- }
- if ((dataObject != null) && (dataObject.get() != null)) {
- logger.trace("\nOVSSFC Exit: {}\n sf: {}",
- Thread.currentThread().getStackTrace()[1], dataObject.get().toString());
- return dataObject.get();
- } else {
- logger.trace("\nOVSSFC Exit: {}, sf: null", Thread.currentThread().getStackTrace()[1]);
- return null;
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014, 2015 Red Hat, 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.ovssfc;
-
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.ServiceFunctionChains;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import java.util.Map;
-
-public class SfcDataListener extends AbstractDataListener {
- private static final Logger logger = LoggerFactory.getLogger(SfcDataListener.class);
-
- public SfcDataListener (DataBroker dataBroker) {
- setDataBroker(dataBroker);
- setIID(InstanceIdentifierUtils.createServiceFunctionChainsPath());
- registerAsDataChangeListener();
- }
-
- @Override
- public void onDataChanged (final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change ) {
- logger.trace("\nOVSSFC Enter: {}", Thread.currentThread().getStackTrace()[1]);
-
- Map<InstanceIdentifier<?>, DataObject> dataCreatedObject = change.getCreatedData();
-
- Map<InstanceIdentifier<?>, DataObject> dataUpdatedConfigurationObject = change.getUpdatedData();
- for (Map.Entry<InstanceIdentifier<?>, DataObject> entry : dataUpdatedConfigurationObject.entrySet()) {
- if (entry.getValue() instanceof ServiceFunctionChains) {
- ServiceFunctionChains updatedServiceFunctionChains = (ServiceFunctionChains) entry.getValue();
- logger.trace("\nOVSSFC sfc:\n {}", updatedServiceFunctionChains.toString());
- }
- }
-
- logger.trace("\nOVSSFC Exit: {}", Thread.currentThread().getStackTrace()[1]);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014, 2015 Red Hat, 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.ovssfc;
-
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.ServiceFunctionPaths;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.ServiceFunctionPath;
-
-public class SfcEvent {
- protected ServiceFunctionPath serviceFunctionPath;
- protected ServiceFunctionPaths serviceFunctionPaths;
- private Type type;
- private Action action;
- public enum Type { SFP, SFPS };
- public enum Action { CREATE, UPDATE, DELETE };
-
- public SfcEvent (Type type) {
- this.type = type;
- }
-
- public SfcEvent (Type type, Action action, ServiceFunctionPath serviceFunctionPath) {
- this.type = type;
- this.action = action;
- this.serviceFunctionPath = serviceFunctionPath;
- }
-
- public SfcEvent (Type type, Action action, ServiceFunctionPaths serviceFunctionPaths) {
- this.type = type;
- this.action = action;
- this.serviceFunctionPaths = serviceFunctionPaths;
- }
-
- public Type getType () {
- return type;
- }
-
- public void setType (Type type) {
- this.type = type;
- }
-
- public Action getAction () {
- return action;
- }
-
- public void setAction (Action action) {
- this.action = action;
- }
-
- @Override
- public String toString () {
- switch (type) {
- case SFP:
- return "SfcEvent{" +
- "type=" + type + ", action=" + action + ", " +
- "ServiceFunctionPath=" + serviceFunctionPath +
- '}';
- case SFPS:
- return "SfcEvent{" +
- "type=" + type + ", action=" + action + ", " +
- "ServiceFunctionPaths=" + serviceFunctionPaths +
- '}';
- default:
- return "undefined";
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014, 2015 Red Hat, 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.ovssfc;
-
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarder;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import java.util.Map;
-
-public class SffDataListener extends AbstractDataListener {
- private static final Logger logger = LoggerFactory.getLogger(SffDataListener.class);
-
- public SffDataListener (DataBroker dataBroker) {
- setDataBroker(dataBroker);
- setIID(InstanceIdentifierUtils.createServiceFunctionForwarderPath());
- registerAsDataChangeListener();
- }
-
- @Override
- public void onDataChanged (final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change ) {
- Map<InstanceIdentifier<?>, DataObject> dataObject;
- logger.trace("\nOVSSFC Enter: {}", Thread.currentThread().getStackTrace()[1]);
-
- dataObject = change.getCreatedData();
- for (Map.Entry<InstanceIdentifier<?>, DataObject> entry : dataObject.entrySet()) {
- if (entry.getValue() instanceof ServiceFunctionForwarder) {
- ServiceFunctionForwarder serviceFunctionForwarder = (ServiceFunctionForwarder) entry.getValue();
- logger.trace("\nOVSSFC CREATE: sff:\n {}", serviceFunctionForwarder.toString());
- }
- }
-
- dataObject = change.getUpdatedData();
- for (Map.Entry<InstanceIdentifier<?>, DataObject> entry : dataObject.entrySet()) {
- if (entry.getValue() instanceof ServiceFunctionForwarder) {
- ServiceFunctionForwarder serviceFunctionForwarder = (ServiceFunctionForwarder) entry.getValue();
- logger.trace("\nOVSSFC UPDATE: sff:\n {}", serviceFunctionForwarder.toString());
- }
- }
-
- logger.trace("\nOVSSFC Exit: {}", Thread.currentThread().getStackTrace()[1]);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014, 2015 Red Hat, 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.ovssfc;
-
-import com.google.common.base.Optional;
-import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-//import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.functions.ServiceFunction;
-//import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.ovs.rev140701.ServiceFunctionForwarder1;
-//import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.ovs.rev140701.service.function.forwarders.service.function.forwarder.ovs.ExternalIds;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarder;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-//import java.util.List;
-import java.util.concurrent.ExecutionException;
-
-public class SffUtils {
- private static final Logger logger = LoggerFactory.getLogger(SffUtils.class);
-
- public ServiceFunctionForwarder readServiceFunctionForwarder (String name) {
- InstanceIdentifier<ServiceFunctionForwarder> iID =
- InstanceIdentifierUtils.createServiceFunctionForwarderPath(name);
-
- ReadOnlyTransaction readTx = OvsSfcProvider.getOvsSfcProvider().getDataBroker().newReadOnlyTransaction();
- Optional<ServiceFunctionForwarder> dataObject = null;
- try {
- dataObject = readTx.read(LogicalDatastoreType.CONFIGURATION, iID).get();
- } catch (InterruptedException | ExecutionException e) {
- e.printStackTrace();
- }
- if ((dataObject != null) && (dataObject.get() != null)) {
- logger.trace("\nOVSSFC Exit: {}\n sff: {}",
- Thread.currentThread().getStackTrace()[1], dataObject.get().toString());
- return dataObject.get();
- } else {
- logger.trace("\nOVSSFC Exit: {}, sff: null", Thread.currentThread().getStackTrace()[1]);
- return null;
- }
- }
-
- public String getSystemId (ServiceFunctionForwarder serviceFunctionForwarder) {
- String systemId = "";
-
- //List<ExternalIds> externalIds = serviceFunctionForwarder.getAugmentation(ServiceFunctionForwarder1.class).getOvs().getExternalIds();
- //for (ExternalIds externalId : externalIds) {
- // if (externalId.getName().equals("system-id")) {
- // systemId = externalId.getValue();
- // }
- //}
-
- logger.trace("\nOVSSFC {}\n system-id: {}",
- Thread.currentThread().getStackTrace()[1],
- systemId);
-
- return systemId;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014, 2015 Red Hat, 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.ovssfc;
-
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
-//import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.ServiceFunctionPaths;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.ServiceFunctionPath;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import java.util.Map;
-//import java.util.Set;
-
-public class SfpDataListener extends AbstractDataListener {
- private static final Logger logger = LoggerFactory.getLogger(SfpDataListener.class);
-
- public SfpDataListener (DataBroker dataBroker) {
- setDataBroker(dataBroker);
- //setIID(InstanceIdentifierUtils.createServiceFunctionPathsPath());
- setIID(InstanceIdentifierUtils.createServiceFunctionPathPath());
- registerAsDataChangeListener(DataBroker.DataChangeScope.BASE);
- }
-
- @Override
- public void onDataChanged (final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change ) {
- Map<InstanceIdentifier<?>, DataObject> dataObject;
-
- logger.trace("\nOVSSFC Enter: {}", Thread.currentThread().getStackTrace()[1]);
-/* Keeping for reference in case I need to use it
- DataObject dom = change.getOriginalSubtree();
- if (dom instanceof ServiceFunctionPaths) {
- ServiceFunctionPaths serviceFunctionPaths = (ServiceFunctionPaths) dom;
- logger.trace("\nOVSSFC ORIGINAL SUBTREE: sfps:\n {}", serviceFunctionPaths.toString());
-
- //OvsSfcProvider.getOvsSfcProvider().eventHandler.enqueueSfpEvent(SfcEvent.Action.CREATE, serviceFunctionPaths);
- }
- dom = change.getUpdatedSubtree();
- if (dom instanceof ServiceFunctionPaths) {
- ServiceFunctionPaths serviceFunctionPaths = (ServiceFunctionPaths) dom;
- logger.trace("\nOVSSFC UPDATED SUBTREE: sfps:\n {}", serviceFunctionPaths.toString());
-
- OvsSfcProvider.getOvsSfcProvider().eventHandler.enqueueSfpEvent(SfcEvent.Action.UPDATE, serviceFunctionPaths);
- }
-
- dataObject = change.getOriginalData();
- for (Map.Entry<InstanceIdentifier<?>, DataObject> entry : dataObject.entrySet()) {
- if (entry.getValue() instanceof ServiceFunctionPaths) {
- ServiceFunctionPaths serviceFunctionPaths = (ServiceFunctionPaths) entry.getValue();
- logger.trace("\nOVSSFC ORIGINAL: sfps:\n {}", serviceFunctionPaths.toString());
-
- //OvsSfcProvider.getOvsSfcProvider().eventHandler.enqueueSfpEvent(SfcEvent.Action.CREATE, serviceFunctionPaths);
- }
- }
-
- Map<InstanceIdentifier<?>, DataObject> originalDataObject = change.getOriginalData();
- Set<InstanceIdentifier<?>> iID = change.getRemovedPaths();
- for (InstanceIdentifier instanceIdentifier : iID) {
- DataObject dObject = originalDataObject.get(instanceIdentifier);
- if (dObject instanceof ServiceFunctionPath) {
- ServiceFunctionPath serviceFunctionPath = (ServiceFunctionPath) dataObject;
- logger.trace("\nOVSSFC DELETE: sfp:\n {}", serviceFunctionPath.toString());
-
- OvsSfcProvider.getOvsSfcProvider().eventHandler.enqueueSfpEvent(SfcEvent.Action.DELETE, serviceFunctionPath);
- }
- }
-
- dataObject = change.getUpdatedData();
- for (Map.Entry<InstanceIdentifier<?>, DataObject> entry : dataObject.entrySet()) {
- if (entry.getValue() instanceof ServiceFunctionPaths) {
- ServiceFunctionPaths updatedServiceFunctionPaths = (ServiceFunctionPaths) entry.getValue();
- logger.trace("\nOVSSFC UPDATE: sfps:\n {}", updatedServiceFunctionPaths.toString());
-
- OvsSfcProvider.getOvsSfcProvider().eventHandler.enqueueSfpsEvent(SfcEvent.Action.UPDATE, updatedServiceFunctionPaths);
- }
- }
-*/
-/*
- dataObject = change.getCreatedData();
- for (Map.Entry<InstanceIdentifier<?>, DataObject> entry : dataObject.entrySet()) {
- if (entry.getValue() instanceof ServiceFunctionPaths) {
- ServiceFunctionPaths serviceFunctionPaths = (ServiceFunctionPaths) entry.getValue();
- logger.trace("\nOVSSFC CREATE: sfps:\n {}", serviceFunctionPaths.toString());
-
- OvsSfcProvider.getOvsSfcProvider().eventHandler.enqueueSfpsEvent(SfcEvent.Action.CREATE, serviceFunctionPaths);
- }
- }
-*/
- dataObject = change.getCreatedData();
- for (Map.Entry<InstanceIdentifier<?>, DataObject> entry : dataObject.entrySet()) {
- if (entry.getValue() instanceof ServiceFunctionPath) {
- ServiceFunctionPath serviceFunctionPath = (ServiceFunctionPath) entry.getValue();
- logger.trace("\nOVSSFC CREATE: sfp:\n {}", serviceFunctionPath.toString());
-
- OvsSfcProvider.getOvsSfcProvider().eventHandler.enqueueSfpEvent(SfcEvent.Action.CREATE, serviceFunctionPath);
- }
- }
-
- dataObject = change.getUpdatedData();
- for (Map.Entry<InstanceIdentifier<?>, DataObject> entry : dataObject.entrySet()) {
- if (entry.getValue() instanceof ServiceFunctionPath) {
- ServiceFunctionPath updatedServiceFunctionPath = (ServiceFunctionPath) entry.getValue();
- logger.trace("\nOVSSFC UPDATE: sfp:\n {}", updatedServiceFunctionPath.toString());
-
- OvsSfcProvider.getOvsSfcProvider().eventHandler.enqueueSfpEvent(SfcEvent.Action.UPDATE, updatedServiceFunctionPath);
- }
- }
-
- logger.trace("\nOVSSFC Exit: {}", Thread.currentThread().getStackTrace()[1]);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014, 2015 Red Hat, 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.ovssfc;
-
-import org.opendaylight.controller.sal.core.Node;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarder;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.ServiceFunctionPaths;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.ServiceFunctionPath;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.service.function.path.ServicePathHop;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev140520.access.lists.access.list.AccessListEntries;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.List;
-
-public class SfpHandler {
- private static final Logger LOGGER = LoggerFactory.getLogger(SfpHandler.class);
- private OvsSfcProvider ovsSfcProvider = OvsSfcProvider.getOvsSfcProvider();
- private int vlan;
-
- public int getVlan () {
- return vlan;
- }
-
- public void setVlan (int vlan) {
- this.vlan = vlan;
- }
-
- void processSfp (SfcEvent.Action action, ServiceFunctionPath serviceFunctionPath) {
- LOGGER.trace("\nOVSSFC Enter: {}, action: {}\n sfp: {}",
- Thread.currentThread().getStackTrace()[1],
- action.toString(),
- serviceFunctionPath.toString());
-
- switch (action) {
- case CREATE:
- case UPDATE:
- sfpUpdate(serviceFunctionPath);
- break;
- case DELETE:
- break;
- default:
- break;
- }
-
- LOGGER.trace("\nOVSSFC Exit: {}", Thread.currentThread().getStackTrace()[1]);
- }
-
- void processSfps (SfcEvent.Action action, ServiceFunctionPaths serviceFunctionPaths) {
- LOGGER.trace("\nOVSSFC Enter: {}, action: {}\n sfps: {}",
- Thread.currentThread().getStackTrace()[1],
- action.toString(),
- serviceFunctionPaths.toString());
-
- switch (action) {
- case CREATE:
- case UPDATE:
- break;
- case DELETE:
- break;
- default:
- break;
- }
-
- LOGGER.trace("\nOVSSFC Exit: {}", Thread.currentThread().getStackTrace()[1]);
- }
-
- /*
- * Get the ingress ssf. This sff will take the ingress acl flows.
- * Get the acl.
- * Get the system-id from the sff to find the ovs node.
- * Program flows.
- *
- */
- private void sfpUpdate (ServiceFunctionPath serviceFunctionPath) {
- LOGGER.trace("\nOVSSFC {}\n Building SFP {}",
- Thread.currentThread().getStackTrace()[1],
- serviceFunctionPath.getName());
-
- // TODO: replace with correct getAccessList when the restonf issue is fixed.
- //ovsSfcProvider.aclUtils.getAccessList(serviceFunctionPath.getName());
- AccessListEntries accessListEntries = null;
- LOGGER.trace("\n acl: {}", accessListEntries);
- // TODO: code to convert acl into flows
-
- String serviceFunctionForwarderName;
- ServiceFunctionForwarder serviceFunctionForwarder = null;
- Short startingIndex = serviceFunctionPath.getStartingIndex();
- List<ServicePathHop> servicePathHopList = serviceFunctionPath.getServicePathHop();
- for (ServicePathHop servicePathHop : servicePathHopList) {
- LOGGER.trace("\n sph: {}", servicePathHop);
-
- serviceFunctionForwarderName = servicePathHop.getServiceFunctionForwarder();
- serviceFunctionForwarder = ovsSfcProvider.sffUtils.readServiceFunctionForwarder(serviceFunctionForwarderName);
- if (serviceFunctionForwarder != null) {
- String systemId = ovsSfcProvider.sffUtils.getSystemId(serviceFunctionForwarder);
- Node ovsNode = ovsSfcProvider.ovsUtils.getNodeFromSystemId(systemId);
- if (ovsNode != null) {
- Long dpid = ovsSfcProvider.ovsUtils.getDpid(ovsNode, serviceFunctionForwarderName);
- if (dpid.equals(0)) {
- LOGGER.warn("cannot find dpid for {}", serviceFunctionForwarderName);
- continue;
- }
- if (servicePathHop.getServiceIndex().equals(startingIndex)) {
- ovsSfcProvider.flows.initializeFlowRules(dpid);
- // Add ingress classifier rule
- ovsSfcProvider.flows.writeIngressAcl(dpid, 0L, 0, true);
- // Add vlan t0 rule
- }
- // Add t30 classifier reg rule
- // Add t31 nextHop rule
- }
- }
- }
- }
-
-}
+++ /dev/null
-<snapshot>
- <configuration>
- <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
- <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
-
- <module>
- <type xmlns:ovssfc="urn:opendaylight:params:xml:ns:yang:controller:config:ovssfc-provider:impl">
- ovssfc:ovssfc-provider-impl
- </type>
- <name>ovssfc-provider-impl</name>
-
- <data-broker>
- <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-async-data-broker</type>
- <name>binding-data-broker</name>
- </data-broker>
- </module>
- </modules>
- </data>
-
- </configuration>
-
- <required-capabilities>
- <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&revision=2013-10-28</capability>
- <capability>urn:opendaylight:params:xml:ns:yang:controller:config:ovssfc-provider:impl?module=ovssfc-provider-impl&revision=2014-06-30</capability>
- </required-capabilities>
-
-</snapshot>
+++ /dev/null
-// vi: set smarttab et sw=4 tabstop=4:
-module ovssfc-provider-impl {
-
- yang-version 1;
- namespace "urn:opendaylight:params:xml:ns:yang:controller:config:ovssfc-provider:impl";
- prefix "ovssfc-provider-impl";
-
- import config { prefix config; revision-date 2013-04-05; }
- import opendaylight-md-sal-binding { prefix mdsal; revision-date 2013-10-28; }
-
-
- description
- "This module contains the base YANG definitions for
- ovssfc-provider impl implementation.";
-
- revision "2014-06-30" {
- description
- "Initial revision.";
- }
-
- identity ovssfc-provider-impl {
- base config:module-type;
-
- config:java-name-prefix OvsSfcProvider;
- }
-
- augment "/config:modules/config:module/config:configuration" {
- case ovssfc-provider-impl {
- when "/config:modules/config:module/config:type = 'ovssfc-provider-impl'";
-
- //wires in the data-broker service
- container data-broker {
- uses config:service-ref {
- refine type {
- mandatory false;
- config:required-identity mdsal:binding-async-data-broker;
- }
- }
- }
- }
- }
-}
+++ /dev/null
-package org.opendaylight.ovsdb.ovssfc;
-
-import static org.junit.Assert.assertTrue;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-//import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.ServiceFunctionPaths;
-//import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.PutServiceFunctionInputBuilder;
-import org.opendaylight.controller.md.sal.common.api.data.DataChangeEvent;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.function.entry.SfDataPlaneLocator;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.function.entry.SfDataPlaneLocatorBuilder;
-//import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.ServiceFunctionPaths;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.ServiceFunctionPathsBuilder;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.ServiceFunctionPath;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.ServiceFunctionPathBuilder;
-//import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.service.function.path.SfpServiceFunction;
-//import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.service.function.path.SfpServiceFunctionBuilder;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.data.plane.locator.locator.type.IpBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
-//import org.opendaylight.yangtools.yang.common.RpcResult;
-//import org.opendaylight.yangtools.yang.binding.DataObject;
-//import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-//import ch.qos.logback.classic.Level;
-
-import java.util.ArrayList;
-//import java.util.HashMap;
-import java.util.List;
-//import java.util.Map;
-//import java.util.concurrent.Future;
-
-import static org.mockito.Mockito.mock;
-//import static org.mockito.Mockito.when;
-//import static org.mockito.Mockito.when;
-
-public class EventHandlerTest {
- static final Logger logger = LoggerFactory.getLogger(EventHandler.class);
- DataBroker dataBroker;
- DataChangeEvent dataChangeEvent;
- OvsSfcProvider sfcProvider;
-
- @Before
- public void setUp() {
- dataBroker = mock(DataBroker.class);
- dataChangeEvent = mock(DataChangeEvent.class);
- sfcProvider = new OvsSfcProvider(dataBroker);
-
- //ch.qos.logback.classic.Logger rootLogger =
- // (ch.qos.logback.classic.Logger)LoggerFactory.getLogger(ch.qos.logback.classic.Logger.ROOT_LOGGER_NAME);
- //rootLogger.setLevel(Level.toLevel("trace"));
- }
-
- @After
- public void tearDown() throws Exception {
- //System.out.println(">>>>>Running test stop 1");
- //sfcProvider.eventHandler.shutdownNow();
- sfcProvider.eventHandler.stop();
- //System.out.println(">>>>>Running test stop 2");
- }
-
- @Test
- public void testNA () {
- assertTrue(true);
- }
-
- @Ignore
- @Test(timeout=1000)
- public void testSfpUpdate() throws Exception {
- //ch.qos.logback.classic.Logger rootLogger =
- // (ch.qos.logback.classic.Logger)LoggerFactory.getLogger(ch.qos.logback.classic.Logger.ROOT_LOGGER_NAME);
- //rootLogger.setLevel(Level.toLevel("trace"));
-
- List<SfDataPlaneLocator> sfDpLList = new ArrayList<>();
- sfDpLList.add(putSf("dpi-1", "dpi", "10.1.1.1", "10.1.1.1", 10000).build());
- sfDpLList.add(putSf("napt44-1", "napt44", "10.1.1.2", "10.1.1.2", 10000).build());
-/* model changed and broke tests
- SfpServiceFunctionBuilder sfBuilder = new SfpServiceFunctionBuilder();
- List<SfpServiceFunction> sfList = new ArrayList<>();
- sfBuilder.setName("sf1");
- sfBuilder.setServiceIndex((short)3);
- sfBuilder.setServiceFunctionForwarder("sff1");
- sfList.add(sfBuilder.build());
- sfBuilder.setName("sf2");
- sfBuilder.setServiceIndex((short)2);
- sfBuilder.setServiceFunctionForwarder("sff1");
- sfList.add(sfBuilder.build());
-*/
- ServiceFunctionPathBuilder sfpBuilder = new ServiceFunctionPathBuilder();
- sfpBuilder.setName("sfp1");
- sfpBuilder.setServiceChainName("sfp1");
- sfpBuilder.setPathId(1L);
- //sfpBuilder.setStartingIndex((short) (sfList.size() + 1));
- //sfpBuilder.setSfpServiceFunction(sfList);
-
- ServiceFunctionPathsBuilder builder = new ServiceFunctionPathsBuilder();
- List<ServiceFunctionPath> sfpList = new ArrayList<>();
- sfpList.add(sfpBuilder.build());
- builder.setServiceFunctionPath(sfpList);
-
- //sfcProvider.eventHandler.enqueueSfpEvent(builder.build());
- Thread.sleep(100);
- System.out.println(">>>>>Running test end");
- }
-
- private SfDataPlaneLocatorBuilder putSf(String name, String type,
- String ipMgmt, String ipLocator, int portLocator) {
- logger.info("\n####### Start: {}", Thread.currentThread().getStackTrace()[1]);
-
- // Build Locator Type (ip and port)
- IpAddress ipAddress = new IpAddress(ipLocator.toCharArray());
- PortNumber portNumber = new PortNumber(portLocator);
- IpBuilder ipBuilder = new IpBuilder();
- ipBuilder = ipBuilder.setIp(ipAddress).setPort(portNumber);
-
- // Build Data Plane Locator and populate with Locator Type
-
- SfDataPlaneLocatorBuilder sfDataPlaneLocatorBuilder = new SfDataPlaneLocatorBuilder();
- sfDataPlaneLocatorBuilder = sfDataPlaneLocatorBuilder.setLocatorType(ipBuilder.build());
- return sfDataPlaneLocatorBuilder;
-
-/*
- // Build ServiceFunctionBuilder and set all data constructed above
- PutServiceFunctionInputBuilder putServiceFunctionInputBuilder = new PutServiceFunctionInputBuilder();
- putServiceFunctionInputBuilder = putServiceFunctionInputBuilder.setName(name).setType(type).
- setIpMgmtAddress(new IpAddress(ipMgmt.toCharArray())).
- setSfDataPlaneLocator(sfDataPlaneLocatorBuilder.build());
-
- try {
- Future<RpcResult<Void>> fr = sfService.putServiceFunction(putServiceFunctionInputBuilder.build());
- RpcResult<Void> result = fr.get();
- if (result != null) {
- logger.info("\n####### {} result: {}", Thread.currentThread().getStackTrace()[1], result);
- if (result.isSuccessful()) {
- logger.info("\n####### {}: successfully finished", Thread.currentThread().getStackTrace()[1]);
- } else {
- logger.warn("\n####### {}: not successfully finished", Thread.currentThread().getStackTrace()[1]);
- }
- return result.isSuccessful();
- } else {
- logger.warn("\n####### {} result is NULL", Thread.currentThread().getStackTrace()[1]);
- return Boolean.FALSE;
- }
-
- } catch (Exception e) {
- logger.warn("\n####### {} Error occurred: {}", Thread.currentThread().getStackTrace()[1], e);
- e.printStackTrace();
- return Boolean.FALSE;
- }
- }
-*/
- }
-}
+++ /dev/null
-{
- "access-lists": {
- "access-list": [
- {
- "acl-name": "http",
- "access-list-entries": [
- {
- "rule-name": "http",
- "matches": {
- "destination-port-range": {
- "lower-port": "80",
- "upper-port": "80"
- }
- },
- "actions": {
- "service-function-path": "sfp1"
- }
- }
- ]
- }
- ]
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "service-function-chains": {
- "service-function-chain": [
- {
- "name": "sfc1",
- "symmetric": false,
- "sfc-service-function": [
- {
- "name": "napt44-abstract1",
- "type": "napt44"
- },
- {
- "name": "napt44-abstract2",
- "type": "napt44"
- }
- ]
- }
- ]
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "service-function-forwarders": {
- "service-function-forwarder": [
- {
- "name": "sff1",
- "service-node": "sff1",
- "classifier": "acl-sfp-1-http",
- "sff-data-plane-locator": [
- {
- "name": "sff1",
- "data-plane-locator": {
- "port": 5000,
- "ip": "192.168.120.45",
- "transport": "service-locator:vxlan-gpe"
- }
- }
- ],
- "service-function-dictionary": [
- {
- "name": "sf11",
- "type": "napt44",
- "failmode": "close",
- "sff-sf-data-plane-locator": {
- "transport": "service-locator:vxlan-gpe",
- "port": 10000,
- "ip": "10.1.11.1"
- },
- "sff-interfaces": [
- {
- "sff-interface": "vsff1-sf11"
- }
- ]
- },
- {
- "name": "sf12",
- "type": "napt44",
- "failmode": "close",
- "sff-sf-data-plane-locator": {
- "transport": "service-locator:vxlan-gpe",
- "port": 10000,
- "ip": "10.1.12.1"
- },
- "sff-interfaces": [
- {
- "sff-interface": "vsff1-sf12"
- }
- ]
- }
- ],
- "ovs": {
- "uuid": "5b791cee-9b85-454d-a915-3c5b33538696",
- "bridge-name": "sff1",
- "rest-uri": "http://www.example.com/sffs/sff-bootstrap",
- "external-ids": [
- {
- "name": "system-id",
- "value": "66485d3b-01d5-4792-a85e-705417f9458b"
- }
- ]
- }
- }
- ]
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "service-function-paths": {
- "service-function-path": [
- {
- "name": "sfp1",
- "service-chain-name": "sfc1",
- "starting-index": "3",
- "path-id": "1",
- "service-path-hop": [
- {
- "hop-number": "1",
- "service-function-name": "sf11",
- "service-function-forwarder": "sff1",
- "service_index": "3"
- },
- {
- "hop-number": "2",
- "service-function-name": "sf12",
- "service-function-forwarder": "sff1",
- "service_index": "2"
- }
- ]
- }
- ]
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "service-functions": {
- "service-function": [
- {
- "name": "sf11",
- "type": "napt44",
- "nsh-aware": false,
- "ip-mgmt-address": "10.1.11.1",
- "sf-data-plane-locator": {
- "name": "sf11",
- "transport": "service-locator:vxlan-gpe",
- "port": 10000,
- "ip": "10.1.11.1",
- "service-function-forwarder": "sff1"
- }
- },
- {
- "name": "sf12",
- "type": "napt44",
- "nsh-aware": false,
- "ip-mgmt-address": "10.1.12.1",
- "sf-data-plane-locator": {
- "name": "sf12",
- "transport": "service-locator:vxlan-gpe",
- "port": 10000,
- "ip": "10.1.12.1",
- "service-function-forwarder": "sff1"
- }
- }
- ]
- }
-}
\ No newline at end of file