Bug 4043 - remote ip prefix of security group is type of ietf ip-prefix 66/26266/3
authorIsaku Yamahata <isaku.yamahata@intel.com>
Mon, 31 Aug 2015 22:45:42 +0000 (15:45 -0700)
committerIsaku Yamahata <isaku.yamahata@intel.com>
Tue, 22 Sep 2015 07:36:43 +0000 (00:36 -0700)
remote ip prefix of security group rule should be type of ietf ip-prefix,
not ip-address.

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

index 697323c5a5af002d8f3c887d7f7f230de4644fcd..68f21b2ecd431e2102965c1a63b29791cece3688 100644 (file)
@@ -95,6 +95,40 @@ public class NeutronSecurityRuleTests {
         ITNeutronE2E.test_fetch(url, false, "Security Rule Element Negative Get Failed");
     }
 
+    public void bug4043_ipv4_test() {
+        String url = base + "/security-group-rules";
+        String content = " {\"security_group_rule\": " +
+            "{\"remote_group_id\": null, \"direction\": \"ingress\", " +
+            "\"remote_ip_prefix\": \"10.10.10.10/16\", \"protocol\": \"tcp\", " +
+            "\"ethertype\": \"IPv4\", \"tenant_id\": " +
+            "\"00f340c7c3b34ab7be1fc690c05a0275\", \"port_range_max\": 77, " +
+            "\"port_range_min\": 77, " +
+            "\"id\": \"01234567-0123-0123-0123-01234567890a\", " +
+            "\"security_group_id\": " +
+            "\"b60490fe-60a5-40be-af63-1d641381b784\"}}";
+        ITNeutronE2E.test_create(url, content, "Security Rule bug4043 IPv4 Failed");
+
+        url = url + "/01234567-0123-0123-0123-01234567890a";
+        ITNeutronE2E.test_delete(url, "Security Rule Delete Failed");
+    }
+
+    public void bug4043_ipv6_test() {
+        String url = base + "/security-group-rules";
+        String content = " {\"security_group_rule\": " +
+            "{\"remote_group_id\": null, \"direction\": \"ingress\", " +
+            "\"remote_ip_prefix\": \"fe80::1/10\", \"protocol\": \"tcp\", " +
+            "\"ethertype\": \"IPv6\", \"tenant_id\": " +
+            "\"00f340c7c3b34ab7be1fc690c05a0275\", \"port_range_max\": 77, " +
+            "\"port_range_min\": 77, " +
+            "\"id\": \"01234567-0123-0123-0123-01234567890a\", " +
+            "\"security_group_id\": " +
+            "\"b60490fe-60a5-40be-af63-1d641381b784\"}}";
+        ITNeutronE2E.test_create(url, content, "Security Rule Bug4043 IPv6 Failed");
+
+        url = url + "/01234567-0123-0123-0123-01234567890a";
+        ITNeutronE2E.test_delete(url, "Security Rule Delete Failed");
+    }
+
     public static void runTests(String base) {
         NeutronSecurityRuleTests securityRule_tester = new NeutronSecurityRuleTests(base);
         securityRule_tester.securityRule_collection_get_test();
@@ -103,5 +137,7 @@ public class NeutronSecurityRuleTests {
         securityRule_tester.sr_element_get_test();
         securityRule_tester.sr_delete_test();
         securityRule_tester.sr_element_negative_get_test();
+        securityRule_tester.bug4043_ipv4_test();
+        securityRule_tester.bug4043_ipv6_test();
     }
 }
index 76db34d0e8b7c915c4d6ec43d2006bcbaf5f0caa..74d6d0ca95307b116af1be5cbda3168d6415d828 100644 (file)
@@ -70,7 +70,7 @@ module neutron-secgroups {
         leaf remote-ip-prefix {
             description "The remote IP Prefix to be associated with this security group rule.
                 You can specify either remote-ip-prefix or remote-group-id in the request body.";
-            type string;
+            type inet:ip-prefix;
         }
         leaf protocol {
             type identityref {
index b0c7d7edac7f8619a2d8f2e9beb2dbe16c156355..e95ebd1fb5a77b596e63d32c6b1431bd055cc9cb 100644 (file)
@@ -20,7 +20,7 @@ import org.opendaylight.neutron.spi.INeutronSecurityRuleCRUD;
 import org.opendaylight.neutron.spi.NeutronCRUDInterfaces;
 import org.opendaylight.neutron.spi.NeutronSecurityGroup;
 import org.opendaylight.neutron.spi.NeutronSecurityRule;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev160807.DirectionBase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev160807.DirectionEgress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev160807.DirectionIngress;
@@ -187,7 +187,7 @@ public class NeutronSecurityRuleInterface extends AbstractNeutronInterface<Secur
             answer.setSecurityRemoteGroupID(rule.getRemoteGroupId().getValue());
         }
         if (rule.getRemoteIpPrefix() != null) {
-            answer.setSecurityRuleRemoteIpPrefix(rule.getRemoteIpPrefix());
+            answer.setSecurityRuleRemoteIpPrefix(new String(rule.getRemoteIpPrefix().getValue()));
         }
         if (rule.getProtocol() != null) {
             answer.setSecurityRuleProtocol(PROTOCOL_MAP.get(rule.getProtocol()));
@@ -226,7 +226,8 @@ public class NeutronSecurityRuleInterface extends AbstractNeutronInterface<Secur
             securityRuleBuilder.setRemoteGroupId(toUuid(securityRule.getSecurityRemoteGroupID()));
         }
         if (securityRule.getSecurityRuleRemoteIpPrefix() != null) {
-            securityRuleBuilder.setRemoteIpPrefix(securityRule.getSecurityRuleRemoteIpPrefix());
+            IpPrefix ipPrefix = new IpPrefix(securityRule.getSecurityRuleRemoteIpPrefix().toCharArray());
+            securityRuleBuilder.setRemoteIpPrefix(ipPrefix);
         }
         if (securityRule.getSecurityRuleProtocol() != null) {
             ImmutableBiMap<String, Class<? extends ProtocolBase>> mapper =