2 * Copyright (c) 2017 Pantheon Technologies s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.openflowplugin.impl.services.singlelayer;
11 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
12 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
13 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
14 import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
15 import org.opendaylight.openflowplugin.impl.services.util.ServiceException;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.OriginalGroup;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.UpdatedGroup;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupMessageBuilder;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupModCommand;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
24 import org.opendaylight.yangtools.yang.binding.DataContainer;
25 import org.opendaylight.yangtools.yang.binding.DataObject;
27 public final class SingleLayerGroupService<O extends DataObject> extends AbstractSimpleService<Group, O> {
29 public SingleLayerGroupService(
30 final RequestContextStack requestContextStack,
31 final DeviceContext deviceContext,
32 final Class<O> clazz) {
33 super(requestContextStack, deviceContext, clazz);
37 protected OfHeader buildRequest(final Xid xid, final Group input) throws ServiceException {
38 final GroupMessageBuilder groupMessageBuilder = new GroupMessageBuilder(input);
39 final Class<? extends DataContainer> clazz = input.getImplementedInterface();
41 if (clazz.equals(AddGroupInput.class)) {
42 groupMessageBuilder.setCommand(GroupModCommand.OFPGCADD);
43 } else if (clazz.equals(UpdatedGroup.class)) {
44 groupMessageBuilder.setCommand(GroupModCommand.OFPGCMODIFY);
45 } else if (clazz.equals(RemoveGroupInput.class)
46 || clazz.equals(OriginalGroup.class)) {
47 groupMessageBuilder.setCommand(GroupModCommand.OFPGCDELETE);
50 return groupMessageBuilder
51 .setVersion(getVersion())
52 .setXid(xid.getValue())