neutron-secgroups.yang: update model for security group 60/23860/1
authorIsaku Yamahata <isaku.yamahata@intel.com>
Mon, 6 Jul 2015 23:59:51 +0000 (16:59 -0700)
committerIsaku Yamahata <isaku.yamahata@intel.com>
Tue, 7 Jul 2015 23:12:07 +0000 (16:12 -0700)
- neutron security group accepts protocol as integer.
  It's defined as uint8.
- neutron security group defines port as uint16 since
  its port number of UDP/TCP.
  There is no point to define it as uint32.

Change-Id: I6fe01623ad07800a663fbd871dcfb030b9eef098
Signed-off-by: Isaku Yamahata <isaku.yamahata@intel.com>
model/src/main/yang/neutron-secgroups.yang
transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronSecurityRuleInterface.java

index 1b4f12cb1d6e1734725e9c3b03021a4d6a6d9c2a..4fee0246bb1fbba2d3b7b976df04667f8e9ac36e 100644 (file)
@@ -78,18 +78,21 @@ module neutron-secgroups {
             type inet:ip-address;
         }
         leaf protocol {
-            type enumeration {
-                enum null {
-                    description "NULL protocol.";
-                }
-                enum icmp {
-                    description "ICMP protocol.";
-                }
-                enum udp {
-                    description "UDP protocol.";
-                }
-                enum tcp {
-                    description "TCP protocol.";
+            type union {
+                type uint8;
+                type enumeration {
+                    enum null {
+                        description "NULL protocol.";
+                    }
+                    enum icmp {
+                        description "ICMP protocol.";
+                    }
+                    enum udp {
+                        description "UDP protocol.";
+                    }
+                    enum tcp {
+                        description "TCP protocol.";
+                    }
                 }
             }
             description "The protocol that is matched by the security group rule.";
@@ -107,14 +110,14 @@ module neutron-secgroups {
             }
         }
         leaf port-range-min {
-            type uint32;
+            type uint16;
             description "The minimum port number in the range that is matched by the
                 security group rule. If the protocol is TCP or UDP, this value must
                 be less than or equal to the value of the attribute. If the protocol
                 is ICMP, this value must be an ICMP type.";
         }
         leaf port-range-max {
-            type uint32;
+            type uint16;
             description "The maximum port number in the range that is matched by the
                 security group rule. If the protocol is TCP or UDP, this value must
                 be less than or equal to the value of the attribute. If the protocol
index 729f4c4fb492dfe09836ec90deaabac1e0f92929..67033111b2ae4d7663d99e8601a326aee39eca0c 100644 (file)
@@ -200,15 +200,20 @@ public class NeutronSecurityRuleInterface extends AbstractNeutronInterface<Secur
         }
         if (securityRule.getSecurityRuleProtocol() != null) {
             boolean foundMatch = false;
-            for (SecurityRuleAttrs.Protocol protocol : SecurityRuleAttrs.Protocol.values()) {
+            for (SecurityRuleAttrs.Protocol.Enumeration protocol : SecurityRuleAttrs.Protocol.Enumeration.values()) {
                 if (protocol.toString().equalsIgnoreCase(securityRule.getSecurityRuleProtocol())) {
-                    securityRuleBuilder.setProtocol(protocol);
+                    securityRuleBuilder.setProtocol(new SecurityRuleAttrs.Protocol(protocol));
                     foundMatch = true;
                     break;
                 }
             }
             if (!foundMatch) {
-                LOGGER.warn("Unable to find protocol value for {}", securityRule.getSecurityRuleProtocol());
+                try {
+                    java.lang.Short protocol = Short.valueOf(securityRule.getSecurityRuleProtocol());
+                    securityRuleBuilder.setProtocol(new SecurityRuleAttrs.Protocol(protocol));
+                } catch (NumberFormatException e) {
+                    LOGGER.warn("Unable to find protocol value for {}", securityRule.getSecurityRuleProtocol());
+                }
             }
         }
         if (securityRule.getSecurityRuleEthertype() != null) {
@@ -225,10 +230,10 @@ public class NeutronSecurityRuleInterface extends AbstractNeutronInterface<Secur
             }
         }
         if (securityRule.getSecurityRulePortMin() != null) {
-            securityRuleBuilder.setPortRangeMin(new Long(securityRule.getSecurityRulePortMin()));
+            securityRuleBuilder.setPortRangeMin(new Integer(securityRule.getSecurityRulePortMin()));
         }
         if (securityRule.getSecurityRulePortMax() != null) {
-            securityRuleBuilder.setPortRangeMax(new Long(securityRule.getSecurityRulePortMax()));
+            securityRuleBuilder.setPortRangeMax(new Integer(securityRule.getSecurityRulePortMax()));
         }
         if (securityRule.getSecurityRuleUUID() != null) {
             securityRuleBuilder.setId(toUuid(securityRule.getSecurityRuleUUID()));