Search in sources :

Example 1 with AddGroupInputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInputBuilder in project netvirt by opendaylight.

the class NexthopManager method installGroupOnDpn.

private void installGroupOnDpn(long groupId, BigInteger dpnId, String groupName, List<BucketInfo> bucketsInfo, String nextHopKey, GroupTypes groupType) {
    NodeRef nodeRef = FibUtil.buildNodeRef(dpnId);
    Buckets buckets = FibUtil.buildBuckets(bucketsInfo);
    GroupRef groupRef = new GroupRef(FibUtil.buildGroupInstanceIdentifier(groupId, dpnId));
    AddGroupInput input = new AddGroupInputBuilder().setNode(nodeRef).setGroupId(new GroupId(groupId)).setBuckets(buckets).setGroupRef(groupRef).setGroupType(groupType).setGroupName(groupName).build();
    Future<RpcResult<AddGroupOutput>> groupStats = salGroupService.addGroup(input);
    RpcResult<AddGroupOutput> rpcResult = null;
    try {
        rpcResult = groupStats.get();
        if (rpcResult != null && rpcResult.isSuccessful()) {
            LOG.info("Group {} with key {} has been successfully installed directly on dpn {}.", groupId, nextHopKey, dpnId);
        } else {
            LOG.error("Unable to install group {} with key {} directly on dpn {} due to {}.", groupId, nextHopKey, dpnId, rpcResult != null ? rpcResult.getErrors() : null);
        }
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("Error while installing group {} directly on dpn {}", groupId, dpnId);
    }
}
Also used : AddGroupInput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) Buckets(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.Buckets) AddGroupInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInputBuilder) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId) NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) AddGroupOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutput) GroupRef(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupRef) ExecutionException(java.util.concurrent.ExecutionException)

Example 2 with AddGroupInputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInputBuilder in project openflowplugin by opendaylight.

the class GroupConvertorTest method testGroupModConvertorBucketwithNOWieghtValuesForGroupTypeFastFailure.

/**
 * test of {@link GroupConvertor#convert(Group, VersionDatapathIdConvertorData)} }.
 */
@Test
public void testGroupModConvertorBucketwithNOWieghtValuesForGroupTypeFastFailure() {
    int actionOrder = 0;
    final AddGroupInputBuilder addGroupBuilder = new AddGroupInputBuilder();
    addGroupBuilder.setGroupId(new GroupId(10L));
    addGroupBuilder.setGroupType(GroupTypes.GroupFf);
    final List<Bucket> bucketList = new ArrayList<>();
    final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actionsList = new ArrayList<>();
    final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actionsList1 = new ArrayList<>();
    // Action1: 005
    actionsList.add(assembleActionBuilder("005", actionOrder++).build());
    // Action2: 006
    actionsList.add(assembleActionBuilder("006", actionOrder++).build());
    // .. and mr.Bond is not coming today
    final BucketsBuilder bucketsB = new BucketsBuilder();
    final BucketBuilder bucketB = new BucketBuilder();
    bucketB.setAction(actionsList);
    final Bucket bucket = bucketB.build();
    // List of bucket
    bucketList.add(bucket);
    final BucketBuilder bucketB1 = new BucketBuilder();
    // Action1
    actionsList1.add(assembleCopyTtlInBuilder(actionOrder++).build());
    // Action2:
    actionsList1.add(assembleSetMplsTtlActionBuilder(actionOrder++).build());
    bucketB1.setAction(actionsList1);
    // second bucket
    final Bucket bucket1 = bucketB1.build();
    bucketList.add(bucket1);
    // List of bucket added to the Buckets
    bucketsB.setBucket(bucketList);
    final Buckets buckets = bucketsB.build();
    addGroupBuilder.setBuckets(buckets);
    VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData((short) 0X4);
    data.setDatapathId(BigInteger.valueOf(1));
    final GroupModInputBuilder outAddGroupInput = convert(addGroupBuilder.build(), data);
    assertEquals(GroupModCommand.OFPGCADD, outAddGroupInput.getCommand());
    assertEquals(GroupType.OFPGTFF, outAddGroupInput.getType());
    assertEquals(10L, outAddGroupInput.getGroupId().getValue().longValue());
    final List<Action> outActionList = outAddGroupInput.getBucketsList().get(0).getAction();
    for (int outItem = 0; outItem < outActionList.size(); outItem++) {
        final Action action = outActionList.get(outItem);
        if (action.getActionChoice() instanceof GroupActionCase) {
            assertEquals((Long) 5L, ((GroupActionCase) action.getActionChoice()).getGroupAction().getGroupId());
        }
    }
    final List<Action> outActionList1 = outAddGroupInput.getBucketsList().get(1).getAction();
    for (int outItem = 0; outItem < outActionList1.size(); outItem++) {
        final Action action = outActionList1.get(outItem);
        if (action.getActionChoice() instanceof GroupActionCase) {
            assertEquals((Long) 6L, ((GroupActionCase) action.getActionChoice()).getGroupAction().getGroupId());
        }
    }
}
Also used : Action(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action) GroupAction(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupAction) SetMplsTtlAction(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.mpls.ttl.action._case.SetMplsTtlAction) VersionDatapathIdConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData) ArrayList(java.util.ArrayList) BucketsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.BucketsBuilder) Buckets(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.Buckets) AddGroupInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInputBuilder) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId) BucketBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketBuilder) Bucket(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket) GroupModInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInputBuilder) GroupActionCase(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCase) Test(org.junit.Test)

