yang model revise: neutron-fwaas.yang 36/35836/5
authorIsaku Yamahata <isaku.yamahata@intel.com>
Fri, 4 Mar 2016 01:41:58 +0000 (17:41 -0800)
committerIsaku Yamahata <isaku.yamahata@intel.com>
Fri, 10 Jun 2016 09:14:03 +0000 (02:14 -0700)
This patch revises yang model of neutron fwaas and related codes.
- fix tcp/udp port
- introduce identity and identityref for protocol/action
- drop descr for consistency
- drop backpointers. firewall-rules
  If openstack provider wants a list of rules associated with
  a given firewall policy, walk through rules and find rules whose
  policy is the uuid of the policy.
- drop status in firewall policy which isn't defined in neutron API
- eliminated deprecated methods in neutron-spi

Change-Id: Ie6fac4202fadcff718d0d4960230eefe06852bc6
Signed-off-by: Isaku Yamahata <isaku.yamahata@intel.com>
Signed-off-by: Ritu Sood <ritu.sood@intel.com>
15 files changed:
integration/test/src/test/java/org/opendaylight/neutron/e2etest/NeutronFirewallRuleTests.java
model/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/neutron/constants/rev150712/NeutronUtils.java [new file with mode: 0644]
model/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/neutron/fwaas/rev150712/FirewallRuleAttributesProtocolBuilder.java [new file with mode: 0644]
model/src/main/yang/neutron-constants.yang
model/src/main/yang/neutron-fwaas.yang
neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronFirewall.java
neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronFirewallPolicy.java
neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronFirewallRule.java
neutron-spi/src/test/java/org/opendaylight/neutron/spi/NeutronFirewallJAXBTest.java
northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronFirewallNorthbound.java
northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronFirewallPolicyNorthbound.java
northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronFirewallRulesNorthbound.java
transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronFirewallInterface.java
transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronFirewallPolicyInterface.java
transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronFirewallRuleInterface.java

