Search in sources :

Example 96 with Flags

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.Xro.Flags in project openflowplugin by opendaylight.

the class MeterConvertor method convert.

@Override
public MeterModInputBuilder convert(Meter source, VersionConvertorData data) {
    MeterModInputBuilder meterModInputBuilder = new MeterModInputBuilder();
    List<Bands> bands = new ArrayList<>();
    if (source instanceof AddMeterInput) {
        meterModInputBuilder.setCommand(MeterModCommand.OFPMCADD);
    } else if (source instanceof RemoveMeterInput) {
        meterModInputBuilder.setCommand(MeterModCommand.OFPMCDELETE);
    } else if (source instanceof UpdatedMeter) {
        meterModInputBuilder.setCommand(MeterModCommand.OFPMCMODIFY);
    }
    meterModInputBuilder.setMeterId(new MeterId(source.getMeterId().getValue()));
    if (null != source.getFlags()) {
        meterModInputBuilder.setFlags(new MeterFlags(source.getFlags().isMeterBurst(), source.getFlags().isMeterKbps(), source.getFlags().isMeterPktps(), source.getFlags().isMeterStats()));
    } else {
        /*
             * As per 0F1.3.1,The rate field indicates the rate value above
             * which the corresponding band may apply to packets (see 5.7.1).
             * The rate value is in kilobit per seconds, unless the flags eld
             * includes OFPMF_PKTPS, in which case the rate is in packets per
             * seconds.
             */
        meterModInputBuilder.setFlags(new MeterFlags(false, false, true, false));
    }
    if (source.getMeterBandHeaders() != null) {
        getBandsFromSAL(source.getMeterBandHeaders(), bands);
        meterModInputBuilder.setBands(bands);
    } else {
        LOG.error("For this meter Id" + source.getMeterId().getValue() + ",no associated band data found!");
    }
    meterModInputBuilder.setVersion(data.getVersion());
    return meterModInputBuilder;
}
Also used : MeterModInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInputBuilder) Bands(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.Bands) AddMeterInput(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInput) MeterFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags) ArrayList(java.util.ArrayList) UpdatedMeter(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.meter.update.UpdatedMeter) RemoveMeterInput(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInput) MeterId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId)

Example 97 with Flags

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.Xro.Flags in project openflowplugin by opendaylight.

the class MultipartReplyMeterConfigDeserializerTest method deserializeDrop.

@Test
public void deserializeDrop() throws Exception {
    ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer();
    writeCommonAtributes(buffer);
    buffer.writeShort(OFPMBTDROP);
    buffer.writeShort(SUB_ITEM);
    buffer.writeInt(DROP_RATE);
    buffer.writeInt(DROP_BURST_SIZE);
    buffer.writeZero(PADDING_IN_METER_BAND_DROP_HEADER);
    final MultipartReplyMeterConfig reply = (MultipartReplyMeterConfig) deserializeMultipart(buffer);
    assertEquals(METER_ID, reply.getMeterConfigStats().get(0).getMeterId().getValue().intValue());
    assertEquals(FLAGS, reply.getMeterConfigStats().get(0).getFlags());
    final Drop drop = (Drop) reply.getMeterConfigStats().get(0).getMeterBandHeaders().getMeterBandHeader().get(0).getBandType();
    assertEquals(DROP_RATE, drop.getDropRate().intValue());
    assertEquals(DROP_BURST_SIZE, drop.getDropBurstSize().intValue());
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) MultipartReplyMeterConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyMeterConfig) Drop(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.Drop) Test(org.junit.Test)

Example 98 with Flags

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.Xro.Flags in project lispflowmapping by opendaylight.

the class MapRegisterSerializationTest method deserialize__Locators.

