Sort out neutron object class hierarchy 38/53438/11
authorRitu Sood <ritu.sood@intel.com>
Mon, 6 Nov 2017 23:11:52 +0000 (15:11 -0800)
committerRitu Sood <ritu.sood@intel.com>
Mon, 4 Dec 2017 22:04:09 +0000 (14:04 -0800)
Consolidated uuid and tenant-id in yang models
Weather report filed for this.

Change-Id: Ib277b2da45ae3d1a273c8c783d16408d19229188
Signed-off-by: Isaku Yamahata <isaku.yamahata@intel.com>
Signed-off-by: Ritu Sood <ritu.sood@intel.com>
17 files changed:
model/src/main/yang/neutron-L3.yang
model/src/main/yang/neutron-attrs.yang
model/src/main/yang/neutron-l2gateways.yang
model/src/main/yang/neutron-lbaasv2.yang
model/src/main/yang/neutron-metering.yang
model/src/main/yang/neutron-qos.yang
model/src/main/yang/neutron-secgroups.yang
neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronL2gatewayConnection.java
transcriber/src/main/java/org/opendaylight/neutron/transcriber/AbstractTranscriberInterface.java
transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronFloatingIpInterface.java
transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronL2gatewayConnectionInterface.java
transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronL2gatewayInterface.java
transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronLoadBalancerHealthMonitorInterface.java
transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronLoadBalancerPoolInterface.java
transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronMeteringLabelRuleInterface.java
transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronQosPolicyInterface.java
transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronSecurityRuleInterface.java