index 7df10861515fbb96b095a7daf0a3cebe3e2534ef..6acda8407c94bd8527c911e7ca9f871faf666fc4 100644 (file)
@@ -32,14 +32,15 @@ public class NeutronFirewallRuleTests {
     public String singleton_fw_rule_create_test() {
         String url = base + "/fw/firewall_rules";
         String content = "{ \"firewall_rule\": { \"action\": \"allow\"," +
-            "\"description\": \"\", \"destination_ip_address\": null," +
-            "\"destination_port\": \"80\", \"enabled\": true," +
+            "\"destination_ip_address\": null," +
+            "\"destination_port_min\": \"80\", \"destination_port_max\": \"80\"," +
+            "\"enabled\": true," +
             "\"firewall_policy_id\": null," +
             "\"id\": \"8722e0e0-9cc9-4490-9660-8c9a5732fbb0\"," +
             "\"ip_version\": 4, \"name\": \"ALLOW_HTTP\"," +
             "\"position\": null, \"protocol\": \"tcp\"," +
             "\"shared\": false, \"source_ip_address\": null," +
-            "\"source_port\": null," +
+            "\"source_port_min\": null, \"source_port_max\": null," +
             "\"tenant_id\": \"45977fa2dbd7482098dd68d0d8970117\" } }";
         ITNeutronE2E.test_create(url, content, "Firewall Rule Singleton Post Failed");
         return content;
@@ -53,16 +54,17 @@ public class NeutronFirewallRuleTests {
     public void fw_rule_modify_test() {
         String url = base + "/fw/firewall_rules/8722e0e0-9cc9-4490-9660-8c9a5732fbb0";
         String content = "{ \"firewall_rule\": { \"action\": \"allow\"," +
-            "\"description\": \"\", \"destination_ip_address\": null," +
-            "\"destination_port\": \"80\", \"enabled\": true," +
+            "\"destination_ip_address\": null," +
+            "\"destination_port_min\": \"80\", \"destination_port_max\": \"80\"," +
+            "\"enabled\": true," +
             "\"firewall_policy_id\": null," +
             "\"id\": \"8722e0e0-9cc9-4490-9660-8c9a5732fbb0\"," +
             "\"ip_version\": 4, \"name\": \"ALLOW_HTTP\"," +
             "\"position\": null, \"protocol\": \"tcp\"," +
             "\"shared\": true, \"source_ip_address\": null," +
-            "\"source_port\": null," +
+            "\"source_port_min\": null, \"source_port_max\": null," +
             "\"tenant_id\": \"45977fa2dbd7482098dd68d0d8970117\" } }";
-        ITNeutronE2E.test_modify(url, content, "Firewall Rule Singleton Post Failed");
+        ITNeutronE2E.test_modify(url, content, "Firewall Rule Singleton Put Failed");
     }
 
     public void fw_rule_element_get_test() {
@@ -72,10 +74,11 @@ public class NeutronFirewallRuleTests {
 
     public void fw_rule_element_get_with_query_test() {
         String url = base + "/fw/firewall_rules/8722e0e0-9cc9-4490-9660-8c9a5732fbb0" +
-            "?fields=id&fields=tenant_id&fields=name&fields=description&fields=status" +
+            "?fields=id&fields=tenant_id&fields=name" +
             "&fields=shared&fields=firewall_policy_id&fields=protocol&fields=enabled" +
             "&fields=source_ip_address&fields=destination_ip_address" +
-            "&fields=destination_port&fields=position&fields=action&fields=source_port" +
+            "&fields=destination_port_min&fields=destination_port_max&fields=position" +
+            "&fields=action&fields=source_port_min&fields=source_port_max" +
             "&fields=limit&fields=marker&fields=page_reverse";
         ITNeutronE2E.test_fetch(url, true, "Firewall Rule Element Get With Query Failed");
     }
diff --git a/model/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/neutron/constants/rev150712/NeutronUtils.java b/model/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/neutron/constants/rev150712/NeutronUtils.java
new file mode 100644 (file)
index 0000000..377f390
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2016 Intel corporation and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712;
+
+import com.google.common.collect.ImmutableBiMap;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.FwProtocolBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.FwProtocolIcmp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.FwProtocolTcp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.FwProtocolUdp;
+
+
+public final class NeutronUtils {
+    private NeutronUtils() {
+        throw new UnsupportedOperationException("Utility class should not be instantiated.");
+    }
+
+    // For FWaaS
+    public static class FwProtocolMapper {
+        private FwProtocolMapper() {
+            throw new UnsupportedOperationException("Utility class should not be instantiated.");
+        }
+
+        private static final ImmutableBiMap<String, Class<? extends FwProtocolBase>> MAPPER
+            = new ImmutableBiMap.Builder<String, Class<? extends FwProtocolBase>>()
+            .put("tcp", FwProtocolTcp.class)
+            .put("udp", FwProtocolUdp.class)
+            .put("icmp", FwProtocolIcmp.class)
+            .build();
+
+        public static Class<? extends FwProtocolBase> get(String key) {
+            return MAPPER.get(key);
+        }
+
+        public static String getName(Class<? extends FwProtocolBase> key) {
+            ImmutableBiMap<Class<? extends FwProtocolBase>, String> inverseMapper = MAPPER.inverse();
+            return inverseMapper.get(key);
+        }
+    }
+}
diff --git a/model/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/neutron/fwaas/rev150712/FirewallRuleAttributesProtocolBuilder.java b/model/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/neutron/fwaas/rev150712/FirewallRuleAttributesProtocolBuilder.java
new file mode 100644 (file)
index 0000000..a4ea413
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2016 Intel corporation and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.fwaas.rev150712;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.FwProtocolBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.NeutronUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.fwaas.rev150712.FirewallRuleAttributes.Protocol;
+
+/**
+ * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation.
+ * In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32).
+ *
+ * The reason behind putting it under src/main/java is:
+ * This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent
+ * loss of user code.
+ *
+ */
+public class FirewallRuleAttributesProtocolBuilder {
+    public static Protocol getDefaultInstance(final java.lang.String defaultValue) {
+        Class<? extends FwProtocolBase> fwProtocol =
+            NeutronUtils.FwProtocolMapper.get(defaultValue);
+        if (fwProtocol != null) {
+            return new Protocol(fwProtocol);
+        }
+        Short protocol = Short.parseShort(defaultValue);
+        return new Protocol(protocol);
+    }
+}
index 617d1ccdc3eb9844c872345a9bf8270b80408a3a..74eea62f32a793d3646170d93b7536a5faee6f0b 100644 (file)
@@ -79,6 +79,26 @@ module neutron-constants {
         base probe-base;
     }
 
+    // FWaaS v1
+    identity fw-protocol-base {
+        description "Base identity for firewall protocol";
+    }
+
+    identity fw-protocol-tcp {
+        description "TCP protocol.";
+        base fw-protocol-base;
+    }
+
+    identity fw-protocol-udp {
+        description "UDP protocol.";
+        base fw-protocol-base;
+    }
+
+    identity fw-protocol-icmp {
+        description "ICMP protocol.";
+        base fw-protocol-base;
+    }
+
     // DIRECTION
     identity direction-base {
         description "Base identity for direction";
index e4ec71adb845090c5a39ef9fa9cd6d7f13fa4329..7705cb4f64cb98d18a8d1a645b6d78035f82c4c6 100644 (file)
@@ -14,9 +14,9 @@ module neutron-fwaas {
     prefix neutron-fwaas;
 
     import ietf-yang-types { prefix "yang"; }
-    // It requires rfc6991 (revision 2013-07-15), but odl don't have it, so this patch verify build will fail.
-    import ietf-inet-types { prefix "inet"; revision-date 2010-09-24; }
     import neutron-attrs { prefix "attrs"; }
+    import neutron-constants { prefix "constants"; }
+    import neutron-types { prefix "types"; }
 
     organization "OpenDaylight Neutron Group";
 
@@ -26,14 +26,10 @@ module neutron-fwaas {
 
     revision "2015-07-12" {
         description
-                "OpenDaylight Beryllium release";    
+                "OpenDaylight Beryllium release";
     }
 
     grouping firewall-attributes {
-        leaf descr {
-            type string;
-            description "Detailed description of the firewall.";
-        }
         leaf shared {
             description "whether the firewall is shared or not";
             type boolean;
@@ -45,10 +41,6 @@ module neutron-fwaas {
     }
 
     grouping firewall-policy-attributes {
-        leaf descr {
-            type string;
-            description "Detailed description of the firewall policy.";
-        }
         leaf shared {
             description "whether the firewall policy is shared or not";
             type boolean;
@@ -57,21 +49,23 @@ module neutron-fwaas {
             description "whether the firewall policy is audited or not";
             type boolean;
         }
-        leaf-list firewall-rules {
-            description "whether the firewall policy is audited or not";
-            type yang:uuid;
-        }
+    }
+
+    identity action-base {
+        description "firewall rule action";
+    }
+
+    identity action-allow {
+        description "firewall rule allow";
+        base action-base;
+    }
+
+    identity action-deny {
+        description "firewall rule deny";
+        base action-base;
     }
 
     grouping firewall-rule-attributes {
-        leaf descr {
-            type string;
-            description "Detailed description of the firewall rule.";
-        }
-        leaf status {
-            type string;
-            description "Status of the firewall rule.";
-        }
         leaf shared {
             description "whether the firewall rule is shared or not";
             type boolean;
@@ -86,27 +80,42 @@ module neutron-fwaas {
         }
         leaf protocol {
             description "the protocol this rule applies to";
-            type string;
+            type union {
+                type uint8;
+                type identityref {
+                    base "constants:fw-protocol-base";
+                }
+            }
         }
         leaf ip-version {
             description "the ip version this rule applies to";
-            type int16;
+            type identityref {
+                base "constants:ip-version-base";
+            }
         }
         leaf source-ip-addr {
-            type inet:ip-address;
+            type types:ip-prefix-or-address;
             description "the source ip address for this rule";
         }
         leaf destination-ip-addr {
-            type inet:ip-address;
+            type types:ip-prefix-or-address;
             description "the destination ip address for this rule";
         }
-        leaf source-port {
-            description "the source port for this rule";
-            type int16;
+        leaf source-port-range-min {
+            description "the source port range min for this rule";
+            type uint16;
         }
-        leaf destination-port {
-            description "the destination port for this rule";
-            type int16;
+        leaf source-port-range-max {
+            description "the source port range max for this rule";
+            type uint16;
+        }
+        leaf destination-port-range-min {
+            description "the destination port range min for this rule";
+            type uint16;
+        }
+        leaf destination-port-range-max {
+            description "the destination port range max for this rule";
+            type uint16;
         }
         leaf position {
             description "the priority position this rule occupies";
@@ -114,7 +123,9 @@ module neutron-fwaas {
         }
         leaf action {
             description "the action fot this rule";
-            type string;
+            type identityref {
+                base "action-base";
+            }
         }
     }
 
index 1452907d770cf74f0091bd37238b0dfa738d67cb..73176e8ec782003b4d1bc09071d1e76bdaa5d67e 100644 (file)
@@ -25,9 +25,7 @@ import java.util.List;
  * id                 uuid-str
  * tenant_id          uuid-str
  * name               String
- * description        String
  * admin_state_up     Bool
- * status             String
  * shared             Bool
  * firewall_policy_id uuid-str
  * http://docs.openstack.org/api/openstack-network/2.0/openstack-network.pdf
@@ -43,41 +41,15 @@ public class NeutronFirewall extends NeutronObject implements Serializable, INeu
     @XmlElement (name = "name")
     String firewallName;
 
-    @XmlElement (name = "description")
-    String firewallDescription;
-
     @XmlElement (defaultValue = "true", name = "admin_state_up")
     Boolean firewallAdminStateIsUp;
 
-    @XmlElement (name = "status")
-    String firewallStatus;
-
     @XmlElement (defaultValue = "false", name = "shared")
     Boolean firewallIsShared;
 
     @XmlElement (name = "firewall_policy_id")
     String neutronFirewallPolicyID;
 
-    // @deprecated use getID()
-    public String getFirewallUUID() {
-        return getID();
-    }
-
-    // @deprecated use setID()
-    public void setFirewallUUID(String uuid) {
-        setID(uuid);
-    }
-
-    @Deprecated
-    public String getFirewallTenantID() {
-        return getTenantID();
-    }
-
-    @Deprecated
-    public void setFirewallTenantID(String tenantID) {
-        setTenantID(tenantID);
-    }
-
     public String getFirewallName() {
         return firewallName;
     }
@@ -86,14 +58,6 @@ public class NeutronFirewall extends NeutronObject implements Serializable, INeu
         this.firewallName = firewallName;
     }
 
-    public String getFirewallDescription() {
-        return firewallDescription;
-    }
-
-    public void setFirewallDescription(String firewallDescription) {
-        this.firewallDescription = firewallDescription;
-    }
-
     public Boolean getFirewallAdminStateIsUp() {
         return firewallAdminStateIsUp;
     }
@@ -102,14 +66,6 @@ public class NeutronFirewall extends NeutronObject implements Serializable, INeu
         this.firewallAdminStateIsUp = firewallAdminStateIsUp;
     }
 
-    public String getFirewallStatus() {
-        return firewallStatus;
-    }
-
-    public void setFirewallStatus(String firewallStatus) {
-        this.firewallStatus = firewallStatus;
-    }
-
     public Boolean getFirewallIsShared() {
         return firewallIsShared;
     }
@@ -140,15 +96,9 @@ public class NeutronFirewall extends NeutronObject implements Serializable, INeu
             if (s.equals("name")) {
                 ans.setFirewallName(this.getFirewallName());
             }
-            if(s.equals("description")) {
-                ans.setFirewallDescription(this.getFirewallDescription());
-            }
             if (s.equals("admin_state_up")) {
                 ans.setFirewallAdminStateIsUp(firewallAdminStateIsUp);
             }
-            if (s.equals("status")) {
-                ans.setFirewallStatus(this.getFirewallStatus());
-            }
             if (s.equals("shared")) {
                 ans.setFirewallIsShared(firewallIsShared);
             }
@@ -165,9 +115,7 @@ public class NeutronFirewall extends NeutronObject implements Serializable, INeu
             "firewallUUID='" + uuid + '\'' +
             ", firewallTenantID='" + tenantID + '\'' +
             ", firewallName='" + firewallName + '\'' +
-            ", firewallDescription='" + firewallDescription + '\'' +
             ", firewallAdminStateIsUp=" + firewallAdminStateIsUp +
-            ", firewallStatus='" + firewallStatus + '\'' +
             ", firewallIsShared=" + firewallIsShared +
             ", firewallRulePolicyID=" + neutronFirewallPolicyID +
             '}';
index ee5e4e963819da9c6415d26dd909f37755a9c5f4..f2c9deb9213edd4fa2f09ab8403072291c85ad9d 100644 (file)
@@ -26,9 +26,7 @@ import java.util.List;
  * id             uuid-str
  * tenant_id      uuid-str
  * name           String
- * description    String
  * shared         Boolean
- * firewall_rules List
  * audited        Boolean
  * http://docs.openstack.org/api/openstack-network/2.0/openstack-network.pdf
  *
@@ -43,15 +41,9 @@ public class NeutronFirewallPolicy extends NeutronObject implements Serializable
     @XmlElement (name = "name")
     String firewallPolicyName;
 
-    @XmlElement (name = "description")
-    String firewallPolicyDescription;
-
     @XmlElement (defaultValue = "false", name = "shared")
     Boolean firewallPolicyIsShared;
 
-    @XmlElement (name = "firewall_rules")
-    List<String> firewallPolicyRules;
-
     @XmlElement (defaultValue = "false", name = "audited")
     Boolean firewallPolicyIsAudited;
 
@@ -63,14 +55,6 @@ public class NeutronFirewallPolicy extends NeutronObject implements Serializable
         this.firewallPolicyIsAudited = firewallPolicyIsAudited;
     }
 
-    public void setFirewallPolicyRules(List<String> firewallPolicyRules) {
-        this.firewallPolicyRules = firewallPolicyRules;
-    }
-
-    public List<String> getFirewallPolicyRules() {
-        return firewallPolicyRules;
-    }
-
     public Boolean getFirewallPolicyIsShared() {
         return firewallPolicyIsShared;
     }
@@ -79,14 +63,6 @@ public class NeutronFirewallPolicy extends NeutronObject implements Serializable
         this.firewallPolicyIsShared = firewallPolicyIsShared;
     }
 
-    public String getFirewallPolicyDescription() {
-        return firewallPolicyDescription;
-    }
-
-    public void setFirewallPolicyDescription(String firewallPolicyDescription) {
-        this.firewallPolicyDescription = firewallPolicyDescription;
-    }
-
     public String getFirewallPolicyName() {
         return firewallPolicyName;
     }
@@ -95,26 +71,6 @@ public class NeutronFirewallPolicy extends NeutronObject implements Serializable
         this.firewallPolicyName = firewallPolicyName;
     }
 
-    @Deprecated
-    public String getFirewallPolicyTenantID() {
-        return getTenantID();
-    }
-
-    @Deprecated
-    public void setFirewallPolicyTenantID(String tenantID) {
-        setTenantID(tenantID);
-    }
-
-    // @deprecated use getID()
-    public String getFirewallPolicyUUID() {
-        return getID();
-    }
-
-    // @deprecated use setID()
-    public void setFirewallPolicyUUID(String uuid) {
-        setID(uuid);
-    }
-
     public NeutronFirewallPolicy extractFields(List<String> fields) {
         NeutronFirewallPolicy ans = new NeutronFirewallPolicy();
         Iterator<String> i = fields.iterator();
@@ -129,17 +85,9 @@ public class NeutronFirewallPolicy extends NeutronObject implements Serializable
             if (s.equals("name")) {
                 ans.setFirewallPolicyName(this.getFirewallPolicyName());
             }
-            if(s.equals("description")) {
-                ans.setFirewallPolicyDescription(this.getFirewallPolicyDescription());
-            }
             if (s.equals("shared")) {
                 ans.setFirewallPolicyIsShared(firewallPolicyIsShared);
             }
-            if (s.equals("firewall_rules")) {
-                List<String> firewallRuleList = new ArrayList<String>();
-                firewallRuleList.addAll(this.getFirewallPolicyRules());
-                ans.setFirewallPolicyRules(firewallRuleList);
-            }
             if (s.equals("audited")) {
                 ans.setFirewallPolicyIsAudited(firewallPolicyIsAudited);
             }
@@ -153,9 +101,7 @@ public class NeutronFirewallPolicy extends NeutronObject implements Serializable
             "firewallPolicyUUID='" + uuid + '\'' +
             ", firewallPolicyTenantID='" + tenantID + '\'' +
             ", firewallPolicyName='" + firewallPolicyName + '\'' +
-            ", firewallPolicyDescription='" + firewallPolicyDescription + '\'' +
             ", firewallPolicyIsShared=" + firewallPolicyIsShared +
-            ", firewallPolicyRules=" + firewallPolicyRules +
             ", firewallPolicyIsAudited='" + firewallPolicyIsAudited + '\'' +
             '}';
     }
index f3617f9421a16c44ec5d5ddd22a2aa7e6ea11815..589dc8c2847595d6c43e6a44ddc36a113e35215f 100644 (file)
@@ -24,17 +24,17 @@ import java.util.List;
  *
  * tenant_id               uuid-str
  * name                    String
- * description             String
  * admin_state_up          Bool
- * status                  String
  * shared                  Bool
  * firewall_policy_id      uuid-str
  * protocol                String
  * ip_version              Integer
  * source_ip_address       String (IP addr or CIDR)
  * destination_ip_address  String (IP addr or CIDR)
- * source_port             Integer
- * destination_port        Integer
+ * source_port_range_min    Integer
+ * source_port_range_max    Integer
+ * destination_port_range_min Integer
+ * destination_port_range_max Integer
  * position                Integer
  * action                  String
  * enabled                 Bool
@@ -52,12 +52,6 @@ public class NeutronFirewallRule extends NeutronObject implements Serializable,
     @XmlElement(name = "name")
     String firewallRuleName;
 
-    @XmlElement(name = "description")
-    String firewallRuleDescription;
-
-    @XmlElement(name = "status")
-    String firewallRuleStatus;
-
     @XmlElement(defaultValue = "false", name = "shared")
     Boolean firewallRuleIsShared;
 
@@ -76,11 +70,17 @@ public class NeutronFirewallRule extends NeutronObject implements Serializable,
     @XmlElement(name = "destination_ip_address")
     String firewallRuleDstIpAddr;
 
-    @XmlElement(name = "source_port")
-    Integer firewallRuleSrcPort;
+    @XmlElement(name = "source_port_range_min")
+    Integer firewallRuleSrcPortRangeMin;
+
+    @XmlElement(name = "source_port_range_max")
+    Integer firewallRuleSrcPortRangeMax;
+
+    @XmlElement(name = "destination_port_range_min")
+    Integer firewallRuleDstPortRangeMin;
 
-    @XmlElement(name = "destination_port")
-    Integer firewallRuleDstPort;
+    @XmlElement(name = "destination_port_range_max")
+    Integer firewallRuleDstPortRangeMax;
 
     @XmlElement(name = "position")
     Integer firewallRulePosition;
@@ -115,20 +115,36 @@ public class NeutronFirewallRule extends NeutronObject implements Serializable,
         this.firewallRulePosition = firewallRulePosition;
     }
 
-    public Integer getFirewallRuleDstPort() {
-        return firewallRuleDstPort;
+    public Integer getFirewallRuleDstPortRangeMin() {
+        return firewallRuleDstPortRangeMin;
+    }
+
+    public void setFirewallRuleDstPortRangeMin(Integer firewallRuleDstPortRangeMin) {
+        this.firewallRuleDstPortRangeMin = firewallRuleDstPortRangeMin;
+    }
+
+    public Integer getFirewallRuleDstPortRangeMax() {
+        return firewallRuleDstPortRangeMax;
     }
 
-    public void setFirewallRuleDstPort(Integer firewallRuleDstPort) {
-        this.firewallRuleDstPort = firewallRuleDstPort;
+    public void setFirewallRuleDstPortRangeMax(Integer firewallRuleDstPortRangeMax) {
+        this.firewallRuleDstPortRangeMax = firewallRuleDstPortRangeMax;
     }
 
-    public Integer getFirewallRuleSrcPort() {
-        return firewallRuleSrcPort;
+    public Integer getFirewallRuleSrcPortRangeMin() {
+        return firewallRuleSrcPortRangeMin;
     }
 
-    public void setFirewallRuleSrcPort(Integer firewallRuleSrcPort) {
-        this.firewallRuleSrcPort = firewallRuleSrcPort;
+    public void setFirewallRuleSrcPortRangeMin(Integer firewallRuleSrcPortRangeMin) {
+        this.firewallRuleSrcPortRangeMin = firewallRuleSrcPortRangeMin;
+    }
+
+    public Integer getFirewallRuleSrcPortRangeMax() {
+        return firewallRuleSrcPortRangeMax;
+    }
+
+    public void setFirewallRuleSrcPortRangeMax(Integer firewallRuleSrcPortRangeMax) {
+        this.firewallRuleSrcPortRangeMax = firewallRuleSrcPortRangeMax;
     }
 
     public String getFirewallRuleDstIpAddr() {
@@ -179,22 +195,6 @@ public class NeutronFirewallRule extends NeutronObject implements Serializable,
         this.firewallRuleIsShared = firewallRuleIsShared;
     }
 
-    public String getFirewallRuleStatus() {
-        return firewallRuleStatus;
-    }
-
-    public void setFirewallRuleStatus(String firewallRuleStatus) {
-        this.firewallRuleStatus = firewallRuleStatus;
-    }
-
-    public String getFirewallRuleDescription() {
-        return firewallRuleDescription;
-    }
-
-    public void setFirewallRuleDescription(String firewallRuleDescription) {
-        this.firewallRuleDescription = firewallRuleDescription;
-    }
-
     public String getFirewallRuleName() {
         return firewallRuleName;
     }
@@ -203,26 +203,6 @@ public class NeutronFirewallRule extends NeutronObject implements Serializable,
         this.firewallRuleName = firewallRuleName;
     }
 
-    @Deprecated
-    public String getFirewallRuleTenantID() {
-        return getTenantID();
-    }
-
-    @Deprecated
-    public void setFirewallRuleTenantID(String tenantID) {
-        setTenantID(tenantID);
-    }
-
-    // @deprecated use getID()
-    public String getFirewallRuleUUID() {
-        return getID();
-    }
-
-    // @deprecated use setID()
-    public void setFireWallRuleID(String uuid) {
-        setID(uuid);
-    }
-
     public NeutronFirewallRule extractFields(List<String> fields) {
         NeutronFirewallRule ans = new NeutronFirewallRule();
         Iterator<String> i = fields.iterator();
@@ -237,12 +217,6 @@ public class NeutronFirewallRule extends NeutronObject implements Serializable,
             if (s.equals("name")) {
                 ans.setFirewallRuleName(this.getFirewallRuleName());
             }
-            if (s.equals("description")) {
-                ans.setFirewallRuleDescription(this.getFirewallRuleDescription());
-            }
-            if (s.equals("status")) {
-                ans.setFirewallRuleStatus(this.getFirewallRuleStatus());
-            }
             if (s.equals("shared")) {
                 ans.setFirewallRuleIsShared(firewallRuleIsShared);
             }
@@ -258,11 +232,17 @@ public class NeutronFirewallRule extends NeutronObject implements Serializable,
             if (s.equals("destination_ip_address")) {
                 ans.setFirewallRuleDstIpAddr(this.getFirewallRuleDstIpAddr());
             }
-            if (s.equals("source_port")) {
-                ans.setFirewallRuleSrcPort(this.getFirewallRuleSrcPort());
+            if (s.equals("source_port_range_min")) {
+                ans.setFirewallRuleSrcPortRangeMin(this.getFirewallRuleSrcPortRangeMin());
+            }
+            if (s.equals("source_port_range_max")) {
+                ans.setFirewallRuleSrcPortRangeMax(this.getFirewallRuleSrcPortRangeMax());
+            }
+            if (s.equals("destination_port_range_min")) {
+                ans.setFirewallRuleDstPortRangeMin(this.getFirewallRuleDstPortRangeMin());
             }
-            if (s.equals("destination_port")) {
-                ans.setFirewallRuleDstPort(this.getFirewallRuleDstPort());
+            if (s.equals("destination_port_range_max")) {
+                ans.setFirewallRuleDstPortRangeMax(this.getFirewallRuleDstPortRangeMax());
             }
             if (s.equals("position")) {
                 ans.setFirewallRulePosition(this.getFirewallRulePosition());
@@ -284,16 +264,14 @@ public class NeutronFirewallRule extends NeutronObject implements Serializable,
             "firewallRuleUUID='" + uuid + '\'' +
             ", firewallRuleTenantID='" + tenantID + '\'' +
             ", firewallRuleName='" + firewallRuleName + '\'' +
-            ", firewallRuleDescription='" + firewallRuleDescription + '\'' +
-            ", firewallRuleStatus='" + firewallRuleStatus + '\'' +
             ", firewallRuleIsShared=" + firewallRuleIsShared +
             ", firewallRulePolicyID=" + firewallRulePolicyID +
             ", firewallRuleProtocol='" + firewallRuleProtocol + '\'' +
             ", firewallRuleIpVer=" + firewallRuleIpVer +
             ", firewallRuleSrcIpAddr='" + firewallRuleSrcIpAddr + '\'' +
             ", firewallRuleDstIpAddr='" + firewallRuleDstIpAddr + '\'' +
-            ", firewallRuleSrcPort=" + firewallRuleSrcPort +
-            ", firewallRuleDstPort=" + firewallRuleDstPort +
+            ", firewallRuleSrcPort=" + firewallRuleSrcPortRangeMin + ':' + firewallRuleSrcPortRangeMax +
+            ", firewallRuleDstPort=" + firewallRuleDstPortRangeMin + ':' + firewallRuleDstPortRangeMax +
             ", firewallRulePosition=" + firewallRulePosition +
             ", firewallRuleAction='" + firewallRuleAction + '\'' +
             ", firewallRuleIsEnabled=" + firewallRuleIsEnabled +
index ff580577203760250280a27e83a5344c4102db23..7f1bf73be9cbf257f00ee6065e05550890f28223 100644 (file)
@@ -36,15 +36,9 @@ public class NeutronFirewallJAXBTest {
             Assert.assertEquals("NeutronFirewall JAXB Test 3: Testing name failed",
                   "jaxb-test", testObject.getFirewallName());
 
-            Assert.assertEquals("NeutronFirewall JAXB Test 4: Testing description failed",
-                  "Test of NeutronFirewall JAXB", testObject.getFirewallDescription());
-
             Assert.assertFalse("NeutronFirewall JAXB Test 5: Testing admin_state_up failed",
                   testObject.getFirewallAdminStateIsUp());
 
-            Assert.assertEquals("NeutronFirewall JAXB Test 6: Testing status failed",
-                  "DOWN", testObject.getFirewallStatus());
-
             Assert.assertTrue("NeutronFirewall JAXB Test 7: Testing shared failed",
                   testObject.getFirewallIsShared());
 
@@ -71,26 +65,17 @@ public class NeutronFirewallJAXBTest {
             Assert.assertEquals("NeutronFirewallPolicy JAXB Test 3: Testing name failed",
                   "jaxb-test", testObject.getFirewallPolicyName());
 
-            Assert.assertEquals("NeutronFirewallPolicy JAXB Test 4: Testing description failed",
-                  "Test of NeutronFirewallPolicy JAXB", testObject.getFirewallPolicyDescription());
-
             Assert.assertTrue("NeutronFirewallPolicy JAXB Test 5: Testing shared failed",
                   testObject.getFirewallPolicyIsShared());
 
             Assert.assertTrue("NeutronFirewallPolicy JAXB Test 6: Testing audited failed",
                   testObject.getFirewallPolicyIsAudited());
-
-            List<String> policyRules = testObject.getFirewallPolicyRules();
-            Assert.assertEquals("NeutronFirewallPolicy JAXB Test 7.1: Testing firewall policy rules length failed",
-                  1, policyRules.size());
-            Assert.assertEquals("NeutronFirewallPolicy JAXB Test 7.2: Testing firewall policy rules content failed", 
-                  "83ca694a-eeff-48e5-b2d8-fe5198cf2e86", policyRules.get(0));
         } catch (Exception e) {
             Assert.assertTrue("Tests failed", false);
         }
     }
 
-    private static final String NeutronFirewallRule_sourceJson="{ \"action\": \"allow\", \"description\": \"Test of NeutronFirewallRule JAXB\", \"destination_ip_address\": \"10.10.10.10\", \"destination_port\": \"80\", \"enabled\": true, \"firewall_policy_id\": \"83ca694a-eeff-48e5-b2d8-fe5198cf2e86\", \"id\": \"8722e0e0-9cc9-4490-9660-8c9a5732fbb0\", \"ip_version\": 4, \"name\": \"ALLOW_HTTP\", \"position\": 1, \"protocol\": \"tcp\", \"shared\": false, \"source_ip_address\": \"10.10.10.8\", \"source_port\": null, \"tenant_id\": \"45977fa2dbd7482098dd68d0d8970117\" }";
+    private static final String NeutronFirewallRule_sourceJson="{ \"action\": \"allow\", \"description\": \"Test of NeutronFirewallRule JAXB\", \"destination_ip_address\": \"10.10.10.10\", \"destination_port_range_min\": \"80\", \"destination_port_range_max\": \"81\", \"enabled\": true, \"firewall_policy_id\": \"83ca694a-eeff-48e5-b2d8-fe5198cf2e86\", \"id\": \"8722e0e0-9cc9-4490-9660-8c9a5732fbb0\", \"ip_version\": 4, \"name\": \"ALLOW_HTTP\", \"position\": 1, \"protocol\": \"tcp\", \"shared\": false, \"source_ip_address\": \"10.10.10.8\", \"source_port\": null, \"tenant_id\": \"45977fa2dbd7482098dd68d0d8970117\" }";
 
     @Test
     public void test_NeutronFirewallRule_JAXB() {
@@ -106,9 +91,6 @@ public class NeutronFirewallJAXBTest {
             Assert.assertEquals("NeutronFirewallRule JAXB Test 3: Testing name failed",
                   "ALLOW_HTTP", testObject.getFirewallRuleName());
 
-            Assert.assertEquals("NeutronFirewallRule JAXB Test 4: Testing description failed",
-                  "Test of NeutronFirewallRule JAXB", testObject.getFirewallRuleDescription());
-
             Assert.assertEquals("NeutronFirewallRule JAXB Test 5: Testing firewaulPolicyRuleID failed",
                   "83ca694a-eeff-48e5-b2d8-fe5198cf2e86", testObject.getFirewallRulePolicyID());
 
@@ -127,11 +109,17 @@ public class NeutronFirewallJAXBTest {
             Assert.assertEquals("NeutronFirewallRule JAXB Test 10: Testing destination IP address failed",
                   "10.10.10.10", testObject.getFirewallRuleDstIpAddr());
 
-            Assert.assertEquals("NeutronFirewallRule JAXB Test 11: Testing source port failed",
-                  null, testObject.getFirewallRuleSrcPort());
+            Assert.assertEquals("NeutronFirewallRule JAXB Test 11.1: Testing source port min failed",
+                  null, testObject.getFirewallRuleSrcPortRangeMin());
+
+            Assert.assertEquals("NeutronFirewallRule JAXB Test 11.2: Testing source port failed",
+                  null, testObject.getFirewallRuleSrcPortRangeMax());
+
+            Assert.assertEquals("NeutronFirewallRule JAXB Test 12.1: Testing destination port min failed",
+                  new Integer(80), testObject.getFirewallRuleDstPortRangeMin());
 
-            Assert.assertEquals("NeutronFirewallRule JAXB Test 12: Testing destination port failed",
-                  new Integer(80), testObject.getFirewallRuleDstPort());
+            Assert.assertEquals("NeutronFirewallRule JAXB Test 12.2: Testing destination port max failed",
+                  new Integer(81), testObject.getFirewallRuleDstPortRangeMax());
 
             Assert.assertEquals("NeutronFirewallRule JAXB Test 13: Testing position failed",
                   new Integer(1), testObject.getFirewallRulePosition());
index d1650654a665025f00fa9dcc028fdcfd2ef834e0..f28d6c5d7dda25a4f92aa92696a987db77266627 100644 (file)
@@ -136,9 +136,7 @@ public class NeutronFirewallNorthbound
             @QueryParam("id") String queryFirewallUUID,
             @QueryParam("tenant_id") String queryFirewallTenantID,
             @QueryParam("name") String queryFirewallName,
-            @QueryParam("description") String queryFirewallDescription,
             @QueryParam("admin_state_up") Boolean queryFirewallAdminStateIsUp,
-            @QueryParam("status") String queryFirewallStatus,
             @QueryParam("shared") Boolean queryFirewallIsShared,
             @QueryParam("firewall_policy_id") String queryFirewallPolicyID,
             // pagination
@@ -156,12 +154,8 @@ public class NeutronFirewallNorthbound
                     queryFirewallTenantID.equals(nsg.getTenantID())) &&
                 (queryFirewallName == null ||
                     queryFirewallName.equals(nsg.getFirewallName())) &&
-                (queryFirewallDescription == null ||
-                    queryFirewallDescription.equals(nsg.getFirewallDescription())) &&
                 (queryFirewallAdminStateIsUp == null ||
                     queryFirewallAdminStateIsUp.equals(nsg.getFirewallAdminStateIsUp())) &&
-                (queryFirewallStatus == null ||
-                    queryFirewallStatus.equals(nsg.getFirewallStatus())) &&
                 (queryFirewallIsShared == null ||
                     queryFirewallIsShared.equals(nsg.getFirewallIsShared())) &&
                 (queryFirewallPolicyID == null ||
index b8c25e98d4184a6afddaabec6321554e451f97a7..8d8a5aa22bda458c2a318dc7e68ae12387128f1e 100644 (file)
@@ -137,9 +137,7 @@ public class NeutronFirewallPolicyNorthbound
             @QueryParam("id") String queryFirewallPolicyUUID,
             @QueryParam("tenant_id") String queryFirewallPolicyTenantID,
             @QueryParam("name") String queryFirewallPolicyName,
-            @QueryParam("description") String querySecurityPolicyDescription,
             @QueryParam("shared") Boolean querySecurityPolicyIsShared,
-            @QueryParam("firewall_rules") List<String> querySecurityPolicyFirewallRules,
             @QueryParam("audited") Boolean querySecurityPolicyIsAudited,
             // pagination
             @QueryParam("limit") String limit,
@@ -156,12 +154,8 @@ public class NeutronFirewallPolicyNorthbound
                     queryFirewallPolicyTenantID.equals(nsg.getTenantID())) &&
                 (queryFirewallPolicyName == null ||
                     queryFirewallPolicyName.equals(nsg.getFirewallPolicyName())) &&
-                (querySecurityPolicyDescription == null ||
-                    querySecurityPolicyDescription.equals(nsg.getFirewallPolicyDescription())) &&
                 (querySecurityPolicyIsShared == null ||
                     querySecurityPolicyIsShared.equals(nsg.getFirewallPolicyIsShared())) &&
-                (querySecurityPolicyFirewallRules.size() == 0 ||
-                    querySecurityPolicyFirewallRules.equals(nsg.getFirewallPolicyRules())) &&
                 (querySecurityPolicyIsAudited == null ||
                     querySecurityPolicyIsAudited.equals(nsg.getFirewallPolicyIsAudited()))) {
                 if (fields.size() > 0) {
index f2324d380ce6fcfe2b57e64ab67cc44e367671df..014abbc0850369ad83d5d7354416248827dcd9bf 100644 (file)
@@ -136,16 +136,16 @@ public class NeutronFirewallRulesNorthbound
             @QueryParam("id") String queryFirewallRuleUUID,
             @QueryParam("tenant_id") String queryFirewallRuleTenantID,
             @QueryParam("name") String queryFirewallRuleName,
-            @QueryParam("description") String queryFirewallRuleDescription,
-            @QueryParam("status") String queryFirewallRuleStatus,
             @QueryParam("shared") Boolean queryFirewallRuleIsShared,
             @QueryParam("firewall_policy_id") String queryFirewallRulePolicyID,
             @QueryParam("protocol") String queryFirewallRuleProtocol,
             @QueryParam("ip_version") Integer queryFirewallRuleIpVer,
             @QueryParam("source_ip_address") String queryFirewallRuleSrcIpAddr,
             @QueryParam("destination_ip_address") String queryFirewallRuleDstIpAddr,
-            @QueryParam("source_port") Integer queryFirewallRuleSrcPort,
-            @QueryParam("destination_port") Integer queryFirewallRuleDstPort,
+            @QueryParam("source_port_range_min") Integer queryFirewallRuleSrcPortRangeMin,
+            @QueryParam("source_port_range_max") Integer queryFirewallRuleSrcPortRangeMax,
+            @QueryParam("destination_port_range_min") Integer queryFirewallRuleDstPortRangeMin,
+            @QueryParam("destination_port_range_max") Integer queryFirewallRuleDstPortRangeMax,
             @QueryParam("position") Integer queryFirewallRulePosition,
             @QueryParam("action") String queryFirewallRuleAction,
             @QueryParam("enabled") Boolean queryFirewallRuleIsEnabled,
@@ -164,10 +164,6 @@ public class NeutronFirewallRulesNorthbound
                             queryFirewallRuleTenantID.equals(nsr.getTenantID())) &&
                     (queryFirewallRuleName == null ||
                             queryFirewallRuleName.equals(nsr.getFirewallRuleName())) &&
-                    (queryFirewallRuleDescription == null ||
-                            queryFirewallRuleDescription.equals(nsr.getFirewallRuleDescription())) &&
-                    (queryFirewallRuleStatus == null ||
-                            queryFirewallRuleStatus.equals(nsr.getFirewallRuleStatus())) &&
                     (queryFirewallRuleIsShared == null ||
                             queryFirewallRuleIsShared.equals(nsr.getFirewallRuleIsShared())) &&
                     (queryFirewallRulePolicyID == null ||
@@ -180,10 +176,14 @@ public class NeutronFirewallRulesNorthbound
                             queryFirewallRuleSrcIpAddr.equals(nsr.getFirewallRuleSrcIpAddr())) &&
                     (queryFirewallRuleDstIpAddr == null ||
                             queryFirewallRuleDstIpAddr.equals(nsr.getFirewallRuleDstIpAddr())) &&
-                    (queryFirewallRuleSrcPort == null ||
-                            queryFirewallRuleSrcPort.equals(nsr.getFirewallRuleSrcPort())) &&
-                    (queryFirewallRuleDstPort == null ||
-                            queryFirewallRuleDstPort.equals(nsr.getFirewallRuleDstPort())) &&
+                    (queryFirewallRuleSrcPortRangeMin == null ||
+                            queryFirewallRuleSrcPortRangeMin.equals(nsr.getFirewallRuleSrcPortRangeMin())) &&
+                    (queryFirewallRuleSrcPortRangeMax == null ||
+                            queryFirewallRuleSrcPortRangeMax.equals(nsr.getFirewallRuleSrcPortRangeMax())) &&
+                    (queryFirewallRuleDstPortRangeMin == null ||
+                            queryFirewallRuleDstPortRangeMin.equals(nsr.getFirewallRuleDstPortRangeMin())) &&
+                    (queryFirewallRuleDstPortRangeMax == null ||
+                            queryFirewallRuleDstPortRangeMax.equals(nsr.getFirewallRuleDstPortRangeMax())) &&
                     (queryFirewallRulePosition == null ||
                             queryFirewallRulePosition.equals(nsr.getFirewallRulePosition())) &&
                     (queryFirewallRuleAction == null ||
index 64b651f7a4053dcf7e0812f4d4635356eeb399bc..0897ba3a8eaefdf0a92a1effadf9fb42a9007a35 100644 (file)
@@ -99,12 +99,6 @@ public class NeutronFirewallInterface extends AbstractNeutronInterface<Firewall,
             answer.setTenantID(firewall.getTenantId());
         }
         answer.setFirewallAdminStateIsUp(firewall.isAdminStateUp());
-        if (firewall.getStatus() != null) {
-            answer.setFirewallStatus(firewall.getStatus());
-        }
-        if (firewall.getDescr() != null) {
-            answer.setFirewallDescription(firewall.getDescr());
-        }
         if (firewall.isShared() != null) {
             answer.setFirewallIsShared(firewall.isShared());
         }
@@ -129,12 +123,6 @@ public class NeutronFirewallInterface extends AbstractNeutronInterface<Firewall,
         if (firewall.getFirewallAdminStateIsUp() != null) {
             firewallBuilder.setAdminStateUp(firewall.getFirewallAdminStateIsUp());
         }
-        if (firewall.getFirewallStatus() != null) {
-            firewallBuilder.setStatus(firewall.getFirewallStatus());
-        }
-        if (firewall.getFirewallDescription() != null) {
-            firewallBuilder.setDescr(firewall.getFirewallDescription());
-        }
         if (firewall.getFirewallIsShared() != null) {
             firewallBuilder.setShared(firewall.getFirewallIsShared());
         }
index 76a055369accdd2bc465335507b5c07ccf9ba3c3..136ccbf0aab4c44a7caccf83197d0b0950ee3db6 100644 (file)
@@ -8,14 +8,12 @@
 
 package org.opendaylight.neutron.transcriber;
 
-import java.util.ArrayList;
 import java.util.List;
 
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
 import org.opendaylight.neutron.spi.INeutronFirewallPolicyCRUD;
 import org.opendaylight.neutron.spi.NeutronFirewallPolicy;
 
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.fwaas.rev150712.policies.attributes.FirewallPolicies;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.fwaas.rev150712.policies.attributes.firewall.policies.FirewallPolicy;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.fwaas.rev150712.policies.attributes.firewall.policies.FirewallPolicyBuilder;
@@ -102,22 +100,12 @@ public class NeutronFirewallPolicyInterface extends AbstractNeutronInterface<Fir
         if (policy.getTenantId() != null) {
             answer.setTenantID(policy.getTenantId());
         }
-        if (policy.getDescr() != null) {
-            answer.setFirewallPolicyDescription(policy.getDescr());
-        }
         if (policy.isShared() != null) {
             answer.setFirewallPolicyIsShared(policy.isShared());
         }
         if (policy.isAudited() != null) {
             answer.setFirewallPolicyIsAudited(policy.isAudited());
         }
-        if (policy.getFirewallRules() != null) {
-            final List<String> rules = new ArrayList<String>();
-            for (final Uuid rule: policy.getFirewallRules()) {
-                rules.add(rule.getValue());
-            }
-            answer.setFirewallPolicyRules(rules);
-        }
         return answer;
     }
 
@@ -133,22 +121,12 @@ public class NeutronFirewallPolicyInterface extends AbstractNeutronInterface<Fir
         if (policy.getTenantID() != null) {
             policyBuilder.setTenantId(toUuid(policy.getTenantID()));
         }
-        if (policy.getFirewallPolicyDescription() != null) {
-            policyBuilder.setDescr(policy.getFirewallPolicyDescription());
-        }
         if (policy.getFirewallPolicyIsShared() != null) {
             policyBuilder.setShared(policy.getFirewallPolicyIsShared());
         }
         if (policy.getFirewallPolicyIsAudited() != null) {
             policyBuilder.setAudited(policy.getFirewallPolicyIsAudited());
         }
-        if (policy.getFirewallPolicyRules() != null) {
-            final List<Uuid> rules = new ArrayList<Uuid>();
-            for (final String rule: policy.getFirewallPolicyRules()) {
-                rules.add(toUuid(rule));
-            }
-            policyBuilder.setFirewallRules(rules);
-        }
         return policyBuilder.build();
     }
 
index fd58f0837560cc76e6b71d2141eb661f8fba9525..c128fe249c68db65d74f54d0af3408f2ef66c44a 100644 (file)
@@ -14,13 +14,23 @@ import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderCo
 import org.opendaylight.neutron.spi.INeutronFirewallRuleCRUD;
 import org.opendaylight.neutron.spi.NeutronFirewallRule;
 
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.IpVersionBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.IpVersionV4;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.IpVersionV6;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.NeutronUtils.FwProtocolMapper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.fwaas.rev150712.ActionAllow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.fwaas.rev150712.ActionBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.fwaas.rev150712.ActionDeny;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.fwaas.rev150712.FirewallRuleAttributes.Protocol;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.fwaas.rev150712.rules.attributes.FirewallRules;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.fwaas.rev150712.rules.attributes.firewall.rules.FirewallRule;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.fwaas.rev150712.rules.attributes.firewall.rules.FirewallRuleBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
-
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.types.rev160517.IpPrefixOrAddress;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+
+import com.google.common.collect.ImmutableBiMap;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceRegistration;
 import org.slf4j.Logger;
@@ -29,6 +39,18 @@ import org.slf4j.LoggerFactory;
 public class NeutronFirewallRuleInterface extends AbstractNeutronInterface<FirewallRule, FirewallRules, NeutronFirewallRule> implements INeutronFirewallRuleCRUD {
     private static final Logger LOGGER = LoggerFactory.getLogger(NeutronFirewallRuleInterface.class);
 
+    private static final ImmutableBiMap<Class<? extends ActionBase>, String> ACTION_MAP
+            = new ImmutableBiMap.Builder<Class<? extends ActionBase>, String>()
+            .put(ActionAllow.class, "allow")
+            .put(ActionDeny.class, "deny")
+            .build();
+
+    private static final ImmutableBiMap<Class<? extends IpVersionBase>, Integer> IP_VERSION_MAP
+            = new ImmutableBiMap.Builder<Class<? extends IpVersionBase>, Integer>()
+            .put(IpVersionV4.class, Integer.valueOf(4))
+            .put(IpVersionV6.class, Integer.valueOf(6))
+            .build();
+
     NeutronFirewallRuleInterface(ProviderContext providerContext) {
         super(providerContext);
     }
@@ -97,12 +119,6 @@ public class NeutronFirewallRuleInterface extends AbstractNeutronInterface<Firew
         if (rule.getTenantId() != null) {
             answer.setTenantID(rule.getTenantId());
         }
-        if (rule.getDescr() != null) {
-            answer.setFirewallRuleDescription(rule.getDescr());
-        }
-        if (rule.getStatus() != null) {
-            answer.setFirewallRuleStatus(rule.getStatus());
-        }
         if (rule.isShared() != null) {
             answer.setFirewallRuleIsShared(rule.isShared());
         }
@@ -113,10 +129,17 @@ public class NeutronFirewallRuleInterface extends AbstractNeutronInterface<Firew
             answer.setFirewallRulePolicyID(rule.getFirewallPolicyId().getValue());
         }
         if (rule.getProtocol() != null) {
-            answer.setFirewallRuleProtocol(rule.getProtocol());
+            final Protocol protocol = rule.getProtocol();
+            if (protocol.getUint8() != null) {
+                // uint8
+                answer.setFirewallRuleProtocol(protocol.getUint8().toString());
+            } else {
+                // symbolic protocol name
+                answer.setFirewallRuleProtocol(FwProtocolMapper.getName(protocol.getIdentityref()));
+            }
         }
         if (rule.getIpVersion() != null) {
-            answer.setFirewallRuleIpVer(rule.getIpVersion().intValue());
+            answer.setFirewallRuleIpVer(IP_VERSION_MAP.get(rule.getIpVersion()));
         }
         if (rule.getSourceIpAddr() != null) {
             answer.setFirewallRuleSrcIpAddr(String.valueOf(rule.getSourceIpAddr().getValue()));
@@ -124,17 +147,23 @@ public class NeutronFirewallRuleInterface extends AbstractNeutronInterface<Firew
         if (rule.getDestinationIpAddr() != null) {
             answer.setFirewallRuleDstIpAddr(String.valueOf(rule.getDestinationIpAddr().getValue()));
         }
-        if (rule.getSourcePort() != null) {
-            answer.setFirewallRuleSrcPort(rule.getSourcePort().intValue());
+        if (rule.getSourcePortRangeMin() != null) {
+            answer.setFirewallRuleSrcPortRangeMin(rule.getSourcePortRangeMin());
         }
-        if (rule.getDestinationPort() != null) {
-            answer.setFirewallRuleDstPort(rule.getDestinationPort().intValue());
+        if (rule.getSourcePortRangeMax() != null) {
+            answer.setFirewallRuleSrcPortRangeMax(rule.getSourcePortRangeMax());
+        }
+        if (rule.getDestinationPortRangeMin() != null) {
+            answer.setFirewallRuleDstPortRangeMin(rule.getDestinationPortRangeMin());
+        }
+        if (rule.getDestinationPortRangeMax() != null) {
+            answer.setFirewallRuleDstPortRangeMax(rule.getDestinationPortRangeMax());
         }
         if (rule.getPosition() != null) {
-            answer.setFirewallRulePosition(rule.getPosition().intValue());
+            answer.setFirewallRulePosition(Integer.valueOf(rule.getPosition().intValue()));
         }
         if (rule.getAction() != null) {
-            answer.setFirewallRuleAction(rule.getAction());
+            answer.setFirewallRuleAction(ACTION_MAP.get(rule.getAction()));
         }
         return answer;
     }
@@ -151,12 +180,6 @@ public class NeutronFirewallRuleInterface extends AbstractNeutronInterface<Firew
         if (rule.getTenantID() != null) {
             ruleBuilder.setTenantId(toUuid(rule.getTenantID()));
         }
-        if (rule.getFirewallRuleDescription() != null) {
-            ruleBuilder.setDescr(rule.getFirewallRuleDescription());
-        }
-        if (rule.getFirewallRuleStatus() != null) {
-            ruleBuilder.setStatus(rule.getFirewallRuleStatus());
-        }
         if (rule.getFirewallRuleIsShared() != null) {
             ruleBuilder.setShared(rule.getFirewallRuleIsShared());
         }
@@ -167,30 +190,40 @@ public class NeutronFirewallRuleInterface extends AbstractNeutronInterface<Firew
             ruleBuilder.setFirewallPolicyId(toUuid(rule.getFirewallRulePolicyID()));
         }
         if (rule.getFirewallRuleProtocol() != null) {
-            ruleBuilder.setProtocol(rule.getFirewallRuleProtocol());
+            final String protocolString = rule.getFirewallRuleProtocol();
+            final Protocol protocol = new Protocol(protocolString.toCharArray());
+            ruleBuilder.setProtocol(protocol);
         }
         if (rule.getFirewallRuleIpVer() != null) {
-            ruleBuilder.setIpVersion(rule.getFirewallRuleIpVer().shortValue());
+            final ImmutableBiMap<Integer, Class<? extends IpVersionBase>> mapper = IP_VERSION_MAP.inverse();
+            ruleBuilder.setIpVersion(mapper.get(rule.getFirewallRuleIpVer()));
         }
         if (rule.getFirewallRuleSrcIpAddr() != null) {
-            final IpAddress ipAddress = new IpAddress(rule.getFirewallRuleSrcIpAddr().toCharArray());
+            final IpPrefixOrAddress ipAddress = new IpPrefixOrAddress(rule.getFirewallRuleSrcIpAddr().toCharArray());
             ruleBuilder.setSourceIpAddr(ipAddress);
         }
         if (rule.getFirewallRuleDstIpAddr() != null) {
-            final IpAddress ipAddress = new IpAddress(rule.getFirewallRuleDstIpAddr().toCharArray());
+            final IpPrefixOrAddress ipAddress = new IpPrefixOrAddress(rule.getFirewallRuleDstIpAddr().toCharArray());
             ruleBuilder.setDestinationIpAddr(ipAddress);
         }
-        if (rule.getFirewallRuleSrcPort() != null) {
-            ruleBuilder.setSourcePort(rule.getFirewallRuleSrcPort().shortValue());
+        if (rule.getFirewallRuleSrcPortRangeMin() != null) {
+            ruleBuilder.setSourcePortRangeMin(rule.getFirewallRuleSrcPortRangeMin());
+        }
+        if (rule.getFirewallRuleSrcPortRangeMax() != null) {
+            ruleBuilder.setSourcePortRangeMax(rule.getFirewallRuleSrcPortRangeMax());
+        }
+        if (rule.getFirewallRuleDstPortRangeMin() != null) {
+            ruleBuilder.setDestinationPortRangeMin(rule.getFirewallRuleDstPortRangeMin());
         }
-        if (rule.getFirewallRuleDstPort() != null) {
-            ruleBuilder.setDestinationPort(rule.getFirewallRuleDstPort().shortValue());
+        if (rule.getFirewallRuleDstPortRangeMax() != null) {
+            ruleBuilder.setDestinationPortRangeMax(rule.getFirewallRuleDstPortRangeMax());
         }
         if (rule.getFirewallRulePosition() != null) {
             ruleBuilder.setPosition(rule.getFirewallRulePosition().shortValue());
         }
         if (rule.getFirewallRuleAction() != null) {
-            ruleBuilder.setAction(rule.getFirewallRuleAction());
+            final ImmutableBiMap<String, Class<? extends ActionBase>> mapper = ACTION_MAP.inverse();
+            ruleBuilder.setAction(mapper.get(rule.getFirewallRuleAction()));
         }
         return ruleBuilder.build();
     }