@Test
public void deserialize__Locators() throws Exception {
    MapRegister mr = MapRegisterSerializer.getInstance().deserialize(hexToByteBuffer("38 00 01 01 " + // 
    "FF BB 00 00 00 00 00 00 00 01 00 14 f1 b8 ab f0 " + // 
    "66 bb 2e ef 12 70 74 46 6f 6b 8e ca bf 1e 68 40 " + // 
    "00 00 00 0a " + // 
    "03 " + // Locator Count
    "20 10 00 00 00 00 01 99 10 fe 01 " + // Locator 1
    "01 64 1f 00 " + // priorities + weights
    "00 05 " + // Flags
    "00 01 c0 a8 88 0a " + // Locator 2
    "67 00 30 34 " + // priorities + weights
    "00 02 " + // Flags
    "00 01 cc aa AA 11 " + // Locator 3
    "60 11 34 A4 " + // priorities + weights
    "00 03 " + // Flags
    "00 01 c0 a8 88 0a "), null);
    assertEquals(1, mr.getMappingRecordItem().size());
    MappingRecordItem eidToLocator = mr.getMappingRecordItem().get(0);
    assertEquals(3, eidToLocator.getMappingRecord().getLocatorRecord().size());
    LocatorRecord loc0 = eidToLocator.getMappingRecord().getLocatorRecord().get(0);
    LocatorRecord loc1 = eidToLocator.getMappingRecord().getLocatorRecord().get(1);
    LocatorRecord loc2 = eidToLocator.getMappingRecord().getLocatorRecord().get(2);
    assertEquals((byte) 0x01, loc0.getPriority().byteValue());
    assertEquals((byte) 0x67, loc1.getPriority().byteValue());
    assertEquals((byte) 0x60, loc2.getPriority().byteValue());
    assertEquals((byte) 0x64, loc0.getWeight().byteValue());
    assertEquals((byte) 0x00, loc1.getWeight().byteValue());
    assertEquals((byte) 0x11, loc2.getWeight().byteValue());
    assertEquals((byte) 0x1F, loc0.getMulticastPriority().byteValue());
    assertEquals((byte) 0x30, loc1.getMulticastPriority().byteValue());
    assertEquals((byte) 0x34, loc2.getMulticastPriority().byteValue());
    assertEquals((byte) 0x00, loc0.getMulticastWeight().byteValue());
    assertEquals((byte) 0x34, loc1.getMulticastWeight().byteValue());
    assertEquals((byte) 0xA4, loc2.getMulticastWeight().byteValue());
    assertTrue(loc0.isLocalLocator());
    assertFalse(loc1.isLocalLocator());
    assertFalse(loc2.isLocalLocator());
    assertFalse(loc0.isRlocProbed());
    assertTrue(loc1.isRlocProbed());
    assertTrue(loc2.isRlocProbed());
    assertTrue(loc0.isRouted());
    assertFalse(loc1.isRouted());
    assertTrue(loc2.isRouted());
    assertEquals(LispAddressUtil.asIpv4Rloc("192.168.136.10"), loc0.getRloc());
    assertEquals(LispAddressUtil.asIpv4Rloc("204.170.170.17"), loc1.getRloc());
}
Also used : MappingRecordItem(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem) MapRegister(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRegister) LocatorRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord) Test(org.junit.Test)

Example 99 with Flags

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.Xro.Flags in project lispflowmapping by opendaylight.

the class LocatorRecordSerializer method deserialize.

protected LocatorRecord deserialize(ByteBuffer buffer) {
    LocatorRecordBuilder builder = new LocatorRecordBuilder();
    builder.setPriority((short) ByteUtil.getUnsignedByte(buffer));
    builder.setWeight((short) ByteUtil.getUnsignedByte(buffer));
    builder.setMulticastPriority((short) ByteUtil.getUnsignedByte(buffer));
    builder.setMulticastWeight((short) ByteUtil.getUnsignedByte(buffer));
    byte flags = (byte) buffer.getShort();
    builder.setLocalLocator(ByteUtil.extractBit(flags, Flags.LOCAL_LOCATOR));
    builder.setRlocProbed(ByteUtil.extractBit(flags, Flags.RLOC_PROBED));
    builder.setRouted(ByteUtil.extractBit(flags, Flags.ROUTED));
    Rloc rloc = LispAddressSerializer.getInstance().deserializeRloc(buffer);
    builder.setRloc(rloc);
    builder.setLocatorId(LispAddressStringifier.getString(rloc));
    return builder.build();
}
Also used : LocatorRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder) Rloc(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc)

