yang model revise: neutron-metering.yang 38/35838/8
authorIsaku Yamahata <isaku.yamahata@intel.com>
Fri, 4 Mar 2016 06:34:01 +0000 (22:34 -0800)
committerIsaku Yamahata <isaku.yamahata@intel.com>
Fri, 10 Jun 2016 09:14:03 +0000 (02:14 -0700)
This patch revises yang model for metering and related codes.
- drop description for consistency, which isn't very useful
- rename id to uuid for consistency
- add missing attributes. shared, tenant-id
- eliminates the deprecated methods in neutron-spi

Change-Id: I1c91fc2bb2712c3301b9690b714a21ff0bf5cef4
Signed-off-by: Isaku Yamahata <isaku.yamahata@intel.com>
Signed-off-by: Ritu Sood <ritu.sood@intel.com>
model/src/main/yang/neutron-metering.yang
neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronMeteringLabel.java
neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronMeteringLabelRule.java
neutron-spi/src/test/java/org/opendaylight/neutron/spi/NeutronMeteringLabelJAXBTest.java
northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronMeteringLabelsNorthbound.java
transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronMeteringLabelInterface.java
transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronMeteringLabelRuleInterface.java

index bed8e14ff37dfd8517b9b6ad85e892b2afd3202a..cd2af9d8000fb41317a843635e019fb21ca6d485 100644 (file)
@@ -32,18 +32,23 @@ module neutron-metering {
 
     grouping metering-label-attributes {
         description "OpenStack Layer3 Metering label information.";
-        leaf description {
-            type string;
-            description "Description for the metering label.";
+        leaf shared {
+            type boolean;
+            description "Indicates whether this metering label is shared across all tenants.";
+            default "false";
         }
     }
 
     grouping metering-rule-attributes {
         description "OpenStack Layer3 Metering label rules.";
-        leaf id {
+        leaf uuid {
             type yang:uuid;
             description "Metering Rule ID.";
         }
+        leaf tenant-id {
+            type yang:uuid;
+            description "The UUID of the tenant that will own the object.";
+        }
         leaf direction {
             type identityref {
                 base "constants:direction-base";
@@ -60,7 +65,7 @@ module neutron-metering {
         }
         leaf excluded {
             type boolean;
-            description "Specify whether the remote_ip_prefix 
+            description "Specify whether the remote_ip_prefix
                 will be excluded or not from traffic counters of
                 the metering label, ie: to not count the traffic
                 of a specific IP address of a range.";
@@ -84,7 +89,7 @@ module neutron-metering {
         container metering-rules {
             description " Container for metering rules.";
             list metering-rule {
-                key "id";
+                key "uuid";
                 uses metering-rule-attributes;
                 description "List of Metering Rules.";
             }
index 1889fba4c9a5bc28014f268aa9a8176da9fd4d20..f98e949f5348115e134f9c7e09a950c6dfa0ee35 100644 (file)
@@ -26,23 +26,13 @@ public class NeutronMeteringLabel extends NeutronObject implements Serializable,
     @XmlElement (name = "name")
     String meteringLabelName;
 
-    @XmlElement (name = "description")
-    String description;
+    @XmlElement (defaultValue = "false", name = "shared")
+    Boolean shared;
 
     /*
      * getters and setters
      */
 
-    // @deprecated use getID()
-    public String getMeteringLabelUUID() {
-        return getID();
-    }
-
-    // @deprecated use setID()
-    public void setMeteringLabelUUID(String uuid) {
-        setID(uuid);
-    }
-
     public String getMeteringLabelName() {
         return meteringLabelName;
     }
@@ -51,22 +41,12 @@ public class NeutronMeteringLabel extends NeutronObject implements Serializable,
         this.meteringLabelName = name;
     }
 
-    @Deprecated
-    public String getMeteringLabelTenantID() {
-        return getTenantID();
-    }
-
-    @Deprecated
-    public void setMeteringLabelTenantID(String tenantID) {
-        setTenantID(tenantID);
-    }
-
-    public String getMeteringLabelDescription() {
-        return description;
+    public Boolean getMeteringLabelShared() {
+        return shared;
     }
 
-    public void setMeteringLabelDescription(String description) {
-        this.description = description;
+    public void setMeteringLabelShared(Boolean shared) {
+        this.shared = shared;
     }
 
     /*
@@ -78,8 +58,9 @@ public class NeutronMeteringLabel extends NeutronObject implements Serializable,
     public String toString() {
         return "NeutronMeteringLabel [id=" + uuid +
             ", name=" + meteringLabelName +
-            ", description=" + description +
-            ", tenant_id=" + tenantID + "]";
+            ", tenant_id=" + tenantID +
+            ", shared=" + shared +
+            "]";
     }
 
     /**
@@ -105,8 +86,8 @@ public class NeutronMeteringLabel extends NeutronObject implements Serializable,
             if (s.equals("tenant_id")) {
                 ans.setTenantID(this.getTenantID());
             }
-            if (s.equals("description")) {
-                ans.setMeteringLabelDescription(this.getMeteringLabelDescription());
+            if (s.equals("shared")) {
+                ans.setMeteringLabelShared(this.getMeteringLabelShared());
             }
         }
         return ans;
index b68693397a23412f64fa14cc0010a6a16d37b7ec..e7a491002d2f0be5c26e9bfe16620b3c31e05125 100644 (file)
@@ -39,16 +39,6 @@ public class NeutronMeteringLabelRule extends NeutronObject implements Serializa
      *  getters and setters
      */
 
-    // @deprecated use getID()
-    public String getMeteringLabelRuleUUID() {
-        return getID();
-    }
-
-    // @deprecated use setID()
-    public void setMeteringLabelRuleUUID(String uuid) {
-        setID(uuid);
-    }
-
     public String getMeteringLabelRuleDirection() {
         return meteringLabelRuleDirection;
     }
@@ -89,6 +79,7 @@ public class NeutronMeteringLabelRule extends NeutronObject implements Serializa
     @Override
     public String toString() {
         return "NeutronMeteringLabelRule [id=" + uuid +
+            ", tenantID=" + tenantID +
             ", direction=" + meteringLabelRuleDirection +
             ", excluded=" + meteringLabelRuleExcluded +
             ", remote_ip_prefix=" + meteringLabelRuleRemoteIPPrefix +
@@ -112,6 +103,9 @@ public class NeutronMeteringLabelRule extends NeutronObject implements Serializa
             if (s.equals("id")) {
                 ans.setID(this.getID());
             }
+            if (s.equals("tenant_id")) {
+                ans.setTenantID(this.getTenantID());
+            }
             if (s.equals("direction")) {
                 ans.setMeteringLabelRuleDirection(this.getMeteringLabelRuleDirection());
             }
index e21417cd2541e9a9dedbfadacc45a6463e6f8b12..718cee466826ed6b3df11be68187b6e64b80a9f8 100644 (file)
@@ -33,9 +33,6 @@ public class NeutronMeteringLabelJAXBTest {
             Assert.assertEquals("NeutronMeteringLabel JAXB Test 2: Testing name failed", "net1",
                     testObject.getMeteringLabelName());
 
-            Assert.assertEquals("NeutronMeteringLabel JAXB Test 3: Testing description failed",
-                    "Provides allowed address pairs", testObject.getMeteringLabelDescription());
-
             Assert.assertEquals("NeutronMeteringLabel JAXB Test 4: Testing tenant_id failed",
                     "9bacb3c5d39d41a79512987f338cf177", testObject.getTenantID());
         } catch (Exception e) {
index 99ca09dcc77fa32171bf017de6c8d572edfe63a7..7d78fe54c911d6dbf3ef82f59474654152ae4f9a 100644 (file)
@@ -141,8 +141,7 @@ public class NeutronMeteringLabelsNorthbound
             // filter fields
             @QueryParam("id") String queryID,
             @QueryParam("name") String queryName,
-            @QueryParam("tenant_id") String queryTenantID,
-            @QueryParam("description") String queryDescription
+            @QueryParam("tenant_id") String queryTenantID
             // pagination and sorting are TODO
             ) {
         INeutronMeteringLabelCRUD labelInterface = getNeutronCRUD();
@@ -153,7 +152,6 @@ public class NeutronMeteringLabelsNorthbound
             NeutronMeteringLabel oSS = i.next();
             if ((queryID == null || queryID.equals(oSS.getID())) &&
                     (queryName == null || queryName.equals(oSS.getMeteringLabelName())) &&
-                    (queryDescription == null || queryDescription.equals(oSS.getMeteringLabelDescription())) &&
                     (queryTenantID == null || queryTenantID.equals(oSS.getTenantID()))) {
                 if (fields.size() > 0) {
                     ans.add(extractFields(oSS,fields));
index be33a1f24ad23ba041e5ad929e66fd588b44c85c..ee621eb9dc245adc020e27d73ee91433a028b69b 100644 (file)
@@ -89,16 +89,16 @@ public class NeutronMeteringLabelInterface extends AbstractNeutronInterface<Mete
     @Override
     protected MeteringLabel toMd(NeutronMeteringLabel meteringLabel) {
         final MeteringLabelBuilder meteringLabelBuilder = new MeteringLabelBuilder();
-        if (meteringLabel.getMeteringLabelName()!=null) {
+        if (meteringLabel.getMeteringLabelName() != null) {
             meteringLabelBuilder.setName(meteringLabel.getMeteringLabelName());
         }
-        if (meteringLabel.getMeteringLabelDescription()!=null) {
-            meteringLabelBuilder.setDescription(meteringLabel.getMeteringLabelDescription());
+        if (meteringLabel.getMeteringLabelShared() != null) {
+            meteringLabelBuilder.setShared(meteringLabel.getMeteringLabelShared());
         }
-        if (meteringLabel.getTenantID()!=null) {
+        if (meteringLabel.getTenantID() != null) {
             meteringLabelBuilder.setTenantId(toUuid(meteringLabel.getTenantID()));
         }
-        if (meteringLabel.getID()!=null) {
+        if (meteringLabel.getID() != null) {
             meteringLabelBuilder.setUuid(toUuid(meteringLabel.getID()));
         }
         return meteringLabelBuilder.build();
@@ -109,10 +109,9 @@ public class NeutronMeteringLabelInterface extends AbstractNeutronInterface<Mete
         if (label.getName() != null) {
             answer.setMeteringLabelName(label.getName());
         }
-        if (label.getDescription() != null) {
-            answer.setMeteringLabelDescription(label.getName());
+        if (label.isShared() != null) {
+            answer.setMeteringLabelShared(label.isShared());
         }
-//todo: remove '-' chars as tenant id doesn't use them
         if (label.getTenantId() != null) {
             answer.setTenantID(label.getTenantId());
         }
index c2be1d8532f659fb5ab1dee278f49a8c4aa78345..471b9d052dbc5c4fea6d986e7cc5834abd549026 100644 (file)
@@ -103,7 +103,10 @@ public class NeutronMeteringLabelRuleInterface extends AbstractNeutronInterface<
     protected MeteringRule toMd(NeutronMeteringLabelRule meteringLabelRule) {
         final MeteringRuleBuilder meteringRuleBuilder = new MeteringRuleBuilder();
         if (meteringLabelRule.getID() != null) {
-            meteringRuleBuilder.setId(toUuid(meteringLabelRule.getID()));
+            meteringRuleBuilder.setUuid(toUuid(meteringLabelRule.getID()));
+        }
+        if (meteringLabelRule.getTenantID() != null) {
+            meteringRuleBuilder.setTenantId(toUuid(meteringLabelRule.getTenantID()));
         }
         if (meteringLabelRule.getMeteringLabelRuleLabelID() != null) {
             meteringRuleBuilder.setMeteringLabelId(toUuid(meteringLabelRule.getMeteringLabelRuleLabelID()));
@@ -123,8 +126,11 @@ public class NeutronMeteringLabelRuleInterface extends AbstractNeutronInterface<
 
     protected NeutronMeteringLabelRule fromMd(MeteringRule rule) {
         final NeutronMeteringLabelRule answer = new NeutronMeteringLabelRule();
-        if (rule.getId() != null) {
-            answer.setID(rule.getId().getValue());
+        if (rule.getUuid() != null) {
+            answer.setID(rule.getUuid().getValue());
+        }
+        if (rule.getTenantId() != null) {
+            answer.setTenantID(rule.getTenantId());
         }
         if (rule.getMeteringLabelId() != null) {
             answer.setMeteringLabelRuleLabelID(rule.getMeteringLabelId().getValue());
@@ -143,7 +149,7 @@ public class NeutronMeteringLabelRuleInterface extends AbstractNeutronInterface<
     @Override
     protected MeteringRule toMd(String uuid) {
         final MeteringRuleBuilder meteringRuleBuilder = new MeteringRuleBuilder();
-        meteringRuleBuilder.setId((toUuid(uuid)));
+        meteringRuleBuilder.setUuid(toUuid(uuid));
         return meteringRuleBuilder.build();
     }