TSC-115: Fix MinimumBandwidthRule direction 60/72460/3
authorVishal Thapar <vthapar@redhat.com>
Wed, 30 May 2018 06:51:59 +0000 (12:21 +0530)
committerVishal Thapar <vthapar@redhat.com>
Sun, 3 Jun 2018 12:13:34 +0000 (17:43 +0530)
minimumbandswidth-rule-attributes has wrongly
defined direction to be constants:direction-minimum-base.
constants:direciton-minimum-base is not reqired at all
as there are already ingress/egress defined.

Changes it to remove the redundant and wrong yang attribute
and fix rest of the code to use the correct direction classes.

Change-Id: I93febb29a77aa19428a3211eaf1712d84388a7d7
JIRA:NEUTRON-163
Signed-off-by: Vishal Thapar <vthapar@redhat.com>
model/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/neutron/constants/rev150712/NeutronUtils.java
model/src/main/yang/neutron-constants.yang
model/src/main/yang/neutron-qos.yang
transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronMeteringLabelRuleInterface.java
transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronQosPolicyInterface.java
transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronSecurityRuleInterface.java

index 21211c7ff265a6b94b0ba2ec49e11de46ced45db..e71d74b8f82629b4084d181155f1ce99261a3a86 100644 (file)
@@ -76,31 +76,13 @@ public final class NeutronUtils {
             .put("ingress", DirectionIngress.class)
             .build();
 
+        private static final ImmutableBiMap<Class<? extends DirectionBase>, String> MAPPER_INVERSE = MAPPER.inverse();
+
         public static Class<? extends DirectionBase> get(String key) {
             return MAPPER.get(key);
         }
-
-        public static String getName(Class<? extends DirectionBase> key) {
-            ImmutableBiMap<Class<? extends DirectionBase>, String> inverseMapper = MAPPER.inverse();
-            return inverseMapper.get(key);
-        }
-
-        private static final ImmutableBiMap<String, Class<? extends DirectionMinimumBandwidthRule>>
-            MINIMUMBANDWIDTHRULE_MAPPER = new ImmutableBiMap.Builder<String, Class<? extends
-            DirectionMinimumBandwidthRule>>()
-            .put("egress", DirectionMinimumBandwidthRule.class)
-            .build();
-
-        public static Class<? extends DirectionMinimumBandwidthRule>
-            getMinimumBandwidthRuleDirection(String minimumBandwidthKey) {
-            return MINIMUMBANDWIDTHRULE_MAPPER.get(minimumBandwidthKey);
-        }
-
-        public static String getMinimumBandwidthRuleDirectionString(Class<? extends DirectionMinimumBandwidthRule>
-            minimumBandwidthKey) {
-            ImmutableBiMap<Class<? extends DirectionMinimumBandwidthRule>, String>
-            inverseMinimBandwidthRuleDirectionMapper = MINIMUMBANDWIDTHRULE_MAPPER.inverse();
-            return inverseMinimBandwidthRuleDirectionMapper.get(minimumBandwidthKey);
+        public static String getDirectionString(Class<? extends DirectionBase> direction) {
+            return MAPPER_INVERSE.get(direction);
         }
     }
 }
index 4b5ce029e549b8683185eb59006db6d661594de6..cf1a209f9c52771443bd05b8f2a96e7ba7d3fb7d 100644 (file)
@@ -127,11 +127,6 @@ module neutron-constants {
 
     }
 
-    identity direction-minimum-bandwidth-rule {
-        description "Direction for minimum bandwidth rule.";
-        base direction-base;
-    }
-
     // IP VERSION
     identity ip-version-base {
         description "the base identity for ip versions";
index bfbc959b9c43aa93cd78cdb778129ad7c1e2e177..29e522bd5471713fb25be0241caa6555fab7cdae 100644 (file)
@@ -71,7 +71,7 @@ module neutron-qos {
         }
         leaf direction {
             type identityref {
-                base "constants:direction-minimum-bandwidth-rule";
+                base "constants:direction-base";
             }
             description "The traffic direction";
         }
index 225ce18d9f8a31e6ba88277d319ab85b47f17e10..d9affc2d2657d963a8b2b93e7c51a41e89d38e55 100644 (file)
@@ -66,7 +66,7 @@ public final class NeutronMeteringLabelRuleInterface
             answer.setMeteringLabelRuleLabelID(rule.getMeteringLabelId().getValue());
         }
         if (rule.getDirection() != null) {
-            answer.setMeteringLabelRuleDirection(DirectionMapper.getName(rule.getDirection()));
+            answer.setMeteringLabelRuleDirection(DirectionMapper.getDirectionString(rule.getDirection()));
         }
         if (rule.getRemoteIpPrefix() != null) {
             answer.setMeteringLabelRuleRemoteIpPrefix(new String(rule.getRemoteIpPrefix().getValue()));
index 398876d52e7e43e5c95f04acd5947c3043d8191f..7b549989e4ba33fbf57b154fcbf029a87a98c35d 100644 (file)
@@ -83,8 +83,7 @@ public final class NeutronQosPolicyInterface
                 minimumBandwidthRulesBuilder.setUuid(toUuid(minimumBandwidthRule.getID()));
                 minimumBandwidthRulesBuilder.setTenantId(toUuid(minimumBandwidthRule.getTenantID()));
                 minimumBandwidthRulesBuilder.setMinKbps(minimumBandwidthRule.getMinKbps());
-                minimumBandwidthRulesBuilder.setDirection(DirectionMapper.getMinimumBandwidthRuleDirection(
-                    minimumBandwidthRule.getDirection()));
+                minimumBandwidthRulesBuilder.setDirection(DirectionMapper.get(minimumBandwidthRule.getDirection()));
                 listMinimumBandwidth.add(minimumBandwidthRulesBuilder.build());
             }
             qosPolicyBuilder.setMinimumbandwidthRules(listMinimumBandwidth);
@@ -125,7 +124,7 @@ public final class NeutronQosPolicyInterface
                 opt.setID(rule.getTenantId().getValue());
                 opt.setTenantID(rule.getTenantId().getValue());
                 opt.setMinKbps(rule.getMinKbps());
-                opt.setDirection(DirectionMapper.getMinimumBandwidthRuleDirectionString(rule.getDirection()));
+                opt.setDirection(DirectionMapper.getDirectionString(rule.getDirection()));
                 minimumBandwidthRules.add(opt);
             }
             result.setMinimumBandwidthRules(minimumBandwidthRules);
index e45c2b048ffed7d84f18ca6f92ad9c73f2f9bc83..a6d16b9589c4f1044bd83a81fd0ee99c22c3c2be 100644 (file)
@@ -54,7 +54,7 @@ public final class NeutronSecurityRuleInterface extends
         final NeutronSecurityRule answer = new NeutronSecurityRule();
         fromMdIds(rule, answer);
         if (rule.getDirection() != null) {
-            answer.setSecurityRuleDirection(DirectionMapper.getName(rule.getDirection()));
+            answer.setSecurityRuleDirection(DirectionMapper.getDirectionString(rule.getDirection()));
         }
         if (rule.getSecurityGroupId() != null) {
             answer.setSecurityRuleGroupID(rule.getSecurityGroupId().getValue());