BUG-50 : adjusted Metric object. 08/2508/1
authorDana Kutenicsova <dkutenic@cisco.com>
Thu, 7 Nov 2013 14:20:08 +0000 (15:20 +0100)
committerDana Kutenicsova <dkutenic@cisco.com>
Thu, 7 Nov 2013 14:20:08 +0000 (15:20 +0100)
Change-Id: I500a26e86a3f43ce7bed605200be56179b04d9ac
Signed-off-by: Dana Kutenicsova <dkutenic@cisco.com>
pcep/api/src/main/yang/pcep-types.yang
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/Activator.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPMetricObjectParser.java
pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/PCEPObjectParserTest.java

index 27d2165787731030d5ffb960d1d14e05937790cf..190d724c3134770a83ba15838caa44faf835b0fd 100644 (file)
@@ -546,26 +546,27 @@ module pcep-types {
        grouping metric-object {
                description "METRIC Object";
                reference "https://tools.ietf.org/html/rfc5440#section-7.8";
-
-               uses object;
-
-               leaf metric-type {
-                       type uint8;
-                       mandatory true;
-               }
-
-               leaf bound {
-                       type boolean;
-                       default false;
-               }
-
-               leaf computed {
-                       type boolean;
-                       default false;
-               }
-
-               leaf value {
-                       type ieee754:float32;
+               container metric {
+                       uses object;
+       
+                       leaf metric-type {
+                               type uint8;
+                               mandatory true;
+                       }
+       
+                       leaf bound {
+                               type boolean;
+                               default false;
+                       }
+       
+                       leaf computed {
+                               type boolean;
+                               default false;
+                       }
+       
+                       leaf value {
+                               type ieee754:float32;
+                       }
                }
        }
 
index 468e5f9fc826ef77759b559bb30a4c6462153007..8ef973da9ec3f7a65111e5007392ed1676db3566 100644 (file)
@@ -81,7 +81,6 @@ import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
 import org.opendaylight.protocol.pcep.spi.XROSubobjectHandlerRegistry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.CloseMessage;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.KeepaliveMessage;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.MetricObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.NoPathObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OpenMessage;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcerrMessage;
@@ -108,6 +107,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.identifiers.tlv.LspIdentifiers;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.object.Lsp;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lspa.object.Lspa;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.metric.object.Metric;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.notification.object.CNotification;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.of.list.tlv.OfList;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.of.object.Of;
@@ -279,7 +279,7 @@ public final class Activator implements PCEPExtensionProviderActivator {
                context.registerObjectSerializer(NoPathObject.class, new PCEPNoPathObjectParser(tlvReg));
                context.registerObjectSerializer(EndpointsObj.class, new PCEPEndPointsObjectParser(tlvReg));
                context.registerObjectSerializer(Bandwidth.class, new PCEPBandwidthObjectParser(tlvReg));
-               context.registerObjectSerializer(MetricObject.class, new PCEPMetricObjectParser(tlvReg));
+               context.registerObjectSerializer(Metric.class, new PCEPMetricObjectParser(tlvReg));
                context.registerObjectSerializer(Ero.class, new PCEPExplicitRouteObjectParser(eroSubReg));
                context.registerObjectSerializer(ReportedRouteObject.class, new PCEPReportedRouteObjectParser(rroSubReg));
                context.registerObjectSerializer(Lspa.class, new PCEPLspaObjectParser(tlvReg));
index 5b5319e09be58ecca08287ae07e7c9a072490b2c..c8ecee85af192f0c84cf2cf6d01462db77af0b24 100644 (file)
@@ -14,17 +14,16 @@ import org.opendaylight.protocol.pcep.PCEPDocumentedException;
 import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ieee754.rev130819.Float32;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.MetricObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Tlv;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.svec.Metric;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.svec.MetricBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.metric.object.Metric;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.metric.object.MetricBuilder;
 
 import com.google.common.primitives.UnsignedBytes;
 
 /**
- * Parser for {@link MetricObject}
+ * Parser for {@link Metric}
  */
 public class PCEPMetricObjectParser extends AbstractObjectWithTlvsParser<MetricBuilder> {
 
@@ -59,8 +58,7 @@ public class PCEPMetricObjectParser extends AbstractObjectWithTlvsParser<MetricB
        }
 
        @Override
-       public MetricObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException,
-                       PCEPDocumentedException {
+       public Metric parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException, PCEPDocumentedException {
                if (bytes == null || bytes.length == 0) {
                        throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
                }
@@ -86,13 +84,13 @@ public class PCEPMetricObjectParser extends AbstractObjectWithTlvsParser<MetricB
 
        @Override
        public byte[] serializeObject(final Object object) {
-               if (!(object instanceof MetricObject)) {
+               if (!(object instanceof Metric)) {
                        throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed MetricObject.");
                }
-               final MetricObject mObj = (MetricObject) object;
+               final Metric mObj = (Metric) object;
                final byte[] retBytes = new byte[SIZE];
                final BitSet flags = new BitSet(FLAGS_F_LENGTH * Byte.SIZE);
-               flags.set(C_FLAG_OFFSET, ((Metric) mObj).isComputed());
+               flags.set(C_FLAG_OFFSET, mObj.isComputed());
                flags.set(B_FLAG_OFFSET, mObj.isBound());
                ByteArray.copyWhole(ByteArray.bitSetToBytes(flags, FLAGS_F_LENGTH), retBytes, FLAGS_F_OFFSET);
                retBytes[TYPE_F_OFFSET] = UnsignedBytes.checkedCast(mObj.getMetricType());
index 2caeb3136165b87d7c5badc64992eb53abb04277..d82d2e2b12848d2130e07eca936cb66cfd5c1c9c 100644 (file)
@@ -78,6 +78,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.error.code.tlv.LspErrorCodeBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.object.LspBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lspa.object.LspaBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.metric.object.MetricBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.notification.object.CNotificationBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.of.object.OfBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder;
@@ -92,7 +93,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.failure.no.path.tlvs.NoPathVectorBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.SvecBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.requests.segment.computation.p2p.ReportedRouteBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.svec.MetricBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.predundancy.group.id.tlv.PredundancyGroupId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.predundancy.group.id.tlv.PredundancyGroupIdBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.req.missing.tlv.ReqMissingBuilder;