Merge "Add to jboss repository snapshot and release properties"
authorGiovanni Meo <gmeo@cisco.com>
Tue, 24 Sep 2013 14:48:45 +0000 (14:48 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Tue, 24 Sep 2013 14:48:45 +0000 (14:48 +0000)
opendaylight/commons/opendaylight/pom.xml
opendaylight/forwardingrulesmanager/implementation/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/FlowEntryDistributionOrderFutureTask.java
opendaylight/forwardingrulesmanager/implementation/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManager.java
opendaylight/md-sal/model/model-flow-base/src/main/yang/flow-types.yang
opendaylight/md-sal/pom.xml
opendaylight/md-sal/sal-compability/pom.xml
opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/FromSalConversionsUtils.java
opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/ToSalConversionsUtils.java
opendaylight/topologymanager/implementation/src/main/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImpl.java

index 0c2ad3f8aa151ba45f718bf347ddc17f913fe6fe..042bc54928a8def322a80c866d61682faed5656b 100644 (file)
@@ -28,6 +28,7 @@
     <siteplugin>3.2</siteplugin>
     <projectinfo>2.6</projectinfo>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
     <compiler.version>2.3.2</compiler.version>
     <surefire.version>2.15</surefire.version>
     <failsafe.version>2.15</failsafe.version>
index 1ebc300c75ac80c05a5ae6e8dc8b88366468f1c6..a51409fc2d241b61f2180b20841a942cf5e2ca36 100644 (file)
@@ -36,6 +36,10 @@ final class FlowEntryDistributionOrderFutureTask implements Future<Status> {
     private CountDownLatch waitingLatch;
     private Status retStatus;
     private static final Logger logger = LoggerFactory.getLogger(FlowEntryDistributionOrderFutureTask.class);
+    // Don't wait forever to program, rather timeout if there are issues, and
+    // log an error
+    private long timeout;
+    private static final Long DEFAULTTIMEOUT = 30000L;
 
     /**
      * @param order
@@ -49,6 +53,14 @@ final class FlowEntryDistributionOrderFutureTask implements Future<Status> {
         this.waitingLatch = new CountDownLatch(1);
         // No return status yet!
         this.retStatus = new Status(StatusCode.UNDEFINED);
+        // Set the timeout
+        String strTimeout = System.getProperty("FlowEntryDistributionOrderFutureTask.timeout",
+                                               DEFAULTTIMEOUT.toString());
+        try {
+            timeout = Long.parseLong(strTimeout);
+        } catch (Exception e) {
+            timeout = DEFAULTTIMEOUT;
+        }
     }
 
     @Override
@@ -58,6 +70,7 @@ final class FlowEntryDistributionOrderFutureTask implements Future<Status> {
 
     @Override
     public Status get() throws InterruptedException, ExecutionException {
+        boolean didFinish = false;
         logger.trace("Getting status for order {}", this.order);
         // If i'm done lets return the status as many times as caller wants
         if (this.waitingLatch.getCount() == 0L) {
@@ -67,16 +80,22 @@ final class FlowEntryDistributionOrderFutureTask implements Future<Status> {
 
         logger.trace("Start waiting for status to come back");
         // Wait till someone signal that we are done
-        this.waitingLatch.await();
+        didFinish = this.waitingLatch.await(this.timeout, TimeUnit.MILLISECONDS);
 
-        logger.trace("Waiting for the status is over, returning it");
-        // Return the known status
-        return retStatus;
+        if (didFinish) {
+            logger.trace("Waiting for the status of order {} is over, returning it", this.order);
+            // Return the known status
+            return retStatus;
+        } else {
+            logger.error("Timing out, the workStatus for order {} has not come back in time!", this.order);
+            return new Status(StatusCode.TIMEOUT);
+        }
     }
 
     @Override
     public Status get(long timeout, TimeUnit unit) throws InterruptedException,
             ExecutionException, TimeoutException {
+        boolean didFinish = false;
         logger.trace("Getting status for order {}", this.order);
         // If i'm done lets return the status as many times as caller wants
         if (this.waitingLatch.getCount() == 0L) {
@@ -86,11 +105,18 @@ final class FlowEntryDistributionOrderFutureTask implements Future<Status> {
 
         logger.trace("Start waiting for status to come back");
         // Wait till someone signal that we are done
-        this.waitingLatch.await(timeout, unit);
+        didFinish = this.waitingLatch.await(timeout, unit);
 
-        logger.trace("Waiting for the status is over, returning it");
-        // Return the known status, could also be null if didn't return
-        return retStatus;
+        if (didFinish) {
+            logger.trace("Waiting for the status is over, returning it");
+            // Return the known status, could also be null if didn't return
+            return retStatus;
+        } else {
+            // No need to bark here as long as this routine could indeed
+            // timeout
+            logger.trace("Timing out, the workStatus for order {} has not come back in time!", this.order);
+            return new Status(StatusCode.TIMEOUT);
+        }
     }
 
     @Override
@@ -123,4 +149,12 @@ final class FlowEntryDistributionOrderFutureTask implements Future<Status> {
         this.waitingLatch.countDown();
         logger.trace("Unlocked the Future");
     }
+
+    /**
+     * Getter for the workOrder for which the order is waiting for
+     * @return the order
+     */
+    public FlowEntryDistributionOrder getOrder() {
+        return order;
+    }
 }
index a6cdf2c466ab579986234f2a5a4c884fe8e7fd33..9c2afe42be0860df310516ff2f5b85ec1dd0261f 100644 (file)
@@ -214,7 +214,8 @@ public class ForwardingRulesManager implements
      * @return a Future object for monitoring the progress of the result, or
      *         null in case the processing should take place locally
      */
-    private Future<Status> distributeWorkOrder(FlowEntryInstall e, FlowEntryInstall u, UpdateType t) {
+    private FlowEntryDistributionOrderFutureTask distributeWorkOrder(FlowEntryInstall e, FlowEntryInstall u,
+            UpdateType t) {
         // A null entry it's an unexpected condition, anyway it's safe to keep
         // the handling local
         if (e == null) {
@@ -544,11 +545,17 @@ public class ForwardingRulesManager implements
      *         contain the unique id assigned to this request
      */
     private Status modifyEntryInternal(FlowEntryInstall currentEntries, FlowEntryInstall newEntries, boolean async) {
-        Future<Status> futureStatus = distributeWorkOrder(currentEntries, newEntries, UpdateType.CHANGED);
+        FlowEntryDistributionOrderFutureTask futureStatus =
+                distributeWorkOrder(currentEntries, newEntries, UpdateType.CHANGED);
         if (futureStatus != null) {
             Status retStatus = new Status(StatusCode.UNDEFINED);
             try {
                 retStatus = futureStatus.get();
+                if (retStatus.getCode()
+                        .equals(StatusCode.TIMEOUT)) {
+                    // A timeout happened, lets cleanup the workMonitor
+                    workMonitor.remove(futureStatus.getOrder());
+                }
             } catch (InterruptedException e) {
                 log.error("", e);
             } catch (ExecutionException e) {
@@ -656,11 +663,16 @@ public class ForwardingRulesManager implements
      *         contain the unique id assigned to this request
      */
     private Status removeEntryInternal(FlowEntryInstall entry, boolean async) {
-        Future<Status> futureStatus = distributeWorkOrder(entry, null, UpdateType.REMOVED);
+        FlowEntryDistributionOrderFutureTask futureStatus = distributeWorkOrder(entry, null, UpdateType.REMOVED);
         if (futureStatus != null) {
             Status retStatus = new Status(StatusCode.UNDEFINED);
             try {
                 retStatus = futureStatus.get();
+                if (retStatus.getCode()
+                        .equals(StatusCode.TIMEOUT)) {
+                    // A timeout happened, lets cleanup the workMonitor
+                    workMonitor.remove(futureStatus.getOrder());
+                }
             } catch (InterruptedException e) {
                 log.error("", e);
             } catch (ExecutionException e) {
@@ -704,11 +716,16 @@ public class ForwardingRulesManager implements
      *         contain the unique id assigned to this request
      */
     private Status addEntriesInternal(FlowEntryInstall entry, boolean async) {
-        Future<Status> futureStatus = distributeWorkOrder(entry, null, UpdateType.ADDED);
+        FlowEntryDistributionOrderFutureTask futureStatus = distributeWorkOrder(entry, null, UpdateType.ADDED);
         if (futureStatus != null) {
             Status retStatus = new Status(StatusCode.UNDEFINED);
             try {
                 retStatus = futureStatus.get();
+                if (retStatus.getCode()
+                        .equals(StatusCode.TIMEOUT)) {
+                    // A timeout happened, lets cleanup the workMonitor
+                    workMonitor.remove(futureStatus.getOrder());
+                }
             } catch (InterruptedException e) {
                 log.error("", e);
             } catch (ExecutionException e) {
@@ -3171,7 +3188,7 @@ public class ForwardingRulesManager implements
              */
             if (fe.getRequestorController()
                     .equals(clusterContainerService.getMyAddress())) {
-                FlowEntryDistributionOrderFutureTask fet = workMonitor.get(fe);
+                FlowEntryDistributionOrderFutureTask fet = workMonitor.remove(fe);
                 if (fet != null) {
                     logsync.trace("workStatus response is for us {}", fe);
                     // Signal we got the status
index cd364b5402425fe63cc7c35bb78fed79b6a519ac..634c8dbd723832378ee7d62230c3d29628cdc5e9 100644 (file)
@@ -5,11 +5,31 @@ module opendaylight-flow-types {
     import ietf-inet-types {prefix inet;}
     import opendaylight-match-types {prefix match;}
     import ietf-yang-types {prefix yang;}
-
+    import opendaylight-l2-types {prefix l2t;}
 
     revision "2013-08-19" {
         description "Initial revision of flow service";
     }
+    
+    
+    typedef vlan-cfi {
+           type int32;    
+    }
+    
+    grouping address {
+        choice address {
+            case ipv4 {
+                leaf ipv4-address {
+                    type inet:ipv4-prefix;
+                }
+            }
+            case ipv6 {
+                leaf ipv6-address {
+                    type inet:ipv6-prefix;
+                }
+            }
+        }
+    }    
 
     grouping action {
         choice action {
@@ -59,9 +79,102 @@ module opendaylight-flow-types {
 
             }
 
+            case drop-action {
+            }
+            
+            case flood-action {
+            }
+            
+            case flood-all-action {
+            }
+            
+            case hw-path-action {
+            }
+            
+            case loopback-action {
+            }
+            
+            case pop-vlan-action {
+            }
+            
             case push-vlan-action {
-
+                leaf tag {               // TPID - 16 bits
+                    type int32;
+                } 
+                leaf pcp {               // PCP - 3 bits
+                    type int32;
+                }
+                leaf cfi {               // CFI - 1 bit (drop eligible)
+                    type vlan-cfi;
+                }
+                leaf vlan-id {           // VID - 12 bits
+                    type l2t:vlan-id;
+                }
+//                leaf tci {               //TCI = [PCP + CFI + VID]
+//                }
+//                leaf header {            //header = [TPID + TCI] 
+//                }
+            }
+            case set-dl-dst-action {
+                leaf address {
+                    type yang:mac-address;
+                }
+            }
+            
+            case set-dl-src-action {
+                leaf address {
+                    type yang:mac-address;
+                }
+            }
+            case set-dl-type-action {
+                leaf dl-type {
+                    type l2t:ether-type;
+                }
+            }
+            case set-next-hop-action {
+                uses address;
+            }
+            case set-nw-dst-action {
+                uses address;            
+            }
+            case set-nw-src-action{
+                uses address;            
+            }
+            case set-nw-tos-action {
+                leaf tos {
+                    type int32;
+                }
+            }
+            
+            case set-tp-dst-action {
+                leaf port {
+                    type inet:port-number;
+                }                
+            }
+            case set-tp-src-action {
+                leaf port {
+                    type inet:port-number;
+                }                
+            }
+            case set-vlan-cfi-action {
+                leaf vlan-cfi {
+                    type vlan-cfi;
+                }
+            }
+            case set-vlan-id-action {
+                leaf vlan-id {
+                    type l2t:vlan-id;
+                } 
+            }
+            case set-vlan-pcp-action {
+                leaf vlan-pcp {
+                    type l2t:vlan-pcp;
+                }            
+            }
+            case sw-path-action {            
             }
+            
+            
         }
     }
 
index 17b87cc279e029cdaec107b1f9997da4b75ed583..bf1b95decf22abaf3620c6bff3be25b14037bfbb 100644 (file)
@@ -25,6 +25,8 @@
         <module>samples</module>
         <!-- Base Models -->
         <module>model</module>
+        <!-- Compability Packages -->
+        <module>sal-compability</module>
        </modules>
 
        <properties>
index e3d8c589f7e135037ffd57738a0a7e4d700fe7a4..40301a379fe404463adae6e65987fb4260dcbdd9 100644 (file)
@@ -5,7 +5,6 @@
                <groupId>org.opendaylight.controller</groupId>
                <artifactId>sal-parent</artifactId>
                <version>1.0-SNAPSHOT</version>
-               <relativePath>../../sal/yang-prototype/sal/pom.xml</relativePath>
        </parent>
        <artifactId>sal-compability</artifactId>
 
@@ -38,7 +37,6 @@
                <dependency>
                        <groupId>com.google.guava</groupId>
                        <artifactId>guava</artifactId>
-                       <type>bundle</type>
                        <version>14.0.1</version>
                </dependency>
        </dependencies>
index e77375fc41a0d53367008064dc67f1a9b21b5d63..1d4f42c7999ebb4269fa9a047f0261715f4aedb4 100644 (file)
@@ -12,43 +12,21 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
-import org.opendaylight.controller.sal.action.Controller;
-import org.opendaylight.controller.sal.action.Drop;
-import org.opendaylight.controller.sal.action.Flood;
-import org.opendaylight.controller.sal.action.FloodAll;
-import org.opendaylight.controller.sal.action.HwPath;
-import org.opendaylight.controller.sal.action.Loopback;
-import org.opendaylight.controller.sal.action.Output;
-import org.opendaylight.controller.sal.action.PopVlan;
-import org.opendaylight.controller.sal.action.PushVlan;
-import org.opendaylight.controller.sal.action.SetDlDst;
-import org.opendaylight.controller.sal.action.SetDlSrc;
-import org.opendaylight.controller.sal.action.SetDlType;
-import org.opendaylight.controller.sal.action.SetNextHop;
-import org.opendaylight.controller.sal.action.SetNwDst;
-import org.opendaylight.controller.sal.action.SetNwSrc;
-import org.opendaylight.controller.sal.action.SetNwTos;
-import org.opendaylight.controller.sal.action.SetTpDst;
-import org.opendaylight.controller.sal.action.SetTpSrc;
-import org.opendaylight.controller.sal.action.SetVlanCfi;
-import org.opendaylight.controller.sal.action.SetVlanId;
-import org.opendaylight.controller.sal.action.SetVlanPcp;
-import org.opendaylight.controller.sal.action.SwPath;
+import org.opendaylight.controller.sal.action.*;
 import org.opendaylight.controller.sal.core.NodeConnector;
 import org.opendaylight.controller.sal.flowprogrammer.Flow;
 import org.opendaylight.controller.sal.match.Match;
 import org.opendaylight.controller.sal.match.MatchField;
 import org.opendaylight.controller.sal.match.MatchType;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Prefix;
-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.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.*;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowAdded;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowAddedBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.action.ControllerActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.action.OutputActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.VlanCfi;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.action.*;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.address.Address;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.address.address.Ipv4Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.address.address.Ipv6Builder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.flow.Action;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.flow.ActionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType;
@@ -59,14 +37,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819.ethernet.match.fields.EthernetDestinationBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819.ethernet.match.fields.EthernetSourceBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819.ethernet.match.fields.EthernetTypeBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819.match.EthernetMatch;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819.match.EthernetMatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819.match.IpMatch;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819.match.IpMatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819.match.Layer3Match;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819.match.Layer4Match;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819.match.VlanMatch;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819.match.VlanMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819.match.*;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819.match.layer._3.match.ArpMatchBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819.match.layer._3.match.Ipv4MatchBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819.match.layer._3.match.Ipv6MatchBuilder;
@@ -120,15 +91,15 @@ public class FromSalConversionsUtils {
         if (sourceAction instanceof Controller) {
             targetAction = new ControllerActionBuilder().build();
         } else if (sourceAction instanceof Drop) {
-            // TODO: define maping
+            targetAction = new DropActionBuilder().build();
         } else if (sourceAction instanceof Flood) {
-            // TODO: define maping
+            targetAction = new FloodActionBuilder().build();
         } else if (sourceAction instanceof FloodAll) {
-            // TODO: define maping
+            targetAction = new FloodAllActionBuilder().build();
         } else if (sourceAction instanceof HwPath) {
-            // TODO: define maping
+            targetAction = new HwPathActionBuilder().build();
         } else if (sourceAction instanceof Loopback) {
-            // TODO: define maping
+            targetAction = new LoopbackActionBuilder().build();
         } else if (sourceAction instanceof Output) {
             NodeConnector nodeConnector = ((Output) sourceAction).getPort();
 
@@ -137,35 +108,101 @@ public class FromSalConversionsUtils {
             targetAction = outputActionBuilder.build();
 
         } else if (sourceAction instanceof PopVlan) {
-            // TODO: define maping
+            targetAction = new PopVlanActionBuilder().build();
         } else if (sourceAction instanceof PushVlan) {
-            // TODO: define maping
+            PushVlan pushVlan = (PushVlan) sourceAction;
+            PushVlanActionBuilder pushVlanActionBuilder = new PushVlanActionBuilder();
+
+            pushVlanActionBuilder.setCfi(new VlanCfi(pushVlan.getCfi()));
+            pushVlanActionBuilder.setVlanId(new VlanId(pushVlan.getVlanId()));
+            pushVlanActionBuilder.setPcp(pushVlan.getPcp());
+            pushVlanActionBuilder.setTag(pushVlan.getTag());
+            targetAction = pushVlanActionBuilder.build();
         } else if (sourceAction instanceof SetDlDst) {
-            // TODO: define maping
+            SetDlDst setDlDst = (SetDlDst) sourceAction;
+            SetDlDstActionBuilder setDlDstActionBuilder = new SetDlDstActionBuilder();
+
+            setDlDstActionBuilder.setAddress(new MacAddress(Arrays.toString(setDlDst.getDlAddress())));
+            targetAction = setDlDstActionBuilder.build();
         } else if (sourceAction instanceof SetDlSrc) {
-            // TODO: define maping
+            SetDlSrc setDlSrc = (SetDlSrc) sourceAction;
+            SetDlSrcActionBuilder setDlSrcActionBuilder = new SetDlSrcActionBuilder();
+
+            setDlSrcActionBuilder.setAddress(new MacAddress(Arrays.toString(setDlSrc.getDlAddress())));
+            targetAction = setDlSrcActionBuilder.build();
         } else if (sourceAction instanceof SetDlType) {
-            // TODO: define maping
+            SetDlType setDlType = (SetDlType) sourceAction;
+            SetDlTypeActionBuilder setDlTypeActionBuilder = new SetDlTypeActionBuilder();
+
+            setDlTypeActionBuilder.setDlType(new EtherType(new Long(setDlType.getDlType())));
+            targetAction = setDlTypeActionBuilder.build();
         } else if (sourceAction instanceof SetNextHop) {
-            // TODO: define maping
+            SetNextHop setNextHop = (SetNextHop) sourceAction;
+            SetNextHopActionBuilder setNextHopActionBuilder = new SetNextHopActionBuilder();
+
+            InetAddress inetAddress = setNextHop.getAddress();
+            setNextHopActionBuilder.setAddress(addressFromAction(inetAddress));
+
+            targetAction = setNextHopActionBuilder.build();
         } else if (sourceAction instanceof SetNwDst) {
-            // TODO: define maping
+            SetNwDst setNwDst = (SetNwDst) sourceAction;
+            SetNwDstActionBuilder setNwDstActionBuilder = new SetNwDstActionBuilder();
+
+            InetAddress inetAddress = setNwDst.getAddress();
+            setNwDstActionBuilder.setAddress(addressFromAction(inetAddress));
+
+            targetAction = setNwDstActionBuilder.build();
         } else if (sourceAction instanceof SetNwSrc) {
-            // TODO: define maping
+            SetNwSrc setNwSrc = (SetNwSrc) sourceAction;
+            SetNwSrcActionBuilder setNwSrcActionBuilder = new SetNwSrcActionBuilder();
+
+            InetAddress inetAddress = setNwSrc.getAddress();
+            setNwSrcActionBuilder.setAddress(addressFromAction(inetAddress));
+
+            targetAction = setNwSrcActionBuilder.build();
         } else if (sourceAction instanceof SetNwTos) {
-            // TODO: define maping
+            SetNwTos setNwTos = (SetNwTos) sourceAction;
+            SetNwTosActionBuilder setNwTosActionBuilder = new SetNwTosActionBuilder();
+
+            setNwTosActionBuilder.setTos(setNwTos.getNwTos());
+            targetAction = setNwTosActionBuilder.build();
         } else if (sourceAction instanceof SetTpDst) {
-            // TODO: define maping
+            SetTpDst setTpDst = (SetTpDst) sourceAction;
+            SetTpDstActionBuilder setTpDstActionBuilder = new SetTpDstActionBuilder();
+
+            setTpDstActionBuilder.setPort(new PortNumber(setTpDst.getPort()));
+
+            targetAction = setTpDstActionBuilder.build();
         } else if (sourceAction instanceof SetTpSrc) {
-            // TODO: define maping
+            SetTpSrc setTpSrc = (SetTpSrc) sourceAction;
+            SetTpSrcActionBuilder setTpSrcActionBuilder = new SetTpSrcActionBuilder();
+
+            setTpSrcActionBuilder.setPort(new PortNumber(setTpSrc.getPort()));
+
+            targetAction = setTpSrcActionBuilder.build();
         } else if (sourceAction instanceof SetVlanCfi) {
-            // TODO: define maping
+            SetVlanCfi setVlanCfi = (SetVlanCfi) sourceAction;
+            SetVlanCfiActionBuilder setVlanCfiActionBuilder = new SetVlanCfiActionBuilder();
+
+            setVlanCfiActionBuilder.setVlanCfi(new VlanCfi(setVlanCfi.getCfi()));
+
+            targetAction = setVlanCfiActionBuilder.build();
         } else if (sourceAction instanceof SetVlanId) {
-            // TODO: define maping
+            SetVlanId setVlanId = (SetVlanId) sourceAction;
+            SetVlanIdActionBuilder setVlanIdActionBuilder = new SetVlanIdActionBuilder();
+
+            setVlanIdActionBuilder.setVlanId(new VlanId(setVlanId.getVlanId()));
+
+            targetAction = setVlanIdActionBuilder.build();
         } else if (sourceAction instanceof SetVlanPcp) {
-            // TODO: define maping
+            SetVlanPcp setVlanPcp = (SetVlanPcp) sourceAction;
+            SetVlanPcpActionBuilder setVlanPcpActionBuilder = new SetVlanPcpActionBuilder();
+
+            setVlanPcpActionBuilder.setVlanPcp(new VlanPcp((short) setVlanPcp.getPcp()));
+
+            targetAction = setVlanPcpActionBuilder.build();
         } else if (sourceAction instanceof SwPath) {
-            // TODO: define maping
+            targetAction = new SwPathActionBuilder().build();
         }
 
         targetActionBuilder.setAction(targetAction);
@@ -173,6 +210,20 @@ public class FromSalConversionsUtils {
         return targetActionBuilder.build();
     }
 
+    private static Address addressFromAction(InetAddress inetAddress) {
+        byte[] byteInetAddresss = inetAddress.getAddress();
+        if (inetAddress instanceof Inet4Address) {
+            Ipv4Builder ipv4Builder = new Ipv4Builder();
+            ipv4Builder.setIpv4Address(new Ipv4Prefix(Arrays.toString(byteInetAddresss)));
+            return ipv4Builder.build();
+        } else if (inetAddress instanceof Inet6Address) {
+            Ipv6Builder ipv6Builder = new Ipv6Builder();
+            ipv6Builder.setIpv6Address(new Ipv6Prefix(Arrays.toString(byteInetAddresss)));
+            return ipv6Builder.build();
+        }
+        return null;
+    }
+
     private static List<Uri> nodeConnectorToUri(NodeConnector nodeConnector) {
         // TODO Define mapping
         return null;
@@ -312,13 +363,9 @@ public class FromSalConversionsUtils {
                 .setAddress(ethernetSourceAddressFrom(sourceMatch));
         targetEthMatchBuild.setEthernetSource(ethSourBuild.build());
 
-        final MatchField dataLinkDest = sourceMatch.getField(DL_DST);
-        if (dataLinkDest != null && dataLinkDest.getValue() != null) {
-            final MacAddress macDestAddress;
-            macDestAddress = new MacAddress((String) (dataLinkDest.getValue()));
-            EthernetDestinationBuilder ethDestBuild = new EthernetDestinationBuilder().setAddress(macDestAddress);
-            targetEthMatchBuild.setEthernetDestination(ethDestBuild.build());
-        }
+        EthernetDestinationBuilder ethDestBuild = new EthernetDestinationBuilder()
+                .setAddress(ethernetDestAddressFrom(sourceMatch));
+        targetEthMatchBuild.setEthernetDestination(ethDestBuild.build());
 
         final MatchField dataLinkType = sourceMatch.getField(MatchType.DL_TYPE);
         if (dataLinkType != null && dataLinkType.getValue() != null) {
index c113cd8924d1f7909fff02cec96323a984646ffb..ad1a2f93872df143a84ffbfe338d7f8d11649ae9 100644 (file)
@@ -17,37 +17,24 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
-import org.opendaylight.controller.sal.action.Controller;
-import org.opendaylight.controller.sal.action.Output;
+import org.opendaylight.controller.sal.action.*;
 import org.opendaylight.controller.sal.core.NodeConnector;
 import org.opendaylight.controller.sal.flowprogrammer.Flow;
 import org.opendaylight.controller.sal.match.Match;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Prefix;
-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.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.*;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeFlow;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.action.ControllerAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.action.OutputAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.action.PopMplsAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.action.PushMplsAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.action.PushPbbAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.action.PushVlanAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.action.SetMplsTtlAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.action.SetNwTtlAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.action.SetQueueAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.VlanCfi;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.action.*;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.address.Address;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.address.address.Ipv4;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.address.address.Ipv6;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.flow.Action;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819.MacAddressFilter;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819.ethernet.match.fields.EthernetType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819.match.EthernetMatch;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819.match.IpMatch;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819.match.Layer3Match;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819.match.Layer4Match;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819.match.VlanMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819.match.*;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819.match.layer._3.match.ArpMatch;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819.match.layer._3.match.Ipv4Match;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819.match.layer._3.match.Ipv6Match;
@@ -128,11 +115,161 @@ public class ToSalConversionsUtils {
         } else if (sourceAction instanceof SetQueueAction) {
             // TODO: define maping
             // targetAction = //no action to map
+        } else if (sourceAction instanceof DropAction) {
+            targetAction.add(new Drop());
+        } else if (sourceAction instanceof FloodAction) {
+            targetAction.add(new Flood());
+        } else if (sourceAction instanceof FloodAllAction) {
+            targetAction.add(new FloodAll());
+        } else if (sourceAction instanceof HwPathAction) {
+            targetAction.add(new HwPath());
+        } else if (sourceAction instanceof LoopbackAction) {
+            targetAction.add(new Loopback());
+        } else if (sourceAction instanceof PopVlanAction) {
+            targetAction.add(new PopVlan());
+        } else if (sourceAction instanceof PushVlanAction) {
+            PushVlanAction pushVlanAction = (PushVlanAction) sourceAction;
+            PushVlan pushVlan = pushVlanFrom(pushVlanAction);
+            if (pushVlan != null) {
+                targetAction.add(pushVlan);
+            }
+        } else if (sourceAction instanceof SetDlDstAction) {
+            MacAddress addressL2Dest = ((SetDlDstAction) sourceAction).getAddress();
+            if (addressL2Dest != null) {
+                String addressValue = addressL2Dest.getValue();
+                if (addressValue != null) {
+                    targetAction.add(new SetDlDst(addressValue.getBytes()));
+                }
+            }
+        } else if (sourceAction instanceof SetDlSrcAction) {
+            MacAddress addressL2Src = ((SetDlSrcAction) sourceAction).getAddress();
+            if (addressL2Src != null) {
+                String addressValue = addressL2Src.getValue();
+                if (addressValue != null) {
+                    targetAction.add(new SetDlSrc(addressValue.getBytes()));
+                }
+            }
+        } else if (sourceAction instanceof SetDlTypeAction) {
+            EtherType dlType = ((SetDlTypeAction) sourceAction).getDlType();
+            if (dlType != null) {
+                Long dlTypeValue = dlType.getValue();
+                if (dlTypeValue != null) {
+                    targetAction.add(new SetDlType(dlTypeValue.intValue()));
+                }
+            }
+        } else if (sourceAction instanceof SetNextHopAction) {
+            Address addressL3 = ((SetNextHopAction) sourceAction).getAddress();
+
+            InetAddress inetAddress = inetAddressFrom(addressL3);
+            if (inetAddress != null) {
+                targetAction.add(new SetNextHop(inetAddress));
+            }
+        } else if (sourceAction instanceof SetNwDstAction) {
+            Address addressL3 = ((SetNwDstAction) sourceAction).getAddress();
+
+            InetAddress inetAddress = inetAddressFrom(addressL3);
+            if (inetAddress != null) {
+                targetAction.add(new SetNwDst(inetAddress));
+            }
+        } else if (sourceAction instanceof SetNwSrcAction) {
+            Address addressL3 = ((SetNwDstAction) sourceAction).getAddress();
+
+            InetAddress inetAddress = inetAddressFrom(addressL3);
+            if (inetAddress != null) {
+                targetAction.add(new SetNwSrc(inetAddress));
+            }
+        } else if (sourceAction instanceof SetNwTosAction) {
+            Integer tos = ((SetNwTosAction) sourceAction).getTos();
+            if (tos != null) {
+                targetAction.add(new SetNwTos(tos));
+            }
+        } else if (sourceAction instanceof SetTpDstAction) {
+            PortNumber port = ((SetTpDstAction) sourceAction).getPort();
+            if (port != null) {
+                Integer portValue = port.getValue();
+                if (port.getValue() != null) {
+                    targetAction.add(new SetTpDst(portValue));
+                }
+            }
+        } else if (sourceAction instanceof SetTpSrcAction) {
+            PortNumber port = ((SetTpSrcAction) sourceAction).getPort();
+            if (port != null) {
+                Integer portValue = port.getValue();
+                if (port.getValue() != null) {
+                    targetAction.add(new SetTpSrc(portValue));
+                }
+            }
+        } else if (sourceAction instanceof SetVlanCfiAction) {
+            VlanCfi vlanCfi = ((SetVlanCfiAction) sourceAction).getVlanCfi();
+            if (vlanCfi != null) {
+                Integer vlanCfiValue = vlanCfi.getValue();
+                if (vlanCfiValue != null) {
+                    targetAction.add(new SetVlanCfi(vlanCfiValue));
+                }
+            }
+        } else if (sourceAction instanceof SetVlanIdAction) {
+            org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId vlanID = ((SetVlanIdAction) sourceAction)
+                    .getVlanId();
+            if (vlanID != null) {
+                Integer vlanIdValue = vlanID.getValue();
+                if (vlanIdValue != null) {
+                    targetAction.add(new SetVlanId(vlanIdValue));
+                }
+            }
+        } else if (sourceAction instanceof SetVlanPcpAction) {
+            VlanPcp vlanPcp = ((SetVlanPcpAction) sourceAction).getVlanPcp();
+            if (vlanPcp != null) {
+                Short vlanPcpValue = vlanPcp.getValue();
+                if (vlanPcpValue != null) {
+                    targetAction.add(new SetVlanPcp(vlanPcpValue));
+                }
+            }
+        } else if (sourceAction instanceof SwPathAction) {
+            targetAction.add(new SwPath());
         }
 
         return targetAction;
     }
 
+    private static InetAddress inetAddressFrom(Address addressL3) {
+        if (addressL3 != null) {
+            if (addressL3 instanceof Ipv4) {
+                Ipv4Prefix addressL3Ipv4 = ((Ipv4) addressL3).getIpv4Address();
+                if (addressL3Ipv4 != null) {
+                    return inetAddressFrom(addressL3Ipv4);
+                }
+            } else if (addressL3 instanceof Ipv6) {
+                Ipv6Prefix addressL3Ipv6 = ((Ipv6) addressL3).getIpv6Address();
+                if (addressL3Ipv6 != null) {
+                    return inetAddressFrom(addressL3Ipv6);
+                }
+            }
+        }
+        return null;
+    }
+
+    private static PushVlan pushVlanFrom(PushVlanAction pushVlanAction) {
+        final int tag;
+        final int pcp;
+        final int cfi;
+        final int vlanId;
+
+        if (pushVlanAction.getTag() != null) {
+            tag = pushVlanAction.getTag();
+            if (pushVlanAction.getPcp() != null) {
+                pcp = pushVlanAction.getPcp();
+                if (pushVlanAction.getCfi() != null && pushVlanAction.getCfi().getValue() != null) {
+                    cfi = pushVlanAction.getCfi().getValue();
+                    if (pushVlanAction.getVlanId() != null && pushVlanAction.getVlanId().getValue() != null) {
+                        vlanId = pushVlanAction.getVlanId().getValue();
+                        return new PushVlan(tag, pcp, cfi, vlanId);
+                    }
+                }
+            }
+        }
+        return null;
+    }
+
     private static NodeConnector fromNodeConnectorRef(Uri uri) {
         // TODO: Define mapping
         return null;
index 8f905a999a02f3b2c5f3d12395bc0d1a97ac5cc1..5ecddcfc88bd501e65164303e946a29ef36ec46e 100644 (file)
@@ -79,7 +79,6 @@ public class TopologyManagerImpl implements
     static final String TOPONODECONNECTORDB = "topologymanager.nodeConnectorDB";
     static final String TOPOUSERLINKSDB = "topologymanager.userLinksDB";
     private static final Logger log = LoggerFactory.getLogger(TopologyManagerImpl.class);
-    private static final String SAVE = "Save";
     private ITopologyService topoService;
     private IClusterContainerServices clusterContainerService;
     // DB of all the Edges with properties which constitute our topology