use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group in project openflowplugin by opendaylight.
the class OpenflowpluginGroupTestCommandProvider method createTestGroup.
private GroupBuilder createTestGroup(String actionType, String groupType, String groupMod) {
// Sample data , committing to DataStore
GroupBuilder group = new GroupBuilder();
BucketBuilder bucket = new BucketBuilder();
bucket.setBucketId(new BucketId((long) 12));
bucket.setKey(new BucketKey(new BucketId((long) 12)));
if (groupType == null) {
groupType = "g1";
}
if (actionType == null) {
actionType = "a1";
}
switch(groupType) {
case "g1":
group.setGroupType(GroupTypes.GroupSelect);
break;
case "g2":
group.setGroupType(GroupTypes.GroupAll);
break;
case "g3":
group.setGroupType(GroupTypes.GroupIndirect);
break;
case "g4":
group.setGroupType(GroupTypes.GroupFf);
break;
default:
break;
}
switch(actionType) {
case "a1":
bucket.setAction(createPopVlanAction());
break;
case "a2":
bucket.setAction(createPushVlanAction());
break;
case "a3":
bucket.setAction(createPushMplsAction());
break;
case "a4":
bucket.setAction(createPopMplsAction());
break;
case "a5":
bucket.setAction(createPopPbbAction());
break;
case "a6":
case "a7":
bucket.setAction(createPushPbbAction());
break;
case "a8":
bucket.setAction(createCopyTtlInAction());
break;
case "a9":
bucket.setAction(createCopyTtlOutAction());
break;
case "a10":
bucket.setAction(createDecMplsTtlAction());
break;
case "a11":
bucket.setAction(createDecNwTtlAction());
break;
case "a12":
bucket.setAction(createSetQueueAction());
break;
case "a13":
bucket.setAction(createSetNwTtlAction());
break;
case "a14":
bucket.setAction(createGroupAction());
break;
case "a15":
bucket.setAction(createSetMplsTtlAction());
break;
case "a16":
bucket.setAction(createFloodOutputAction());
break;
case "a17":
bucket.setAction(createAllOutputAction());
break;
case "a18":
bucket.setAction(createNormalOutputAction());
break;
case "a19":
bucket.setAction(creatTableOutputAction());
break;
case "a20":
bucket.setAction(createControllerAction());
break;
case "a21":
bucket.setAction(createLocalOutputAction());
break;
case "a22":
bucket.setAction(createAnyOutputAction());
break;
case "a23":
bucket.setAction(createInportOutputAction());
break;
case "a24":
bucket.setAction(null);
break;
case "a25":
bucket.setAction(createNonAppyOutputAction());
break;
case "a26":
bucket.setAction(createNonAppyPushMplsAction());
break;
case "a27":
bucket.setAction(createNonAppyPushPbbAction());
break;
case "a28":
bucket.setAction(createNonAppyPushVlanAction());
break;
default:
break;
}
if ("add".equals(groupMod)) {
bucket.setWatchGroup((long) 14);
bucket.setWatchPort((long) 1234);
bucket.setWeight(50);
} else {
bucket.setWatchGroup((long) 13);
bucket.setWatchPort((long) 134);
bucket.setWeight(30);
}
long id = 1;
GroupKey key = new GroupKey(new GroupId(id));
group.setKey(key);
// group.setInstall(false);
group.setGroupId(new GroupId(id));
group.setGroupName(ORIGINAL_GROUP_NAME);
group.setBarrier(false);
BucketsBuilder value = new BucketsBuilder();
List<Bucket> value1 = new ArrayList<>();
value1.add(bucket.build());
value.setBucket(value1);
group.setBuckets(value.build());
testGroup = group.build();
return group;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group in project openflowplugin by opendaylight.
the class OpenflowpluginMeterTestCommandProvider method _removeMeter.
public void _removeMeter(final CommandInterpreter ci) {
String nref = ci.nextArgument();
if (nref == null) {
ci.println("test node added");
createTestNode();
} else {
ci.println("User node added" + nref);
createUserNode(nref);
}
createTestMeter();
ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
InstanceIdentifier<Meter> path1 = InstanceIdentifier.create(Nodes.class).child(Node.class, testNode.getKey()).augmentation(FlowCapableNode.class).child(Meter.class, new MeterKey(testMeter.getMeterId()));
modification.delete(LogicalDatastoreType.CONFIGURATION, path1);
CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
Futures.addCallback(commitFuture, new FutureCallback<Void>() {
@Override
public void onSuccess(Void notUsed) {
ci.println("Status of Group Data Loaded Transaction: success.");
}
@Override
public void onFailure(Throwable throwable) {
ci.println(String.format("Status of Group Data Loaded Transaction : failure. Reason : %s", throwable));
}
}, MoreExecutors.directExecutor());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group in project openflowplugin by opendaylight.
the class OpenflowpluginMeterTestCommandProvider method writeMeter.
private void writeMeter(final CommandInterpreter ci, Meter meter, Meter meter1) {
ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
InstanceIdentifier<Meter> path1 = InstanceIdentifier.create(Nodes.class).child(Node.class, testNode.getKey()).augmentation(FlowCapableNode.class).child(Meter.class, new MeterKey(meter.getMeterId()));
modification.merge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode), testNode, true);
modification.merge(LogicalDatastoreType.CONFIGURATION, path1, meter, true);
InstanceIdentifier<Meter> path2 = InstanceIdentifier.create(Nodes.class).child(Node.class, testNode.getKey()).augmentation(FlowCapableNode.class).child(Meter.class, new MeterKey(meter1.getMeterId()));
modification.merge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode), testNode, true);
modification.merge(LogicalDatastoreType.CONFIGURATION, path2, meter1, true);
CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
Futures.addCallback(commitFuture, new FutureCallback<Void>() {
@Override
public void onSuccess(Void notUsed) {
ci.println("Status of Group Data Loaded Transaction: success.");
}
@Override
public void onFailure(Throwable throwable) {
ci.println(String.format("Status of Group Data Loaded Transaction : failure. Reason : %s", throwable));
}
}, MoreExecutors.directExecutor());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group in project openflowplugin by opendaylight.
the class OpenflowpluginStatsTestCommandProvider method _groupStats.
public void _groupStats(CommandInterpreter ci) {
int groupCount = 0;
int groupStatsCount = 0;
NodeGroupStatistics data = null;
List<Node> nodes = getNodes();
for (Node node2 : nodes) {
NodeKey nodeKey = node2.getKey();
InstanceIdentifier<FlowCapableNode> nodeRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class);
ReadOnlyTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction();
FlowCapableNode node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef);
if (node != null) {
if (node.getGroup() != null) {
List<Group> groups = node.getGroup();
for (Group group2 : groups) {
groupCount++;
GroupKey groupKey = group2.getKey();
InstanceIdentifier<Group> groupRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).child(Group.class, groupKey);
Group group = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, groupRef);
if (group != null) {
data = group.getAugmentation(NodeGroupStatistics.class);
if (null != data) {
groupStatsCount++;
}
}
}
}
}
}
if (groupCount == groupStatsCount) {
LOG.debug("---------------------groupStats - Success-------------------------------");
} else {
LOG.debug("------------------------------groupStats - Failed--------------------------");
LOG.debug("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group in project openflowplugin by opendaylight.
the class FlowConvertorTest method test.
/**
* Tests {@link FlowConvertor#convert(Flow, VersionDatapathIdConvertorData)} }.
*/
@Test
public void test() {
RemoveFlowInputBuilder flowBuilder = new RemoveFlowInputBuilder();
flowBuilder.setBarrier(false);
flowBuilder.setCookie(new FlowCookie(new BigInteger("4")));
flowBuilder.setCookieMask(new FlowCookie(new BigInteger("5")));
flowBuilder.setTableId((short) 6);
flowBuilder.setStrict(true);
flowBuilder.setIdleTimeout(50);
flowBuilder.setHardTimeout(500);
flowBuilder.setPriority(40);
flowBuilder.setBufferId(18L);
flowBuilder.setOutPort(new BigInteger("65535"));
flowBuilder.setOutGroup(5000L);
flowBuilder.setFlags(null);
flowBuilder.setMatch(null);
RemoveFlowInput flow = flowBuilder.build();
VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);
data.setDatapathId(new BigInteger("42"));
List<FlowModInputBuilder> flowMod = convert(flow, data);
Assert.assertEquals("Wrong version", 4, flowMod.get(0).getVersion().intValue());
Assert.assertEquals("Wrong cookie", 4, flowMod.get(0).getCookie().intValue());
Assert.assertEquals("Wrong cookie mask", 5, flowMod.get(0).getCookieMask().intValue());
Assert.assertEquals("Wrong table id", 6, flowMod.get(0).getTableId().getValue().intValue());
Assert.assertEquals("Wrong command", FlowModCommand.OFPFCDELETESTRICT, flowMod.get(0).getCommand());
Assert.assertEquals("Wrong idle timeout", 50, flowMod.get(0).getIdleTimeout().intValue());
Assert.assertEquals("Wrong hard timeout", 500, flowMod.get(0).getHardTimeout().intValue());
Assert.assertEquals("Wrong priority", 40, flowMod.get(0).getPriority().intValue());
Assert.assertEquals("Wrong buffer id", 18, flowMod.get(0).getBufferId().intValue());
Assert.assertEquals("Wrong out port", 65535, flowMod.get(0).getOutPort().getValue().intValue());
Assert.assertEquals("Wrong out group", 5000, flowMod.get(0).getOutGroup().intValue());
Assert.assertEquals("Wrong flags", new FlowModFlags(false, false, false, false, false), flowMod.get(0).getFlags());
Assert.assertEquals("Wrong match", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmMatchType", flowMod.get(0).getMatch().getType().getName());
Assert.assertEquals("Wrong match entries size", 0, flowMod.get(0).getMatch().getMatchEntry().size());
}
Aggregations