index 58a116cfd7e8c578a861916f43af9bbd8b6f5409..5e2ce387cd54ebc1f5020d89f2b86b6d208492ae 100644 (file)
@@ -56,14 +56,6 @@ module neutron-L3 {
     }
 
     grouping L3-floatingip-attributes {
-        leaf uuid {
-            type yang:uuid;
-            description "UUID to index this object.";
-        }
-        leaf tenant-id {
-            type yang:uuid;
-            description "The Tenant ID of this object.";
-        }
         leaf router-id {
             description "Contains the Router ID of this floatingip object.";
             type yang:uuid;
@@ -142,6 +134,7 @@ module neutron-L3 {
                     attached to an internal network.";
 
                 key "uuid";
+                uses attrs:id-attributes;
                 uses L3-floatingip-attributes;
             }
         }
index a2d2bf669a631dab26309b38cd93dd3a2b706f7d..4ca1d6de1479dd46a97f49ac91a95106f275ebe8 100644 (file)
@@ -27,18 +27,11 @@ module neutron-attrs {
                 "OpenDaylight Beryllium release";
     }
 
-    grouping base-attributes {
-
+    grouping id-attributes {
         leaf uuid {
             type yang:uuid;
             description "UUID to index this neutron object.";
         }
-
-        leaf name {
-            type string;
-            description "Human-readable name for the item. Might not be unique.";
-        }
-
         leaf tenant-id {
             status deprecated;
             type yang:uuid;
@@ -60,6 +53,14 @@ module neutron-attrs {
         }
     }
 
+    grouping base-attributes {
+        uses id-attributes;
+        leaf name {
+            type string;
+            description "Human-readable name for the item. Might not be unique.";
+        }
+    }
+
     grouping admin-attributes {
         leaf admin-state-up {
             type boolean;
index 074d389bfff70ba371d559b6ccd5e6c36733e837..98dc2909f2f4d101f384141c0853612100039487 100644 (file)
@@ -40,9 +40,6 @@ module neutron-l2gateways{
     }
 
     grouping l2gateway-attributes {
-        leaf l2gateway-name {
-            type string;
-        }
         list devices {
             description "Description of devices.";
             key "uuid";
index dca83f87014ef82a9e1f8702e2f287c338c2828f..fa5764d2cee856bc11b7544f5a8b13e5c82c818f 100644 (file)
@@ -117,15 +117,6 @@ module neutron-lbaasv2 {
         }
     }
     grouping member-attributes {
-        leaf uuid {
-            type yang:uuid;
-            description "The unique ID for the member.";
-        }
-        leaf tenant-id {
-            type yang:uuid;
-            description "Owner of the member. Only an administrative user can specify
-                a tenant ID other than its own.";
-        }
         leaf subnet-id {
             type yang:uuid;
             description "Subnet in which to access this member.";
@@ -155,15 +146,6 @@ module neutron-lbaasv2 {
         }
     }
     grouping healthmonitor-attributes {
-        leaf uuid {
-            type yang:uuid;
-            description "The unique ID for the healthmonitor.";
-        }
-        leaf tenant-id {
-            type yang:uuid;
-            description "Owner of the VIP. Only an administrative user can specify
-                a tenant ID other than its own.";
-        }
         leaf type {
             description "The type of probe, which is PING, TCP, HTTP, or HTTPS, that
                 is sent by the load balancer to verify the member state.";
@@ -246,6 +228,7 @@ module neutron-lbaasv2 {
                     description "Container for pool members.";
                     list member {
                         key "uuid";
+                        uses attrs:id-attributes;
                         uses member-attributes;
                         description "List of members.";
                     }
@@ -256,6 +239,7 @@ module neutron-lbaasv2 {
             description "Container for LBaaSV2.0 healthmonitors.";
             list healthmonitor {
                 key "uuid";
+                uses attrs:id-attributes;
                 uses healthmonitor-attributes;
                 description "List of healthmonitors.";
             }
index 767f8f4e36ccab0dc48745f8389931572d790dbf..aa72814fec5f6e69f8263f2f19ba66a15597f7a0 100644 (file)
@@ -40,14 +40,6 @@ module neutron-metering {
 
     grouping metering-rule-attributes {
         description "OpenStack Layer3 Metering label rules.";
-        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";
@@ -89,6 +81,7 @@ module neutron-metering {
             description " Container for metering rules.";
             list metering-rule {
                 key "uuid";
+                uses attrs:id-attributes;
                 uses metering-rule-attributes;
                 description "List of Metering Rules.";
             }
index d84204dfa68e5d36d840bbefb57fcd5cf990197b..746619e816954ad60b7e47260d58117a5210f327 100644 (file)
@@ -43,14 +43,6 @@ module neutron-qos {
     }
 
     grouping bandwidthlimit-rule-attributes {
-        leaf uuid {
-            type yang:uuid;
-            description "The rule id of the associated rule";
-        }
-        leaf tenant-id {
-            type yang:uuid;
-            description "The tenant id of OpenStack Tenant";
-        }
         leaf max-kbps {
             type uint64;
             description "The maximum KBPS value";
@@ -62,14 +54,6 @@ module neutron-qos {
     }
 
     grouping dscpmarking-rule-attributes {
-        leaf uuid {
-            type yang:uuid;
-            description "The rule id of the associated rule";
-        }
-        leaf tenant-id {
-            type yang:uuid;
-            description "The tenant id of OpenStack Tenant";
-        }
         leaf dscp-mark {
             type uint8 {
                 range "0 | 8 | 10 | 12 | 14 | 16 | 18 | 20 | 22 | 24 | 26 | 28 | 30 | 32 | 34 | 36
@@ -87,10 +71,12 @@ module neutron-qos {
                 uses qos-policy-attributes;
                 list bandwidth-limit-rules {
                     key "uuid";
+                    uses attrs:id-attributes;
                     uses bandwidthlimit-rule-attributes;
                 }
                 list dscpmarking-rules {
                     key "uuid";
+                    uses attrs:id-attributes;
                     uses dscpmarking-rule-attributes;
                 }
             }
index 3ea9aa1b957e6827f958714a1ca73a571f9deecc..609b6fc53cee9afc90c2ecf022e5ac3b226e4b62 100644 (file)
@@ -34,14 +34,6 @@ module neutron-secgroups {
     }
     grouping security-rule-attributes {
         description "OpenStack Layer3 Security Group rules.";
-        leaf uuid {
-            type yang:uuid;
-            description "Security Rule ID.";
-        }
-        leaf tenant-id {
-            type yang:uuid;
-            description "UUID of the tenant.";
-        }
         leaf direction {
             type identityref {
                 base "constants:direction-base";
@@ -114,6 +106,7 @@ module neutron-secgroups {
             description "Container for security group rules.";
             list security-rule {
                 key "uuid";
+                uses attrs:id-attributes;
                 uses security-rule-attributes;
                 description "List of Security Group Rules.";
             }
index b6c300cac76a3deda116d20a287635c81cdfa327..d8b2b87af08f390a8e4643b78a2fe0361a5e544d 100644 (file)
@@ -16,8 +16,8 @@ import javax.xml.bind.annotation.XmlRootElement;
 
 @XmlRootElement(name = "l2gatewayConnection")
 @XmlAccessorType(XmlAccessType.NONE)
-public final class NeutronL2gatewayConnection extends NeutronObject<NeutronL2gatewayConnection>
-        implements Serializable, INeutronObject<NeutronL2gatewayConnection> {
+public final class NeutronL2gatewayConnection extends NeutronBaseAttributes<NeutronL2gatewayConnection>
+            implements Serializable {
     private static final long serialVersionUID = 1L;
 
     @XmlElement(name = "gateway_id")
index 5060996cfff3b2068b565885cd75ae8c3e759886..0281306bad375d5470475076b5e105d831f5efd6 100644 (file)
@@ -36,6 +36,7 @@ import org.opendaylight.neutron.spi.INeutronObject;
 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.attrs.rev150712.AdminAttributes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.attrs.rev150712.BaseAttributes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.attrs.rev150712.IdAttributes;
 import org.opendaylight.yangtools.concepts.Builder;
 import org.opendaylight.yangtools.yang.binding.Augmentable;
 import org.opendaylight.yangtools.yang.binding.ChildOf;
@@ -145,14 +146,12 @@ public abstract class AbstractTranscriberInterface<
         try {
             setUuid = builderClass.getDeclaredMethod("setUuid", Uuid.class);
             setTenantId = builderClass.getDeclaredMethod("setTenantId", Uuid.class);
+            setProjectId = builderClass.getDeclaredMethod("setProjectId", String.class);
+            setRevisionNumber = builderClass.getDeclaredMethod("setRevisionNumber", Long.class);
             if (INeutronBaseAttributes.class.isAssignableFrom(neutronObjectClass)) {
                 setName = builderClass.getDeclaredMethod("setName", String.class);
-                setProjectId = builderClass.getDeclaredMethod("setProjectId", String.class);
-                setRevisionNumber = builderClass.getDeclaredMethod("setRevisionNumber", Long.class);
             } else {
                 setName = null;
-                setProjectId = null;
-                setRevisionNumber = null;
             }
 
             if (INeutronAdminAttributes.class.isAssignableFrom(neutronObjectClass)) {
@@ -180,7 +179,36 @@ public abstract class AbstractTranscriberInterface<
         return InstanceIdentifier.create(mdParentClass).child(mdContainerClass);
     }
 
-    protected <S1 extends INeutronBaseAttributes<S1>, M extends BaseAttributes, B extends Builder<M>>
+    protected <S1 extends INeutronObject<S1>, M extends IdAttributes, B extends Builder<M>>
+        B toMdIds(INeutronObject<S1> neutronObject, Class<B> builderClass) {
+        B builder;
+        try {
+            builder = builderClass.newInstance();
+
+            if (neutronObject.getID() != null) {
+                final Method setUuid = builderClass.getMethod("setUuid", Uuid.class);
+                setUuid.invoke(builder, toUuid(neutronObject.getID()));
+            }
+            if (neutronObject.getTenantID() != null && !neutronObject.getTenantID().isEmpty()) {
+                final Method setTenantId = builderClass.getMethod("setTenantId", Uuid.class);
+                setTenantId.invoke(builder, toUuid(neutronObject.getTenantID()));
+            }
+            if (neutronObject.getProjectID() != null) {
+                final Method setProjectId = builderClass.getMethod("setProjectId", String.class);
+                setProjectId.invoke(builder, neutronObject.getTenantID());
+            }
+            if (neutronObject.getRevisionNumber() != null) {
+                final Method setRevisionNumber = builderClass.getMethod("setRevisionNumber", Long.class);
+                setRevisionNumber.invoke(builder, neutronObject.getRevisionNumber());
+            }
+        } catch (IllegalAccessException | InstantiationException | InvocationTargetException
+                | NoSuchMethodException e) {
+            throw new IllegalArgumentException(e);
+        }
+        return builder;
+    }
+
+    protected <S1 extends INeutronObject<S1>, M extends IdAttributes, B extends Builder<M>>
         void toMdIds(INeutronObject<S1> neutronObject, B builder) {
         try {
             if (neutronObject.getID() != null) {
@@ -194,21 +222,27 @@ public abstract class AbstractTranscriberInterface<
             if (neutronObject.getProjectID() != null) {
                 setProjectId.invoke(builder, neutronObject.getTenantID());
             }
+            if (neutronObject.getRevisionNumber() != null) {
+                setRevisionNumber.invoke(builder, neutronObject.getRevisionNumber());
+            }
         } catch (IllegalAccessException | InvocationTargetException e) {
             throw new IllegalArgumentException(e);
         }
     }
 
-    protected <S1 extends INeutronBaseAttributes<S1>>
-        void fromMdIds(BaseAttributes baseAttributes, INeutronObject<S1> answer) {
-        if (baseAttributes.getUuid() != null) {
-            answer.setID(baseAttributes.getUuid().getValue());
+    protected <S1 extends INeutronObject<S1>>
+        void fromMdIds(IdAttributes idAttributes, INeutronObject<S1> answer) {
+        if (idAttributes.getUuid() != null) {
+            answer.setID(idAttributes.getUuid().getValue());
         }
-        if (baseAttributes.getTenantId() != null) {
-            answer.setTenantID(baseAttributes.getTenantId());
+        if (idAttributes.getTenantId() != null) {
+            answer.setTenantID(idAttributes.getTenantId());
         }
-        if (baseAttributes.getProjectId() != null) {
-            answer.setProjectID(baseAttributes.getProjectId());
+        if (idAttributes.getProjectId() != null) {
+            answer.setProjectID(idAttributes.getProjectId());
+        }
+        if (idAttributes.getRevisionNumber() != null) {
+            answer.setRevisionNumber(idAttributes.getRevisionNumber());
         }
     }
 
@@ -219,9 +253,6 @@ public abstract class AbstractTranscriberInterface<
             if (neutronObject.getName() != null) {
                 setName.invoke(builder, neutronObject.getName());
             }
-            if (neutronObject.getRevisionNumber() != null) {
-                setRevisionNumber.invoke(builder, neutronObject.getRevisionNumber());
-            }
         } catch (IllegalAccessException | InvocationTargetException e) {
             throw new IllegalArgumentException(e);
         }
@@ -233,9 +264,6 @@ public abstract class AbstractTranscriberInterface<
         if (baseAttributes.getName() != null) {
             answer.setName(baseAttributes.getName());
         }
-        if (baseAttributes.getRevisionNumber() != null) {
-            answer.setRevisionNumber(baseAttributes.getRevisionNumber());
-        }
     }
 
     protected <S1 extends INeutronAdminAttributes<S1>, M extends BaseAttributes & AdminAttributes, B extends Builder<M>>
index f96952933da510ed138d0a42cda09ee2c1671d2a..ad1b36639890950ccefb1d1b72e7af951f348cdc 100644 (file)
@@ -39,6 +39,7 @@ public final class NeutronFloatingIpInterface
     @Override
     protected Floatingip toMd(NeutronFloatingIp floatingIp) {
         final FloatingipBuilder floatingipBuilder = new FloatingipBuilder();
+        toMdIds(floatingIp, floatingipBuilder);
         if (floatingIp.getFixedIpAddress() != null) {
             floatingipBuilder.setFixedIpAddress(new IpAddress(floatingIp.getFixedIpAddress().toCharArray()));
         }
@@ -57,21 +58,13 @@ public final class NeutronFloatingIpInterface
         if (floatingIp.getStatus() != null) {
             floatingipBuilder.setStatus(floatingIp.getStatus());
         }
-        if (floatingIp.getTenantID() != null) {
-            floatingipBuilder.setTenantId(toUuid(floatingIp.getTenantID()));
-        }
-        if (floatingIp.getID() != null) {
-            floatingipBuilder.setUuid(toUuid(floatingIp.getID()));
-        } else {
-            LOG.warn("Attempting to write neutron floating IP without UUID");
-        }
         return floatingipBuilder.build();
     }
 
     @Override
     protected NeutronFloatingIp fromMd(Floatingip fip) {
         final NeutronFloatingIp result = new NeutronFloatingIp();
-        result.setID(fip.getUuid().getValue());
+        fromMdIds(fip, result);
         if (fip.getFloatingNetworkId() != null) {
             result.setFloatingNetworkUUID(String.valueOf(fip.getFloatingNetworkId().getValue()));
         }
@@ -84,9 +77,6 @@ public final class NeutronFloatingIpInterface
         if (fip.getFloatingIpAddress() != null) {
             result.setFloatingIpAddress(String.valueOf(fip.getFloatingIpAddress().getValue()));
         }
-        if (fip.getTenantId() != null) {
-            result.setTenantID(fip.getTenantId());
-        }
         if (fip.getRouterId() != null) {
             result.setRouterUUID(String.valueOf(fip.getRouterId().getValue()));
         }
index efade47eff063587c33d5de0e5ee732124af976e..67eafbd237dd83339c36614f2afc85cb5b87e107 100644 (file)
@@ -34,15 +34,11 @@ public final class NeutronL2gatewayConnectionInterface
     @Override
     protected NeutronL2gatewayConnection fromMd(L2gatewayConnection l2gatewayConnection) {
         final NeutronL2gatewayConnection result = new NeutronL2gatewayConnection();
-        if (l2gatewayConnection.getUuid() != null) {
-            result.setID(l2gatewayConnection.getUuid().getValue());
-        }
+        fromMdBaseAttributes(l2gatewayConnection, result);
+
         if (l2gatewayConnection.getL2gatewayId().getValue() != null) {
             result.setL2gatewayID(String.valueOf(l2gatewayConnection.getL2gatewayId().getValue()));
         }
-        if (l2gatewayConnection.getTenantId() != null) {
-            result.setTenantID(l2gatewayConnection.getTenantId());
-        }
         if (l2gatewayConnection.getNetworkId().getValue() != null) {
             result.setNetworkID(String.valueOf(l2gatewayConnection.getNetworkId().getValue()));
         }
@@ -58,9 +54,8 @@ public final class NeutronL2gatewayConnectionInterface
     @Override
     protected L2gatewayConnection toMd(NeutronL2gatewayConnection neutronObject) {
         final L2gatewayConnectionBuilder l2gatewayConnectionBuilder = new L2gatewayConnectionBuilder();
-        if (neutronObject.getID() != null) {
-            l2gatewayConnectionBuilder.setUuid(toUuid(neutronObject.getID()));
-        }
+        toMdBaseAttributes(neutronObject, l2gatewayConnectionBuilder);
+
         if (neutronObject.getL2gatewayID() != null) {
             l2gatewayConnectionBuilder.setL2gatewayId(toUuid(neutronObject.getL2gatewayID()));
         }
@@ -70,9 +65,6 @@ public final class NeutronL2gatewayConnectionInterface
         if (neutronObject.getSegmentID() != null) {
             l2gatewayConnectionBuilder.setSegmentId((neutronObject.getSegmentID()));
         }
-        if (neutronObject.getTenantID() != null) {
-            l2gatewayConnectionBuilder.setTenantId(toUuid(neutronObject.getTenantID()));
-        }
         if (neutronObject.getPortID() != null) {
             l2gatewayConnectionBuilder.setPortId(toUuid(neutronObject.getPortID()));
         }
index cc97ab41d46739d0c094dde2edfc8cc83e03552f..bed0b6dea63484d04d24e718259f5d385007cf93 100644 (file)
@@ -39,17 +39,9 @@ public final class NeutronL2gatewayInterface
     @Override
     protected NeutronL2gateway fromMd(L2gateway l2gateway) {
         final NeutronL2gateway result = new NeutronL2gateway();
+        fromMdBaseAttributes(l2gateway, result);
         final List<NeutronL2gatewayDevice> neutronL2gatewayDevices = new ArrayList<>();
 
-        if (l2gateway.getUuid() != null) {
-            result.setID(l2gateway.getUuid().getValue());
-        }
-        if (l2gateway.getL2gatewayName() != null) {
-            result.setName(String.valueOf(l2gateway.getL2gatewayName()));
-        }
-        if (l2gateway.getTenantId() != null) {
-            result.setTenantID(l2gateway.getTenantId());
-        }
         if (l2gateway.getDevices() != null) {
             for (final Devices device : l2gateway.getDevices()) {
                 final NeutronL2gatewayDevice neutronL2gatewayDevice = new NeutronL2gatewayDevice();
@@ -90,15 +82,7 @@ public final class NeutronL2gatewayInterface
     @Override
     protected L2gateway toMd(NeutronL2gateway neutronObject) {
         final L2gatewayBuilder l2gatewayBuilder = new L2gatewayBuilder();
-        if (neutronObject.getName() != null) {
-            l2gatewayBuilder.setL2gatewayName(neutronObject.getName());
-        }
-        if (neutronObject.getID() != null) {
-            l2gatewayBuilder.setUuid(toUuid(neutronObject.getID()));
-        }
-        if (neutronObject.getTenantID() != null) {
-            l2gatewayBuilder.setTenantId(toUuid(neutronObject.getTenantID()));
-        }
+        toMdBaseAttributes(neutronObject, l2gatewayBuilder);
 
         if (neutronObject.getNeutronL2gatewayDevices() != null) {
             final List<Devices> devices = new ArrayList<>();
index 973c8c02b383bb3175dcb5cc427a2e5a765e3d7d..959e2cce4e8462453d71ecae4d3027fc7494ac7c 100644 (file)
@@ -51,6 +51,7 @@ public final class NeutronLoadBalancerHealthMonitorInterface
     @Override
     protected Healthmonitor toMd(NeutronLoadBalancerHealthMonitor healthMonitor) {
         final HealthmonitorBuilder healthmonitorBuilder = new HealthmonitorBuilder();
+        toMdIds(healthMonitor, healthmonitorBuilder);
         healthmonitorBuilder.setAdminStateUp(healthMonitor.getLoadBalancerHealthMonitorAdminStateIsUp());
         if (healthMonitor.getLoadBalancerHealthMonitorDelay() != null) {
             healthmonitorBuilder.setDelay(Long.valueOf(healthMonitor.getLoadBalancerHealthMonitorDelay()));
@@ -71,9 +72,6 @@ public final class NeutronLoadBalancerHealthMonitorInterface
             }
             healthmonitorBuilder.setPools(listUuid);
         }
-        if (healthMonitor.getTenantID() != null) {
-            healthmonitorBuilder.setTenantId(toUuid(healthMonitor.getTenantID()));
-        }
         if (healthMonitor.getLoadBalancerHealthMonitorTimeout() != null) {
             healthmonitorBuilder.setTimeout(Long.valueOf(healthMonitor.getLoadBalancerHealthMonitorTimeout()));
         }
@@ -85,17 +83,13 @@ public final class NeutronLoadBalancerHealthMonitorInterface
         if (healthMonitor.getLoadBalancerHealthMonitorUrlPath() != null) {
             healthmonitorBuilder.setUrlPath(healthMonitor.getLoadBalancerHealthMonitorUrlPath());
         }
-        if (healthMonitor.getID() != null) {
-            healthmonitorBuilder.setUuid(toUuid(healthMonitor.getID()));
-        } else {
-            LOG.warn("Attempting to write neutron laod balancer health monitor without UUID");
-        }
         return healthmonitorBuilder.build();
     }
 
     @Override
     protected NeutronLoadBalancerHealthMonitor fromMd(Healthmonitor healthMonitor) {
         final NeutronLoadBalancerHealthMonitor answer = new NeutronLoadBalancerHealthMonitor();
+        fromMdIds(healthMonitor, answer);
         if (healthMonitor.isAdminStateUp() != null) {
             answer.setLoadBalancerHealthMonitorAdminStateIsUp(healthMonitor.isAdminStateUp());
         }
@@ -118,9 +112,6 @@ public final class NeutronLoadBalancerHealthMonitorInterface
             }
             answer.setLoadBalancerHealthMonitorPools(list);
         }
-        if (healthMonitor.getTenantId() != null) {
-            answer.setTenantID(healthMonitor.getTenantId());
-        }
         if (healthMonitor.getTimeout() != null) {
             answer.setLoadBalancerHealthMonitorTimeout(healthMonitor.getTimeout().intValue());
         }
@@ -130,11 +121,6 @@ public final class NeutronLoadBalancerHealthMonitorInterface
         if (healthMonitor.getUrlPath() != null) {
             answer.setLoadBalancerHealthMonitorUrlPath(healthMonitor.getUrlPath());
         }
-        if (healthMonitor.getUuid() != null) {
-            answer.setID(healthMonitor.getUuid().getValue());
-        } else {
-            LOG.warn("Attempting to write neutron laod balancer health monitor without UUID");
-        }
         return answer;
     }
 }
index 1164f382da0c99b41ec442d6368b5544fad35f13..64d26bb9a315f12422c00702c850dcf98942c939 100644 (file)
@@ -69,6 +69,7 @@ public final class NeutronLoadBalancerPoolInterface
     @Override
     protected Pool toMd(NeutronLoadBalancerPool pool) {
         final PoolBuilder poolBuilder = new PoolBuilder();
+        toMdBaseAttributes(pool, poolBuilder);
         poolBuilder.setAdminStateUp(pool.getLoadBalancerPoolAdminIsStateIsUp());
         if (pool.getLoadBalancerPoolHealthMonitorID() != null) {
             poolBuilder.setHealthmonitorId(toUuid(pool.getLoadBalancerPoolHealthMonitorID()));
@@ -85,9 +86,6 @@ public final class NeutronLoadBalancerPoolInterface
         }
         // because members are another container, we don't want to copy
         // it over, so just skip it here
-        if (pool.getName() != null) {
-            poolBuilder.setName(pool.getName());
-        }
         if (pool.getLoadBalancerPoolProtocol() != null) {
             final ImmutableBiMap<String, Class<? extends ProtocolBase>> mapper = PROTOCOL_MAP.inverse();
             poolBuilder.setProtocol(mapper.get(pool.getLoadBalancerPoolProtocol()));
@@ -100,20 +98,13 @@ public final class NeutronLoadBalancerPoolInterface
             sessionPersistenceBuilder.setType(sessionPersistence.getType());
             poolBuilder.setSessionPersistence(sessionPersistenceBuilder.build());
         }
-        if (pool.getTenantID() != null) {
-            poolBuilder.setTenantId(toUuid(pool.getTenantID()));
-        }
-        if (pool.getID() != null) {
-            poolBuilder.setUuid(toUuid(pool.getID()));
-        } else {
-            LOG.warn("Attempting to write neutron load balancer pool without UUID");
-        }
         return poolBuilder.build();
     }
 
     @Override
     protected NeutronLoadBalancerPool fromMd(Pool pool) {
         final NeutronLoadBalancerPool answer = new NeutronLoadBalancerPool();
+        fromMdBaseAttributes(pool, answer);
         if (pool.isAdminStateUp() != null) {
             answer.setLoadBalancerPoolAdminStateIsUp(pool.isAdminStateUp());
         }
@@ -137,9 +128,6 @@ public final class NeutronLoadBalancerPoolInterface
             }
             answer.setLoadBalancerPoolMembers(members);
         }
-        if (pool.getName() != null) {
-            answer.setName(pool.getName());
-        }
         if (pool.getProtocol() != null) {
             answer.setLoadBalancerPoolProtocol(PROTOCOL_MAP.get(pool.getProtocol()));
         }
@@ -151,12 +139,6 @@ public final class NeutronLoadBalancerPoolInterface
 
             answer.setLoadBalancerSessionPersistence(sessionPersistence);
         }
-        if (pool.getTenantId() != null) {
-            answer.setTenantID(pool.getTenantId());
-        }
-        if (pool.getUuid() != null) {
-            answer.setID(pool.getUuid().getValue());
-        }
         return answer;
     }
 
@@ -236,8 +218,9 @@ public final class NeutronLoadBalancerPoolInterface
                 .child(Members.class);
     }
 
-    static NeutronLoadBalancerPoolMember fromMemberMd(Member member) {
+    protected NeutronLoadBalancerPoolMember fromMemberMd(Member member) {
         final NeutronLoadBalancerPoolMember answer = new NeutronLoadBalancerPoolMember();
+        fromMdIds(member, answer);
         if (member.isAdminStateUp() != null) {
             answer.setPoolMemberAdminStateIsUp(member.isAdminStateUp());
         }
@@ -247,16 +230,9 @@ public final class NeutronLoadBalancerPoolInterface
         if (member.getProtocolPort() != null) {
             answer.setPoolMemberProtoPort(member.getProtocolPort());
         }
-        if (member.getUuid() != null) {
-            answer.setID(member.getUuid().getValue());
-            answer.setPoolID(member.getUuid().getValue());
-        }
         if (member.getSubnetId() != null) {
             answer.setPoolMemberSubnetID(member.getSubnetId().getValue());
         }
-        if (member.getTenantId() != null) {
-            answer.setTenantID(member.getTenantId());
-        }
         if (member.getWeight() != null) {
             answer.setPoolMemberWeight(member.getWeight());
         }
@@ -264,7 +240,7 @@ public final class NeutronLoadBalancerPoolInterface
     }
 
     protected Member toMemberMd(NeutronLoadBalancerPoolMember member) {
-        final MemberBuilder memberBuilder = new MemberBuilder();
+        final MemberBuilder memberBuilder = toMdIds(member, MemberBuilder.class);
         memberBuilder.setAdminStateUp(member.getPoolMemberAdminStateIsUp());
         if (member.getPoolMemberAddress() != null) {
             final IpAddress ipAddress = new IpAddress(member.getPoolMemberAddress().toCharArray());
@@ -273,15 +249,9 @@ public final class NeutronLoadBalancerPoolInterface
         if (member.getPoolMemberProtoPort() != null) {
             memberBuilder.setProtocolPort(member.getPoolMemberProtoPort());
         }
-        if (member.getID() != null) {
-            memberBuilder.setUuid(toUuid(member.getID()));
-        }
         if (member.getPoolMemberSubnetID() != null) {
             memberBuilder.setSubnetId(toUuid(member.getPoolMemberSubnetID()));
         }
-        if (member.getTenantID() != null) {
-            memberBuilder.setTenantId(toUuid(member.getTenantID()));
-        }
         if (member.getPoolMemberWeight() != null) {
             memberBuilder.setWeight(member.getPoolMemberWeight());
         }
index e34404df974c15d104aa0316532e04fc26ae8e03..ccfabb53a241414666a6cab01c374407b65c7f11 100644 (file)
@@ -42,12 +42,7 @@ public final class NeutronMeteringLabelRuleInterface
     @Override
     protected MeteringRule toMd(NeutronMeteringLabelRule meteringLabelRule) {
         final MeteringRuleBuilder meteringRuleBuilder = new MeteringRuleBuilder();
-        if (meteringLabelRule.getID() != null) {
-            meteringRuleBuilder.setUuid(toUuid(meteringLabelRule.getID()));
-        }
-        if (meteringLabelRule.getTenantID() != null) {
-            meteringRuleBuilder.setTenantId(toUuid(meteringLabelRule.getTenantID()));
-        }
+        toMdIds(meteringLabelRule, meteringRuleBuilder);
         if (meteringLabelRule.getMeteringLabelRuleLabelID() != null) {
             meteringRuleBuilder.setMeteringLabelId(toUuid(meteringLabelRule.getMeteringLabelRuleLabelID()));
         }
@@ -68,12 +63,7 @@ public final class NeutronMeteringLabelRuleInterface
     @Override
     protected NeutronMeteringLabelRule fromMd(MeteringRule rule) {
         final NeutronMeteringLabelRule answer = new NeutronMeteringLabelRule();
-        if (rule.getUuid() != null) {
-            answer.setID(rule.getUuid().getValue());
-        }
-        if (rule.getTenantId() != null) {
-            answer.setTenantID(rule.getTenantId());
-        }
+        fromMdIds(rule, answer);
         if (rule.getMeteringLabelId() != null) {
             answer.setMeteringLabelRuleLabelID(rule.getMeteringLabelId().getValue());
         }
index 63bb0b1d658903108ed07eced0aead4d18574c0e..9699df0afb2c5e217fa8aad0c6b28ed814cd4bc4 100644 (file)
@@ -46,21 +46,20 @@ public final class NeutronQosPolicyInterface
         if (qosPolicy.getBandwidthLimitRules() != null) {
             final List<BandwidthLimitRules> listBandwith = new ArrayList<>();
             for (final NeutronQosBandwidthLimitRule bandwidthLimitRule : qosPolicy.getBandwidthLimitRules()) {
-                final BandwidthLimitRulesBuilder bandwidthLimitRulesBuilder = new BandwidthLimitRulesBuilder();
-                bandwidthLimitRulesBuilder.setUuid(toUuid(bandwidthLimitRule.getID()));
-                bandwidthLimitRulesBuilder.setTenantId(toUuid(bandwidthLimitRule.getTenantID()));
+                final BandwidthLimitRulesBuilder bandwidthLimitRulesBuilder =
+                        toMdIds(bandwidthLimitRule, BandwidthLimitRulesBuilder.class);
                 bandwidthLimitRulesBuilder.setMaxKbps(bandwidthLimitRule.getMaxKbps());
                 bandwidthLimitRulesBuilder.setMaxBurstKbps(bandwidthLimitRule.getMaxBurstKbps());
                 listBandwith.add(bandwidthLimitRulesBuilder.build());
             }
             qosPolicyBuilder.setBandwidthLimitRules(listBandwith);
         }
+
         if (qosPolicy.getDscpMarkingRules() != null) {
             final List<DscpmarkingRules> listDscpMarking = new ArrayList<>();
             for (final NeutronQosDscpMarkingRule dscpMarkingRule : qosPolicy.getDscpMarkingRules()) {
-                final DscpmarkingRulesBuilder dscpmarkingRulesBuilder = new DscpmarkingRulesBuilder();
-                dscpmarkingRulesBuilder.setUuid(toUuid(dscpMarkingRule.getID()));
-                dscpmarkingRulesBuilder.setTenantId(toUuid(dscpMarkingRule.getTenantID()));
+                final DscpmarkingRulesBuilder dscpmarkingRulesBuilder =
+                        toMdIds(dscpMarkingRule, DscpmarkingRulesBuilder.class);
                 dscpmarkingRulesBuilder.setDscpMark(dscpMarkingRule.getDscpMark());
                 listDscpMarking.add(dscpmarkingRulesBuilder.build());
             }
@@ -80,8 +79,6 @@ public final class NeutronQosPolicyInterface
             final List<NeutronQosBandwidthLimitRule> bandwidthLimitRules = new ArrayList<>();
             for (final BandwidthLimitRules rule : qosPolicy.getBandwidthLimitRules()) {
                 NeutronQosBandwidthLimitRule opt = new NeutronQosBandwidthLimitRule();
-                opt.setID(rule.getUuid().getValue());
-                opt.setTenantID(rule.getTenantId().getValue());
                 opt.setMaxKbps(rule.getMaxKbps());
                 opt.setMaxBurstKbps(rule.getMaxBurstKbps());
                 bandwidthLimitRules.add(opt);
@@ -92,8 +89,6 @@ public final class NeutronQosPolicyInterface
             final List<NeutronQosDscpMarkingRule> dscpMarkingRules = new ArrayList<>();
             for (final DscpmarkingRules rule : qosPolicy.getDscpmarkingRules()) {
                 NeutronQosDscpMarkingRule opt = new NeutronQosDscpMarkingRule();
-                opt.setID(rule.getUuid().getValue());
-                opt.setTenantID(rule.getTenantId().getValue());
                 opt.setDscpMark(rule.getDscpMark());
                 dscpMarkingRules.add(opt);
             }
index 9f74b8d159d41cfbfbec1a941a40097a2ef7f013..97fff3fef5cffaca71e661c5ee929dbebf8b883d 100644 (file)
@@ -54,9 +54,7 @@ public final class NeutronSecurityRuleInterface extends
     @Override
     protected NeutronSecurityRule fromMd(SecurityRule rule) {
         final NeutronSecurityRule answer = new NeutronSecurityRule();
-        if (rule.getTenantId() != null) {
-            answer.setTenantID(rule.getTenantId());
-        }
+        fromMdIds(rule, answer);
         if (rule.getDirection() != null) {
             answer.setSecurityRuleDirection(DIRECTION_MAP.get(rule.getDirection()));
         }
@@ -88,19 +86,13 @@ public final class NeutronSecurityRuleInterface extends
         if (rule.getPortRangeMax() != null) {
             answer.setSecurityRulePortMax(Integer.valueOf(rule.getPortRangeMax()));
         }
-        if (rule.getUuid() != null) {
-            answer.setID(rule.getUuid().getValue());
-        }
         return answer;
     }
 
     @Override
     protected SecurityRule toMd(NeutronSecurityRule securityRule) {
         final SecurityRuleBuilder securityRuleBuilder = new SecurityRuleBuilder();
-
-        if (securityRule.getTenantID() != null) {
-            securityRuleBuilder.setTenantId(toUuid(securityRule.getTenantID()));
-        }
+        toMdIds(securityRule, securityRuleBuilder);
         if (securityRule.getSecurityRuleDirection() != null) {
             final ImmutableBiMap<String, Class<? extends DirectionBase>> mapper = DIRECTION_MAP.inverse();
             securityRuleBuilder
@@ -137,11 +129,6 @@ public final class NeutronSecurityRuleInterface extends
         if (securityRule.getSecurityRulePortMax() != null) {
             securityRuleBuilder.setPortRangeMax(Integer.valueOf(securityRule.getSecurityRulePortMax()));
         }
-        if (securityRule.getID() != null) {
-            securityRuleBuilder.setUuid(toUuid(securityRule.getID()));
-        } else {
-            LOG.warn("Attempting to write neutron securityRule without UUID");
-        }
         return securityRuleBuilder.build();
     }
 }