yang model revise: neutron-l2gateways.yang 38/39238/5
authorIsaku Yamahata <isaku.yamahata@intel.com>
Wed, 18 May 2016 19:46:44 +0000 (12:46 -0700)
committerIsaku Yamahata <isaku.yamahata@intel.com>
Fri, 10 Jun 2016 09:14:03 +0000 (02:14 -0700)
This patch revises yang model for l2gateways and the related code
- missing uuid for devices
- pyang warning. unused import, missing key for list
- code indentation

Change-Id: Id20201bc09ea904476d428c4a411d27c1d7bbcf3
Signed-off-by: Isaku Yamahata <isaku.yamahata@intel.com>
integration/test/src/test/java/org/opendaylight/neutron/e2etest/NeutronL2GatewayTests.java
model/src/main/yang/neutron-l2gateways.yang
neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronL2gatewayDevice.java
transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronL2gatewayInterface.java

index cc0d9d062aa40f5789bf0cfd35866d5500cd3d70..d7c720326cdc5be0e2dfe482d57977dc8b1d9fa3 100644 (file)
@@ -30,12 +30,13 @@ public class NeutronL2GatewayTests {
 
     public String singleton_l2gateway_create_test() {
         String url = base + "/l2-gateways";
-        String content = " { \"l2_gateway\": { \"name\": \"gateway1\"," +
+        String content = "{ \"l2_gateway\": { \"name\": \"gateway1\"," +
             "\"id\": \"3b0ef8f4-82c7-44d4-a4fb-6177f9a21977\"," +
             "\"tenant_id\": \"45977fa2dbd7482098dd68d0d8970117\"," +
-            "\"devices\": [{\"device_name\": \"device1\"," +
-            "\"interfaces\": [{\"name\": \"interface1\", \"segmentation_id\": [100] }] " +
-            "}] } }";
+            "\"devices\": [{ \"device_name\": \"device1\"," +
+                            "\"id\": \"0a24b09a-88a1-4f2c-94e9-92515972a704\"," +
+                            "\"interfaces\": [{\"name\": \"interface1\", \"segmentation_id\": [100] }] }]" +
+            "} }";
         ITNeutronE2E.test_create(url, content, "L2 Gateway Singleton Post Failed");
         return content;
     }
@@ -47,12 +48,13 @@ public class NeutronL2GatewayTests {
 
     public void l2gateway_modify_test() {
         String url = base + "/l2-gateways/3b0ef8f4-82c7-44d4-a4fb-6177f9a21977";
-        String content = " { \"l2_gateway\": { \"name\": \"gateway1\"," +
+        String content = "{ \"l2_gateway\": { \"name\": \"gateway1\"," +
             "\"id\": \"3b0ef8f4-82c7-44d4-a4fb-6177f9a21977\"," +
             "\"tenant_id\": \"45977fa2dbd7482098dd68d0d8970117\"," +
-            "\"devices\": [{\"device_name\": \"device1\"," +
-            "\"interfaces\": [{\"name\": \"interface1\", \"segmentation_id\": [100, 50] }] " +
-            "}] } }";
+            "\"devices\": [{ \"device_name\": \"device1\"," +
+                            "\"id\": \"0a24b09a-88a1-4f2c-94e9-92515972a704\"," +
+                            "\"interfaces\": [{\"name\": \"interface1\", \"segmentation_id\": [100, 50] }] }]" +
+            "} }";
         ITNeutronE2E.test_modify(url, content, "L2 Gateway  Singleton Put Failed");
     }
 
index 01eb74c8aa8e7f7ae85c65aa1a2aa6649b4a3fe9..074d389bfff70ba371d559b6ccd5e6c36733e837 100644 (file)
@@ -11,7 +11,6 @@ module neutron-l2gateways{
     prefix neutron-l2gateways;
 
     import ietf-yang-types { prefix "yang"; }
-    import ietf-inet-types { prefix "inet"; revision-date 2010-09-24; }
     import neutron-attrs { prefix "attrs"; }
 
     organization "OpenDaylight Neutron Group";
@@ -26,38 +25,43 @@ module neutron-l2gateways{
     }
 
     grouping l2gateway-connection-attributes {
-                leaf l2gateway-id {
-                    type yang:uuid;
-                }
-                leaf network-id {
-                    type yang:uuid;
-                }
-                leaf segment-id {
-                    type int32;
-                }
-                leaf port-id {
-                    type yang:uuid;
-                }
-     }
+        leaf l2gateway-id {
+            type yang:uuid;
+        }
+        leaf network-id {
+            type yang:uuid;
+        }
+        leaf segment-id {
+            type int32;
+        }
+        leaf port-id {
+            type yang:uuid;
+        }
+    }
 
     grouping l2gateway-attributes {
-        leaf l2gateway-name{
+        leaf l2gateway-name {
             type string;
         }
         list devices {
             description "Description of devices.";
-            leaf device-name{
+            key "uuid";
+            leaf uuid {
+                type yang:uuid;
+            }
+            leaf device-name {
                 type string;
             }
             list interfaces {
-               description "Description of interfaces";
-               leaf interface-name {
-                   type string;
-               }
-               leaf-list segmentation-ids {
-                description "Description of segmentations";
-                   type int32;
-               }
+                description "Description of interfaces";
+                key interface-name;
+                leaf interface-name {
+                    type string;
+                }
+                leaf-list segmentation-ids {
+                    description "Description of segmentations";
+                    type int32;
+                }
             }
         }
      }
index badd4f614957f48e8ad3a8492723fbff7b2bc760..96812db9f1116728f0002fec69351e987b982b97 100644 (file)
@@ -13,7 +13,7 @@ import java.util.List;
 
 import javax.xml.bind.annotation.XmlElement;
 
-public class NeutronL2gatewayDevice implements Serializable {
+public class NeutronL2gatewayDevice extends Neutron_ID implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
@@ -41,7 +41,9 @@ public class NeutronL2gatewayDevice implements Serializable {
     }
     @Override
     public String toString() {
-        return "NeutronL2gatewayDevice [neutronL2gwDeviceInterfaces="
+        return "NeutronL2gatewayDevice ["
+                + "id=" + uuid
+                + ", neutronL2gwDeviceInterfaces="
                 + neutronL2gatewayDeviceInterfaces + ", deviceName=" + deviceName
                 + "]";
     }
index 3012b724376bf1d9248509cb908da73e85c77d17..eeb93c1e09fc7429d87563f3d35172584644c32a 100644 (file)
@@ -86,6 +86,9 @@ public class NeutronL2gatewayInterface extends
                 if (device.getDeviceName() != null){
                     neutronL2gatewayDevice.setDeviceName(device.getDeviceName().toString());
                 }
+                if (device.getUuid() != null) {
+                    neutronL2gatewayDevice.setID(device.getUuid().getValue());
+                }
                 if(device.getInterfaces() != null){
                     for(final Interfaces deviceInterface:device.getInterfaces()){
                         final NeutronL2gatewayDeviceInterface neutronL2gatewayDeviceInterface =
@@ -147,6 +150,7 @@ public class NeutronL2gatewayInterface extends
                     interfaces.add(interfacesBuilder.build());
                 }
                 deviceBuilder.setDeviceName(neutronL2gatewayDevice.getDeviceName());
+                deviceBuilder.setUuid(toUuid(neutronL2gatewayDevice.getID()));
                 deviceBuilder.setInterfaces(interfaces);
                 devices.add(deviceBuilder.build());
             }