Example 3 with AddGroupInputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInputBuilder in project openflowplugin by opendaylight.

the class GroupConvertorTest method testGroupModConvertorNoBucket.

/**
 * test of {@link GroupConvertor#convert(Group, VersionDatapathIdConvertorData)} }.
 */
@Test
public void testGroupModConvertorNoBucket() {
    final AddGroupInputBuilder addGroupBuilder = new AddGroupInputBuilder();
    addGroupBuilder.setGroupId(new GroupId(10L));
    addGroupBuilder.setGroupType(GroupTypes.GroupAll);
    VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData((short) 0X4);
    data.setDatapathId(BigInteger.valueOf(1));
    final GroupModInputBuilder outAddGroupInput = convert(addGroupBuilder.build(), data);
    assertEquals(GroupModCommand.OFPGCADD, outAddGroupInput.getCommand());
    assertEquals(GroupType.OFPGTALL, outAddGroupInput.getType());
}
Also used : VersionDatapathIdConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData) GroupModInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInputBuilder) AddGroupInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInputBuilder) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId) Test(org.junit.Test)

Example 4 with AddGroupInputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInputBuilder in project openflowplugin by opendaylight.

the class BundleAddMessageConverter method convertBundleGroupCase.

private BundleGroupModCase convertBundleGroupCase(final BundleInnerMessage messageCase, final VersionDatapathIdConvertorData data) throws ConversionException {
    Optional<GroupModInputBuilder> groupModInput = Optional.empty();
    final Class clazz = messageCase.getImplementedInterface();
    if (clazz.equals(BundleAddGroupCase.class)) {
        groupModInput = CONVERTER_EXECUTOR.convert(new AddGroupInputBuilder(((BundleAddGroupCase) messageCase).getAddGroupCaseData()).build(), data);
    } else if (clazz.equals(BundleUpdateGroupCase.class)) {
        groupModInput = CONVERTER_EXECUTOR.convert(new UpdatedGroupBuilder(((BundleUpdateGroupCase) messageCase).getUpdateGroupCaseData()).build(), data);
    } else if (clazz.equals(BundleRemoveGroupCase.class)) {
        groupModInput = CONVERTER_EXECUTOR.convert(new RemoveGroupInputBuilder(((BundleRemoveGroupCase) messageCase).getRemoveGroupCaseData()).build(), data);
    }
    if (groupModInput.isPresent()) {
        return new BundleGroupModCaseBuilder().setGroupModCaseData(new GroupModCaseDataBuilder(groupModInput.get().setXid(xid).build()).build()).build();
    } else {
        throw new ConversionException("BundleGroupCase conversion unsuccessful.");
    }
}
Also used : ConversionException(org.opendaylight.openflowplugin.extension.api.exception.ConversionException) BundleRemoveGroupCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.bundle.inner.message.grouping.bundle.inner.message.BundleRemoveGroupCase) BundleAddGroupCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.bundle.inner.message.grouping.bundle.inner.message.BundleAddGroupCase) BundleUpdateGroupCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.bundle.inner.message.grouping.bundle.inner.message.BundleUpdateGroupCase) RemoveGroupInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInputBuilder) GroupModInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInputBuilder) UpdatedGroupBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.UpdatedGroupBuilder) GroupModCaseDataBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.add.message.grouping.bundle.inner.message.bundle.group.mod._case.GroupModCaseDataBuilder) AddGroupInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInputBuilder) BundleGroupModCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.add.message.grouping.bundle.inner.message.BundleGroupModCaseBuilder)

Example 5 with AddGroupInputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInputBuilder in project openflowplugin by opendaylight.

the class SalGroupServiceImplTest method addGroup.

private void addGroup() {
    final GroupId dummyGroupId = new GroupId(DUMMY_GROUP_ID);
    AddGroupInput addGroupInput = new AddGroupInputBuilder().setGroupId(dummyGroupId).build();
    this.<AddGroupOutput>mockSuccessfulFuture();
    salGroupService.addGroup(addGroupInput);
    verify(mockedRequestContextStack).createRequestContext();
}
Also used : AddGroupInput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput) AddGroupOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutput) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId) AddGroupInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInputBuilder)

Aggregations

AddGroupInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInputBuilder)12 GroupId (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId)8 Test (org.junit.Test)6 GroupModInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInputBuilder)6 ArrayList (java.util.ArrayList)5 VersionDatapathIdConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)5 AddGroupInput (org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput)5 Buckets (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.Buckets)4 BucketsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.BucketsBuilder)4 Bucket (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket)4 BucketBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketBuilder)4 GroupActionCase (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCase)3 GroupAction (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupAction)3 SetMplsTtlAction (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.mpls.ttl.action._case.SetMplsTtlAction)3 AddGroupOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutput)3 GroupRef (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupRef)3 NodeRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef)3 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action)3 Uri (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri)2 GroupActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder)2