<developerConnection>scm:git:ssh://git.opendaylight.org:29418/openflowplugin.git</developerConnection>
</scm>
<properties>
- <xtend.version>2.4.3</xtend.version>
<bundle.plugin.version>2.4.0</bundle.plugin.version>
- <maven.clean.plugin.version>2.5</maven.clean.plugin.version>
</properties>
<dependencies>
<dependency>
<dependency>
<groupId>org.opendaylight.controller.model</groupId>
<artifactId>model-inventory</artifactId>
- </dependency>
- <dependency>
- <groupId>org.eclipse.xtend</groupId>
- <artifactId>org.eclipse.xtend.lib</artifactId>
- <version>${xtend.version}</version>
</dependency>
<dependency>
<groupId>equinoxSDK381</groupId>
<manifestLocation>${project.basedir}/META-INF</manifestLocation>
</configuration>
</plugin>
- <plugin>
- <groupId>org.eclipse.xtend</groupId>
- <artifactId>xtend-maven-plugin</artifactId>
- <version>${xtend.version}</version>
- <executions>
- <execution>
- <goals>
- <goal>compile</goal>
- </goals>
- <configuration>
- <outputDirectory>${basedir}/src/main/xtend-gen</outputDirectory>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-clean-plugin</artifactId>
- <version>${maven.clean.plugin.version}</version>
- <configuration>
- <filesets>
- <fileset>
- <directory>${basedir}/src/main/xtend-gen</directory>
- <includes>
- <include>**</include>
- </includes>
- </fileset>
- </filesets>
- </configuration>
- </plugin>
</plugins>
</build>
</project>
--- /dev/null
+/**
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.droptest;
+
+import org.opendaylight.controller.sal.binding.api.AbstractBindingAwareProvider;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
+import org.opendaylight.openflowplugin.outputtest.OutputTestCommandProvider;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
+import org.osgi.framework.BundleContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@SuppressWarnings("all")
+public class DropTestActivator extends AbstractBindingAwareProvider {
+ private static Logger LOG = LoggerFactory.getLogger(DropTestActivator.class);
+
+ private static DropTestProvider provider = new DropTestProvider();
+
+ private static DropTestRpcProvider rpcProvider = new DropTestRpcProvider();
+
+ private static DropTestCommandProvider cmdProvider;
+
+ private static OutputTestCommandProvider outCmdProvider;
+
+ public void onSessionInitiated(final ProviderContext session) {
+ LOG.debug("Activator DropAllPack INIT");
+ provider.setDataService(session.<DataProviderService>getSALService(DataProviderService.class));
+
+ provider.setNotificationService(session.<NotificationProviderService>getSALService(NotificationProviderService.class));
+
+ cmdProvider.onSessionInitiated(session);
+
+ rpcProvider.setNotificationService(session.<NotificationProviderService>getSALService(NotificationProviderService.class));
+
+ rpcProvider.setFlowService(session.<SalFlowService>getRpcService(SalFlowService.class));
+ outCmdProvider.onSessionInitiated(session);
+
+ LOG.debug("Activator DropAllPack END");
+ }
+
+ public void startImpl(final BundleContext ctx) {
+ super.startImpl(ctx);
+// LOG.debug("------------------------------------- DROP ALL PACK TEST INITIATED ------------------------ ")
+ cmdProvider = new DropTestCommandProvider(ctx, provider, rpcProvider);;
+ outCmdProvider = new OutputTestCommandProvider(ctx);
+ }
+
+ protected void stopImpl(final BundleContext context) {
+// LOG.debug("-------------------------------------- DROP ALL PACK TEST STOPED --------------------------- ")
+ provider.close();
+ }
+}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.openflowplugin.droptest
-
-import org.opendaylight.controller.sal.binding.api.AbstractBindingAwareProvider
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext
-import org.opendaylight.controller.sal.binding.api.NotificationProviderService
-import org.opendaylight.controller.sal.binding.api.data.DataProviderService
-import org.opendaylight.openflowplugin.outputtest.OutputTestCommandProvider
-import org.osgi.framework.BundleContext
-import org.slf4j.Logger
-import org.slf4j.LoggerFactory
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService
-
-class DropTestActivator extends AbstractBindingAwareProvider {
-
- static Logger LOG = LoggerFactory.getLogger(DropTestActivator);
-
- static var DropTestProvider provider = new DropTestProvider();
- static var DropTestRpcProvider rpcProvider = new DropTestRpcProvider();
-
- static var DropTestCommandProvider cmdProvider
- static var OutputTestCommandProvider outCmdProvider
-
- override onSessionInitiated(ProviderContext session) {
- LOG.debug("Activator DropAllPack INIT")
- provider.dataService = session.getSALService(DataProviderService)
- provider.notificationService = session.getSALService(NotificationProviderService)
- cmdProvider.onSessionInitiated(session);
-
- rpcProvider.notificationService = session.getSALService(NotificationProviderService)
- rpcProvider.flowService = session.getRpcService(SalFlowService)
-
- outCmdProvider.onSessionInitiated(session);
- LOG.debug("Activator DropAllPack END")
- }
-
- override startImpl(BundleContext ctx) {
- super.startImpl(ctx);
-// LOG.debug("------------------------------------- DROP ALL PACK TEST INITIATED ------------------------ ")
- cmdProvider = new DropTestCommandProvider(ctx,provider,rpcProvider);
- outCmdProvider = new OutputTestCommandProvider(ctx);
- }
-
- override protected stopImpl(BundleContext context) {
-// LOG.debug("-------------------------------------- DROP ALL PACK TEST STOPED --------------------------- ")
- provider.close();
- }
-
-}
--- /dev/null
+/**
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.droptest;
+
+import org.apache.commons.codec.binary.Hex;
+import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingListener;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceived;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+@SuppressWarnings("all")
+public class DropTestCommiter implements PacketProcessingListener {
+ private final static Logger LOG = LoggerFactory.getLogger(DropTestProvider.class);
+
+ private final DropTestProvider _manager;
+
+ public DropTestProvider getManager() {
+ return this._manager;
+ }
+
+ public DropTestCommiter(final DropTestProvider manager) {
+ this._manager = manager;
+ }
+
+ public void onPacketReceived(final PacketReceived notification) {
+ LOG.debug("onPacketReceived - Entering - " + notification);
+
+ // Get the Ingress nodeConnectorRef
+ final NodeConnectorRef ncr = notification.getIngress();
+
+ // Get the instance identifier for the nodeConnectorRef
+ final InstanceIdentifier<NodeConnector> ncri = (InstanceIdentifier<NodeConnector>) ncr.getValue();
+
+ final NodeConnectorKey ncKey = InstanceIdentifier.<NodeConnector, NodeConnectorKey>keyOf(ncri);
+
+ // Get the instanceID for the Node in the tree above us
+ final InstanceIdentifier<Node> nodeInstanceId = ncri.<Node>firstIdentifierOf(Node.class);
+ final NodeKey nodeKey = InstanceIdentifier.<Node, NodeKey>keyOf(nodeInstanceId);
+ final byte[] rawPacket = notification.getPayload();
+
+ LOG.debug("onPacketReceived - received Packet on Node {} and NodeConnector {} payload {}",
+ nodeKey.getId(), ncKey.getId(), Hex.encodeHexString(rawPacket));
+
+ final byte[] srcMac = Arrays.copyOfRange(rawPacket, 6, 12);
+
+ LOG.debug("onPacketReceived - received Packet on Node {} and NodeConnector {} srcMac {}",
+ nodeKey.getId(), ncKey.getId(), Hex.encodeHexString(srcMac));
+
+ final MatchBuilder match = new MatchBuilder();
+ final EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
+ final EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
+
+ //TODO: use HEX, use binary form
+ //Hex.decodeHex("000000000001".toCharArray());
+
+ ethSourceBuilder.setAddress(new MacAddress(DropTestUtils.macToString(srcMac)));
+ ethernetMatch.setEthernetSource(ethSourceBuilder.build());
+ match.setEthernetMatch(ethernetMatch.build());
+
+ final DropActionBuilder dab = new DropActionBuilder();
+ final DropAction dropAction = dab.build();
+ final ActionBuilder ab = new ActionBuilder();
+ ab.setOrder(0);
+ ab.setAction(new DropActionCaseBuilder().setDropAction(dropAction).build());
+
+ // Add our drop action to a list
+ final ArrayList<Action> actionList = new ArrayList<Action>();
+ actionList.add(ab.build());
+
+ // Create an Apply Action
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ aab.setAction(actionList);
+
+ // Wrap our Apply Action in an Instruction
+ final InstructionBuilder ib = new InstructionBuilder();
+ ib.setOrder(0);
+ ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+
+ // Put our Instruction in a list of Instructions
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final ArrayList<Instruction> instructions = new ArrayList<Instruction>();
+ instructions.add(ib.build());
+ isb.setInstruction(instructions);
+
+ // Finally build our flow
+ final FlowBuilder fb = new FlowBuilder();
+ fb.setMatch(match.build());
+ fb.setInstructions(isb.build());
+ fb.setId(new FlowId(Long.toString(fb.hashCode())));
+ fb.setPriority(4);
+ fb.setBufferId(0L);
+ final BigInteger value = new BigInteger("10", 10);
+ fb.setCookie(value);
+ fb.setCookieMask(value);
+
+ fb.setTableId(Short.valueOf(((short) 0)));
+ fb.setHardTimeout(300);
+ fb.setIdleTimeout(240);
+ fb.setFlags(new FlowModFlags(false, false, false, false, false));
+
+ // Construct the flow instance id
+ final InstanceIdentifier<Flow> flowInstanceId =
+ InstanceIdentifier.builder(Nodes.class) // File under nodes
+ .child(Node.class, nodeKey) // A particular node indentified by nodeKey
+ .augmentation(FlowCapableNode.class) // That is flow capable, only FlowCapableNodes have tables
+ .child(Table.class, new TableKey(new Short(((short) 0)))) // In the table identified by TableKey
+ .child(Flow.class, new FlowKey(fb.getId())) // A flow identified by flowKey
+ .build();
+
+ final Flow flow = fb.build();
+ final DataModificationTransaction transaction = this._manager.getDataService().beginTransaction();
+
+ LOG.debug("onPacketReceived - About to write flow - " + flow);
+ transaction.putConfigurationData(flowInstanceId, flow);
+ transaction.commit();
+ LOG.debug("onPacketReceived - About to write flow commited");
+ }
+}
+++ /dev/null
-/**
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.openflowplugin.droptest
-
-import java.util.ArrayList
-import java.util.Arrays
-import org.apache.commons.codec.binary.Hex
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCaseBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropActionBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingListener
-import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceived
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress
-import org.slf4j.LoggerFactory
-import java.math.BigInteger
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags
-
-class DropTestCommiter implements PacketProcessingListener {
- static val LOG = LoggerFactory.getLogger(DropTestProvider);
- @Property
- val DropTestProvider manager;
-
- new(DropTestProvider manager) {
- _manager = manager;
- }
-
- override onPacketReceived(PacketReceived notification) {
- LOG.debug("onPacketReceived - Entering - " + notification);
- val ncr = notification.ingress // Get the Ingress nodeConnectorRef
- val ncri = (ncr.value as InstanceIdentifier<NodeConnector>); // Get the instance identifier for the nodeConnectorRef
- val ncKey = InstanceIdentifier.keyOf(ncri);
- val nodeInstanceId = ncri.firstIdentifierOf(Node); // Get the instanceID for the Node in the tree above us
- val nodeKey = InstanceIdentifier.keyOf(nodeInstanceId);
- val rawPacket = notification.payload;
- LOG.debug("onPacketReceived - received Packet on Node {} and NodeConnector {} payload {}",nodeKey.id,ncKey.id,Hex.encodeHexString(rawPacket));
- val srcMac = Arrays.copyOfRange(rawPacket,6,12);
- LOG.debug("onPacketReceived - received Packet on Node {} and NodeConnector {} srcMac {}",nodeKey.id,ncKey.id,Hex.encodeHexString(srcMac));
-
- val match = new MatchBuilder();
- val ethernetMatch = new EthernetMatchBuilder();
- val ethSourceBuilder = new EthernetSourceBuilder();
- //TODO: use HEX, use binary form
- //Hex.decodeHex("000000000001".toCharArray());
- ethSourceBuilder.setAddress(new MacAddress(DropTestUtils.macToString(srcMac)));
- ethernetMatch.setEthernetSource(ethSourceBuilder.build());
- match.setEthernetMatch(ethernetMatch.build());
- val dab = new DropActionBuilder();
- val dropAction = dab.build();
- val ab = new ActionBuilder();
- ab.setOrder(0);
- ab.setAction(new DropActionCaseBuilder().setDropAction(dropAction).build());
-
- // Add our drop action to a list
- val actionList = new ArrayList<Action>();
- actionList.add(ab.build());
-
- // Create an Apply Action
- val aab = new ApplyActionsBuilder();
- aab.setAction(actionList);
-
- // Wrap our Apply Action in an Instruction
- val ib = new InstructionBuilder();
- ib.setOrder(0);
- ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
-
- // Put our Instruction in a list of Instructions
- val isb = new InstructionsBuilder();
- val instructions = new ArrayList<Instruction>();
- instructions.add(ib.build());
- isb.setInstruction(instructions);
-
- // Finally build our flow
- val fb = new FlowBuilder();
- fb.setMatch(match.build());
- fb.setInstructions(isb.build());
- fb.setId(new FlowId(Long.toString(fb.hashCode)));
- fb.setPriority(4);
- fb.setBufferId(0L);
- val value = new BigInteger("10", 10);
- fb.setCookie(value);
- fb.setCookieMask(value);
- fb.setTableId(0 as short);
- fb.setHardTimeout(300);
- fb.setIdleTimeout(240);
- fb.setFlags(new FlowModFlags(false, false, false, false, false));
-
- // Construct the flow instance id
- val flowInstanceId = InstanceIdentifier.builder(Nodes) // File under nodes
- .child(Node,nodeKey) // A particular node indentified by nodeKey
- .augmentation(FlowCapableNode) // That is flow capable, only FlowCapableNodes have tables
- .child(Table,new TableKey(new Short((0 as short)))) // In the table identified by TableKey
- .child(Flow,new FlowKey(fb.id)) // A flow identified by flowKey
- .build();
- val flow = fb.build()
- val transaction = _manager.dataService.beginTransaction
- LOG.debug("onPacketReceived - About to write flow - " + flow);
- transaction.putConfigurationData(flowInstanceId,flow);
- transaction.commit;
- LOG.debug("onPacketReceived - About to write flow commited");
- }
-
-}
--- /dev/null
+/**
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.droptest;
+
+import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
+import org.opendaylight.yangtools.concepts.Registration;
+import org.opendaylight.yangtools.yang.binding.NotificationListener;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@SuppressWarnings("all")
+public class DropTestProvider implements AutoCloseable {
+ private final static Logger LOG = LoggerFactory.getLogger(DropTestProvider.class);
+
+ private DataProviderService _dataService;
+ private NotificationProviderService _notificationService;
+ private Registration<NotificationListener> listenerRegistration;
+ private final DropTestCommiter commiter = new DropTestCommiter(this);
+
+ public DataProviderService getDataService() {
+ return this._dataService;
+ }
+
+ public void setDataService(final DataProviderService dataService) {
+ this._dataService = dataService;
+ }
+
+
+ public NotificationProviderService getNotificationService() {
+ return this._notificationService;
+ }
+
+ public void setNotificationService(final NotificationProviderService notificationService) {
+ this._notificationService = notificationService;
+ }
+
+ public void start() {
+ this.listenerRegistration = this.getNotificationService().registerNotificationListener(commiter);
+ LOG.debug("DropTestProvider Started.");
+ }
+
+ public void close() {
+ try {
+ LOG.debug("DropTestProvider stopped.");
+ if (this.listenerRegistration != null) {
+ this.listenerRegistration.close();
+ }
+ } catch (Exception e) {
+ throw new Error(e);
+ }
+ }
+}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.openflowplugin.droptest
-
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext
-import org.opendaylight.controller.sal.binding.api.NotificationProviderService
-import org.opendaylight.controller.sal.binding.api.data.DataProviderService
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInput
-import org.opendaylight.yangtools.concepts.CompositeObjectRegistration
-import org.opendaylight.yangtools.concepts.Registration
-import org.slf4j.LoggerFactory
-import org.opendaylight.yangtools.yang.binding.NotificationListener
-
-class DropTestProvider implements AutoCloseable {
-
-
- static val LOG = LoggerFactory.getLogger(DropTestProvider);
-
- @Property
- DataProviderService dataService;
-
- @Property
- NotificationProviderService notificationService;
-
- val DropTestCommiter commiter = new DropTestCommiter(this);
-
- Registration<NotificationListener> listenerRegistration
-
- def void start() {
- listenerRegistration = notificationService.registerNotificationListener(commiter);
- LOG.debug("DropTestProvider Started.");
-
- }
-
- override close() {
- LOG.debug("DropTestProvider stopped.");
- listenerRegistration?.close();
- }
-
-}
-
-
--- /dev/null
+/**
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.droptest;
+
+import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
+import org.opendaylight.yangtools.concepts.Registration;
+import org.opendaylight.yangtools.yang.binding.NotificationListener;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@SuppressWarnings("all")
+public class DropTestRpcProvider implements AutoCloseable {
+ private final static Logger LOG = LoggerFactory.getLogger(DropTestProvider.class);
+
+ private SalFlowService _flowService;
+ private NotificationProviderService _notificationService;
+ private DropTestRpcSender commiter;
+ private Registration<NotificationListener> listenerRegistration;
+
+ public SalFlowService getFlowService() {
+ return this._flowService;
+ }
+
+ public void setFlowService(final SalFlowService flowService) {
+ this._flowService = flowService;
+ }
+
+ public NotificationProviderService getNotificationService() {
+ return this._notificationService;
+ }
+
+ public void setNotificationService(final NotificationProviderService notificationService) {
+ this._notificationService = notificationService;
+ }
+
+ public void start() {
+ this.commiter = new DropTestRpcSender(this, this.getFlowService());;
+ this.listenerRegistration = this.getNotificationService().registerNotificationListener(this.commiter);
+ LOG.debug("DropTestProvider Started.");
+ }
+
+ public void close() {
+ try {
+ LOG.debug("DropTestProvider stopped.");
+ if (this.listenerRegistration != null) {
+ this.listenerRegistration.close();
+ }
+ } catch (Exception _e) {
+ throw new Error(_e);
+ }
+ }
+}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.openflowplugin.droptest
-
-import org.opendaylight.controller.sal.binding.api.NotificationProviderService
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService
-import org.opendaylight.yangtools.concepts.Registration
-import org.opendaylight.yangtools.yang.binding.NotificationListener
-import org.slf4j.LoggerFactory
-
-class DropTestRpcProvider implements AutoCloseable {
-
-
- static val LOG = LoggerFactory.getLogger(DropTestProvider);
-
- @Property
- SalFlowService flowService;
-
-
-
-
- @Property
- NotificationProviderService notificationService;
-
- var DropTestRpcSender commiter
-
- Registration<NotificationListener> listenerRegistration
-
- def void start() {
- commiter = new DropTestRpcSender(this,flowService)
- listenerRegistration = notificationService.registerNotificationListener(commiter);
- LOG.debug("DropTestProvider Started.");
-
- }
-
- override close() {
- LOG.debug("DropTestProvider stopped.");
- listenerRegistration?.close();
- }
-
-}
-
-
--- /dev/null
+/**
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.droptest;
+
+import org.apache.commons.codec.binary.Hex;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingListener;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceived;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+@SuppressWarnings("all")
+public class DropTestRpcSender implements PacketProcessingListener {
+ private final static Logger LOG = LoggerFactory.getLogger(DropTestProvider.class);
+
+ private final DropTestRpcProvider _manager;
+ private final SalFlowService _flowService;
+
+ public DropTestRpcProvider getManager() {
+ return this._manager;
+ }
+
+ public SalFlowService getFlowService() {
+ return this._flowService;
+ }
+
+ public DropTestRpcSender(final DropTestRpcProvider manager, final SalFlowService flowService) {
+ this._manager = manager;
+ this._flowService = flowService;
+ }
+
+ public void onPacketReceived(final PacketReceived notification) {
+ LOG.debug("onPacketReceived - Entering - " + notification);
+
+ // Get the Ingress nodeConnectorRef
+ final NodeConnectorRef ncr = notification.getIngress();
+
+ // Get the instance identifier for the nodeConnectorRef
+ final InstanceIdentifier<NodeConnector> ncri = (InstanceIdentifier<NodeConnector>) ncr.getValue();
+ final NodeConnectorKey ncKey = InstanceIdentifier.<NodeConnector, NodeConnectorKey>keyOf(ncri);
+
+ // Get the instanceID for the Node in the tree above us
+ final InstanceIdentifier<Node> nodeInstanceId = ncri.<Node>firstIdentifierOf(Node.class);
+ final NodeKey nodeKey = InstanceIdentifier.<Node, NodeKey>keyOf(nodeInstanceId);
+ final byte[] rawPacket = notification.getPayload();
+
+ LOG.debug("onPacketReceived - received Packet on Node {} and NodeConnector {} payload {}",
+ nodeKey.getId(), ncKey.getId(), Hex.encodeHexString(rawPacket));
+
+ final byte[] srcMac = Arrays.copyOfRange(rawPacket, 6, 12);
+
+ LOG.debug("onPacketReceived - received Packet on Node {} and NodeConnector {} srcMac {}",
+ nodeKey.getId(), ncKey.getId(), Hex.encodeHexString(srcMac));
+
+ final MatchBuilder match = new MatchBuilder();
+ final EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
+ final EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
+
+ //TODO: use HEX, use binary form
+ //Hex.decodeHex("000000000001".toCharArray());
+
+ ethSourceBuilder.setAddress(new MacAddress(DropTestUtils.macToString(srcMac)));
+ ethernetMatch.setEthernetSource(ethSourceBuilder.build());
+ match.setEthernetMatch(ethernetMatch.build());
+ final DropActionBuilder dab = new DropActionBuilder();
+ final DropAction dropAction = dab.build();
+ final ActionBuilder ab = new ActionBuilder();
+ ab.setAction(new DropActionCaseBuilder().setDropAction(dropAction).build());
+
+ // Add our drop action to a list
+ final ArrayList<Action> actionList = new ArrayList<Action>();
+ actionList.add(ab.build());
+
+ // Create an Apply Action
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ aab.setAction(actionList);
+
+ // Wrap our Apply Action in an Instruction
+ final InstructionBuilder ib = new InstructionBuilder();
+ ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+
+ // Put our Instruction in a list of Instructions
+ final InstructionsBuilder isb = new InstructionsBuilder();;
+ final ArrayList<Instruction> instructions = new ArrayList<Instruction>();
+ instructions.add(ib.build());
+ isb.setInstruction(instructions);
+
+ // Finally build our flow
+ final AddFlowInputBuilder fb = new AddFlowInputBuilder();
+ fb.setMatch(match.build());
+ fb.setInstructions(isb.build());
+ //fb.setId(new FlowId(Long.toString(fb.hashCode)));
+
+ // Construct the flow instance id
+ final InstanceIdentifier<Node> flowInstanceId = InstanceIdentifier
+ .builder(Nodes.class) // File under nodes
+ .child(Node.class, nodeKey).toInstance(); // A particular node indentified by nodeKey
+ fb.setNode(new NodeRef(flowInstanceId));
+
+ fb.setPriority(4);
+ fb.setBufferId(0L);
+ final BigInteger value = new BigInteger("10", 10);
+ fb.setCookie(value);
+ fb.setCookieMask(value);
+ fb.setTableId(Short.valueOf(((short) 0)));
+ fb.setHardTimeout(300);
+ fb.setIdleTimeout(240);
+ fb.setFlags(new FlowModFlags(false, false, false, false, false));
+
+ // Add flow
+ this.getFlowService().addFlow(fb.build());
+ }
+}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.openflowplugin.droptest
-
-import java.math.BigInteger
-import java.util.ArrayList
-import java.util.Arrays
-import org.apache.commons.codec.binary.Hex
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCaseBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropActionBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingListener
-import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceived
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
-import org.slf4j.LoggerFactory
-
-class DropTestRpcSender implements PacketProcessingListener {
- static val LOG = LoggerFactory.getLogger(DropTestProvider);
- @Property
- val DropTestRpcProvider manager;
-
- @Property
- val SalFlowService flowService;
-
- new(DropTestRpcProvider manager,SalFlowService flowService) {
- _manager = manager;
- _flowService = flowService;
- }
-
- override onPacketReceived(PacketReceived notification) {
- LOG.debug("onPacketReceived - Entering - " + notification);
- val ncr = notification.ingress // Get the Ingress nodeConnectorRef
- val ncri = (ncr.value as InstanceIdentifier<NodeConnector>); // Get the instance identifier for the nodeConnectorRef
- val ncKey = InstanceIdentifier.keyOf(ncri);
- val nodeInstanceId = ncri.firstIdentifierOf(Node); // Get the instanceID for the Node in the tree above us
- val nodeKey = InstanceIdentifier.keyOf(nodeInstanceId);
- val rawPacket = notification.payload;
- LOG.debug("onPacketReceived - received Packet on Node {} and NodeConnector {} payload {}",nodeKey.id,ncKey.id,Hex.encodeHexString(rawPacket));
- val srcMac = Arrays.copyOfRange(rawPacket,6,12);
- LOG.debug("onPacketReceived - received Packet on Node {} and NodeConnector {} srcMac {}",nodeKey.id,ncKey.id,Hex.encodeHexString(srcMac));
-
- val match = new MatchBuilder();
- val ethernetMatch = new EthernetMatchBuilder();
- val ethSourceBuilder = new EthernetSourceBuilder();
- //TODO: use HEX, use binary form
- //Hex.decodeHex("000000000001".toCharArray());
- ethSourceBuilder.setAddress(new MacAddress(DropTestUtils.macToString(srcMac)));
- ethernetMatch.setEthernetSource(ethSourceBuilder.build());
- match.setEthernetMatch(ethernetMatch.build());
- val dab = new DropActionBuilder();
- val dropAction = dab.build();
- val ab = new ActionBuilder();
- ab.setAction(new DropActionCaseBuilder().setDropAction(dropAction).build());
-
- // Add our drop action to a list
- val actionList = new ArrayList<Action>();
- actionList.add(ab.build());
-
- // Create an Apply Action
- val aab = new ApplyActionsBuilder();
- aab.setAction(actionList);
-
- // Wrap our Apply Action in an Instruction
- val ib = new InstructionBuilder();
- ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
-
- // Put our Instruction in a list of Instructions
- val isb = new InstructionsBuilder();
- val instructions = new ArrayList<Instruction>();
- instructions.add(ib.build());
- isb.setInstruction(instructions);
-
- // Finally build our flow
- val fb = new AddFlowInputBuilder
- fb.setMatch(match.build());
- fb.setInstructions(isb.build());
- //fb.setId(new FlowId(Long.toString(fb.hashCode)));
-
- // Construct the flow instance id
- val flowInstanceId = InstanceIdentifier.builder(Nodes) // File under nodes
- .child(Node,nodeKey).toInstance // A particular node indentified by nodeKey
- fb.setNode(new NodeRef(flowInstanceId));
-
- fb.setPriority(4);
- fb.setBufferId(0L);
- val value = new BigInteger("10", 10);
- fb.setCookie(value);
- fb.setCookieMask(value);
- fb.setTableId(0 as short);
- fb.setHardTimeout(300);
- fb.setIdleTimeout(240);
- fb.setFlags(new FlowModFlags(false, false, false, false, false));
-
- // Construct the flow instance id
- flowService.addFlow(fb.build());
- }
-
-}
import org.apache.commons.lang.ArrayUtils;
import org.eclipse.osgi.framework.console.CommandInterpreter;
import org.eclipse.osgi.framework.console.CommandProvider;
-import org.eclipse.xtext.xbase.lib.Conversions;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder;
NodeConnectorRef nEngressConRef = _nodeConnectorRef_2;
final ArrayList<Byte> _converted_list = list;
- byte[] _primitive = ArrayUtils.toPrimitive(((Byte[]) Conversions.unwrapArray(_converted_list, Byte.class)));
+ byte[] _primitive = ArrayUtils.toPrimitive(_converted_list.toArray(new Byte[0]));
List<Action> actionList = new ArrayList<Action>();
ActionBuilder ab = new ActionBuilder();
--- /dev/null
+/**
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.outputtest;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+
+import org.apache.commons.lang.ArrayUtils;
+import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
+import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInputBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+@SuppressWarnings("all")
+public class OutputTestUtil {
+
+ private OutputTestUtil() {
+ throw new UnsupportedOperationException("Utility class. Instantiation is not allowed.");
+ }
+
+ public static TransmitPacketInput buildTransmitInputPacket(final String nodeId, final byte[] packValue,
+ final String outPort, final String inPort) {
+ ArrayList<Byte> list = new ArrayList<Byte>(40);
+ byte[] msg = new String("sendOutputMsg_TEST").getBytes();
+
+ int index = 0;
+ for (byte b : msg) {
+ list.add(b);
+ index = index < 7 ? index + 1 : 0;
+ }
+
+ while (index < 8) {
+ list.add(new Byte("0"));
+ index++;
+ }
+ NodeRef ref = createNodeRef(nodeId);
+ NodeConnectorRef nEgressConfRef = new NodeConnectorRef(createNodeConnRef(nodeId, outPort));
+
+ NodeConnectorRef nIngressConRef = new NodeConnectorRef(createNodeConnRef(nodeId, inPort));
+
+ TransmitPacketInputBuilder tPackBuilder = new TransmitPacketInputBuilder();
+
+ final ArrayList<Byte> _converted_list = (ArrayList<Byte>) list;
+ byte[] _primitive = ArrayUtils.toPrimitive(_converted_list.toArray(new Byte[0]));
+ tPackBuilder.setPayload(_primitive);
+
+ tPackBuilder.setNode(ref);
+ // TODO VD P2 missing cookies in Test
+ tPackBuilder.setCookie(null);
+ tPackBuilder.setEgress(nEgressConfRef);
+ tPackBuilder.setIngress(nIngressConRef);
+ return tPackBuilder.build();
+ }
+
+ public static String makePingFlowForNode(final String nodeId, final ProviderContext pc) {
+ NodeBuilder nodeBuilder = createNodeBuilder(nodeId);
+ FlowBuilder flowBuilder = createFlowBuilder(1235, null, "ping");
+
+ DataBrokerService dataBrokerService = pc.<DataBrokerService>getSALService(DataBrokerService.class);
+ DataModificationTransaction modif = dataBrokerService.beginTransaction();
+
+ InstanceIdentifier<Flow> path = InstanceIdentifier.<Nodes>builder(Nodes.class)
+ .<Node, NodeKey>child(Node.class, nodeBuilder.getKey())
+ .<FlowCapableNode>augmentation(FlowCapableNode.class)
+ .<Table, TableKey>child(Table.class, new TableKey(flowBuilder.getTableId()))
+ .<Flow, FlowKey>child(Flow.class, flowBuilder.getKey())
+ .build();
+
+ modif.putConfigurationData(path, flowBuilder.build());
+ Future<RpcResult<TransactionStatus>> commitFuture = modif.commit();
+
+ try {
+ RpcResult<TransactionStatus> resutl = commitFuture.get();
+ TransactionStatus status = resutl.getResult();
+ return "Status of Flow Data Loaded Transaction: " + status;
+
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ return e.getClass().getName();
+ } catch (ExecutionException e) {
+ e.printStackTrace();
+ return e.getClass().getName();
+ }
+ }
+
+ public static NodeRef createNodeRef(final String nodeId) {
+ NodeKey key = new NodeKey(new NodeId(nodeId));
+ InstanceIdentifier<Node> path = InstanceIdentifier.<Nodes>builder(Nodes.class)
+ .<Node, NodeKey>child(Node.class, key)
+ .toInstance();
+ return new NodeRef(path);
+ }
+
+ public static NodeConnectorRef createNodeConnRef(final String nodeId, final String port) {
+ StringBuilder sBuild = new StringBuilder(nodeId).append(":").append(port);
+ NodeConnectorId _nodeConnectorId = new NodeConnectorId(sBuild.toString());
+
+ NodeConnectorKey nConKey = new NodeConnectorKey(new NodeConnectorId(sBuild.toString()));
+
+ InstanceIdentifier<NodeConnector> path = InstanceIdentifier.<Nodes>builder(Nodes.class)
+ .<Node, NodeKey>child(Node.class, new NodeKey(new NodeId(nodeId)))
+ .<NodeConnector, NodeConnectorKey>child(NodeConnector.class, nConKey)
+ .toInstance();
+
+ return new NodeConnectorRef(path);
+ }
+
+ private static NodeBuilder createNodeBuilder(final String nodeId) {
+ NodeBuilder builder = new NodeBuilder();
+ builder.setId(new NodeId(nodeId));
+ builder.setKey(new NodeKey(builder.getId()));
+ return builder;
+ }
+
+ private static FlowBuilder createFlowBuilder(final long flowId, final String tableId, final String flowName) {
+
+ FlowBuilder fBuild = new FlowBuilder();
+ fBuild.setMatch(new MatchBuilder().build());
+ fBuild.setInstructions(createPingInstructionsBuilder().build());
+
+ FlowKey key = new FlowKey(new FlowId(Long.toString(flowId)));
+ fBuild.setBarrier(false);
+ // flow.setBufferId(new Long(12));
+ BigInteger value = new BigInteger("10", 10);
+ fBuild.setCookie(value);
+ fBuild.setCookieMask(value);
+ fBuild.setHardTimeout(0);
+ fBuild.setIdleTimeout(0);
+ fBuild.setInstallHw(false);
+ fBuild.setStrict(false);
+ fBuild.setContainerName(null);
+ fBuild.setFlags(new FlowModFlags(false, false, false, false, false));
+ fBuild.setId(new FlowId("12"));
+ fBuild.setTableId(checkTableId(tableId));
+ fBuild.setOutGroup(new Long(2));
+ fBuild.setOutPort(value);
+
+ fBuild.setKey(key);
+ fBuild.setPriority(2);
+ fBuild.setFlowName(flowName);
+ return fBuild;
+
+ }
+
+ private static InstructionsBuilder createPingInstructionsBuilder() {
+ ArrayList<Action> aList = new ArrayList<Action>();
+ ActionBuilder aBuild = new ActionBuilder();
+
+ OutputActionBuilder output = new OutputActionBuilder();
+ output.setMaxLength(56);
+ output.setOutputNodeConnector(new Uri("CONTROLLER"));
+ aBuild.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
+ aBuild.setOrder(0);
+ aBuild.setKey(new ActionKey(0));
+ aList.add(aBuild.build());
+ ApplyActionsBuilder asBuild = new ApplyActionsBuilder();
+ asBuild.setAction(aList);
+
+ InstructionBuilder iBuild = new InstructionBuilder();
+ iBuild.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(asBuild.build()).build());
+ iBuild.setOrder(0);
+ iBuild.setKey(new InstructionKey(0));
+
+ ArrayList<Instruction> instr = new ArrayList<Instruction>();
+ instr.add(iBuild.build());
+ return new InstructionsBuilder().setInstruction(instr);
+ }
+
+ private static short checkTableId(final String tableId) {
+ try {
+ return Short.parseShort(tableId);
+ } catch (Exception ex) {
+ return Short.parseShort("2");
+ }
+ }
+}
+++ /dev/null
-/**
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.openflowplugin.outputtest
-
-import java.math.BigInteger
-import java.util.ArrayList
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey
-import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInputBuilder
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
-import org.opendaylight.controller.sal.binding.api.data.DataBrokerService
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext
-import java.util.concurrent.ExecutionException
-import org.apache.commons.lang.ArrayUtils
-
-class OutputTestUtil {
-
- private new() {
- throw new UnsupportedOperationException("Utility class. Instantiation is not allowed.");
- }
-
- public static def buildTransmitInputPacket(String nodeId, byte[] packValue, String outPort, String inPort) {
-
- var list = new ArrayList<Byte>(40);
- var msg = (new String("sendOutputMsg_TEST")).getBytes();
- var index =0;
- for (byte b : msg) {
- list.add(b);
- if(index < 7) {index = index+1} else {index = 0}
- }
- while(index < 8) {
- list.add(new Byte("0"));
- index = index+1;
- }
-
- var ref = createNodeRef(nodeId);
- var nEgressConfRef = new NodeConnectorRef(createNodeConnRef(nodeId, outPort));
- var nIngressConRef = new NodeConnectorRef(createNodeConnRef(nodeId, inPort));
- var tPackBuilder = new TransmitPacketInputBuilder
- tPackBuilder.setPayload(ArrayUtils.toPrimitive(list));
- tPackBuilder.setNode(ref);
- // TODO VD P2 missing cookies in Test
- tPackBuilder.setCookie(null);
- tPackBuilder.setEgress(nEgressConfRef)
- tPackBuilder.setIngress(nIngressConRef)
- return tPackBuilder.build
- }
-
- public static def makePingFlowForNode(String nodeId, ProviderContext pc) {
- var nodeBuilder = createNodeBuilder(nodeId)
- var flowBuilder = createFlowBuilder(1235, null, "ping")
-
- var dataBrokerService = pc.getSALService(DataBrokerService)
- var modif = dataBrokerService.beginTransaction
-
- var path = InstanceIdentifier
- .builder(Nodes)
- .child(Node, nodeBuilder.getKey)
- .augmentation(FlowCapableNode)
- .child(Table, new TableKey(flowBuilder.getTableId))
- .child(Flow, flowBuilder.getKey()).build;
-
- modif.putConfigurationData(path, flowBuilder.build)
- var commitFuture = modif.commit
-
- try {
- var resutl = commitFuture.get
- var status = resutl.result
- return "Status of Flow Data Loaded Transaction: " + status
- } catch (InterruptedException e) {
- e.printStackTrace();
- return e.class.name
- } catch (ExecutionException e) {
- e.printStackTrace();
- return e.class.name
- }
- }
-
- public static def createNodeRef(String nodeId) {
- var key = new NodeKey(new NodeId(nodeId));
- var path = InstanceIdentifier.builder(Nodes).child(Node, key).toInstance
- return new NodeRef(path)
- }
-
- public static def createNodeConnRef(String nodeId, String port) {
- var sBuild = new StringBuilder(nodeId).append(":").append(port);
- var nConKey = new NodeConnectorKey(new NodeConnectorId(sBuild.toString));
- var path = InstanceIdentifier.builder(Nodes)
- .child(Node, new NodeKey(new NodeId(nodeId)))
- .child(NodeConnector, nConKey).toInstance()
- return new NodeConnectorRef(path)
- }
-
-
-
- private static def createNodeBuilder(String nodeId) {
- var builder = new NodeBuilder()
- builder.setId(new NodeId(nodeId))
- builder.setKey(new NodeKey(builder.getId()))
- return builder
- }
-
- private static def createFlowBuilder(long flowId, String tableId, String flowName) {
- var fBuild = new FlowBuilder();
- fBuild.setMatch(new MatchBuilder().build)
- fBuild.setInstructions(createPingInstructionsBuilder().build)
-
- var key = new FlowKey(new FlowId(Long.toString(flowId)));
- fBuild.setBarrier(false);
- // flow.setBufferId(new Long(12));
- var value = new BigInteger("10", 10);
- fBuild.setCookie(value);
- fBuild.setCookieMask(value);
- fBuild.setHardTimeout(0);
- fBuild.setIdleTimeout(0);
- fBuild.setInstallHw(false);
- fBuild.setStrict(false);
- fBuild.setContainerName(null);
- fBuild.setFlags(new FlowModFlags(false, false, false, false, false));
- fBuild.setId(new FlowId("12"));
- fBuild.setTableId(checkTableId(tableId));
- fBuild.setOutGroup(new Long(2));
- fBuild.setOutPort(value);
-
- fBuild.setKey(key);
- fBuild.setPriority(2);
- fBuild.setFlowName(flowName);
- return fBuild
- }
-
- private static def createPingInstructionsBuilder() {
- var aList = new ArrayList<Action>
- var aBuild = new ActionBuilder
-
- var output = new OutputActionBuilder
- output.setMaxLength(56)
- output.setOutputNodeConnector(new Uri("CONTROLLER"))
- aBuild.setAction(new OutputActionCaseBuilder().setOutputAction(output.build).build)
- aBuild.setOrder(0)
- aBuild.setKey(new ActionKey(0))
- aList.add(aBuild.build)
- var asBuild = new ApplyActionsBuilder(); asBuild.setAction(aList)
-
- var iBuild = new InstructionBuilder
- iBuild.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(asBuild.build).build);
- iBuild.setOrder(0);
- iBuild.setKey(new InstructionKey(0));
-
- var instr = new ArrayList<Instruction>(); instr.add(iBuild.build)
- return new InstructionsBuilder().setInstruction(instr)
- }
-
- private static def checkTableId(String tableId) {
- try {
- return Short.parseShort(tableId)
- } catch (Exception ex) {
- return Short.parseShort("2")
- }
- }
-}
\ No newline at end of file