use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType in project openflowplugin by opendaylight.
the class MultipartRequestInputFactory method makeDefaultMultiLayerBody.
private static MultipartRequestBody makeDefaultMultiLayerBody(@Nonnull final MultipartType type, final short version) {
switch(type) {
case OFPMPDESC:
return new MultipartRequestDescCaseBuilder().build();
case OFPMPFLOW:
final MultipartRequestFlowCaseBuilder multipartRequestFlowCaseBuilder = new MultipartRequestFlowCaseBuilder();
MultipartRequestFlowBuilder multipartRequestFlowBuilder = new MultipartRequestFlowBuilder();
multipartRequestFlowBuilder.setTableId(OFConstants.OFPTT_ALL);
multipartRequestFlowBuilder.setOutPort(OFConstants.OFPP_ANY);
multipartRequestFlowBuilder.setOutGroup(OFConstants.OFPG_ANY);
multipartRequestFlowBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
multipartRequestFlowBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
switch(version) {
case OFConstants.OFP_VERSION_1_0:
MatchV10Builder matchV10Builder = MatchUtil.createEmptyV10Match();
multipartRequestFlowBuilder.setMatchV10(matchV10Builder.build());
break;
case OFConstants.OFP_VERSION_1_3:
multipartRequestFlowBuilder.setMatch(new MatchBuilder().setType(OxmMatchType.class).build());
break;
default:
throw new IllegalArgumentException("Unknown version " + version);
}
multipartRequestFlowCaseBuilder.setMultipartRequestFlow(multipartRequestFlowBuilder.build());
return multipartRequestFlowCaseBuilder.build();
case OFPMPAGGREGATE:
return new MultipartRequestAggregateCaseBuilder().build();
case OFPMPTABLE:
return new MultipartRequestTableCaseBuilder().build();
case OFPMPPORTSTATS:
MultipartRequestPortStatsCaseBuilder multipartRequestPortStatsCaseBuilder = new MultipartRequestPortStatsCaseBuilder();
MultipartRequestPortStatsBuilder multipartRequestPortStatsBuilder = new MultipartRequestPortStatsBuilder();
multipartRequestPortStatsBuilder.setPortNo(OFConstants.OFPP_ANY);
multipartRequestPortStatsCaseBuilder.setMultipartRequestPortStats(multipartRequestPortStatsBuilder.build());
return multipartRequestPortStatsCaseBuilder.build();
case OFPMPQUEUE:
MultipartRequestQueueCaseBuilder multipartRequestQueueCaseBuilder = new MultipartRequestQueueCaseBuilder();
MultipartRequestQueueBuilder multipartRequestQueueBuilder = new MultipartRequestQueueBuilder();
multipartRequestQueueBuilder.setPortNo(OFConstants.OFPP_ANY);
multipartRequestQueueBuilder.setQueueId(OFConstants.OFPQ_ALL);
multipartRequestQueueCaseBuilder.setMultipartRequestQueue(multipartRequestQueueBuilder.build());
return multipartRequestQueueCaseBuilder.build();
case OFPMPGROUP:
MultipartRequestGroupCaseBuilder multipartRequestGroupCaseBuilder = new MultipartRequestGroupCaseBuilder();
MultipartRequestGroupBuilder multipartRequestGroupBuilder = new MultipartRequestGroupBuilder();
GroupId groupId = new GroupId(OFConstants.OFPG_ALL);
multipartRequestGroupBuilder.setGroupId(groupId);
multipartRequestGroupCaseBuilder.setMultipartRequestGroup(multipartRequestGroupBuilder.build());
return multipartRequestGroupCaseBuilder.build();
case OFPMPGROUPDESC:
return new MultipartRequestGroupDescCaseBuilder().build();
case OFPMPGROUPFEATURES:
return new MultipartRequestGroupFeaturesCaseBuilder().build();
case OFPMPMETER:
MultipartRequestMeterCaseBuilder multipartRequestMeterCaseBuilder = new MultipartRequestMeterCaseBuilder();
MultipartRequestMeterBuilder multipartRequestMeterBuilder = new MultipartRequestMeterBuilder();
MeterId meterId = new MeterId(OFConstants.OFPM_ALL);
multipartRequestMeterBuilder.setMeterId(meterId);
multipartRequestMeterCaseBuilder.setMultipartRequestMeter(multipartRequestMeterBuilder.build());
return multipartRequestMeterCaseBuilder.build();
case OFPMPMETERCONFIG:
MultipartRequestMeterConfigCaseBuilder multipartRequestMeterConfigCaseBuilder = new MultipartRequestMeterConfigCaseBuilder();
MultipartRequestMeterConfigBuilder multipartRequestMeterConfigBuilder = new MultipartRequestMeterConfigBuilder();
MeterId configMeterId = new MeterId(OFConstants.OFPM_ALL);
multipartRequestMeterConfigBuilder.setMeterId(configMeterId);
multipartRequestMeterConfigCaseBuilder.setMultipartRequestMeterConfig(multipartRequestMeterConfigBuilder.build());
return multipartRequestMeterConfigCaseBuilder.build();
case OFPMPMETERFEATURES:
return new MultipartRequestMeterFeaturesCaseBuilder().build();
case OFPMPTABLEFEATURES:
MultipartRequestTableFeaturesCaseBuilder tableFeaturesCaseBuilder = new MultipartRequestTableFeaturesCaseBuilder();
tableFeaturesCaseBuilder.setMultipartRequestTableFeatures(new MultipartRequestTableFeaturesBuilder().build());
return tableFeaturesCaseBuilder.build();
case OFPMPPORTDESC:
return new MultipartRequestPortDescCaseBuilder().build();
case OFPMPEXPERIMENTER:
return new MultipartRequestExperimenterCaseBuilder().build();
default:
throw new IllegalArgumentException("Unknown MultipartType " + type);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType in project openflowplugin by opendaylight.
the class StatisticsGatheringUtilsTest method testGatherStatistics_meter.
@Test
public void testGatherStatistics_meter() throws Exception {
final MultipartType type = MultipartType.OFPMPMETER;
final long meterIdValue = 19L;
final MeterBandStatsBuilder meterBandStatsBld = new MeterBandStatsBuilder().setByteBandCount(BigInteger.valueOf(91L)).setPacketBandCount(BigInteger.valueOf(92L));
final MeterStatsBuilder meterStatsBld = new MeterStatsBuilder().setMeterId(new MeterId(meterIdValue)).setByteInCount(BigInteger.valueOf(111L)).setDurationSec(112L).setDurationNsec(113L).setFlowCount(114L).setPacketInCount(BigInteger.valueOf(115L)).setMeterBandStats(Lists.newArrayList(meterBandStatsBld.build()));
final MultipartReplyMeterBuilder mpReplyMeterBld = new MultipartReplyMeterBuilder();
mpReplyMeterBld.setMeterStats(Lists.newArrayList(meterStatsBld.build()));
final MultipartReplyMeterCaseBuilder mpReplyMeterCaseBld = new MultipartReplyMeterCaseBuilder();
mpReplyMeterCaseBld.setMultipartReplyMeter(mpReplyMeterBld.build());
final MultipartReply meterStatsUpdated = assembleMPReplyMessage(type, mpReplyMeterCaseBld.build());
final List<MultipartReply> statsData = Collections.singletonList(meterStatsUpdated);
fireAndCheck(type, statsData);
final InstanceIdentifier<MeterStatistics> meterPath = dummyNodePath.augmentation(FlowCapableNode.class).child(Meter.class, new MeterKey(new org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId(meterIdValue))).augmentation(NodeMeterStatistics.class).child(MeterStatistics.class);
verify(deviceContext).writeToTransaction(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.eq(meterPath), Matchers.any(MeterStatistics.class));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType in project openflowplugin by opendaylight.
the class StatisticsGatheringUtilsTest method testGatherStatistics_group.
@Test
public void testGatherStatistics_group() throws Exception {
final MultipartType type = MultipartType.OFPMPGROUP;
final long groupIdValue = 19L;
final GroupStatsBuilder groupStatsBld = new GroupStatsBuilder().setBucketStats(Lists.newArrayList(createBucketStat(21L, 42L))).setByteCount(BigInteger.valueOf(84L)).setPacketCount(BigInteger.valueOf(63L)).setDurationSec(11L).setDurationNsec(12L).setRefCount(13L).setGroupId(new GroupId(groupIdValue));
final MultipartReplyGroupBuilder mpReplyGroupBld = new MultipartReplyGroupBuilder();
mpReplyGroupBld.setGroupStats(Lists.newArrayList(groupStatsBld.build()));
final MultipartReplyGroupCaseBuilder mpReplyGroupCaseBld = new MultipartReplyGroupCaseBuilder();
mpReplyGroupCaseBld.setMultipartReplyGroup(mpReplyGroupBld.build());
final MultipartReply groupStatsUpdated = assembleMPReplyMessage(type, mpReplyGroupCaseBld.build());
final List<MultipartReply> statsData = Collections.singletonList(groupStatsUpdated);
fireAndCheck(type, statsData);
final InstanceIdentifier<GroupStatistics> groupPath = dummyNodePath.augmentation(FlowCapableNode.class).child(Group.class, new GroupKey(new org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId(groupIdValue))).augmentation(NodeGroupStatistics.class).child(GroupStatistics.class);
verify(deviceContext).writeToTransaction(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.eq(groupPath), Matchers.any(GroupStatistics.class));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType in project openflowplugin by opendaylight.
the class StatisticsGatheringUtilsTest method testGatherStatistics_queue.
@Test
public void testGatherStatistics_queue() throws Exception {
final MultipartType type = MultipartType.OFPMPQUEUE;
final long queueIdValue = 4L;
final QueueStatsBuilder queueStatsBld = new QueueStatsBuilder().setPortNo(11L).setTxBytes(BigInteger.valueOf(44L)).setTxErrors(BigInteger.valueOf(45L)).setTxPackets(BigInteger.valueOf(46L)).setDurationSec(47L).setDurationNsec(48L).setQueueId(queueIdValue);
final MultipartReplyQueueBuilder mpReplyQueueBld = new MultipartReplyQueueBuilder();
mpReplyQueueBld.setQueueStats(Lists.newArrayList(queueStatsBld.build()));
final MultipartReplyQueueCaseBuilder mpReplyQueueCaseBld = new MultipartReplyQueueCaseBuilder();
mpReplyQueueCaseBld.setMultipartReplyQueue(mpReplyQueueBld.build());
final MultipartReply meterStatsUpdated = assembleMPReplyMessage(type, mpReplyQueueCaseBld.build());
final List<MultipartReply> statsData = Collections.singletonList(meterStatsUpdated);
fireAndCheck(type, statsData);
final KeyedInstanceIdentifier<Queue, QueueKey> queuePath = dummyNodePath.child(NodeConnector.class, new NodeConnectorKey(new NodeConnectorId("openflow:" + DUMMY_NODE_ID_VALUE + ":11"))).augmentation(FlowCapableNodeConnector.class).child(Queue.class, new QueueKey(new QueueId(queueIdValue)));
verify(deviceContext).writeToTransaction(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.eq(queuePath), Matchers.any(Queue.class));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType in project openflowplugin by opendaylight.
the class MultipartRequestMessageSerializer method getMultipartType.
private static MultipartType getMultipartType(final MultipartRequestBody multipartRequestBody) {
final Class<? extends DataContainer> clazz = multipartRequestBody.getImplementedInterface();
final MultipartType multipartType = MultipartRequestDesc.class.equals(clazz) ? MultipartType.OFPMPDESC : MultipartRequestFlowTableStats.class.equals(clazz) ? MultipartType.OFPMPTABLE : MultipartRequestGroupDesc.class.equals(clazz) ? MultipartType.OFPMPGROUPDESC : MultipartRequestGroupFeatures.class.equals(clazz) ? MultipartType.OFPMPGROUPFEATURES : MultipartRequestGroupStats.class.equals(clazz) ? MultipartType.OFPMPGROUP : MultipartRequestMeterFeatures.class.equals(clazz) ? MultipartType.OFPMPMETERFEATURES : MultipartRequestMeterStats.class.equals(clazz) ? MultipartType.OFPMPMETER : MultipartRequestMeterConfig.class.equals(clazz) ? MultipartType.OFPMPMETERCONFIG : MultipartRequestPortDesc.class.equals(clazz) ? MultipartType.OFPMPPORTDESC : MultipartRequestPortStats.class.equals(clazz) ? MultipartType.OFPMPPORTSTATS : MultipartRequestFlowStats.class.equals(clazz) ? MultipartType.OFPMPFLOW : MultipartRequestFlowAggregateStats.class.equals(clazz) ? MultipartType.OFPMPAGGREGATE : MultipartRequestTableFeatures.class.equals(clazz) ? MultipartType.OFPMPTABLEFEATURES : MultipartRequestQueueStats.class.equals(clazz) ? MultipartType.OFPMPQUEUE : MultipartRequestExperimenter.class.equals(clazz) ? MultipartType.OFPMPEXPERIMENTER : null;
if (Objects.isNull(multipartType)) {
throw new IllegalArgumentException(clazz.toString() + " is not valid multipart type");
}
return multipartType;
}
Aggregations