Example 100 with Flags

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.Xro.Flags in project genius by opendaylight.

the class HwVtepTunnelsStateHandler method startMonitoringTask.

@Override
public void startMonitoringTask(MonitoringInfo monitorInfo) {
    EndpointType source = monitorInfo.getSource().getEndpointType();
    if (source instanceof Interface) {
        Interface intf = (Interface) source;
        intf.getInterfaceName();
    } else {
        LOG.warn("Invalid source endpoint. Could not retrieve source interface to configure BFD");
        return;
    }
    MonitorProfile profile;
    long profileId = monitorInfo.getProfileId();
    Optional<MonitorProfile> optProfile = alivenessMonitor.getMonitorProfile(profileId);
    if (optProfile.isPresent()) {
        profile = optProfile.get();
    } else {
        LOG.warn("No monitor profile associated with id {}. " + "Could not send Monitor packet for monitor-id {}", profileId, monitorInfo);
        return;
    }
    // TODO: get the corresponding hwvtep tunnel from the sourceInterface
    // once InterfaceMgr
    // Implements renderer for hwvtep VXLAN tunnels
    String tunnelLocalMacAddress = "<TODO>";
    String tunnelLocalIpAddress = "<TODO>";
    String tunnelRemoteMacAddress = "<TODO>";
    List<BfdParams> bfdParams = new ArrayList<>();
    fillBfdParams(bfdParams, profile);
    List<BfdLocalConfigs> bfdLocalConfigs = new ArrayList<>();
    fillBfdLocalConfigs(bfdLocalConfigs, tunnelLocalMacAddress, tunnelLocalIpAddress);
    List<BfdRemoteConfigs> bfdRemoteConfigs = new ArrayList<>();
    fillBfdRemoteConfigs(bfdRemoteConfigs, tunnelRemoteMacAddress);
    // tunnelKey is initialized to null and passed to setKey which FindBugs flags as a
    // "Load of known null value" violation. Not sure sure what the intent is...
    // TunnelsKey tunnelKey = null;
    Tunnels tunnelWithBfd = new TunnelsBuilder().setKey(/*tunnelKey*/
    null).setBfdParams(bfdParams).setBfdLocalConfigs(bfdLocalConfigs).setBfdRemoteConfigs(bfdRemoteConfigs).build();
    // TODO: get the following parameters from the interface and use it to
    // update hwvtep datastore
    // and not sure sure tunnels are creating immediately once interface mgr
    // writes termination point
    // into hwvtep datastore. if tunnels are not created during that time,
    // then start monitoring has to
    // be done as part of tunnel add DCN handling.
    String topologyId = "";
    String nodeId = "";
    MDSALUtil.syncUpdate(dataBroker, LogicalDatastoreType.CONFIGURATION, getTunnelIdentifier(topologyId, nodeId, new TunnelsKey(/*localRef*/
    null, /*remoteRef*/
    null)), tunnelWithBfd);
}
Also used : BfdLocalConfigs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.tunnel.attributes.BfdLocalConfigs) MonitorProfile(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.profiles.MonitorProfile) ArrayList(java.util.ArrayList) TunnelsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.TunnelsBuilder) EndpointType(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.endpoint.EndpointType) BfdRemoteConfigs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.tunnel.attributes.BfdRemoteConfigs) TunnelsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.TunnelsKey) BfdParams(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.tunnel.attributes.BfdParams) Interface(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.endpoint.endpoint.type.Interface) Tunnels(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.Tunnels)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)117 Test (org.junit.Test)104 BitArray (org.opendaylight.protocol.util.BitArray)63 MultipartRequestFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags)61 MultipartRequestInput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput)40 ArrayList (java.util.ArrayList)25 MultipartRequestInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder)25 MultipartReplyMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage)23 MultipartReplyMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder)20 BigInteger (java.math.BigInteger)15 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)12 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder)12 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)10 Update (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Update)10 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)8 BundleFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundleFlags)8 Attributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes)8 AsNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber)7 UpdateBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.UpdateBuilder)7 AsPathBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.AsPathBuilder)7