ONOS-688 (ONOS-1835,1836,1837) :
 - Implements features to create and remove tunnels and tunnel flow policies.
 - Implements REST API to create/show/delete tunnels and policies.
 - Supports only single instance for now.
 - Fix "apply" actions to "write" actions of all flow rules
Change-Id: I3740ed82fed8eab4ab8b03839192da72d3e223f1
diff --git a/src/main/java/org/onosproject/segmentrouting/RoutingRulePopulator.java b/src/main/java/org/onosproject/segmentrouting/RoutingRulePopulator.java
index 7092093..8c84e39 100644
--- a/src/main/java/org/onosproject/segmentrouting/RoutingRulePopulator.java
+++ b/src/main/java/org/onosproject/segmentrouting/RoutingRulePopulator.java
@@ -98,7 +98,8 @@
         sbuilder.matchIPDst(IpPrefix.valueOf(hostIp, 32));
         sbuilder.matchEthType(Ethernet.TYPE_IPV4);
 
-        tbuilder.setEthDst(hostMac)
+        tbuilder.deferred()
+                .setEthDst(hostMac)
                 .setEthSrc(config.getDeviceMac(deviceId))
                 .setOutput(outPort);
 
@@ -163,10 +164,10 @@
         // If the next hop is the same as the final destination, then MPLS label
         // is not set.
         if (nextHops.size() == 1 && nextHops.toArray()[0].equals(destSw)) {
-            tbuilder.decNwTtl();
+            tbuilder.deferred().decNwTtl();
             ns = new NeighborSet(nextHops);
         } else {
-            tbuilder.copyTtlOut();
+            tbuilder.deferred().copyTtlOut();
             ns = new NeighborSet(nextHops, config.getSegmentId(destSw));
         }
 
@@ -295,15 +296,15 @@
 
         if (phpRequired) {
             log.debug("getMplsForwardingObjective: php required");
-            tbuilder.copyTtlIn();
+            tbuilder.deferred().copyTtlIn();
             if (isBos) {
-                tbuilder.popMpls(Ethernet.TYPE_IPV4).decNwTtl();
+                tbuilder.deferred().popMpls(Ethernet.TYPE_IPV4).decNwTtl();
             } else {
-                tbuilder.popMpls(Ethernet.MPLS_UNICAST).decMplsTtl();
+                tbuilder.deferred().popMpls(Ethernet.MPLS_UNICAST).decMplsTtl();
             }
         } else {
             log.debug("getMplsForwardingObjective: php not required");
-            tbuilder.decMplsTtl();
+            tbuilder.deferred().decMplsTtl();
         }
 
         if (!isECMPSupportedInTransitRouter() && !config.isEdgeDevice(deviceId)) {
@@ -313,7 +314,8 @@
                 log.warn("No link from {} to {}", deviceId, nextHops);
                 return null;
             }
-            tbuilder.setEthSrc(config.getDeviceMac(deviceId))
+            tbuilder.deferred()
+                    .setEthSrc(config.getDeviceMac(deviceId))
                     .setEthDst(config.getDeviceMac(nextHop))
                     .setOutput(port);
             fwdBuilder.withTreatment(tbuilder.build());