Update EVC QoS bandwidth 25/34025/2
authoradetalhouet <adetalhouet@inocybe.com>
Wed, 3 Feb 2016 20:28:47 +0000 (15:28 -0500)
committerAlexis de Talhouët <adetalhouet@inocybe.com>
Wed, 3 Feb 2016 20:29:44 +0000 (20:29 +0000)
Change-Id: I086c88286a51f7c2393cbb84ccd7ddae3908e467
Signed-off-by: adetalhouet <adetalhouet@inocybe.com>
impl/src/main/java/org/opendaylight/unimgr/command/EvcUpdateCommand.java
impl/src/main/java/org/opendaylight/unimgr/impl/UnimgrUtils.java

index 34dd437fa38578cea7c8bbf9d11c5aceaf34dcf9..9dec29e103d844a319043e20c95e7dde5a69f20e 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.unimgr.command;
 
 import java.util.Map;
 import java.util.Map.Entry;
-import java.util.concurrent.ExecutionException;
 
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadTransaction;
@@ -44,17 +43,17 @@ public class EvcUpdateCommand extends AbstractUpdateCommand {
     @Override
     public void execute() {
         for (final Entry<InstanceIdentifier<?>, DataObject> updated : changes.entrySet()) {
-            if (updated.getValue() != null && updated.getValue() instanceof EvcAugmentation) {
+            if ((updated.getValue() != null) && (updated.getValue() instanceof EvcAugmentation)) {
                 final EvcAugmentation evc = (EvcAugmentation) updated.getValue();
                 final InstanceIdentifier<?> evcKey = updated.getKey();
 
                 // FIXME: For now, we assume that there is 1 uni per
                 // source/destination
-                if (evc.getUniDest() == null || evc.getUniDest().isEmpty()) {
+                if ((evc.getUniDest() == null) || evc.getUniDest().isEmpty()) {
                     LOG.error("Destination UNI cannot be null.");
                     break;
                 }
-                if (evc.getUniSource() == null || evc.getUniSource().isEmpty()) {
+                if ((evc.getUniSource() == null) || evc.getUniSource().isEmpty()) {
                     LOG.error("Source UNI cannot be null.");
                     break;
                 }
@@ -160,6 +159,8 @@ public class EvcUpdateCommand extends AbstractUpdateCommand {
                         final Optional<Node> optionalDestinationBr = UnimgrUtils.readNode(dataBroker,
                                 LogicalDatastoreType.OPERATIONAL,
                                 destinationBridgeIid);
+                        //update ovsdb qos-entry and queues with max-rate to match evc ingress BW
+                        UnimgrUtils.updateMaxRate(dataBroker, sourceUniAugmentation, destinationUniAugmentation, evc);
                         Node sourceBr = null;
                         Node destinationBr = null;
                         if (optionalSourceBr.isPresent() && optionalDestinationBr.isPresent()) {
index f7a1b5bad5911db5e9f2d7bc890207f72877e926..d4df0871b0258ecca7fe247b64ec9be79eb5e79c 100644 (file)
@@ -268,7 +268,7 @@ public class UnimgrUtils {
      */
     public static OvsdbBridgeAugmentation createOvsdbBridgeAugmentation(Uni uni) throws Exception {
         final OvsdbNodeRef ovsdbNodeRef = uni.getOvsdbNodeRef();
-        if (ovsdbNodeRef != null && ovsdbNodeRef.getValue() != null) {
+        if ((ovsdbNodeRef != null) && (ovsdbNodeRef.getValue() != null)) {
             final UUID bridgeUuid = UUID.randomUUID();
             final OvsdbBridgeAugmentation ovsdbBridge = new OvsdbBridgeAugmentationBuilder()
                                                         .setBridgeName(
@@ -474,20 +474,20 @@ public class UnimgrUtils {
     private static String getSpeed(Speed speedObject) {
         String speed = null;
         if (speedObject instanceof Speed10M) {
-            // map to 1MB
-            speed = "1000000";
+            // map to 10MB
+            speed = "10000000";
         }
         else if (speedObject instanceof Speed100M) {
-            // map to 2MB
-            speed = "2000000";
+            // map to 20MB
+            speed = "20000000";
         }
         else if (speedObject instanceof Speed1G) {
-            // map to 3MB
-            speed = "3000000";
+            // map to 30MB
+            speed = "30000000";
         }
         else if (speedObject instanceof Speed10G) {
-            // map to 4MB
-            speed = "4000000";
+            // map to 40MB
+            speed = "40000000";
         }
         return speed;
     }
@@ -913,7 +913,7 @@ public class UnimgrUtils {
     public static <T extends DataObject> Map<InstanceIdentifier<T>,T> extract(
             Map<InstanceIdentifier<?>, DataObject> changes, Class<T> klazz) {
         final Map<InstanceIdentifier<T>,T> result = new HashMap<InstanceIdentifier<T>,T>();
-        if (changes != null && changes.entrySet() != null) {
+        if ((changes != null) && (changes.entrySet() != null)) {
             for (final Entry<InstanceIdentifier<?>, DataObject> created : changes.entrySet()) {
                 if (klazz.isInstance(created.getValue())) {
                     @SuppressWarnings("unchecked")
@@ -952,7 +952,7 @@ public class UnimgrUtils {
     public static <T extends DataObject> Set<InstanceIdentifier<T>> extractRemoved(
             AsyncDataChangeEvent<InstanceIdentifier<?>,DataObject> changes,Class<T> klazz) {
         final Set<InstanceIdentifier<T>> result = new HashSet<InstanceIdentifier<T>>();
-        if (changes != null && changes.getRemovedPaths() != null) {
+        if ((changes != null) && (changes.getRemovedPaths() != null)) {
             for (final InstanceIdentifier<?> iid : changes.getRemovedPaths()) {
                 if (iid.getTargetType().equals(klazz)) {
                     @SuppressWarnings("unchecked") // Actually checked above
@@ -1048,7 +1048,7 @@ public class UnimgrUtils {
         final Topology topology = UnimgrUtils.read(dataBroker,
                                              LogicalDatastoreType.OPERATIONAL,
                                              evcTopology);
-        if (topology != null && topology.getLink() != null) {
+        if ((topology != null) && (topology.getLink() != null)) {
             for (final Link link : topology.getLink()) {
                 final EvcAugmentation evcAugmentation = link.getAugmentation(EvcAugmentation.class);
                 if (evcAugmentation != null) {
@@ -1087,7 +1087,7 @@ public class UnimgrUtils {
         final Topology topology = UnimgrUtils.read(dataBroker,
                                              LogicalDatastoreType.OPERATIONAL,
                                              ovsdbTopoIdentifier);
-        if (topology != null && topology.getNode() != null) {
+        if ((topology != null) && (topology.getNode() != null)) {
             for (final Node node : topology.getNode()) {
                 final OvsdbNodeAugmentation ovsdbNodeAugmentation = node.getAugmentation(OvsdbNodeAugmentation.class);
                 if (ovsdbNodeAugmentation != null) {
@@ -1109,7 +1109,7 @@ public class UnimgrUtils {
         final Topology topology = read(dataBroker,
                                  LogicalDatastoreType.CONFIGURATION,
                                  topologyInstanceIdentifier);
-        if (topology != null && topology.getNode() != null) {
+        if ((topology != null) && (topology.getNode() != null)) {
             for (final Node node : topology.getNode()) {
                 final UniAugmentation uniAugmentation = node.getAugmentation(UniAugmentation.class);
                 if (uniAugmentation != null) {
@@ -1133,7 +1133,7 @@ public class UnimgrUtils {
         final Topology topology = read(dataBroker,
                                  store,
                                  topologyInstanceIdentifier);
-        if (topology != null && topology.getNode() != null) {
+        if ((topology != null) && (topology.getNode() != null)) {
             for (final Node node : topology.getNode()) {
                 final UniAugmentation uniAugmentation = node.getAugmentation(UniAugmentation.class);
                 if (uniAugmentation != null) {
@@ -1157,7 +1157,7 @@ public class UnimgrUtils {
         final Topology topology = read(dataBroker,
                                  store,
                                  topologyInstanceIdentifier);
-        if (topology != null && topology.getNode() != null) {
+        if ((topology != null) && (topology.getNode() != null)) {
             for (final Node node : topology.getNode()) {
                 final UniAugmentation uniAugmentation = node.getAugmentation(UniAugmentation.class);
                 if (uniAugmentation != null) {
@@ -1181,10 +1181,10 @@ public class UnimgrUtils {
         final Topology topology = read(dataBroker,
                                  store,
                                  topologyInstanceIdentifier);
-        if (topology != null && topology.getNode() != null) {
+        if ((topology != null) && (topology.getNode() != null)) {
             for (final Node node : topology.getNode()) {
                 final UniAugmentation uniAugmentation = node.getAugmentation(UniAugmentation.class);
-                if (uniAugmentation != null && uniAugmentation.getIpAddress().getIpv4Address().getValue().equals(ipAddress.getIpv4Address().getValue())) {
+                if ((uniAugmentation != null) && uniAugmentation.getIpAddress().getIpv4Address().getValue().equals(ipAddress.getIpv4Address().getValue())) {
                     return uniAugmentation;
                 }
             }
@@ -1378,7 +1378,7 @@ public class UnimgrUtils {
                                      InstanceIdentifier<?> destinationUniIid,
                                      DataBroker dataBroker) {
         final EvcAugmentationBuilder updatedEvcBuilder = new EvcAugmentationBuilder(evcAugmentation);
-        if (sourceUniIid != null && destinationUniIid != null) {
+        if ((sourceUniIid != null) && (destinationUniIid != null)) {
             final List<UniSource> sourceList = new ArrayList<UniSource>();
             final UniSourceKey sourceKey = evcAugmentation.getUniSource().iterator().next().getKey();
             final short sourceOrder = evcAugmentation.getUniSource().iterator().next().getOrder();